Skip to content

Commit

Permalink
Add original node coordinates when creating a Mesh from a Grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
oehmke committed Sep 15, 2023
1 parent 0d3066d commit 58508ba
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Infrastructure/Mesh/src/ESMCI_Mesh_GToM_Glue.C
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,15 @@ void ESMCI_GridToMesh(const Grid &grid_, int staggerLoc,

// original spatial dim is the same as grid dimension
mesh.orig_spatial_dim=pdim;
int orig_sdim=mesh.orig_spatial_dim; // for convenience also put in a local var.

// Get coordinate system
mesh.coordsys=grid.getCoordSys();

// See if we should add original coords
bool add_orig_coords=false;
if (mesh.coordsys != ESMC_COORDSYS_CART) add_orig_coords=true;

// See if this is for conservative regridding
bool isConserve=false;
if (*regridConserve == ESMC_REGRID_CONSERVE_ON) isConserve=true;
Expand Down Expand Up @@ -423,6 +430,13 @@ Par::Out() << "GID=" << gid << ", LID=" << lid << std::endl;
// Now set up the nodal coordinates
IOField<NodalField> *node_coord = mesh.RegisterNodalField(mesh, "coordinates", sdim);

// If required, add orig_coords
IOField<NodalField> *node_orig_coord = NULL;
if (add_orig_coords) {
node_orig_coord = mesh.RegisterNodalField(mesh, "orig_coordinates", orig_sdim);
}


#if 0
if (*regridConserve == ESMC_REGRID_CONSERVE_ON) {
// Register the iwts field
Expand Down Expand Up @@ -473,8 +487,16 @@ Par::Out() << "GID=" << gid << ", LID=" << lid << std::endl;
MeshDB::iterator ni = mesh.node_begin(), ne = mesh.node_end();

for (; ni != ne; ++ni) {
// Get Cart. coords
double *c = node_coord->data(*ni);

// Get orig coords
double *orig_c;
if (add_orig_coords) {
orig_c=node_orig_coord->data(*ni);
}

// field data
double fdata;

UInt lid = ngid2lid[ni->get_id()]; // we set this above when creating the node
Expand All @@ -494,6 +516,20 @@ Par::Out() << "GID=" << gid << ", LID=" << lid << std::endl;
}
}


// If requested and local fill in orig coords
if (add_orig_coords) {
if (gni->isLocal()) {
gni->getCoord(orig_c);
} else { // set to Null value to be ghosted later
for (int i=0; i<orig_sdim; i++) {
orig_c[i]=-10;
}
}
}

/// STOPPED HERE, BUT CHECK ABOVE

// Other arrays
for (UInt i = 0; i < arrays.size(); ++i) {

Expand Down

0 comments on commit 58508ba

Please sign in to comment.