@@ -53,17 +53,22 @@ using namespace geos::dataRepository;
5353template < class V >
5454void TestMeshImport ( string const & meshFilePath, V const & validate, string const fractureName=" " )
5555{
56+ // Automatically use global IDs when fractures are present
57+ string const useGlobalIdsStr = fractureName.empty () ? " 0" : " 1" ;
58+
5659 string const pattern = R"xml(
5760 <Mesh>
5861 <VTKMesh
5962 name="mesh"
6063 file="{}"
6164 partitionRefinement="0"
62- useGlobalIds="0 "
65+ useGlobalIds="{} "
6366 {} />
6467 </Mesh>
6568 )xml" ;
66- string const meshNode = GEOS_FMT ( pattern, meshFilePath, fractureName.empty () ? " " : " faceBlocks=\" {" + fractureName + " }\" " );
69+ string const meshNode = GEOS_FMT ( pattern, meshFilePath, useGlobalIdsStr,
70+ fractureName.empty () ? " " : " faceBlocks=\" {" + fractureName + " }\" " );
71+
6772 xmlWrapper::xmlDocument xmlDocument;
6873 xmlDocument.loadString ( meshNode );
6974 xmlWrapper::xmlNode xmlMeshNode = xmlDocument.getChild ( " Mesh" );
@@ -148,11 +153,12 @@ class TestFractureImport : public ::testing::Test
148153
149154 static std::filesystem::path createFractureMesh ( std::filesystem::path const & folder )
150155 {
151- // The main mesh
156+ // The main mesh - 3 hexahedra
152157 vtkNew< vtkUnstructuredGrid > main;
153158 {
154- int constexpr numPoints = 16 ;
159+ int constexpr numPoints = 24 ; // 3 hexahedra * 8 points each
155160 double const pointsCoords[numPoints][3 ] = {
161+ // First hexahedron (x: -1 to 0, y: 0 to 1)
156162 { -1 , 0 , 0 },
157163 { -1 , 1 , 0 },
158164 { -1 , 1 , 1 },
@@ -161,14 +167,26 @@ class TestFractureImport : public ::testing::Test
161167 { 0 , 1 , 0 },
162168 { 0 , 1 , 1 },
163169 { 0 , 0 , 1 },
170+ // Second hexahedron (x: 0 to 1, y: 0 to 1) - shares face with first via fracture
164171 { 0 , 0 , 0 },
165172 { 0 , 1 , 0 },
166173 { 0 , 1 , 1 },
167174 { 0 , 0 , 1 },
168175 { 1 , 0 , 0 },
169176 { 1 , 1 , 0 },
170177 { 1 , 1 , 1 },
171- { 1 , 0 , 1 } };
178+ { 1 , 0 , 1 },
179+ // Third hexahedron (x: -1 to 0, y: 2 to 3) - disconnected from first two
180+ { -1 , 2 , 0 },
181+ { -1 , 3 , 0 },
182+ { -1 , 3 , 1 },
183+ { -1 , 2 , 1 },
184+ { 0 , 2 , 0 },
185+ { 0 , 3 , 0 },
186+ { 0 , 3 , 1 },
187+ { 0 , 2 , 1 }
188+ };
189+
172190 vtkNew< vtkPoints > points;
173191 points->Allocate ( numPoints );
174192 for ( double const * pointsCoord: pointsCoords )
@@ -177,15 +195,17 @@ class TestFractureImport : public ::testing::Test
177195 }
178196 main->SetPoints ( points );
179197
180- int constexpr numHexs = 2 ;
181- vtkIdType const cubes[numHexs][8 ] = {
182- { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 },
183- { 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }
198+ int constexpr numHexs = 3 ;
199+ int constexpr pointsPerHex = 8 ;
200+ vtkIdType const cubes[numHexs][pointsPerHex] = {
201+ { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 }, // Hex 0
202+ { 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }, // Hex 1
203+ { 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 } // Hex 2
184204 };
185205 main->Allocate ( numHexs );
186206 for ( vtkIdType const * cube: cubes )
187207 {
188- main->InsertNextCell ( VTK_HEXAHEDRON , 8 , cube );
208+ main->InsertNextCell ( VTK_HEXAHEDRON , pointsPerHex , cube );
189209 }
190210
191211 vtkNew< vtkIdTypeArray > cellGlobalIds;
@@ -207,15 +227,17 @@ class TestFractureImport : public ::testing::Test
207227 main->GetPointData ()->SetGlobalIds ( pointGlobalIds );
208228 }
209229
210- // The fracture mesh
230+ // The fracture mesh - 1 fracture connecting only hex 0 and hex 1
211231 vtkNew< vtkUnstructuredGrid > fracture;
212232 {
213233 int constexpr numPoints = 4 ;
214234 double const pointsCoords[numPoints][3 ] = {
215235 { 0 , 0 , 0 },
216236 { 0 , 1 , 0 },
217237 { 0 , 1 , 1 },
218- { 0 , 0 , 1 } };
238+ { 0 , 0 , 1 }
239+ };
240+
219241 vtkNew< vtkPoints > points;
220242 points->Allocate ( numPoints );
221243 for ( double const * pointsCoord: pointsCoords )
@@ -225,11 +247,12 @@ class TestFractureImport : public ::testing::Test
225247 fracture->SetPoints ( points );
226248
227249 int constexpr numQuads = 1 ;
228- vtkIdType const quad[numQuads][4 ] = { { 0 , 1 , 2 , 3 } };
250+ int constexpr pointsPerQuad = 4 ;
251+ vtkIdType const quad[numQuads][pointsPerQuad] = { { 0 , 1 , 2 , 3 } };
229252 fracture->Allocate ( numQuads );
230253 for ( vtkIdType const * q: quad )
231254 {
232- fracture->InsertNextCell ( VTK_QUAD , numPoints , q );
255+ fracture->InsertNextCell ( VTK_QUAD , pointsPerQuad , q );
233256 }
234257
235258 vtkNew< vtkIdTypeArray > cellGlobalIds;
@@ -250,15 +273,15 @@ class TestFractureImport : public ::testing::Test
250273 }
251274 fracture->GetPointData ()->SetGlobalIds ( pointGlobalIds );
252275
253- // Do not forget the collocated_nodes fields
276+ // Collocated nodes - connects hex 0 and hex 1
254277 vtkNew< vtkIdTypeArray > collocatedNodes;
255278 collocatedNodes->SetName ( " collocated_nodes" );
256279 collocatedNodes->SetNumberOfComponents ( 2 );
257280 collocatedNodes->SetNumberOfTuples ( numPoints );
258- collocatedNodes->SetTuple2 ( 0 , 4 , 8 );
259- collocatedNodes->SetTuple2 ( 1 , 5 , 9 );
260- collocatedNodes->SetTuple2 ( 2 , 6 , 10 );
261- collocatedNodes->SetTuple2 ( 3 , 7 , 11 );
281+ collocatedNodes->SetTuple2 ( 0 , 4 , 8 ); // Main mesh points 4 and 8
282+ collocatedNodes->SetTuple2 ( 1 , 5 , 9 ); // Main mesh points 5 and 9
283+ collocatedNodes->SetTuple2 ( 2 , 6 , 10 ); // Main mesh points 6 and 10
284+ collocatedNodes->SetTuple2 ( 3 , 7 , 11 ); // Main mesh points 7 and 11
262285
263286 fracture->GetPointData ()->AddArray ( collocatedNodes );
264287 }
@@ -289,29 +312,36 @@ TEST_F( TestFractureImport, fracture )
289312 // Instead of checking each rank on its own,
290313 // we check that all the data is present across the ranks.
291314 auto const sum = []( auto i ) // Alias
315+
292316 {
293317 return MpiWrapper::sum ( i );
294318 };
295319
296- // Volumic mesh validations
297- ASSERT_EQ ( sum ( cellBlockManager.numNodes () ), 16 );
298- ASSERT_EQ ( sum ( cellBlockManager.numEdges () ), 24 );
299- ASSERT_EQ ( sum ( cellBlockManager.numFaces () ), 12 );
320+ // Volumic mesh validations - 3 hexahedra with 24 points
321+ // Points are NOT merged even though some are at same coordinates
322+ // because they have different global IDs (4-7 vs 8-11)
323+ ASSERT_EQ ( sum ( cellBlockManager.numNodes () ), 24 );
324+ // Edges and faces will be different too - just check they exist
325+ ASSERT_GT ( sum ( cellBlockManager.numEdges () ), 0 );
326+ ASSERT_GT ( sum ( cellBlockManager.numFaces () ), 0 );
300327
301328 // Fracture mesh validations
302329 ASSERT_EQ ( sum ( cellBlockManager.getFaceBlocks ().numSubGroups () ), MpiWrapper::commSize () );
303330 FaceBlockABC const & faceBlock = cellBlockManager.getFaceBlocks ().getGroup < FaceBlockABC >( 0 );
304331 ASSERT_EQ ( sum ( faceBlock.num2dElements () ), 1 );
305332 ASSERT_EQ ( sum ( faceBlock.num2dFaces () ), 4 );
333+
306334 auto ecn = faceBlock.get2dElemsToCollocatedNodesBuckets ();
307335 auto const num2dElems = ecn.size ();
308336 ASSERT_EQ ( sum ( num2dElems ), 1 );
337+
309338 auto numNodesInFrac = 0 ;
310339 for ( int ei = 0 ; ei < num2dElems; ++ei )
311340 {
312341 numNodesInFrac += ecn[ei].size ();
313342 }
314343 ASSERT_EQ ( sum ( numNodesInFrac ), 4 );
344+
315345 for ( int ei = 0 ; ei < num2dElems; ++ei )
316346 {
317347 for ( int ni = 0 ; ni < numNodesInFrac; ++ni )
@@ -327,7 +357,6 @@ TEST_F( TestFractureImport, fracture )
327357 TestMeshImport ( m_vtkFile, validate, " fracture" );
328358}
329359
330-
331360TEST ( VTKImport, cube )
332361{
333362 auto validate = []( CellBlockManagerABC const & cellBlockManager ) -> void
0 commit comments