@@ -129,9 +129,11 @@ SimMeshInfo getSimMeshInfo(pMesh m) {
129
129
struct SimMeshEntInfo {
130
130
int maxDim;
131
131
bool hasNumbering;
132
+ pMeshDataId* transformedCoordId;
132
133
133
- SimMeshEntInfo (std::array<int ,4 > numEnts, bool hasNumbering_in) {
134
+ SimMeshEntInfo (std::array<int ,4 > numEnts, bool hasNumbering_in, pMeshDataId* transformedCoordId_in = NULL ) {
134
135
hasNumbering = hasNumbering_in;
136
+ transformedCoordId = transformedCoordId_in;
135
137
maxDim = getMaxDim (numEnts);
136
138
}
137
139
@@ -160,9 +162,30 @@ struct SimMeshEntInfo {
160
162
VIter vertices = M_vertexIter (m);
161
163
pVertex vtx;
162
164
LO v = 0 ;
165
+
163
166
while ((vtx = (pVertex) VIter_next (vertices))) {
164
167
double xyz[3 ];
165
168
V_coord (vtx,xyz);
169
+
170
+ // Convert coordinates from 3d cartesian to desired coordinates
171
+ if (transformedCoordId)
172
+ {
173
+ if (EN_getDataPtr ((pEntity)vtx, *transformedCoordId, NULL ))
174
+ {
175
+ double * tData; // transformation data
176
+ EN_getDataPtr ((pEntity)vtx, *transformedCoordId, (void **)&tData);
177
+ xyz[0 ] = tData[0 ];
178
+ xyz[1 ] = tData[1 ];
179
+ xyz[2 ] = tData[2 ];
180
+ }
181
+ else
182
+ {
183
+ Omega_h_fail (" Coordinate transformation pointer is not NULL and transformation data is not \n "
184
+ " accessible on the vertex with location %f, %f, %f. Make sure \n "
185
+ " to attach transformation data or set transformedCoordId pointer to NULL. \n "
186
+ , xyz[0 ], xyz[1 ], xyz[2 ]);
187
+ }
188
+ }
166
189
if ( maxDim < 3 && xyz[2 ] != 0 )
167
190
Omega_h_fail (" The z coordinate must be zero for a 2d mesh!\n " );
168
191
for (int j=0 ; j<maxDim; j++) {
@@ -529,7 +552,7 @@ void readMixed_internal(pMesh m, MixedMesh* mesh, SimMeshInfo info) {
529
552
Read<I8>(mixedRgnClass.pyramid .dim .write ()));
530
553
}
531
554
532
- void read_internal (pMesh m, Mesh* mesh, pMeshNex numbering, SimMeshInfo info) {
555
+ void read_internal (pMesh m, Mesh* mesh, pMeshNex numbering, SimMeshInfo info, pMeshDataId* transformedCoordId = NULL ) {
533
556
assert (info.is_simplex || info.is_hypercube );
534
557
if (!info.is_simplex && !info.is_hypercube ) {
535
558
Omega_h_fail (" Attempting to use the mono topology reader for a mixed"
@@ -543,7 +566,7 @@ void read_internal(pMesh m, Mesh* mesh, pMeshNex numbering, SimMeshInfo info) {
543
566
544
567
const bool hasNumbering = (numbering != NULL );
545
568
546
- SimMeshEntInfo simEnts ({{numVtx,numEdges,numFaces,numRegions}}, hasNumbering);
569
+ SimMeshEntInfo simEnts ({{numVtx,numEdges,numFaces,numRegions}}, hasNumbering, transformedCoordId );
547
570
mesh->set_dim (simEnts.maxDim );
548
571
if (info.is_simplex ) {
549
572
mesh->set_family (OMEGA_H_SIMPLEX);
@@ -660,14 +683,14 @@ MixedMesh readMixedImpl(filesystem::path const& mesh_fname,
660
683
return mesh;
661
684
}
662
685
663
- Mesh read (pMesh* m, filesystem::path const & numbering_fname, CommPtr comm) {
686
+ Mesh read (pMesh* m, filesystem::path const & numbering_fname, CommPtr comm, pMeshDataId* transformedCoordId ) {
664
687
auto simMeshInfo = getSimMeshInfo (*m);
665
688
const bool hasNumbering = (numbering_fname.native () != std::string (" " ));
666
689
pMeshNex numbering = hasNumbering ? MeshNex_load (numbering_fname.c_str (), *m) : nullptr ;
667
690
auto mesh = Mesh (comm->library ());
668
691
mesh.set_comm (comm);
669
692
mesh.set_parting (OMEGA_H_ELEM_BASED);
670
- meshsim::read_internal (*m, &mesh, numbering, simMeshInfo);
693
+ meshsim::read_internal (*m, &mesh, numbering, simMeshInfo, transformedCoordId );
671
694
if (hasNumbering) MeshNex_delete (numbering);
672
695
return mesh;
673
696
}
0 commit comments