Skip to content

Commit

Permalink
Add coordinate system to PointList.
Browse files Browse the repository at this point in the history
  • Loading branch information
oehmke committed Sep 26, 2023
1 parent 1b2cc3d commit 13d8bc0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/Infrastructure/GridUtil/src/ESMCI_GridToMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,10 @@ void CpMeshDataToArray(Grid &grid, int staggerLoc, ESMCI::Mesh &mesh, ESMCI::Arr
int orig_coord_dim=0; // 0 indicates not to add orig coords
if (add_orig_coords) orig_coord_dim=grid.getDimCount();

// If needed get coordsys
ESMC_CoordSys_Flag coordSys=ESMC_COORDSYS_UNINIT;
if (add_orig_coords) coordSys==grid.getCoordSys();

// Loop nodes of the grid. Here we loop all nodes, both owned and not.
ESMCI::GridIter *gni=new ESMCI::GridIter(&grid,staggerLoc,true);

Expand Down Expand Up @@ -1061,7 +1065,7 @@ void CpMeshDataToArray(Grid &grid, int staggerLoc, ESMCI::Mesh &mesh, ESMCI::Arr

// Create PointList
// (Put Cartesian coordinates in list)
ESMCI::PointList *pl=new PointList(num_local_pts, grid.getCartCoordDimCount(), orig_coord_dim);
ESMCI::PointList *pl=new PointList(num_local_pts, grid.getCartCoordDimCount(), orig_coord_dim, coordSys);

// loop through all nodes in the Grid
for(gni->toBeg(); !gni->isDone(); gni->adv()) {
Expand Down Expand Up @@ -1112,7 +1116,7 @@ void CpMeshDataToArray(Grid &grid, int staggerLoc, ESMCI::Mesh &mesh, ESMCI::Arr

// Create PointList
// (Put Cartesian coordinates in list)
ESMCI::PointList *pl=new PointList(num_local_pts, grid.getCartCoordDimCount(), orig_coord_dim);
ESMCI::PointList *pl=new PointList(num_local_pts, grid.getCartCoordDimCount(), orig_coord_dim, coordSys);

// loop through all nodes in the Grid
for(gni->toBeg(); !gni->isDone(); gni->adv()) {
Expand Down
8 changes: 7 additions & 1 deletion src/Infrastructure/PointList/include/ESMCI_PointList.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
//EOPI
//-------------------------------------------------------------------------

#include "ESMCI_CoordSys.h"


namespace ESMCI {

Expand Down Expand Up @@ -68,6 +70,7 @@ namespace ESMCI {

point *points;

ESMC_CoordSys_Flag orig_coord_sys;
int orig_coord_dim;
point *orig_points; // Contains original coord points. Id is repeated from above to allow sorting. In separate list to
// keep typical implementation as standard as possible. i
Expand All @@ -76,13 +79,16 @@ namespace ESMCI {
public:

// Construct
PointList(int max_size, int coord_dim, int orig_coord_dim=0);
PointList(int max_size, int coord_dim, int orig_coord_dim=0,ESMC_CoordSys_Flag orig_coord_sys=ESMC_COORDSYS_UNINIT);

// Destruct
~PointList();

// Detect original coords
bool hasOrigCoords() const {return (orig_points != NULL);}

// Get coordinate system of original points
ESMC_CoordSys_Flag get_orig_coord_sys() const {return orig_coord_sys;}

// Add Point to List
int add(int _id, const double *_coord);
Expand Down
12 changes: 6 additions & 6 deletions src/Infrastructure/PointList/src/ESMCI_PointList.C
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ namespace ESMCI {
// !ARGUMENTS:
int _max_num_pts,
int _coord_dim,
int _orig_coord_dim // If 0, no original coords allocated
// Defaults to 0.
int _orig_coord_dim, // If 0, no original coords allocated
// Defaults to 0.
ESMC_CoordSys_Flag _orig_coord_sys // coordinate system of original
// coords, defaults to uninit
){
//
// !DESCRIPTION:
Expand All @@ -85,7 +87,8 @@ namespace ESMCI {
orig_coord_dim=_orig_coord_dim;
max_num_pts=_max_num_pts;
curr_num_pts=0;

orig_coord_sys=_orig_coord_sys;

// Allocate point memory
points = NULL;
if (max_num_pts>=0) {
Expand All @@ -99,9 +102,6 @@ namespace ESMCI {
}
}


// STOPPED HERE ///

#undef ESMC_METHOD
#define ESMC_METHOD "ESMCI::~PointList()"
//BOPI
Expand Down

0 comments on commit 13d8bc0

Please sign in to comment.