Changeset 25827
- Timestamp:
- 12/04/20 13:54:48 (4 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/classes/FemModel.cpp ¶
r25812 r25827 3814 3814 3815 3815 /*Get vertices coordinates*/ 3816 VertexCoordinatesx(&x,&y,&z, NULL,femmodel_vertices,false) ;3816 VertexCoordinatesx(&x,&y,&z,femmodel_vertices,false) ; 3817 3817 3818 3818 /*Get element vertices*/ … … 4971 4971 4972 4972 /*recover lat,long and radius vectors from vertices: */ 4973 VertexCoordinatesx(&latitude,&longitude,&radius, NULL,this->vertices,spherical);4973 VertexCoordinatesx(&latitude,&longitude,&radius,this->vertices,spherical); 4974 4974 4975 4975 /* Green's function (1+k_2-h_2/g): checked against Glenn Milne's thesis Chapter 3 (eqs: 3.3-4, 3.10-11) -
TabularUnified issm/trunk-jpl/src/c/classes/Vertex.cpp ¶
r25812 r25827 205 205 } 206 206 /*}}}*/ 207 void Vertex::VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz, Vector<IssmDouble>* vrank,bool spherical){/*{{{*/207 void Vertex::VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,bool spherical){/*{{{*/ 208 208 209 209 if(this->clone==true) return; … … 219 219 vz->SetValue(this->sid,this->R,INS_VAL); 220 220 } 221 if(vrank){222 int rank=IssmComm::GetRank();223 vrank->SetValue(this->sid,rank,INS_VAL);224 }225 226 221 return; 227 222 } -
TabularUnified issm/trunk-jpl/src/c/classes/Vertex.h ¶
r25812 r25827 61 61 int Sid(void); 62 62 void UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed); 63 void VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz, Vector<IssmDouble>* vrank,bool spherical=false);63 void VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,bool spherical=false); 64 64 }; 65 65 -
TabularUnified issm/trunk-jpl/src/c/cores/esa_core.cpp ¶
r25812 r25827 44 44 45 45 /* recover coordinates of vertices: */ 46 VertexCoordinatesx(&latitude,&longitude,&radius, NULL,femmodel->vertices,spherical);47 VertexCoordinatesx(&xx,&yy,&zz, NULL,femmodel->vertices);46 VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical); 47 VertexCoordinatesx(&xx,&yy,&zz,femmodel->vertices); 48 48 49 49 /*Figure out size of g-set deflection vector and allocate solution vector: */ -
TabularUnified issm/trunk-jpl/src/c/cores/gia_core.cpp ¶
r25812 r25827 45 45 46 46 /*first, recover x and y vectors from vertices: */ 47 VertexCoordinatesx(&x,&y,NULL, NULL,femmodel->vertices); //no need for z coordinate47 VertexCoordinatesx(&x,&y,NULL,femmodel->vertices); //no need for z coordinate 48 48 49 49 /*call the main module: */ -
TabularUnified issm/trunk-jpl/src/c/cores/sealevelchange_core.cpp ¶
r25812 r25827 392 392 393 393 /*first, recover lat,long and radius vectors from vertices: */ 394 VertexCoordinatesx(&latitude,&longitude,&radius, NULL,femmodel->vertices,spherical);395 if(horiz) VertexCoordinatesx(&xx,&yy,&zz, NULL,femmodel->vertices);394 VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical); 395 if(horiz) VertexCoordinatesx(&xx,&yy,&zz,femmodel->vertices); 396 396 397 397 … … 659 659 660 660 /*retrieve geometric information: */ 661 VertexCoordinatesx(&latitude,&longitude,&radius, NULL,femmodel->vertices,spherical);662 VertexCoordinatesx(&xx,&yy,&zz, NULL,femmodel->vertices);661 VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical); 662 VertexCoordinatesx(&xx,&yy,&zz,femmodel->vertices); 663 663 664 664 /*call the elastic main modlule:*/ -
TabularUnified issm/trunk-jpl/src/c/main/esmfbinders.cpp ¶
r25826 r25827 6 6 #include <ESMC.h> 7 7 8 /*G CMspecific declarations:*/8 /*GEOS 5 specific declarations:*/ 9 9 const int GCMForcingNumTerms = 1; 10 10 const int GCMForcingTerms[GCMForcingNumTerms]= { SMBgcmEnum}; 11 12 11 const int ISSMOutputNumTerms = 1; 13 12 const int ISSMOutputTerms[ISSMOutputNumTerms]= { SurfaceEnum }; … … 159 158 /*Intermediary*/ 160 159 int rc; 160 int rank = IssmComm::GetRank(); 161 161 162 162 /*Initialize femmodel from arguments provided command line: */ … … 165 165 /*Initialize ESMC Mesh*/ 166 166 int pdim; /*parametric dimension is the same as the domain dimensions */ 167 int sdim = 3; /*coordinates of each vertex is always 3*/168 ESMC_CoordSys_Flag coordsys = ESMC_COORDSYS_CART; /*Cartesian coordinate system by default 167 int sdim = 3; /*coordinates of each vertex is always 2 (just x,y for now) */ 168 ESMC_CoordSys_Flag coordsys = ESMC_COORDSYS_CART; /*Cartesian coordinate system by default */ 169 169 femmodel->parameters->FindParam(&pdim,DomainDimensionEnum); 170 170 ESMC_Mesh mesh = ESMC_MeshCreate(pdim,sdim,&coordsys,&rc); … … 172 172 173 173 /*How to install ESMG with lib/libesmf.so 174 * what is a PET?175 * should all of these arrays be specific to an MPI? or do all vectors need to be serialized176 174 * do indices need to be 1 based? 177 * do we need ElementMask, ElementArea or Element Coords?*/ 175 * ESMF installation, how can we get everything in /lib 176 * What do we do with vertices at the boundary, declare twice? 177 * Do we need a restart file or save femmodel somewhere?*/ 178 178 179 179 /*Add nodes (which are ISSM Vertices)*/ 180 int numnodes = femmodel->vertices->NumberOfVertices(); 181 182 IssmDouble* x=NULL; 183 IssmDouble* y=NULL; 184 IssmDouble* z=NULL; 185 int* nodeOwner=NULL; 186 VertexCoordinatesx(&x,&y,&z,&nodeOwner,femmodel->vertices); 187 188 int* nodeId = xNew<int>(numnodes); 189 IssmDouble* nodeCoord = xNew<IssmDouble>(sdim*numnodes); 190 for(int i=0;i<numnodes;i++){ 191 nodeId[i] = i; 192 nodeCoord[sdim*i+0] = x[i]; 193 nodeCoord[sdim*i+1] = y[i]; 194 nodeCoord[sdim*i+2] = z[i]; 195 } 196 xDelete<IssmDouble>(x); 197 xDelete<IssmDouble>(y); 198 xDelete<IssmDouble>(z); 199 180 int numnodes = femmodel->vertices->Size(); 181 int *nodeId = xNew<int>(numnodes); 182 int *nodeOwner = xNew<int>(numnodes); 183 IssmDouble *nodeCoord = xNew<IssmDouble>(sdim*numnodes); 184 for (int i=0;i<femmodel->elements->Size();i++){ 185 Vertex* vertex = xDynamicCast<Vertex*>(femmodel->vertices->GetObjectByOffset(i)); 186 nodeId[i] = vertex->Sid()+1; 187 nodeOwner[i] = rank; 188 nodeCoord[sdim*i+0] = vertex->x; 189 nodeCoord[sdim*i+1] = vertex->y; 190 } 200 191 rc = ESMC_MeshAddNodes(mesh,numnodes,nodeId,nodeCoord,nodeOwner); 201 192 if(rc!=ESMF_SUCCESS) _error_("could not add nodes to EMSC_Mesh"); 202 193 xDelete<int>(nodeId); 203 194 xDelete<int>(nodeOwner); 204 xDelete<int>(nodeId);205 195 xDelete<IssmDouble>(nodeCoord); 206 196 207 197 /*Add Elements (Assume triangles only for now)*/ 208 int numelements = femmodel->elements-> NumberOfElements();198 int numelements = femmodel->elements->Size(); 209 199 int* elemId = xNew<int>(numelements); 210 200 int* elemType = xNew<int>(numelements); 211 201 int* elemConn = xNew<int>(numelements*3); /*Assuming triangles*/ 212 for(int i=0;i< numelements;i++){213 _error_("STOP");214 elemId[i] = i;202 for(int i=0;i<femmodel->elements->Size();i++){ 203 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 204 elemId[i] = element->Sid()+1; 215 205 elemType[i] = ESMC_MESHELEMTYPE_TRI; /*Assuming triangles*/ 206 elemConn[i*3+0] = element->vertices[0]->Lid()+1; 207 elemConn[i*3+1] = element->vertices[1]->Lid()+1; 208 elemConn[i*3+2] = element->vertices[2]->Lid()+1; 216 209 } 217 210 rc = ESMC_MeshAddElements(mesh,numelements,elemId,elemType,elemConn,NULL,NULL,NULL); … … 220 213 xDelete<int>(elemConn); 221 214 222 /*Some specific code here for the binding: */ 223 _error_("not coded yet, will depend on what FISOC provides"); 224 //femmodel->parameters->SetParam(SMBgcmEnum,SmbEnum); /*bypass SMB model, will be provided by GCM*/ 215 /*DO we need to create fields here? https://earthsystemmodeling.org/docs/nightly/develop/ESMC_crefdoc/node5.html#SECTION05024400000000000000*/ 216 //ESMC_InterArrayInt *gridToFieldMap, // in 217 //ESMC_InterArrayInt *ungriddedLBound, // in 218 //ESMC_InterArrayInt *ungriddedUBound, // in 219 //ESMC_Field esmf_shelfbase = ESMC_FieldCreateMeshTypeKind(mesh,ESMC_TYPEKIND_R8,???,gridToFieldMap,ungriddedLBound,ungriddedUBound,"ShelfTopography",&rc); 220 if(rc!=ESMF_SUCCESS) _error_("could not create EMSC_Field"); 225 221 226 222 /*Create restart file for later */ -
TabularUnified issm/trunk-jpl/src/c/modules/VertexCoordinatesx/VertexCoordinatesx.cpp ¶
r25813 r25827 9 9 #include "../../toolkits/toolkits.h" 10 10 11 void VertexCoordinatesx( IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** prank,Vertices* vertices,bool spherical) {11 void VertexCoordinatesx( IssmDouble** px, IssmDouble** py, IssmDouble** pz,Vertices* vertices,bool spherical) { 12 12 13 13 /*figure out how many vertices we have: */ … … 17 17 Vector<IssmDouble>* vy=new Vector<IssmDouble>(numberofvertices); 18 18 Vector<IssmDouble>* vz=new Vector<IssmDouble>(numberofvertices); 19 Vector<IssmDouble>* vrank=NULL;20 if(prank) vrank = new Vector<IssmDouble>(numberofvertices);21 19 22 20 /*march through our vertices: */ 23 21 for(Object* & object : vertices->objects){ 24 22 Vertex* vertex=(Vertex*)object; 25 vertex->VertexCoordinates(vx,vy,vz, vrank,spherical);23 vertex->VertexCoordinates(vx,vy,vz,spherical); 26 24 } 27 25 … … 30 28 vy->Assemble(); 31 29 vz->Assemble(); 32 if(prank) vrank->Assemble();33 30 34 31 /*serialize: */ … … 36 33 IssmDouble* y=vy->ToMPISerial(); 37 34 IssmDouble* z=vz->ToMPISerial(); 38 int* rank = NULL;39 if(prank){40 /*Need to convert from IssmDouble to int*/41 IssmDouble* drank = vrank->ToMPISerial();42 rank = xNew<int>(numberofvertices);43 for(int i=0;i<numberofvertices;i++) rank[i] = reCast<int>(drank[i]);44 xDelete<IssmDouble>(drank);45 delete vrank;46 }47 35 48 36 /*Free ressources: */ … … 58 46 if(pz) *pz=z; 59 47 else xDelete<IssmDouble>(z); 60 if(prank) *prank=rank;61 48 } -
TabularUnified issm/trunk-jpl/src/c/modules/VertexCoordinatesx/VertexCoordinatesx.h ¶
r25812 r25827 8 8 9 9 /* local prototypes: */ 10 void VertexCoordinatesx( IssmDouble** px, IssmDouble** py, IssmDouble** pz, int** prank,Vertices* vertices,bool spherical=false);10 void VertexCoordinatesx( IssmDouble** px, IssmDouble** py, IssmDouble** pz,Vertices* vertices,bool spherical=false); 11 11 12 12 #endif /* _VERTEX_COORDINATESX_H */
Note:
See TracChangeset
for help on using the changeset viewer.