Changeset 22778
- Timestamp:
- 05/15/18 13:42:52 (7 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Vertex.cpp
r20810 r22778 31 31 this->z = iomodel->Data("md.mesh.z")[i]; 32 32 this->domaintype = iomodel->domaintype; 33 34 this->latitute = iomodel->Data("md.mesh.lat")[i]; 35 this->longitude = iomodel->Data("md.mesh.long")[i]; 33 36 34 37 switch(iomodel->domaintype){ … … 195 198 /*}}}*/ 196 199 int Vertex::Sid(void){ return sid; }/*{{{*/ 197 /*}}}*/198 void Vertex::ToXYZ(Matrix<IssmDouble>* matrix){/*{{{*/199 200 IssmDouble xyz[3];201 int indices[3];202 203 if (this->clone==true) return;204 205 xyz[0]=x;206 xyz[1]=y;207 xyz[2]=z;208 indices[0]=0;209 indices[1]=1;210 indices[2]=2;211 212 matrix->SetValues(1,&sid,3,&indices[0],&xyz[0],INS_VAL);213 }214 200 /*}}}*/ 215 201 void Vertex::UpdateClonePids(int* alltruepids){/*{{{*/ -
issm/trunk-jpl/src/c/classes/Vertex.h
r20810 r22778 62 62 void ShowTruePids(int* borderpids); 63 63 int Sid(void); 64 void ToXYZ(Matrix<IssmDouble>* matrix);65 64 void UpdateClonePids(int* allborderpids); 66 65 void UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed); -
issm/trunk-jpl/src/c/classes/Vertices.cpp
r22004 r22778 180 180 } 181 181 /*}}}*/ 182 IssmDouble* Vertices::ToXYZ(void){/*{{{*/ 183 184 /*intermediary: */ 185 int i; 186 int my_rank; 187 int num_vertices; 182 void Vertices::LatLonList(IssmDouble** plat,IssmDouble** plon){/*{{{*/ 188 183 189 184 /*output: */ 190 Matrix<IssmDouble>* xyz = NULL;191 185 IssmDouble* xyz_serial=NULL; 192 186 193 187 /*recover my_rank:*/ 194 my_rank=IssmComm::GetRank();188 int my_rank=IssmComm::GetRank(); 195 189 196 190 /*First, figure out number of vertices: */ 197 num_vertices=this->NumberOfVertices(); 198 199 /*Now, allocate matrix to hold all the vertices x,y and z values: */ 200 xyz= new Matrix<IssmDouble>(num_vertices,3); 191 int num_vertices=this->NumberOfVertices(); 192 193 /*Now, allocate vectors*/ 194 Vector<IssmDouble>* lat = new Vector<IssmDouble>(num_vertices); 195 Vector<IssmDouble>* lon = new Vector<IssmDouble>(num_vertices); 201 196 202 197 /*Go through vertices, and for each vertex, object, report it cpu: */ 203 for(i=0;i<this->Size();i++){ 204 205 /*let vertex fill matrix: */ 206 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 207 vertex->ToXYZ(xyz); 198 for(int i=0;i<this->Size();i++){ 199 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 200 lat->SetValue(vertex->sid,vertex->GetLatitude() ,INS_VAL); 201 lon->SetValue(vertex->sid,vertex->GetLongitude(),INS_VAL); 208 202 } 209 203 210 204 /*Assemble:*/ 211 xyz->Assemble(); 205 lat->Assemble(); 206 lon->Assemble(); 212 207 213 208 /*gather on cpu 0: */ 214 xyz_serial=xyz->ToSerial(); 215 209 IssmDouble* lat_serial=lat->ToMPISerial(); 210 IssmDouble* lon_serial=lon->ToMPISerial(); 211 212 printf("lat_serial %g %g %g \n",lat_serial[0],lat_serial[2], lat_serial[799]); 216 213 /*free ressources: */ 217 delete xyz; 218 if(my_rank!=0)delete xyz_serial; 219 220 /*return matrix: */ 221 return xyz_serial; 222 } 223 /*}}}*/ 214 *plat = lat_serial; 215 *plon = lon_serial; 216 //delete lat; 217 //delete lon; 218 } 219 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Vertices.h
r15067 r22778 25 25 int NumberOfVertices(void); 26 26 void Ranks(int* ranks); 27 IssmDouble* ToXYZ(void);27 void LatLonList(IssmDouble** lat,IssmDouble** lon); 28 28 }; 29 29 -
issm/trunk-jpl/src/c/cores/transient_core.cpp
r22711 r22778 93 93 tomitgcmcomm=parcom->GetParameterValue(); 94 94 if(my_rank==0){ 95 /*Recover fixed parameters and store them*/ 95 96 ISSM_MPI_Send(&coupling_time,1,ISSM_MPI_DOUBLE,0,10001000,tomitgcmcomm); 96 97 ISSM_MPI_Recv(&oceangridnxsize,1,ISSM_MPI_INT,0,10001003,tomitgcmcomm,&status); … … 102 103 oceangridy = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 103 104 ISSM_MPI_Recv(oceangridy,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001006,tomitgcmcomm,&status); 104 105 femmodel->parameters->SetParam(oceangridx,oceangridnxsize*oceangridnysize,OceanGridXEnum); 106 femmodel->parameters->SetParam(oceangridy,oceangridnxsize*oceangridnysize,OceanGridYEnum); 107 108 /*Exchange varying parameters for the initialization*/ 105 109 ISSM_MPI_Send(&time,1,ISSM_MPI_DOUBLE,0,10001001,tomitgcmcomm); 106 110 ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status); … … 162 166 femmodel->parameters->SetParam(save_results,SaveResultsEnum); 163 167 164 if(isoceancoupling){ {{{168 if(isoceancoupling){ /*{{{*/ 165 169 if(VerboseSolution()) _printf0_(" ocean coupling: exchanging information\n"); 166 170 int my_rank; 167 int oceangridnxsize,oceangridnysize ;171 int oceangridnxsize,oceangridnysize,ngrids_ocean; 168 172 IssmDouble *oceanmelt; 169 173 IssmDouble *icebase; 174 IssmDouble *oceangridx; 175 IssmDouble *oceangridy; 170 176 IssmDouble oceantime; 171 177 ISSM_MPI_Comm tomitgcmcomm; … … 180 186 ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status); 181 187 if((oceantime - time > 0.1*yts) & (oceantime - time < -0.1*yts)) _error_("Ocean and ice time are starting to diverge"); 188 189 /*Recover inputs needed*/ 182 190 femmodel->parameters->FindParam(&oceangridnxsize,OceanGridNxEnum); 183 191 femmodel->parameters->FindParam(&oceangridnysize,OceanGridNyEnum); 184 oceanmelt = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 185 ISSM_MPI_Recv(oceanmelt,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status); 186 icebase = xNew<IssmDouble>(oceangridnxsize*oceangridnysize); 192 femmodel->parameters->FindParam(&oceangridx,&ngrids_ocean,OceanGridXEnum); 193 femmodel->parameters->FindParam(&oceangridy,&ngrids_ocean,OceanGridYEnum); 194 195 /*Exchange information*/ 196 oceanmelt = xNew<IssmDouble>(ngrids_ocean); 197 ISSM_MPI_Recv(oceanmelt,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status); 198 icebase = xNew<IssmDouble>(ngrids_ocean); 187 199 for(int i=0;i<oceangridnxsize;i++){ 188 200 for(int j=0;j<oceangridnysize;j++){ … … 190 202 } 191 203 } 192 ISSM_MPI_Send(icebase,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); 204 ISSM_MPI_Send(icebase,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); 205 206 /*Interpolate melt onto mesh*/ 207 IssmDouble* x_ice = NULL; 208 IssmDouble* y_ice = NULL; 209 IssmDouble* lat_ice = NULL; 210 IssmDouble* lon_ice = NULL; 211 IssmDouble* z_ice = NULL; 212 IssmDouble* melt_mesh = NULL; 213 int* index_ice= NULL; 214 int* index_ocean = NULL; 215 int nels_ocean; 216 int ngrids_ice=femmodel->vertices->NumberOfVertices(); 217 lat_ice= xNew<IssmDouble>(ngrids_ice); 218 lon_ice= xNew<IssmDouble>(ngrids_ice); 219 melt_mesh= xNew<IssmDouble>(ngrids_ice); 220 femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice); 221 BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean); 222 femmodel->vertices->LatLonList(&lat_ice,&lon_ice); 223 InterpFromMeshToMesh2dx(&melt_mesh,index_ocean,oceangridx,oceangridy,ngrids_ocean,nels_ocean, 224 oceanmelt,ngrids_ocean,1, 225 lat_ice,lon_ice,ngrids_ice,NULL); /*FIXME: may be wrong: y=lat x=lon*/ 226 InputUpdateFromVectorx(femmodel,melt_mesh,BasalforcingsFloatingiceMeltingRateEnum,VertexSIdEnum); 227 xDelete<IssmDouble>(lat_ice); 228 xDelete<IssmDouble>(lon_ice); 229 xDelete<IssmDouble>(x_ice); 230 xDelete<IssmDouble>(y_ice); 231 xDelete<IssmDouble>(z_ice); 232 xDelete<IssmDouble>(melt_mesh); 233 xDelete<int>(index_ice); 234 xDelete<IssmDouble>(oceangridx); 235 xDelete<IssmDouble>(oceangridy); 193 236 xDelete<IssmDouble>(oceanmelt); 194 237 xDelete<IssmDouble>(icebase); 195 238 } 196 239 } 197 }}}240 /*}}}*/ 198 241 199 242 if(isthermal && domaintype==Domain3DEnum){ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
r22647 r22778 16 16 bool dakota_analysis; 17 17 bool adolc_analysis; 18 bool isoceancoupling; 18 19 int nnat,dummy; 19 20 int* nature=NULL; … … 24 25 iomodel->FindConstant(&materials_type,"md.materials.type"); 25 26 iomodel->FindConstant(&adolc_analysis,"md.autodiff.isautodiff"); 27 iomodel->FindConstant(&isoceancoupling,"md.transient.isoceancoupling"); 26 28 27 29 /*Did we already create the elements? : */ … … 232 234 if (iomodel->domaintype == Domain3DsurfaceEnum) iomodel->FetchData(3,"md.mesh.lat","md.mesh.long","md.mesh.r"); 233 235 else iomodel->FetchDataToInput(elements,"md.mesh.scale_factor",MeshScaleFactorEnum,1.); 236 if (isoceancoupling) iomodel->FetchData(2,"md.mesh.lat","md.mesh.long"); 234 237 235 238 CreateNumberNodeToElementConnectivity(iomodel,solution_type); … … 242 245 iomodel->DeleteData(6,"md.mesh.x","md.mesh.y","md.mesh.z","md.geometry.base","md.geometry.thickness","md.mask.ice_levelset"); 243 246 if (iomodel->domaintype == Domain3DsurfaceEnum) iomodel->DeleteData(3,"md.mesh.lat","md.mesh.long","md.mesh.r"); 247 if (isoceancoupling) iomodel->DeleteData(2,"md.mesh.lat","md.mesh.long"); 244 248 }
Note:
See TracChangeset
for help on using the changeset viewer.