From f46fb7aeafd0fae4ac1268b80cad3800d93a6865 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Thu, 12 Dec 2024 15:44:20 -0600 Subject: [PATCH 1/7] fix: fix issue #2615 (#3477) --- src/coreComponents/mesh/FieldIdentifiers.hpp | 7 ++++--- .../mesh/mpiCommunications/NeighborCommunicator.cpp | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/coreComponents/mesh/FieldIdentifiers.hpp b/src/coreComponents/mesh/FieldIdentifiers.hpp index dcbd8620f6..82a0505056 100644 --- a/src/coreComponents/mesh/FieldIdentifiers.hpp +++ b/src/coreComponents/mesh/FieldIdentifiers.hpp @@ -98,11 +98,11 @@ class FieldIdentifiers * @brief Get the Location object * * @param key key used to store the list of fields in the map. - * @param location mesh location where fields defined by the key provided were registered. + * @return mesh location where fields defined by the key provided were registered. */ - void getLocation( string const & key, - FieldLocation & location ) const + FieldLocation getLocation( string const & key ) const { + FieldLocation location{}; if( key.find( m_locationKeys.nodesKey() ) != string::npos ) { location = FieldLocation::Node; @@ -123,6 +123,7 @@ class FieldIdentifiers { GEOS_ERROR( GEOS_FMT( "Invalid key, {}, was provided. Location cannot be retrieved.", key ) ); } + return location; } private: diff --git a/src/coreComponents/mesh/mpiCommunications/NeighborCommunicator.cpp b/src/coreComponents/mesh/mpiCommunications/NeighborCommunicator.cpp index fd8cfbf366..3300cd2dda 100644 --- a/src/coreComponents/mesh/mpiCommunications/NeighborCommunicator.cpp +++ b/src/coreComponents/mesh/mpiCommunications/NeighborCommunicator.cpp @@ -511,8 +511,7 @@ int NeighborCommunicator::packCommSizeForSync( FieldIdentifiers const & fieldsTo for( auto const & iter : fieldsToBeSync.getFields() ) { - FieldLocation location{}; - fieldsToBeSync.getLocation( iter.first, location ); + FieldLocation const location = fieldsToBeSync.getLocation( iter.first ); switch( location ) { case FieldLocation::Node: @@ -569,8 +568,7 @@ void NeighborCommunicator::packCommBufferForSync( FieldIdentifiers const & field for( auto const & iter : fieldsToBeSync.getFields() ) { - FieldLocation location{}; - fieldsToBeSync.getLocation( iter.first, location ); + FieldLocation const location = fieldsToBeSync.getLocation( iter.first ); switch( location ) { case FieldLocation::Node: @@ -628,8 +626,7 @@ void NeighborCommunicator::unpackBufferForSync( FieldIdentifiers const & fieldsT for( auto const & iter : fieldsToBeSync.getFields() ) { - FieldLocation location{}; - fieldsToBeSync.getLocation( iter.first, location ); + FieldLocation const location = fieldsToBeSync.getLocation( iter.first ); switch( location ) { case FieldLocation::Node: From da4cd7f555c62efe144dc2edce0f462e44fefc2a Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Thu, 12 Dec 2024 21:43:12 -0600 Subject: [PATCH 2/7] fix: fix small typo in ATS docs (#3478) --- .github/workflows/ci_tests.yml | 2 +- src/docs/sphinx/developerGuide/Contributing/IntegratedTests.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index a1803a9e00..32d77b0cc5 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -330,7 +330,7 @@ jobs: DOCKER_CERTS_DIR: "/etc/pki/ca-trust/source/anchors" DOCKER_CERTS_UPDATE_COMMAND: "update-ca-trust" - - name: Pangea 3 (AlmaLinux 8.8, gcc 9.4.0, open-mpi 4.1.2, cuda 11.5.0, openblas 0.3.10) + - name: Pangea 3 CUDA (AlmaLinux 8.8, gcc 9.4.0, open-mpi 4.1.2, cuda 11.5.0, openblas 0.3.10) BUILD_AND_TEST_CLI_ARGS: "--build-exe-only --no-install-schema" CMAKE_BUILD_TYPE: Release BUILD_GENERATOR: "--makefile" diff --git a/src/docs/sphinx/developerGuide/Contributing/IntegratedTests.rst b/src/docs/sphinx/developerGuide/Contributing/IntegratedTests.rst index 2f712ee550..4841a4fab4 100644 --- a/src/docs/sphinx/developerGuide/Contributing/IntegratedTests.rst +++ b/src/docs/sphinx/developerGuide/Contributing/IntegratedTests.rst @@ -121,7 +121,7 @@ After building GEOS, the integrated tests can be triggered in the GEOS build dir .. note:: - The `make_ats_environment` and `ats_run` steps may require internet access to collect python packages and baseline files. + The `make ats_environment` and `make ats_run` steps may require internet access to collect python packages and baseline files. .. note:: From b5ea7ce672974c5a68c7ac2443dfe8ac02c81f67 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Fri, 13 Dec 2024 11:47:46 -0600 Subject: [PATCH 3/7] refactor: some more details for mesh import, unify createChild log messages (#3476) Co-authored-by: Nicola Castelletto <38361926+castelletto1@users.noreply.github.com> --- .../constitutive/ConstitutiveManager.cpp | 1 + .../dataRepository/xmlWrapper.cpp | 2 +- src/coreComponents/events/EventBase.cpp | 2 +- src/coreComponents/events/EventManager.cpp | 2 +- .../events/tasks/TasksManager.cpp | 1 + .../FieldSpecificationManager.cpp | 1 + .../fileIO/Outputs/OutputManager.cpp | 2 +- .../FiniteElementDiscretizationManager.cpp | 1 + .../finiteVolume/FiniteVolumeManager.cpp | 1 + .../functions/FunctionManager.cpp | 2 +- .../mesh/ElementRegionManager.cpp | 2 +- .../mesh/ExternalDataSourceBase.cpp | 2 +- .../mesh/ExternalDataSourceManager.cpp | 2 +- src/coreComponents/mesh/MeshManager.cpp | 96 +++++++++---------- src/coreComponents/mesh/MeshManager.hpp | 17 ++++ src/coreComponents/mesh/ParticleManager.cpp | 2 +- .../mesh/generators/MeshGeneratorBase.cpp | 2 +- .../mesh/generators/VTKMeshGenerator.cpp | 22 ++--- .../mesh/generators/WellGeneratorBase.cpp | 2 +- .../GeometricObjectManager.cpp | 2 +- .../physicsSolvers/PhysicsSolverManager.cpp | 2 +- 21 files changed, 94 insertions(+), 72 deletions(-) diff --git a/src/coreComponents/constitutive/ConstitutiveManager.cpp b/src/coreComponents/constitutive/ConstitutiveManager.cpp index e3e59bb755..3babd88203 100644 --- a/src/coreComponents/constitutive/ConstitutiveManager.cpp +++ b/src/coreComponents/constitutive/ConstitutiveManager.cpp @@ -43,6 +43,7 @@ ConstitutiveManager::~ConstitutiveManager() Group * ConstitutiveManager::createChild( string const & childKey, string const & childName ) { + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< ConstitutiveBase > material = ConstitutiveBase::CatalogInterface::factory( childKey, childName, this ); return ®isterGroup< ConstitutiveBase >( childName, std::move( material ) ); } diff --git a/src/coreComponents/dataRepository/xmlWrapper.cpp b/src/coreComponents/dataRepository/xmlWrapper.cpp index 19f0f223e1..e0ada302c4 100644 --- a/src/coreComponents/dataRepository/xmlWrapper.cpp +++ b/src/coreComponents/dataRepository/xmlWrapper.cpp @@ -171,7 +171,7 @@ void xmlDocument::addIncludedXML( xmlNode & targetNode, int const level ) return isAbsolutePath( fileName ) ? fileName : joinPath( splitPath( currentFilePath ).first, fileName ); }(); - GEOS_LOG_RANK_0( "Included additionnal XML file: " << getAbsolutePath( includedFilePath ) ); + GEOS_LOG_RANK_0( "Included additional XML file: " << getAbsolutePath( includedFilePath ) ); xmlDocument includedXmlDocument; xmlResult const result = includedXmlDocument.loadFile( includedFilePath, hasNodeFileInfo() ); diff --git a/src/coreComponents/events/EventBase.cpp b/src/coreComponents/events/EventBase.cpp index 6b9a2f2c0c..6212dc89d6 100644 --- a/src/coreComponents/events/EventBase.cpp +++ b/src/coreComponents/events/EventBase.cpp @@ -122,7 +122,7 @@ EventBase::CatalogInterface::CatalogType & EventBase::getCatalog() Group * EventBase::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Event: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< EventBase >( childName, std::move( event ) ); } diff --git a/src/coreComponents/events/EventManager.cpp b/src/coreComponents/events/EventManager.cpp index a30706b8aa..69c3a46dd9 100644 --- a/src/coreComponents/events/EventManager.cpp +++ b/src/coreComponents/events/EventManager.cpp @@ -93,7 +93,7 @@ EventManager::~EventManager() Group * EventManager::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Event: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< EventBase >( childName, std::move( event ) ); } diff --git a/src/coreComponents/events/tasks/TasksManager.cpp b/src/coreComponents/events/tasks/TasksManager.cpp index ea0eea28a4..9f95aefb2a 100644 --- a/src/coreComponents/events/tasks/TasksManager.cpp +++ b/src/coreComponents/events/tasks/TasksManager.cpp @@ -38,6 +38,7 @@ TasksManager::~TasksManager() Group * TasksManager::createChild( string const & childKey, string const & childName ) { + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< TaskBase > task = TaskBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< TaskBase >( childName, std::move( task ) ); } diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 307437e748..155596304d 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -51,6 +51,7 @@ FieldSpecificationManager & FieldSpecificationManager::getInstance() Group * FieldSpecificationManager::createChild( string const & childKey, string const & childName ) { + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< FieldSpecificationBase > bc = FieldSpecificationBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup( childName, std::move( bc ) ); } diff --git a/src/coreComponents/fileIO/Outputs/OutputManager.cpp b/src/coreComponents/fileIO/Outputs/OutputManager.cpp index 157328fa24..42ea71af77 100644 --- a/src/coreComponents/fileIO/Outputs/OutputManager.cpp +++ b/src/coreComponents/fileIO/Outputs/OutputManager.cpp @@ -39,7 +39,7 @@ OutputManager::~OutputManager() Group * OutputManager::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Output: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< OutputBase > output = OutputBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< OutputBase >( childName, std::move( output ) ); } diff --git a/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp b/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp index 2e7c8e3ccc..8bd43f0cda 100644 --- a/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp +++ b/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp @@ -40,6 +40,7 @@ FiniteElementDiscretizationManager::~FiniteElementDiscretizationManager() Group * FiniteElementDiscretizationManager::createChild( string const & childKey, string const & childName ) { // These objects should probably not be registered on managed group... + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< Group > fem = Group::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup( childName, std::move( fem ) ); } diff --git a/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp b/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp index 14161b5a0e..500d1da5ec 100644 --- a/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp +++ b/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp @@ -42,6 +42,7 @@ FiniteVolumeManager::~FiniteVolumeManager() Group * FiniteVolumeManager::createChild( string const & childKey, string const & childName ) { + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); if( childKey == HybridMimeticDiscretization::catalogName() ) { std::unique_ptr< HybridMimeticDiscretization > hm = std::make_unique< HybridMimeticDiscretization >( childName, this ); diff --git a/src/coreComponents/functions/FunctionManager.cpp b/src/coreComponents/functions/FunctionManager.cpp index 738432e89d..0cd5a92ba9 100644 --- a/src/coreComponents/functions/FunctionManager.cpp +++ b/src/coreComponents/functions/FunctionManager.cpp @@ -53,7 +53,7 @@ FunctionManager & FunctionManager::getInstance() Group * FunctionManager::createChild( string const & functionCatalogKey, string const & functionName ) { - GEOS_LOG_RANK_0( " " << functionCatalogKey << ": " << functionName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), functionCatalogKey, functionName ) ); std::unique_ptr< FunctionBase > function = FunctionBase::CatalogInterface::factory( functionCatalogKey, functionName, this ); return &this->registerGroup< FunctionBase >( functionName, std::move( function ) ); } diff --git a/src/coreComponents/mesh/ElementRegionManager.cpp b/src/coreComponents/mesh/ElementRegionManager.cpp index 89c0500338..18da04ec06 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -75,7 +75,7 @@ Group * ElementRegionManager::createChild( string const & childKey, string const { GEOS_ERROR_IF( !(CatalogInterface::hasKeyName( childKey )), "KeyName ("<getGroup( ElementRegionManager::groupKeyStruct::elementRegionsGroup() ); return &elementRegions.registerGroup( childName, diff --git a/src/coreComponents/mesh/ExternalDataSourceBase.cpp b/src/coreComponents/mesh/ExternalDataSourceBase.cpp index 2f3ea7bf8a..157fe3de31 100644 --- a/src/coreComponents/mesh/ExternalDataSourceBase.cpp +++ b/src/coreComponents/mesh/ExternalDataSourceBase.cpp @@ -27,7 +27,7 @@ ExternalDataSourceBase::ExternalDataSourceBase( string const & name, Group * con Group * ExternalDataSourceBase::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding External Data Source: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< ExternalDataSourceBase > event = ExternalDataSourceBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< ExternalDataSourceBase >( childName, std::move( event ) ); } diff --git a/src/coreComponents/mesh/ExternalDataSourceManager.cpp b/src/coreComponents/mesh/ExternalDataSourceManager.cpp index 5cd6eb6fd8..8a22203af8 100644 --- a/src/coreComponents/mesh/ExternalDataSourceManager.cpp +++ b/src/coreComponents/mesh/ExternalDataSourceManager.cpp @@ -35,7 +35,7 @@ ExternalDataSourceManager::~ExternalDataSourceManager() Group * ExternalDataSourceManager::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding External Data Source: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< ExternalDataSourceBase > externalDataSource = ExternalDataSourceBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< ExternalDataSourceBase >( childName, std::move( externalDataSource ) ); } diff --git a/src/coreComponents/mesh/MeshManager.cpp b/src/coreComponents/mesh/MeshManager.cpp index e5bc0979c8..662b06002b 100644 --- a/src/coreComponents/mesh/MeshManager.cpp +++ b/src/coreComponents/mesh/MeshManager.cpp @@ -20,7 +20,6 @@ #include "mesh/mpiCommunications/SpatialPartition.hpp" #include "generators/CellBlockManagerABC.hpp" -#include "generators/MeshGeneratorBase.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" #include "common/TimingMacros.hpp" @@ -43,7 +42,7 @@ MeshManager::~MeshManager() Group * MeshManager::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Mesh: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< MeshGeneratorBase > mesh = MeshGeneratorBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< MeshGeneratorBase >( childName, std::move( mesh ) ); } @@ -81,7 +80,7 @@ void MeshManager::generateMeshes( DomainPartition & domain ) void MeshManager::generateMeshLevels( DomainPartition & domain ) { - this->forSubGroups< MeshGeneratorBase >( [&]( MeshGeneratorBase & meshGen ) + forSubGroups< MeshGeneratorBase >( [&]( MeshGeneratorBase & meshGen ) { string const & meshName = meshGen.getName(); domain.getMeshBodies().registerGroup< MeshBody >( meshName ).createMeshLevel( MeshBody::groupStructKeys::baseDiscretizationString() ); @@ -126,50 +125,10 @@ void MeshManager::importFields( DomainPartition & domain ) } GEOS_LOG_RANK_0( GEOS_FMT( "{}: importing field data from mesh dataset", generator.getName() ) ); - - auto const importFields = [&generator]( ElementRegionBase const & region, - ElementSubRegionBase & subRegion, - MeshGeneratorBase::Block block, - std::map< string, string > const & fieldsMapping, - FieldIdentifiers & fieldsToBeSync ) - { - std::unordered_set< string > const materialWrapperNames = getMaterialWrapperNames( subRegion ); - // Writing properties - for( auto const & pair : fieldsMapping ) - { - string const & meshFieldName = pair.first; - string const & geosFieldName = pair.second; - // Find destination - if( !subRegion.hasWrapper( geosFieldName ) ) - { - // Skip - the user may have not enabled a particular physics model/solver on this destination region. - if( generator.getLogLevel() >= 1 ) - { - GEOS_LOG_RANK_0( "Skipping import of " << meshFieldName << " -> " << geosFieldName << - " on " << region.getName() << "/" << subRegion.getName() << " (field not found)" ); - } - - continue; - } - - // Now that we know that the subRegion has this wrapper, - // we can add the geosFieldName to the list of fields to synchronize - fieldsToBeSync.addElementFields( { geosFieldName }, { region.getName() } ); - WrapperBase & wrapper = subRegion.getWrapperBase( geosFieldName ); - if( generator.getLogLevel() >= 1 ) - { - GEOS_LOG_RANK_0( "Importing field " << meshFieldName << " into " << geosFieldName << - " on " << region.getName() << "/" << subRegion.getName() ); - } - - bool const isMaterialField = materialWrapperNames.count( geosFieldName ) > 0 && wrapper.numArrayDims() > 1; - generator.importFieldOnArray( block, subRegion.getName(), meshFieldName, isMaterialField, wrapper ); - } - }; - - dataRepository::Group & meshLevels = domain.getMeshBody( generator.getName() ).getMeshLevels(); - meshLevels.forSubGroups< MeshLevel >( [&]( MeshLevel & meshLevel ) + MeshBody & meshBody = domain.getMeshBody( generator.getName() ); + meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) { + GEOS_LOG_RANK_0( GEOS_FMT( " mesh level = {}", meshLevel.getName() ) ); FieldIdentifiers fieldsToBeSync; meshLevel.getElemManager().forElementSubRegionsComplete< CellElementSubRegion >( [&]( localIndex, @@ -177,7 +136,8 @@ void MeshManager::importFields( DomainPartition & domain ) ElementRegionBase const & region, CellElementSubRegion & subRegion ) { - importFields( region, subRegion, MeshGeneratorBase::Block::VOLUMIC, generator.getVolumicFieldsMapping(), fieldsToBeSync ); + GEOS_LOG_RANK_0( GEOS_FMT( " volumic fields on {}/{}", region.getName(), subRegion.getName() ) ); + importFields( generator, region.getName(), subRegion, MeshGeneratorBase::Block::VOLUMIC, generator.getVolumicFieldsMapping(), fieldsToBeSync ); } ); meshLevel.getElemManager().forElementSubRegionsComplete< FaceElementSubRegion >( [&]( localIndex, @@ -185,7 +145,8 @@ void MeshManager::importFields( DomainPartition & domain ) ElementRegionBase const & region, FaceElementSubRegion & subRegion ) { - importFields( region, subRegion, MeshGeneratorBase::Block::SURFACIC, generator.getSurfacicFieldsMapping(), fieldsToBeSync ); + GEOS_LOG_RANK_0( GEOS_FMT( " surfaic fields on {}/{}", region.getName(), subRegion.getName() ) ); + importFields( generator, region.getName(), subRegion, MeshGeneratorBase::Block::SURFACIC, generator.getSurfacicFieldsMapping(), fieldsToBeSync ); } ); CommunicationTools::getInstance().synchronizeFields( fieldsToBeSync, meshLevel, domain.getNeighbors(), false ); // TODO Validate this. } ); @@ -197,4 +158,43 @@ void MeshManager::importFields( DomainPartition & domain ) } ); } +void MeshManager::importFields( MeshGeneratorBase const & generator, + string const & regionName, + ElementSubRegionBase & subRegion, + MeshGeneratorBase::Block const block, + std::map< string, string > const & fieldsMapping, + FieldIdentifiers & fieldsToBeSync ) +{ + std::unordered_set< string > const materialWrapperNames = getMaterialWrapperNames( subRegion ); + // Writing properties + for( auto const & pair : fieldsMapping ) + { + string const & meshFieldName = pair.first; + string const & geosFieldName = pair.second; + // Find destination + if( !subRegion.hasWrapper( geosFieldName ) ) + { + // Skip - the user may have not enabled a particular physics model/solver on this destination region. + if( generator.getLogLevel() >= 1 ) + { + GEOS_LOG_RANK_0( GEOS_FMT( " Skipping import of {} -> {} (field not found)", meshFieldName, geosFieldName ) ); + } + + continue; + } + + // Now that we know that the subRegion has this wrapper, + // we can add the geosFieldName to the list of fields to synchronize + fieldsToBeSync.addElementFields( { geosFieldName }, { regionName } ); + WrapperBase & wrapper = subRegion.getWrapperBase( geosFieldName ); + if( generator.getLogLevel() >= 1 ) + { + GEOS_LOG_RANK_0( GEOS_FMT( " {} -> {}", meshFieldName, geosFieldName ) ); + } + + bool const isMaterialField = materialWrapperNames.count( geosFieldName ) > 0 && wrapper.numArrayDims() > 1; + generator.importFieldOnArray( block, subRegion.getName(), meshFieldName, isMaterialField, wrapper ); + } +} + } /* namespace geos */ diff --git a/src/coreComponents/mesh/MeshManager.hpp b/src/coreComponents/mesh/MeshManager.hpp index 9f8ed2aaaa..d2f7eff56d 100644 --- a/src/coreComponents/mesh/MeshManager.hpp +++ b/src/coreComponents/mesh/MeshManager.hpp @@ -22,6 +22,7 @@ #include "dataRepository/Group.hpp" #include "mesh/DomainPartition.hpp" +#include "generators/MeshGeneratorBase.hpp" namespace geos { @@ -74,6 +75,22 @@ class MeshManager : public dataRepository::Group */ void importFields( DomainPartition & domain ); + /** + * @brief Import fields data + * @param[in] generator reference to mesh generator + * @param[in] regionName name of the region + * @param[in] subRegion reference to the subregion + * @param[in] block block type + * @param[in] fieldsMapping mapping for fields + * @param[out] fieldsToBeSync list of fields to synchronize + */ + static void importFields( MeshGeneratorBase const & generator, + string const & regionName, + ElementSubRegionBase & subRegion, + MeshGeneratorBase::Block block, + std::map< string, string > const & fieldsMapping, + FieldIdentifiers & fieldsToBeSync ); + private: /** diff --git a/src/coreComponents/mesh/ParticleManager.cpp b/src/coreComponents/mesh/ParticleManager.cpp index 34ddd5ae39..314c23120b 100644 --- a/src/coreComponents/mesh/ParticleManager.cpp +++ b/src/coreComponents/mesh/ParticleManager.cpp @@ -88,7 +88,7 @@ Group * ParticleManager::createChild( string const & childKey, string const & ch { GEOS_ERROR_IF( !(CatalogInterface::hasKeyName( childKey )), "KeyName ("<getGroup( ParticleManager::groupKeyStruct::particleRegionsGroup() ); return &particleRegions.registerGroup( childName, diff --git a/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp b/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp index 45971d410b..555bef9216 100644 --- a/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp @@ -29,7 +29,7 @@ MeshGeneratorBase::MeshGeneratorBase( string const & name, Group * const parent Group * MeshGeneratorBase::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Mesh attribute: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< MeshComponentBase > comp = MeshComponentBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< MeshComponentBase >( childName, std::move( comp ) ); } diff --git a/src/coreComponents/mesh/generators/VTKMeshGenerator.cpp b/src/coreComponents/mesh/generators/VTKMeshGenerator.cpp index 2b9d94ca06..6d791068df 100644 --- a/src/coreComponents/mesh/generators/VTKMeshGenerator.cpp +++ b/src/coreComponents/mesh/generators/VTKMeshGenerator.cpp @@ -125,7 +125,7 @@ void VTKMeshGenerator::fillCellBlockManager( CellBlockManager & cellBlockManager { vtk::AllMeshes allMeshes; - GEOS_LOG_LEVEL_RANK_0( 2, " reading the dataset..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': reading the dataset...", catalogName(), getName() ) ); if( !m_filePath.empty()) { @@ -183,33 +183,33 @@ void VTKMeshGenerator::fillCellBlockManager( CellBlockManager & cellBlockManager } } - GEOS_LOG_LEVEL_RANK_0( 2, " redistributing mesh..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': redistributing mesh...", catalogName(), getName() ) ); vtk::AllMeshes redistributedMeshes = vtk::redistributeMeshes( getLogLevel(), allMeshes.getMainMesh(), allMeshes.getFaceBlocks(), comm, m_partitionMethod, m_partitionRefinement, m_useGlobalIds ); m_vtkMesh = redistributedMeshes.getMainMesh(); m_faceBlockMeshes = redistributedMeshes.getFaceBlocks(); - GEOS_LOG_LEVEL_RANK_0( 2, " finding neighbor ranks..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': finding neighbor ranks...", catalogName(), getName() ) ); std::vector< vtkBoundingBox > boxes = vtk::exchangeBoundingBoxes( *m_vtkMesh, comm ); std::vector< int > const neighbors = vtk::findNeighborRanks( std::move( boxes ) ); partition.setMetisNeighborList( std::move( neighbors ) ); - GEOS_LOG_LEVEL_RANK_0( 2, " done!" ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': done!", catalogName(), getName() ) ); } - GEOS_LOG_RANK_0( GEOS_FMT( "{} '{}': generating GEOSX mesh data structure", catalogName(), getName() ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "{} '{}': generating GEOS mesh data structure", catalogName(), getName() ) ); - GEOS_LOG_LEVEL_RANK_0( 2, " preprocessing..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': preprocessing...", catalogName(), getName() ) ); m_cellMap = vtk::buildCellMap( *m_vtkMesh, m_attributeName ); - GEOS_LOG_LEVEL_RANK_0( 2, " writing nodes..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': writing nodes...", catalogName(), getName() ) ); cellBlockManager.setGlobalLength( writeNodes( getLogLevel(), *m_vtkMesh, m_nodesetNames, cellBlockManager, this->m_translate, this->m_scale ) ); - GEOS_LOG_LEVEL_RANK_0( 2, " writing cells..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': writing cells...", catalogName(), getName() ) ); writeCells( getLogLevel(), *m_vtkMesh, m_cellMap, cellBlockManager ); - GEOS_LOG_LEVEL_RANK_0( 2, " writing surfaces..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': writing surfaces...", catalogName(), getName() ) ); writeSurfaces( getLogLevel(), *m_vtkMesh, m_cellMap, cellBlockManager ); - GEOS_LOG_LEVEL_RANK_0( 2, " building connectivity maps..." ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': building connectivity maps...", catalogName(), getName() ) ); cellBlockManager.buildMaps(); for( auto const & [name, mesh]: m_faceBlockMeshes ) @@ -217,7 +217,7 @@ void VTKMeshGenerator::fillCellBlockManager( CellBlockManager & cellBlockManager vtk::importFractureNetwork( name, mesh, m_vtkMesh, cellBlockManager ); } - GEOS_LOG_LEVEL_RANK_0( 2, " done!" ); + GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{} '{}': done!", catalogName(), getName() ) ); vtk::printMeshStatistics( *m_vtkMesh, m_cellMap, comm ); } diff --git a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp index 56e7195544..f64e0e9b7d 100644 --- a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp @@ -80,7 +80,7 @@ Group * WellGeneratorBase::createChild( string const & childKey, string const & // keep track of the perforations that have been added m_perforationList.emplace_back( childName ); - GEOS_LOG_RANK_0( "Adding Well attribute: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); return ®isterGroup< Perforation >( childName ); } else diff --git a/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp b/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp index bb964e0c6d..c5843dbc74 100644 --- a/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp +++ b/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp @@ -53,7 +53,7 @@ GeometricObjectManager & GeometricObjectManager::getInstance() Group * GeometricObjectManager::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Geometric Object: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); std::unique_ptr< SimpleGeometricObjectBase > geometriObject = SimpleGeometricObjectBase::CatalogInterface::factory( childKey, childName, this ); return &this->registerGroup< SimpleGeometricObjectBase >( childName, std::move( geometriObject ) ); } diff --git a/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp b/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp index 0bf40f860d..0267c7df81 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp @@ -49,7 +49,7 @@ Group * PhysicsSolverManager::createChild( string const & childKey, string const Group * rval = nullptr; if( PhysicsSolverBase::CatalogInterface::hasKeyName( childKey ) ) { - GEOS_LOG_RANK_0( "Adding Solver of type " << childKey << ", named " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); rval = ®isterGroup( childName, PhysicsSolverBase::CatalogInterface::factory( childKey, childName, this ) ); } From 8497dfac811373c0cc4bb36deed5417e09cd1d69 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Fri, 13 Dec 2024 16:41:49 -0600 Subject: [PATCH 4/7] refactor: cleanup setMGRStrategy a bit (#3422) --- .../SolidMechanicsEmbeddedFractures.cpp | 30 +++++++--- .../SolidMechanicsEmbeddedFractures.hpp | 2 + .../contact/SolidMechanicsLagrangeContact.cpp | 25 ++++++-- .../contact/SolidMechanicsLagrangeContact.hpp | 5 +- ...mpositionalMultiphaseReservoirAndWells.cpp | 58 +++++++++++-------- ...mpositionalMultiphaseReservoirAndWells.hpp | 4 +- .../CoupledReservoirAndWellsBase.hpp | 16 ++++- .../multiphysics/HydrofractureSolver.cpp | 21 +++++-- .../multiphysics/HydrofractureSolver.hpp | 1 + .../multiphysics/MultiphasePoromechanics.cpp | 40 ++++++++++--- .../multiphysics/MultiphasePoromechanics.hpp | 6 ++ .../multiphysics/SinglePhasePoromechanics.cpp | 44 ++++++++++---- .../multiphysics/SinglePhasePoromechanics.hpp | 6 ++ ...ePhasePoromechanicsConformingFractures.cpp | 19 ++++-- ...ePhasePoromechanicsConformingFractures.hpp | 7 ++- ...glePhasePoromechanicsEmbeddedFractures.cpp | 22 +++++-- ...glePhasePoromechanicsEmbeddedFractures.hpp | 2 + .../SinglePhaseReservoirAndWells.cpp | 51 +++++++++------- .../SinglePhaseReservoirAndWells.hpp | 8 ++- .../SolidMechanicsLagrangianFEM.cpp | 1 + 20 files changed, 269 insertions(+), 99 deletions(-) diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.cpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.cpp index 15cc190fed..b78afce691 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.cpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.cpp @@ -64,23 +64,37 @@ SolidMechanicsEmbeddedFractures::~SolidMechanicsEmbeddedFractures() void SolidMechanicsEmbeddedFractures::postInputInitialization() { - SolidMechanicsLagrangianFEM::postInputInitialization(); + ContactSolverBase::postInputInitialization(); - LinearSolverParameters & linParams = m_linearSolverParameters.get(); - - linParams.dofsPerNode = 3; + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); if( m_useStaticCondensation ) { - linParams.isSymmetric = true; - linParams.amg.separateComponents = true; + // configure AMG + linearSolverParameters.isSymmetric = true; + linearSolverParameters.amg.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; } else { - linParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::solidMechanicsEmbeddedFractures; - linParams.mgr.separateComponents = true; + setMGRStrategy(); } } +void SolidMechanicsEmbeddedFractures::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::solidMechanicsEmbeddedFractures; + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); +} + void SolidMechanicsEmbeddedFractures::registerDataOnMesh( dataRepository::Group & meshBodies ) { ContactSolverBase::registerDataOnMesh( meshBodies ); diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.hpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.hpp index 6e146d3486..384137706c 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.hpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsEmbeddedFractures.hpp @@ -135,6 +135,8 @@ class SolidMechanicsEmbeddedFractures : public ContactSolverBase virtual void postInputInitialization() override final; + void setMGRStrategy(); + private: void updateJump( DofManager const & dofManager, diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp index 7ca9cd24c2..c0be250ff1 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp @@ -73,11 +73,28 @@ SolidMechanicsLagrangeContact::SolidMechanicsLagrangeContact( const string & nam setDescription( "It be used to increase the scale of the stabilization entries. A value < 1.0 results in larger entries in the stabilization matrix." ); addLogLevel< logInfo::Configuration >(); +} + +void SolidMechanicsLagrangeContact::postInputInitialization() +{ + ContactSolverBase::postInputInitialization(); + + setMGRStrategy(); +} + +void SolidMechanicsLagrangeContact::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; - LinearSolverParameters & linSolParams = m_linearSolverParameters.get(); - linSolParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanics; - linSolParams.mgr.separateComponents = true; - linSolParams.dofsPerNode = 3; + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanics; + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } void SolidMechanicsLagrangeContact::registerDataOnMesh( Group & meshBodies ) diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp index b77fac6ef2..da33861a54 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp @@ -31,7 +31,6 @@ class NumericalMethodsManager; class SolidMechanicsLagrangeContact : public ContactSolverBase { public: - SolidMechanicsLagrangeContact( const string & name, Group * const parent ); @@ -179,6 +178,10 @@ class SolidMechanicsLagrangeContact : public ContactSolverBase DofManager const & dofManager, arrayView1d< real64 const > const & localRhs ); + virtual void postInputInitialization() override final; + + void setMGRStrategy(); + private: string m_stabilizationName; diff --git a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.cpp b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.cpp index b2c668bb18..ea2c6f34b3 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.cpp @@ -77,26 +77,39 @@ void CompositionalMultiphaseReservoirAndWells<>:: setMGRStrategy() { - LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; linearSolverParameters.mgr.separateComponents = true; linearSolverParameters.dofsPerNode = 3; - if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM ) - { - // add Reservoir - linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM; - } - else if( isThermal() ) + if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) ) { - m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalCompositionalMultiphaseReservoirFVM; - + if( isThermal() ) + { + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for thermal {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName())); + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM; + } } else { - // add Reservoir - linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirFVM; + if( isThermal() ) + { + m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalCompositionalMultiphaseReservoirFVM; + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirFVM; + } } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template<> @@ -104,21 +117,25 @@ void CompositionalMultiphaseReservoirAndWells< MultiphasePoromechanics<> >:: setMGRStrategy() { - LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; linearSolverParameters.mgr.separateComponents = true; linearSolverParameters.dofsPerNode = 3; - // flow solver here is indeed flow solver, not poromechanics solver - if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM ) + if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) ) { - GEOS_ERROR( "The poromechanics MGR strategy for hybrid FVM is not implemented" ); + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName() ) ); } else { - // add Reservoir linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanicsReservoirFVM; } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename RESERVOIR_SOLVER > @@ -140,15 +157,6 @@ initializePreSubGroups() InputError ); } -template< typename RESERVOIR_SOLVER > -void -CompositionalMultiphaseReservoirAndWells< RESERVOIR_SOLVER >:: -initializePostInitialConditionsPreSubGroups() -{ - Base::initializePostInitialConditionsPreSubGroups(); - setMGRStrategy(); -} - template< typename RESERVOIR_SOLVER > void CompositionalMultiphaseReservoirAndWells< RESERVOIR_SOLVER >:: diff --git a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.hpp b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.hpp index 65a2e813be..0ceee38fdf 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.hpp @@ -95,14 +95,12 @@ class CompositionalMultiphaseReservoirAndWells : public CoupledReservoirAndWells virtual void initializePreSubGroups() override; - virtual void initializePostInitialConditionsPreSubGroups() override; + virtual void setMGRStrategy() override; private: CompositionalMultiphaseBase * flowSolver() const; - void setMGRStrategy(); - }; } /* namespace geos */ diff --git a/src/coreComponents/physicsSolvers/multiphysics/CoupledReservoirAndWellsBase.hpp b/src/coreComponents/physicsSolvers/multiphysics/CoupledReservoirAndWellsBase.hpp index a34cf78847..c40265648f 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/CoupledReservoirAndWellsBase.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/CoupledReservoirAndWellsBase.hpp @@ -201,10 +201,18 @@ class CoupledReservoirAndWellsBase : public CoupledSolver< RESERVOIR_SOLVER, WEL // Validate well perforations: Ensure that each perforation is in a region targeted by the solver if( !validateWellPerforations( domain )) { - return; + GEOS_ERROR( GEOS_FMT( "{}: well perforations validation failed, bad perforations found", this->getName())); } } + virtual void + postInputInitialization() override + { + Base::postInputInitialization(); + + setMGRStrategy(); + } + virtual void implicitStepSetup( real64 const & time_n, real64 const & dt, @@ -298,6 +306,12 @@ class CoupledReservoirAndWellsBase : public CoupledSolver< RESERVOIR_SOLVER, WEL DofManager const & dofManager, SparsityPatternView< globalIndex > const & pattern ) const = 0; + virtual void setMGRStrategy() + { + if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr ) + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName())); + } + /// Flag to determine whether the well transmissibility needs to be computed bool m_isWellTransmissibilityComputed; diff --git a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp index 3a526d7ccb..c11d99f3fa 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp @@ -81,12 +81,23 @@ HydrofractureSolver< POROMECHANICS_SOLVER >::HydrofractureSolver( const string & setDescription( "Flag to determine whether or not to apply lagging update for the fracture stencil weights. " ); m_numResolves[0] = 0; +} - // This may need to be different depending on whether poroelasticity is on or not. - m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::hydrofracture; - m_linearSolverParameters.get().mgr.separateComponents = true; - m_linearSolverParameters.get().dofsPerNode = 3; +template< typename POROMECHANICS_SOLVER > +void HydrofractureSolver< POROMECHANICS_SOLVER >::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + // This may need to be different depending on whether poroelasticity is on or not. + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::hydrofracture; + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", this->getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename POROMECHANICS_SOLVER > @@ -157,6 +168,8 @@ void HydrofractureSolver< POROMECHANICS_SOLVER >::postInputInitialization() { Base::postInputInitialization(); + setMGRStrategy(); + static const std::set< integer > binaryOptions = { 0, 1 }; GEOS_ERROR_IF( binaryOptions.count( m_isMatrixPoroelastic ) == 0, viewKeyStruct::isMatrixPoroelasticString() << " option can be either 0 (false) or 1 (true)" ); diff --git a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.hpp b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.hpp index d08f7d89e4..05a9683044 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.hpp @@ -215,6 +215,7 @@ class HydrofractureSolver : public POROMECHANICS_SOLVER DofManager const & dofManager, CRSMatrix< real64, globalIndex > & localMatrix ); + virtual void setMGRStrategy() override; private: diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp index dc3875a88e..30cd3db9a6 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp @@ -25,6 +25,7 @@ #include "constitutive/fluid/multifluid/MultiFluidBase.hpp" #include "constitutive/solid/PorousSolid.hpp" #include "physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp" #include "physicsSolvers/multiphysics/poromechanicsKernels/MultiphasePoromechanics.hpp" #include "physicsSolvers/multiphysics/poromechanicsKernels/ThermalMultiphasePoromechanics.hpp" #include "physicsSolvers/solidMechanics/SolidMechanicsFields.hpp" @@ -45,18 +46,15 @@ template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::MultiphasePoromechanics( const string & name, Group * const parent ) : Base( name, parent ) -{ - LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); - linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics; - linearSolverParameters.mgr.separateComponents = true; - linearSolverParameters.dofsPerNode = 3; -} +{} template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitialization() { Base::postInputInitialization(); + setMGRStrategy(); + GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "CompositionalMultiphaseReservoir" && this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential, GEOS_FMT( "{}: {} solver is only designed to work for {} = {}", @@ -244,11 +242,37 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::initializePostIni getCatalogName(), this->getDataContext(), poromechanicsTargetRegionNames[i], this->flowSolver()->getDataContext() ), InputError ); } +} + +template<> +void MultiphasePoromechanics<>::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; - if( this->m_isThermal ) + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) ) + { + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName())); + } + else { - this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics; + if( this->m_isThermal ) + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics; + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics; + } } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp index 89d46b554b..30259c11b4 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp @@ -107,6 +107,12 @@ class MultiphasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHANI virtual void initializePostInitialConditionsPreSubGroups() override; + virtual void setMGRStrategy() + { + if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr ) + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName())); + } + /** * @brief Helper function to recompute the bulk density * @param[in] subRegion the element subRegion diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp index b28c0d0b9a..4c3d3fc6e9 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp @@ -32,6 +32,7 @@ #include "physicsSolvers/solidMechanics/kernels/ImplicitSmallStrainQuasiStatic.hpp" #include "physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp" #include "physicsSolvers/contact/SolidMechanicsEmbeddedFractures.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseHybridFVM.hpp" namespace geos { @@ -45,18 +46,15 @@ template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::SinglePhasePoromechanics( const string & name, Group * const parent ) : Base( name, parent ) -{ - LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); - linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanics; - linearSolverParameters.mgr.separateComponents = true; - linearSolverParameters.dofsPerNode = 3; -} +{} template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitialization() { Base::postInputInitialization(); + setMGRStrategy(); + GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "SinglePhaseReservoir" && this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential, GEOS_FMT( "{}: {} solver is only designed to work for {} = {}", @@ -113,18 +111,44 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::initializePostIn getCatalogName(), this->getDataContext(), poromechanicsTargetRegionNames[i], this->flowSolver()->getDataContext() ), InputError ); } +} + +template<> +void SinglePhasePoromechanics<>::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; - if( this->m_isThermal ) + if( dynamic_cast< SinglePhaseHybridFVM * >( this->flowSolver() ) ) { - this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalSinglePhasePoromechanics; + if( this->m_isThermal ) + { + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for thermal {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName() )); + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::hybridSinglePhasePoromechanics; + } } else { - if( this->flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::singlePhaseHybridFVM ) + if( this->m_isThermal ) + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalSinglePhasePoromechanics; + } + else { - this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::hybridSinglePhasePoromechanics; + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanics; } } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp index 4b9dfbf742..e742fb9715 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp @@ -118,6 +118,12 @@ class SinglePhasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHAN virtual void initializePostInitialConditionsPreSubGroups() override; + virtual void setMGRStrategy() + { + if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr ) + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName())); + } + /** * @brief Helper function to recompute the bulk density * @param[in] subRegion the element subRegion diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.cpp index 50e56820a1..51fef65a2d 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.cpp @@ -44,11 +44,22 @@ template< typename FLOW_SOLVER > SinglePhasePoromechanicsConformingFractures< FLOW_SOLVER >::SinglePhasePoromechanicsConformingFractures( const string & name, Group * const parent ) : Base( name, parent ) +{} + +template<> +void SinglePhasePoromechanicsConformingFractures<>::setMGRStrategy() { - LinearSolverParameters & params = this->m_linearSolverParameters.get(); - params.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsConformingFractures; - params.mgr.separateComponents = true; - params.dofsPerNode = 3; + LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsConformingFractures; + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename FLOW_SOLVER > diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.hpp index 3d109b4e0b..0e657441f1 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsConformingFractures.hpp @@ -103,6 +103,12 @@ class SinglePhasePoromechanicsConformingFractures : public SinglePhasePoromechan virtual void updateState( DomainPartition & domain ) override final; + virtual void setMGRStrategy() override + { + if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr ) + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName())); + } + /**@}*/ private: @@ -176,7 +182,6 @@ class SinglePhasePoromechanicsConformingFractures : public SinglePhasePoromechan */ void updateHydraulicApertureAndFracturePermeability( DomainPartition & domain ); - std::unique_ptr< CRSMatrix< real64, localIndex > > & getRefDerivativeFluxResidual_dAperture() { return m_derivativeFluxResidual_dAperture; diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.cpp index 9c1dab6f9a..6c6e2be5bc 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.cpp @@ -41,16 +41,26 @@ using namespace fields; SinglePhasePoromechanicsEmbeddedFractures::SinglePhasePoromechanicsEmbeddedFractures( const std::string & name, Group * const parent ): SinglePhasePoromechanics( name, parent ) -{ - LinearSolverParameters & params = m_linearSolverParameters.get(); - params.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsEmbeddedFractures; - params.mgr.separateComponents = true; - params.dofsPerNode = 3; -} +{} SinglePhasePoromechanicsEmbeddedFractures::~SinglePhasePoromechanicsEmbeddedFractures() {} +void SinglePhasePoromechanicsEmbeddedFractures::setMGRStrategy() +{ + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsEmbeddedFractures; + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); +} + void SinglePhasePoromechanicsEmbeddedFractures::postInputInitialization() { Base::postInputInitialization(); diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.hpp index 497ebdffe6..95c3e7b7f8 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.hpp @@ -105,6 +105,8 @@ class SinglePhasePoromechanicsEmbeddedFractures : public SinglePhasePoromechanic virtual void initializePostInitialConditionsPreSubGroups() override final; + virtual void setMGRStrategy() override; + private: template< typename CONSTITUTIVE_BASE, diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.cpp index 06361544a3..f83652d745 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.cpp @@ -24,6 +24,7 @@ #include "mesh/PerforationFields.hpp" #include "physicsSolvers/KernelLaunchSelectors.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseFVM.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseHybridFVM.hpp" #include "physicsSolvers/fluidFlow/wells/SinglePhaseWellFields.hpp" #include "physicsSolvers/fluidFlow/wells/WellControls.hpp" #include "physicsSolvers/fluidFlow/wells/kernels/SinglePhaseWellKernels.hpp" @@ -69,33 +70,50 @@ void SinglePhaseReservoirAndWells<>:: setMGRStrategy() { - if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::singlePhaseHybridFVM ) + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + if( dynamic_cast< SinglePhaseHybridFVM * >( this->flowSolver() ) ) { - // add Reservoir - m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhaseReservoirHybridFVM; + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhaseReservoirHybridFVM; } else { - // add Reservoir - m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhaseReservoirFVM; + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhaseReservoirFVM; } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } -template< typename POROMECHANICS_SOLVER > +template<> void -SinglePhaseReservoirAndWells< POROMECHANICS_SOLVER >:: +SinglePhaseReservoirAndWells< SinglePhasePoromechanics<> >:: setMGRStrategy() { - // flow solver here is indeed flow solver, not poromechanics solver - if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::singlePhaseHybridFVM ) + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + if( dynamic_cast< SinglePhaseHybridFVM * >( this->flowSolver() ) ) { - GEOS_LOG_RANK_0( "The poromechanics MGR strategy for hybrid FVM is not implemented" ); + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for poromechanics {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName())); } else { - // add Reservoir - m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsReservoirFVM; + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsReservoirFVM; } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", this->getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } template< typename RESERVOIR_SOLVER > @@ -108,15 +126,6 @@ initializePreSubGroups() Base::wellSolver()->setFlowSolverName( flowSolver->getName() ); } -template< typename RESERVOIR_SOLVER > -void -SinglePhaseReservoirAndWells< RESERVOIR_SOLVER >:: -initializePostInitialConditionsPreSubGroups() -{ - Base::initializePostInitialConditionsPreSubGroups(); - setMGRStrategy(); -} - template< typename RESERVOIR_SOLVER > void SinglePhaseReservoirAndWells< RESERVOIR_SOLVER >:: diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.hpp index 0ded9b7bd3..6ce8df9632 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.hpp @@ -111,14 +111,16 @@ class SinglePhaseReservoirAndWells : public CoupledReservoirAndWellsBase< RESERV virtual void initializePreSubGroups() override; - virtual void initializePostInitialConditionsPreSubGroups() override; + virtual void setMGRStrategy() override + { + if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr ) + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName())); + } private: SinglePhaseBase * flowSolver() const; - void setMGRStrategy(); - }; } /* namespace geos */ diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp index 434e4fde4a..70cb8b3c56 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp @@ -130,6 +130,7 @@ void SolidMechanicsLagrangianFEM::postInputInitialization() { PhysicsSolverBase::postInputInitialization(); + // configure AMG LinearSolverParameters & linParams = m_linearSolverParameters.get(); linParams.isSymmetric = true; linParams.dofsPerNode = 3; From 5ce649762bce0f5676aafe136ba84f2fc7cf2a93 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Fri, 13 Dec 2024 21:07:11 -0600 Subject: [PATCH 5/7] feat: Enable fully coupled mode for CompositionalMultiphaseReservoirPoromechanics and SinglePhaseReservoirPoromechanics (#3388) --- .../multiphysics/MultiphasePoromechanics.cpp | 79 +++++++++++++++++-- .../multiphysics/SinglePhasePoromechanics.cpp | 74 +++++++++++++++-- 2 files changed, 139 insertions(+), 14 deletions(-) diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp index 30cd3db9a6..6b01f872f5 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp @@ -24,6 +24,7 @@ #include "dataRepository/LogLevelsInfo.hpp" #include "constitutive/fluid/multifluid/MultiFluidBase.hpp" #include "constitutive/solid/PorousSolid.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp" #include "physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp" #include "physicsSolvers/multiphysics/poromechanicsKernels/MultiphasePoromechanics.hpp" @@ -54,13 +55,6 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitiali Base::postInputInitialization(); setMGRStrategy(); - - GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "CompositionalMultiphaseReservoir" && - this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential, - GEOS_FMT( "{}: {} solver is only designed to work for {} = {}", - this->getDataContext(), catalogName(), NonlinearSolverParameters::viewKeysStruct::couplingTypeString(), - EnumStrings< NonlinearSolverParameters::CouplingType >::toString( NonlinearSolverParameters::CouplingType::Sequential ) - )); } template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > @@ -82,6 +76,7 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleSystem( r { GEOS_MARK_FUNCTION; + // Steps 1 and 2: compute element-based terms (mechanics and local flow terms) assembleElementBasedTerms( time, dt, domain, @@ -110,6 +105,50 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleSystem( r } } +template<> +void MultiphasePoromechanics< CompositionalMultiphaseReservoirAndWells<>, SolidMechanicsLagrangianFEM >::assembleSystem( real64 const time, + real64 const dt, + DomainPartition & domain, + DofManager const & dofManager, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) +{ + GEOS_MARK_FUNCTION; + + // Steps 1 and 2: compute element-based terms (mechanics and local flow terms) + assembleElementBasedTerms( time, + dt, + domain, + dofManager, + localMatrix, + localRhs ); + + // step 3: compute the fluxes (face-based contributions) + + if( m_stabilizationType == StabilizationType::Global || + m_stabilizationType == StabilizationType::Local ) + { + this->flowSolver()->assembleStabilizedFluxTerms( dt, + domain, + dofManager, + localMatrix, + localRhs ); + } + else + { + this->flowSolver()->assembleFluxTerms( dt, + domain, + dofManager, + localMatrix, + localRhs ); + } + + // step 4: assemble well contributions + + this->flowSolver()->wellSolver()->assembleSystem( time, dt, domain, dofManager, localMatrix, localRhs ); + this->flowSolver()->assembleCouplingTerms( time, dt, domain, dofManager, localMatrix, localRhs ); +} + template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBasedTerms( real64 const time_n, real64 const dt, @@ -275,6 +314,32 @@ void MultiphasePoromechanics<>::setMGRStrategy() EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } +template<> +void MultiphasePoromechanics< CompositionalMultiphaseReservoirAndWells<>, SolidMechanicsLagrangianFEM >::setMGRStrategy() +{ + // same as CompositionalMultiphaseReservoirAndWells< MultiphasePoromechanics<> >::setMGRStrategy + + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) ) + { + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName() ) ); + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanicsReservoirFVM; + } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); +} + template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::updateBulkDensity( ElementSubRegionBase & subRegion ) { diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp index 4c3d3fc6e9..0bfa9146a2 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp @@ -54,13 +54,6 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitial Base::postInputInitialization(); setMGRStrategy(); - - GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "SinglePhaseReservoir" && - this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential, - GEOS_FMT( "{}: {} solver is only designed to work for {} = {}", - this->getName(), catalogName(), NonlinearSolverParameters::viewKeysStruct::couplingTypeString(), - EnumStrings< NonlinearSolverParameters::CouplingType >::toString( NonlinearSolverParameters::CouplingType::Sequential ) - )); } template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > @@ -151,6 +144,32 @@ void SinglePhasePoromechanics<>::setMGRStrategy() EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); } +template<> +void SinglePhasePoromechanics< SinglePhaseReservoirAndWells<>, SolidMechanicsLagrangianFEM >::setMGRStrategy() +{ + // same as SinglePhaseReservoirAndWells< SinglePhasePoromechanics<> >::setMGRStrategy + + LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get(); + + if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr ) + return; + + linearSolverParameters.mgr.separateComponents = true; + linearSolverParameters.dofsPerNode = 3; + + if( dynamic_cast< SinglePhaseHybridFVM * >( this->flowSolver() ) ) + { + GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for poromechanics {}/{}", + this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName())); + } + else + { + linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanicsReservoirFVM; + } + GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", this->getName(), + EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy ))); +} + template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleSystem( real64 const time_n, real64 const dt, @@ -186,7 +205,48 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleSystem( localMatrix, localRhs ); } +} + +template<> +void SinglePhasePoromechanics< SinglePhaseReservoirAndWells<>, SolidMechanicsLagrangianFEM >::assembleSystem( real64 const time_n, + real64 const dt, + DomainPartition & domain, + DofManager const & dofManager, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) +{ + GEOS_MARK_FUNCTION; + + // Steps 1 and 2: compute element-based terms (mechanics and local flow terms) + assembleElementBasedTerms( time_n, + dt, + domain, + dofManager, + localMatrix, + localRhs ); + + // Step 3: compute the fluxes (face-based contributions) + if( m_stabilizationType == StabilizationType::Global || m_stabilizationType == StabilizationType::Local ) + { + this->flowSolver()->assembleStabilizedFluxTerms( dt, + domain, + dofManager, + localMatrix, + localRhs ); + } + else + { + this->flowSolver()->assembleFluxTerms( dt, + domain, + dofManager, + localMatrix, + localRhs ); + } + + // step 4: assemble well contributions + this->flowSolver()->wellSolver()->assembleSystem( time_n, dt, domain, dofManager, localMatrix, localRhs ); + this->flowSolver()->assembleCouplingTerms( time_n, dt, domain, dofManager, localMatrix, localRhs ); } template< typename FLOW_SOLVER, typename MECHANICS_SOLVER > From bc41885b617a679e1add79905bfc289ab76a3cee Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Sat, 14 Dec 2024 21:18:14 -0600 Subject: [PATCH 6/7] fix: remove setNextDt from SolidMechanicsLagrangeContact (#3490) --- .integrated_tests.yaml | 2 +- BASELINE_NOTES.md | 4 ++++ .../contact/SolidMechanicsLagrangeContact.cpp | 7 ------- .../contact/SolidMechanicsLagrangeContact.hpp | 4 ---- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 31ce96119a..09af5eafaf 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3450-9221-37d940c + baseline: integratedTests/baseline_integratedTests-pr3490-9351-03417a1 allow_fail: all: '' streak: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index 3b09722325..74e7e6efed 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3450 (2024-12-14) +===================== +Fix time step selecor flaw in SolidMechanicsLagrangeContact. + PR #3450 (2024-12-08) ===================== Added test for explicit runge kutta sprinslider. diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp index c0be250ff1..9a76b95632 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.cpp @@ -2359,13 +2359,6 @@ bool SolidMechanicsLagrangeContact::isFractureAllInStickCondition( DomainPartiti return ( ( numNewSlip + numSlip + numOpen ) == 0 ); } -real64 SolidMechanicsLagrangeContact::setNextDt( real64 const & currentDt, - DomainPartition & domain ) -{ - GEOS_UNUSED_VAR( domain ); - return currentDt; -} - REGISTER_CATALOG_ENTRY( PhysicsSolverBase, SolidMechanicsLagrangeContact, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp index da33861a54..a39b137473 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContact.hpp @@ -100,10 +100,6 @@ class SolidMechanicsLagrangeContact : public ContactSolverBase virtual void resetStateToBeginningOfStep( DomainPartition & domain ) override; - virtual real64 - setNextDt( real64 const & currentDt, - DomainPartition & domain ) override; - void updateState( DomainPartition & domain ) override final; void assembleContact( DomainPartition & domain, From ab079a48d5ad8af7973411459c7ecbe90238ef40 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Sun, 15 Dec 2024 17:43:48 -0600 Subject: [PATCH 7/7] test: refine comp flow tests (#3479) --- .integrated_tests.yaml | 2 +- BASELINE_NOTES.md | 6 ++- .../2ph_cap_1d_ihu.xml | 2 +- .../4comp_2ph_1d.xml | 2 +- .../4comp_2ph_cap_1d.xml | 7 ++- .../co2_flux_3d.xml | 8 ++- .../co2_flux_dirichlet.xml | 5 +- .../co2_hybrid_1d.xml | 7 ++- .../compositionalMultiphaseFlow.ats | 50 +++++++++---------- ...l_2ph_staircase_gravity_segregation_3d.xml | 5 +- .../deadoil_3ph_baker_1d.xml | 7 ++- .../deadoil_3ph_corey_1d.xml | 4 +- .../deadoil_3ph_corey_1d_fractured.xml | 18 +++---- .../deadoil_3ph_staircase_3d.xml | 8 +-- .../deadoil_3ph_staircase_hybrid_3d.xml | 6 +-- .../deadoil_3ph_staircase_obl_3d.xml | 6 +-- .../deadoil_3ph_stone2_1d.xml | 10 ++-- 17 files changed, 74 insertions(+), 79 deletions(-) diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 09af5eafaf..6dfbf981b0 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3490-9351-03417a1 + baseline: integratedTests/baseline_integratedTests-pr3479-9362-cffefcc allow_fail: all: '' streak: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index 74e7e6efed..0bc5c80f56 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -6,9 +6,13 @@ This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3479 (2024-12-15) +===================== +Refine inputFiles/compositionalMultiphaseFlow: shift reference pressures to initial pressures, make nonlinear tuning more reasonable, minimize output. + PR #3450 (2024-12-14) ===================== -Fix time step selecor flaw in SolidMechanicsLagrangeContact. +Fix timestep selector flaw in SolidMechanicsLagrangeContact. PR #3450 (2024-12-08) ===================== diff --git a/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml b/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml index 07a0f5d473..8c25605b33 100644 --- a/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml +++ b/inputFiles/compositionalMultiphaseFlow/2ph_cap_1d_ihu.xml @@ -94,7 +94,7 @@ + name="fluidTPFA"/> @@ -117,7 +116,7 @@ @@ -92,7 +90,7 @@ diff --git a/inputFiles/compositionalMultiphaseFlow/co2_hybrid_1d.xml b/inputFiles/compositionalMultiphaseFlow/co2_hybrid_1d.xml index 99e5d1ad3b..345c17b0b9 100644 --- a/inputFiles/compositionalMultiphaseFlow/co2_hybrid_1d.xml +++ b/inputFiles/compositionalMultiphaseFlow/co2_hybrid_1d.xml @@ -14,8 +14,7 @@ targetRegions="{ region }"> + newtonMaxIter="10"/> @@ -50,7 +49,7 @@ maxTime="1e5"> + newtonMaxIter="15"/> @@ -108,7 +107,7 @@ + newtonMaxIter="10"/> @@ -46,7 +45,7 @@ maxTime="2e7"> + directParallel="0"/> @@ -111,18 +109,18 @@ + materialList="{ fluid, rock, relperm }"/> + newtonMaxIter="10"/> @@ -57,11 +57,11 @@ maxTime="2e8"> @@ -51,7 +51,7 @@ maxTime="2e8"> + newtonMaxIter="10"/> @@ -60,7 +60,7 @@ maxTime="2e8"> + temperature="300" + targetRegions="{ region }"> - +