@@ -68,84 +68,50 @@ void MeshManager::expandObjectCatalogs()
6868
6969void MeshManager::generateMeshes ( DomainPartition & domain )
7070{
71- // First, check if there's any work to do at all.
72- // Count the number of mesh generators registered.
71+ // Early return if no work to do
7372 int numMeshGenerators = 0 ;
7473 forSubGroups< MeshGeneratorBase >( [&]( MeshGeneratorBase const & ) { ++numMeshGenerators; } );
7574
76- // If there are no mesh generators, this is a meshless run.
77- // This function has nothing to do, so return immediately.
7875 if ( numMeshGenerators == 0 )
7976 {
8077 GEOS_LOG_RANK_0 ( " No mesh generators found in MeshManager. Assuming meshless simulation." );
8178 return ;
8279 }
8380
84- // Temporary partitioner manager for unit tests (will be deleted at end of function )
81+ // Get partitioner (create temporary if needed for unit tests )
8582 std::unique_ptr< PartitionerManager > tempPartitionerManager;
83+ DomainPartitioner * partitioner = nullptr ;
8684
87- // If no partitioner exists, create a default one based on mesh type
88- // This might happen in tests where there's no ProblemManager parent
89- if ( !domain.hasPartitioner () )
85+ if ( domain.hasPartitioner () )
9086 {
91- // Check if the domain has a parent (ProblemManager)
92- PartitionerManager * partitionerManager = nullptr ;
93-
94- if ( domain.hasParent () )
95- {
96- Group & problemManager = domain.getParent ();
97- if ( problemManager.hasGroup ( ProblemManager::groupKeysStruct ().partitionerManager .key () ) )
98- {
99- partitionerManager = &problemManager.getGroup < PartitionerManager >(
100- ProblemManager::groupKeysStruct ().partitionerManager .key () );
101- }
102- }
103-
104- // If no PartitionerManager found, create a temporary one (for unit tests)
105- if ( partitionerManager == nullptr )
106- {
107- GEOS_LOG_RANK_0 ( " No PartitionerManager available (likely a unit test). "
108- " Creating temporary PartitionerManager." );
109- tempPartitionerManager = std::make_unique< PartitionerManager >( " tempPartitionerManager" , &domain );
110- partitionerManager = tempPartitionerManager.get ();
111- }
87+ partitioner = &domain.getPartitioner ();
88+ }
89+ else
90+ {
91+ GEOS_LOG_RANK_0 ( " No PartitionerManager available (likely a unit test). "
92+ " Creating temporary PartitionerManager." );
93+ tempPartitionerManager = std::make_unique< PartitionerManager >( " tempPartitionerManager" , &domain );
94+ partitioner = &tempPartitionerManager->getPartitioner ();
11295 }
11396
97+ // Generate all meshes
11498 forSubGroups< MeshGeneratorBase >( [&]( MeshGeneratorBase & meshGen )
11599 {
116100 MeshBody & meshBody = domain.getMeshBodies ().registerGroup < MeshBody >( meshGen.getName () );
117101 meshBody.createMeshLevel ( 0 );
118102
119- // Get the partitioner (either from ProblemManager or temporary)
120- DomainPartitioner * partitioner = nullptr ;
121- if ( domain.hasPartitioner () )
122- {
123- partitioner = &domain.getPartitioner ();
124- }
125- else if ( tempPartitionerManager != nullptr )
126- {
127- partitioner = &tempPartitionerManager->getPartitioner ();
128- }
129-
130- if ( partitioner != nullptr )
131- {
132- meshGen.generateMesh ( meshBody, *partitioner );
133- }
134- else
135- {
136- GEOS_ERROR ( " No partitioner available for mesh generation" );
137- }
103+ meshGen.generateMesh ( meshBody, *partitioner );
138104
139105 if ( !meshBody.hasParticles () )
140106 {
141107 CellBlockManagerABC const & cellBlockManager = meshBody.getCellBlockManager ();
142-
143108 meshBody.setGlobalLengthScale ( std::max ( cellBlockManager.getGlobalLength (),
144109 cellBlockManager.getGlobalOffset () ) );
145110 }
146111 } );
147112}
148113
114+
149115void MeshManager::generateMeshLevels ( DomainPartition & domain )
150116{
151117 forSubGroups< MeshGeneratorBase >( [&]( MeshGeneratorBase & meshGen )
@@ -292,7 +258,7 @@ void MeshManager::createDefaultPartitioner( PartitionerManager & partitionerMana
292258 }
293259 } );
294260
295- // Check for incompatible combination FIRST
261+ // Check for incompatible combination
296262 if ( hasInternalMesh && hasExternalMesh )
297263 {
298264 GEOS_ERROR ( " Both internal and external meshes detected, but no partitioner specified." );
0 commit comments