From e71281488fbf8f415005fd1775f4afcf24b29bb5 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 24 Oct 2024 11:18:16 +0200 Subject: [PATCH 01/27] =?UTF-8?q?=F0=9F=90=9B=20bugfix:=20Proper=20error?= =?UTF-8?q?=20when=20detecting=20child=20that=20is=20not=20a=20xml=20eleme?= =?UTF-8?q?nts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/Group.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index abbf6379fa9..f194f38af63 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -147,6 +147,11 @@ void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, { xmlDocument.addIncludedXML( targetNode ); + if( nodePos.isFound() ) + { + m_dataContext = std::make_unique< DataFileContext >( targetNode, nodePos ); + } + // Handle the case where the node was imported from a different input file // Set the path prefix to make sure all relative Path variables are interpreted correctly string const oldPrefix = std::string( Path::getPathPrefix() ); @@ -162,9 +167,12 @@ void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, { xmlWrapper::xmlNodePos childNodePos = xmlDocument.getNodePosition( childNode ); + GEOS_ERROR_IF( childNode.type() != xmlWrapper::xmlNodeType::node_element, + GEOS_FMT( "Error in {}: GEOS XML nodes cannot contain text data nor anything but XML nodes.", + getDataContext() )); + // Get the child tag and name string childName; - try { xmlWrapper::readAttributeAsType( childName, "name", @@ -212,12 +220,6 @@ void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, void Group::processInputFile( xmlWrapper::xmlNode const & targetNode, xmlWrapper::xmlNodePos const & nodePos ) { - if( nodePos.isFound() ) - { - m_dataContext = std::make_unique< DataFileContext >( targetNode, nodePos ); - } - - std::set< string > processedAttributes; for( std::pair< string const, WrapperBase * > & pair : m_wrappers ) { From afd945e16d885fc70be8cec4ce367ad57c24df78 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 24 Oct 2024 11:19:48 +0200 Subject: [PATCH 02/27] =?UTF-8?q?=F0=9F=92=84=20small=20error=20edit=20for?= =?UTF-8?q?=20uniformisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/Group.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index f194f38af63..29aa99510bc 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -235,10 +235,10 @@ void Group::processInputFile( xmlWrapper::xmlNode const & targetNode, if( !xmlWrapper::isFileMetadataAttribute( attributeName ) ) { GEOS_THROW_IF( processedAttributes.count( attributeName ) == 0, - GEOS_FMT( "XML Node at '{}' with name={} contains unused attribute '{}'.\n" + GEOS_FMT( "Error in {}: XML Node at '{}' contains unused attribute '{}'.\n" "Valid attributes are:\n{}\nFor more details, please refer to documentation at:\n" "http://geosx-geosx.readthedocs-hosted.com/en/latest/docs/sphinx/userGuide/Index.html", - targetNode.path(), m_dataContext->toString(), attributeName, + getDataContext(), targetNode.path(), attributeName, dumpInputOptions() ), InputError ); } From d6ea052495e4b4ff1808b27a6b1ba54767b3511b Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 24 Oct 2024 15:05:06 +0200 Subject: [PATCH 03/27] =?UTF-8?q?=F0=9F=92=A1=20Added=20note=20on=20all=20?= =?UTF-8?q?empty=20createChild()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../discretizationMethods/NumericalMethodsManager.cpp | 1 + src/coreComponents/mainInterface/ProblemManager.cpp | 5 ++++- src/coreComponents/mesh/generators/CellBlockManager.cpp | 1 + src/coreComponents/mesh/generators/ParticleBlockManager.cpp | 1 + src/coreComponents/physicsSolvers/SolverBase.cpp | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/discretizationMethods/NumericalMethodsManager.cpp b/src/coreComponents/discretizationMethods/NumericalMethodsManager.cpp index b57a2fe5192..e1afb5d7145 100644 --- a/src/coreComponents/discretizationMethods/NumericalMethodsManager.cpp +++ b/src/coreComponents/discretizationMethods/NumericalMethodsManager.cpp @@ -41,6 +41,7 @@ NumericalMethodsManager::~NumericalMethodsManager() Group * NumericalMethodsManager::createChild( string const & GEOS_UNUSED_PARAM( childKey ), string const & GEOS_UNUSED_PARAM( childName ) ) { + // Unused as all children are created within the constructor return nullptr; } diff --git a/src/coreComponents/mainInterface/ProblemManager.cpp b/src/coreComponents/mainInterface/ProblemManager.cpp index 0a134a6bcea..f9ef19ea92d 100644 --- a/src/coreComponents/mainInterface/ProblemManager.cpp +++ b/src/coreComponents/mainInterface/ProblemManager.cpp @@ -156,7 +156,10 @@ ProblemManager::~ProblemManager() Group * ProblemManager::createChild( string const & GEOS_UNUSED_PARAM( childKey ), string const & GEOS_UNUSED_PARAM( childName ) ) -{ return nullptr; } +{ + // Unused as all children are created within the constructor + return nullptr; +} void ProblemManager::problemSetup() diff --git a/src/coreComponents/mesh/generators/CellBlockManager.cpp b/src/coreComponents/mesh/generators/CellBlockManager.cpp index 2db3b3cfff2..d417d0f2665 100644 --- a/src/coreComponents/mesh/generators/CellBlockManager.cpp +++ b/src/coreComponents/mesh/generators/CellBlockManager.cpp @@ -46,6 +46,7 @@ void CellBlockManager::resize( integer_array const & numElements, Group * CellBlockManager::createChild( string const & GEOS_UNUSED_PARAM( childKey ), string const & GEOS_UNUSED_PARAM( childName ) ) { + // Unused as all children are created within the constructor return nullptr; } diff --git a/src/coreComponents/mesh/generators/ParticleBlockManager.cpp b/src/coreComponents/mesh/generators/ParticleBlockManager.cpp index b9645f04fd2..2db282a1d36 100644 --- a/src/coreComponents/mesh/generators/ParticleBlockManager.cpp +++ b/src/coreComponents/mesh/generators/ParticleBlockManager.cpp @@ -38,6 +38,7 @@ void ParticleBlockManager::resize( integer_array const & numParticles, Group * ParticleBlockManager::createChild( string const & GEOS_UNUSED_PARAM( childKey ), string const & GEOS_UNUSED_PARAM( childName ) ) { + // Unused as all children are created within the constructor return nullptr; } diff --git a/src/coreComponents/physicsSolvers/SolverBase.cpp b/src/coreComponents/physicsSolvers/SolverBase.cpp index 1420ce45fd2..2a91bb7f6e0 100644 --- a/src/coreComponents/physicsSolvers/SolverBase.cpp +++ b/src/coreComponents/physicsSolvers/SolverBase.cpp @@ -191,6 +191,7 @@ void SolverBase::registerDataOnMesh( Group & meshBodies ) Group * SolverBase::createChild( string const & GEOS_UNUSED_PARAM( childKey ), string const & GEOS_UNUSED_PARAM( childName ) ) { + // Unused as all children are created within the constructor return nullptr; } From e4c1c411d4c52e02fc82941a3a0492a1f2aac460 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 11:01:06 +0200 Subject: [PATCH 04/27] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20typo=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/common/format/StringUtilities.hpp | 6 +++--- src/coreComponents/mesh/CellElementRegionSelector.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreComponents/common/format/StringUtilities.hpp b/src/coreComponents/common/format/StringUtilities.hpp index 8f083816c86..3dd0a056390 100644 --- a/src/coreComponents/common/format/StringUtilities.hpp +++ b/src/coreComponents/common/format/StringUtilities.hpp @@ -88,7 +88,7 @@ string join( CONTAINER const & container, S const & delim = S() ) * @return a string containing input values concatenated with a delimiter */ template< typename IT, typename S, typename LAMBDA > -string joinLamda( IT first, IT last, S const & delim, LAMBDA formattingFunc ) +string joinLambda( IT first, IT last, S const & delim, LAMBDA formattingFunc ) { if( first == last ) { @@ -114,9 +114,9 @@ string joinLamda( IT first, IT last, S const & delim, LAMBDA formattingFunc ) * @return a string containing input values concatenated with a delimiter */ template< typename CONTAINER, typename S, typename LAMBDA > -string joinLamda( CONTAINER const & container, S const & delim, LAMBDA formattingFunc ) +string joinLambda( CONTAINER const & container, S const & delim, LAMBDA formattingFunc ) { - return joinLamda( std::begin( container ), std::end( container ), delim, formattingFunc ); + return joinLambda( std::begin( container ), std::end( container ), delim, formattingFunc ); } /** diff --git a/src/coreComponents/mesh/CellElementRegionSelector.cpp b/src/coreComponents/mesh/CellElementRegionSelector.cpp index 80047d71c79..54e9faed685 100644 --- a/src/coreComponents/mesh/CellElementRegionSelector.cpp +++ b/src/coreComponents/mesh/CellElementRegionSelector.cpp @@ -66,9 +66,9 @@ CellElementRegionSelector::getMatchingCellblocks( CellElementRegion const & regi "Available cellBlock list: {{ {} }}\nAvailable region attribute list: {{ {} }}", region.getWrapperDataContext( ViewKeys::sourceCellBlockNamesString() ), matchPattern, - stringutilities::joinLamda( m_regionAttributesOwners, ", ", + stringutilities::joinLambda( m_regionAttributesOwners, ", ", []( auto pair ) { return pair->first; } ), - stringutilities::joinLamda( m_cellBlocksOwners, ", ", + stringutilities::joinLambda( m_cellBlocksOwners, ", ", []( auto pair ) { return pair->first; } ) ), InputError ); return matchedCellBlocks; @@ -85,7 +85,7 @@ CellElementRegionSelector::verifyRequestedCellBlocks( CellElementRegion const & GEOS_FMT( "{}: No cellBlock named '{}'.\nAvailable cellBlock list: {{ {} }}", region.getWrapperDataContext( ViewKeys::sourceCellBlockNamesString() ), requestedCellBlockName, - stringutilities::joinLamda( m_cellBlocksOwners, ", ", + stringutilities::joinLambda( m_cellBlocksOwners, ", ", []( auto pair ) { return pair->first; } ) ), InputError ); } @@ -161,7 +161,7 @@ void CellElementRegionSelector::checkSelectionConsistency() const multipleRefsErrors.push_back( GEOS_FMT( "The {} '{}' has been referenced in multiple {}:\n{}", qualifierType, qualifier, CellElementRegion::catalogName(), - stringutilities::joinLamda( owningRegions, '\n', getRegionStr ) ) ); + stringutilities::joinLambda( owningRegions, '\n', getRegionStr ) ) ); } } GEOS_THROW_IF( !multipleRefsErrors.empty(), stringutilities::join( multipleRefsErrors, "\n\n" ), InputError ); From 814a2b33a79fcada74112b788be5ccdd71a0b808 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 16:38:33 +0200 Subject: [PATCH 05/27] Re rewrite of ObjectCatalog errors for bad children : Added context to know the erroneous parent & exposed a unique error reference for other classes. --- examples/ObjectCatalog/Base.hpp | 14 +++++-- examples/ObjectCatalog/main.cpp | 12 ++++-- .../constitutive/ConstitutiveBase.cpp | 3 +- .../constitutive/ConstitutiveManager.cpp | 3 +- src/coreComponents/dataRepository/Group.cpp | 3 +- src/coreComponents/dataRepository/Group.hpp | 3 +- .../dataRepository/ObjectCatalog.hpp | 39 ++++++++++--------- src/coreComponents/events/EventBase.cpp | 3 +- src/coreComponents/events/EventManager.cpp | 3 +- .../events/tasks/TasksManager.cpp | 3 +- .../FieldSpecificationManager.cpp | 3 +- .../fileIO/Outputs/OutputManager.cpp | 3 +- .../FiniteElementDiscretizationManager.cpp | 3 +- .../finiteVolume/FiniteVolumeManager.cpp | 3 +- .../functions/FunctionManager.cpp | 3 +- .../mesh/ElementRegionManager.cpp | 3 +- src/coreComponents/mesh/MeshManager.cpp | 3 +- src/coreComponents/mesh/ParticleManager.cpp | 3 +- .../mesh/generators/MeshGeneratorBase.cpp | 3 +- .../GeometricObjectManager.cpp | 3 +- .../physicsSolvers/PhysicsSolverManager.cpp | 3 +- 21 files changed, 74 insertions(+), 45 deletions(-) diff --git a/examples/ObjectCatalog/Base.hpp b/examples/ObjectCatalog/Base.hpp index 19ba0cb73e8..646d8e801b3 100644 --- a/examples/ObjectCatalog/Base.hpp +++ b/examples/ObjectCatalog/Base.hpp @@ -5,7 +5,7 @@ * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC * Copyright (c) 2018-2024 Total, S.A * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2023-2024 Chevron + * Copyright (c) 2023-2024 Chevron * Copyright (c) 2019- GEOS/GEOSX Contributors * All rights reserved * @@ -46,7 +46,7 @@ class Parameter class Base { public: - Base( int junk, double const & junk2, Parameter& pbv ) + Base( int junk, double const & junk2, Parameter & pbv ) { GEOS_LOG( "calling Base constructor with arguments (" << junk << " " << junk2 << ")" ); } @@ -56,14 +56,20 @@ class Base GEOS_LOG( "calling Base destructor" ); } - using CatalogInterface = dataRepository::CatalogInterface< Base, int, double const &, Parameter& >; - static CatalogInterface::CatalogType& getCatalog() + using CatalogInterface = dataRepository::CatalogInterface< Base, int, double const &, Parameter & >; + static CatalogInterface::CatalogType & getCatalog() { static CatalogInterface::CatalogType catalog; return catalog; } virtual std::string const getName() const = 0; + + static DataContext const & getDataContext() + { + static DataFileContext const context = DataFileContext( "Base Test Class", __FILE__, __LINE__ ); + return context; + } }; #endif diff --git a/examples/ObjectCatalog/main.cpp b/examples/ObjectCatalog/main.cpp index 11452b82e93..ca00fe9acd1 100644 --- a/examples/ObjectCatalog/main.cpp +++ b/examples/ObjectCatalog/main.cpp @@ -5,7 +5,7 @@ * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC * Copyright (c) 2018-2024 Total, S.A * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2023-2024 Chevron + * Copyright (c) 2023-2024 Chevron * Copyright (c) 2019- GEOS/GEOSX Contributors * All rights reserved * @@ -31,10 +31,14 @@ int main( int argc, char *argv[] ) GEOS_LOG( "Attempting to create a Derived1 object" ); - std::unique_ptr derived1 = Base::CatalogInterface::Factory( "derived1", junk, junk2, param ); + std::unique_ptr< Base > derived1 = Base::CatalogInterface::factory( "derived1", + Base::getDataContext(), + junk, junk2, param ); GEOS_LOG( "Attempting to create a Derived2 object" ); - std::unique_ptr derived2 = Base::CatalogInterface::Factory( "derived2", junk, junk3, param ); + std::unique_ptr< Base > derived2 = Base::CatalogInterface::factory( "derived2", + Base::getDataContext(), + junk, junk3, param ); - Base::CatalogInterface::catalog_cast( *(derived2.get())); + Base::CatalogInterface::catalog_cast< Derived1 >( *(derived2.get())); GEOS_LOG( "EXITING MAIN" ); } diff --git a/src/coreComponents/constitutive/ConstitutiveBase.cpp b/src/coreComponents/constitutive/ConstitutiveBase.cpp index 2c7334239c3..4a94dc36327 100644 --- a/src/coreComponents/constitutive/ConstitutiveBase.cpp +++ b/src/coreComponents/constitutive/ConstitutiveBase.cpp @@ -83,7 +83,8 @@ ConstitutiveBase::deliverClone( string const & name, Group * const parent ) const { std::unique_ptr< ConstitutiveBase > - newModel = ConstitutiveBase::CatalogInterface::factory( this->getCatalogName(), name, parent ); + newModel = ConstitutiveBase::CatalogInterface::factory( this->getCatalogName(), getDataContext(), + name, parent ); newModel->forWrappers( [&]( WrapperBase & wrapper ) { diff --git a/src/coreComponents/constitutive/ConstitutiveManager.cpp b/src/coreComponents/constitutive/ConstitutiveManager.cpp index 38d47321344..31cfc5ac918 100644 --- a/src/coreComponents/constitutive/ConstitutiveManager.cpp +++ b/src/coreComponents/constitutive/ConstitutiveManager.cpp @@ -43,7 +43,8 @@ ConstitutiveManager::~ConstitutiveManager() Group * ConstitutiveManager::createChild( string const & childKey, string const & childName ) { - std::unique_ptr< ConstitutiveBase > material = ConstitutiveBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< ConstitutiveBase > material = ConstitutiveBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ); return ®isterGroup< ConstitutiveBase >( childName, std::move( material ) ); } diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index 29aa99510bc..7abb1fbc7a7 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -270,7 +270,8 @@ Group * Group::createChild( string const & childKey, string const & childName ) "KeyName ("< T & registerGroup( string const & name, string const & catalogName ) { - std::unique_ptr< TBASE > newGroup = TBASE::CatalogInterface::Factory( catalogName, name, this ); + std::unique_ptr< TBASE > newGroup = TBASE::CatalogInterface::Factory( catalogName, getDataContext(), + name, this ); return registerGroup< T >( name, std::move( newGroup ) ); } diff --git a/src/coreComponents/dataRepository/ObjectCatalog.hpp b/src/coreComponents/dataRepository/ObjectCatalog.hpp index c03715e09df..c9a832d6af7 100644 --- a/src/coreComponents/dataRepository/ObjectCatalog.hpp +++ b/src/coreComponents/dataRepository/ObjectCatalog.hpp @@ -30,6 +30,7 @@ #include "common/logger/Logger.hpp" #include "common/format/StringUtilities.hpp" #include "LvArray/src/system.hpp" +#include "DataContext.hpp" #include #include @@ -178,32 +179,32 @@ class CatalogInterface */ //START_SPHINX_2 static std::unique_ptr< BASETYPE > factory( std::string const & objectTypeName, + DataContext const & context, ARGS... args ) { - // We stop the simulation if the product is not found - if( !hasKeyName( objectTypeName ) ) - { - std::list< typename CatalogType::key_type > keys = getKeys(); - string const tmp = stringutilities::join( keys.cbegin(), keys.cend(), ",\n" ); - - string errorMsg = "Could not find keyword \"" + objectTypeName + "\" in this context. "; - errorMsg += "Please be sure that all your keywords are properly spelled or that input file parameters have not changed.\n"; - errorMsg += "All available keys are: [\n" + tmp + "\n]"; - GEOS_ERROR( errorMsg ); - } + // We stop the simulation if the type to create is not found + GEOS_ERROR_IF( !hasKeyName( objectTypeName ), unknownTypeError( objectTypeName, context, getKeys() ) ); // We also stop the simulation if the builder is not here. CatalogInterface< BASETYPE, ARGS... > const * builder = getCatalog().at( objectTypeName ).get(); - if( builder == nullptr ) - { - const string errorMsg = "\"" + objectTypeName + "\" could be found. But the builder is invalid.\n"; - GEOS_ERROR( errorMsg ); - } + GEOS_ERROR_IF( builder == nullptr, + GEOS_FMT( "Type \"{}\" is valid in {}, but the builder is invalid.", + objectTypeName, context ) ); return builder->allocate( args ... ); } //STOP_SPHINX + template< typename KEYS_CONTAINER_T > + static string unknownTypeError( std::string const & objectTypeName, DataContext const & context, + KEYS_CONTAINER_T const & allowedKeys ) + { + return GEOS_FMT( "The tag \"{}\" is invalid within {}. Please verify the keywords spelling and that " + "input file parameters have not changed.\n" + "All available tags are: {}\n", + objectTypeName, context, stringutilities::join( allowedKeys, ", " ) ); + } + /** * @brief Downcast base type reference to derived type * @tparam TYPE type to cast to @@ -303,7 +304,7 @@ class CatalogEntry final : public CatalogInterface< BASETYPE, ARGS... > */ CatalogEntry & operator=( CatalogEntry && source ) { - CatalogInterface< BASETYPE, ARGS... >::operator=( std::move(source)); + CatalogInterface< BASETYPE, ARGS... >::operator=( std::move( source )); } /** @@ -312,7 +313,7 @@ class CatalogEntry final : public CatalogInterface< BASETYPE, ARGS... > * @return a unique_ptr to the newly allocated class. */ //START_SPHINX_4 - virtual std::unique_ptr< BASETYPE > allocate( ARGS... args ) const override + virtual std::unique_ptr< BASETYPE > allocate( ARGS ... args ) const override { #if OBJECTCATALOGVERBOSE > 0 GEOS_LOG( "Creating type " << LvArray::system::demangle( typeid(TYPE).name()) @@ -589,7 +590,7 @@ class CatalogEntry< BASETYPE, TYPE > final : public CatalogInterface< BASETYPE > */ CatalogEntry & operator=( CatalogEntry && source ) { - CatalogInterface< BASETYPE >::operator=( std::move(source)); + CatalogInterface< BASETYPE >::operator=( std::move( source )); } /** diff --git a/src/coreComponents/events/EventBase.cpp b/src/coreComponents/events/EventBase.cpp index 5a185d1c719..4e18b96291b 100644 --- a/src/coreComponents/events/EventBase.cpp +++ b/src/coreComponents/events/EventBase.cpp @@ -123,7 +123,8 @@ EventBase::CatalogInterface::CatalogType & EventBase::getCatalog() Group * EventBase::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Event: " << childKey << ", " << childName ); - std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, getDataContext(), + 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 11515e27574..c392eed1d7f 100644 --- a/src/coreComponents/events/EventManager.cpp +++ b/src/coreComponents/events/EventManager.cpp @@ -94,7 +94,8 @@ EventManager::~EventManager() Group * EventManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Event: " << childKey << ", " << childName ); - std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< EventBase > event = EventBase::CatalogInterface::factory( childKey, getDataContext(), + 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 ad23ae788b1..ff49c319644 100644 --- a/src/coreComponents/events/tasks/TasksManager.cpp +++ b/src/coreComponents/events/tasks/TasksManager.cpp @@ -38,7 +38,8 @@ TasksManager::~TasksManager() Group * TasksManager::createChild( string const & childKey, string const & childName ) { - std::unique_ptr< TaskBase > task = TaskBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< TaskBase > task = TaskBase::CatalogInterface::factory( childKey, getDataContext(), + 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 6edc963b457..2216a601539 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -51,7 +51,8 @@ FieldSpecificationManager & FieldSpecificationManager::getInstance() Group * FieldSpecificationManager::createChild( string const & childKey, string const & childName ) { - std::unique_ptr< FieldSpecificationBase > bc = FieldSpecificationBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< FieldSpecificationBase > bc = FieldSpecificationBase::CatalogInterface::factory( childKey, getDataContext(), + 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 19034f1326b..d0a5b49942c 100644 --- a/src/coreComponents/fileIO/Outputs/OutputManager.cpp +++ b/src/coreComponents/fileIO/Outputs/OutputManager.cpp @@ -40,7 +40,8 @@ OutputManager::~OutputManager() Group * OutputManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Output: " << childKey << ", " << childName ); - std::unique_ptr< OutputBase > output = OutputBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< OutputBase > output = OutputBase::CatalogInterface::factory( childKey, getDataContext(), + 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 fe7a1d668c8..122040225c2 100644 --- a/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp +++ b/src/coreComponents/finiteElement/FiniteElementDiscretizationManager.cpp @@ -40,7 +40,8 @@ FiniteElementDiscretizationManager::~FiniteElementDiscretizationManager() Group * FiniteElementDiscretizationManager::createChild( string const & childKey, string const & childName ) { // These objects should probably not be registered on managed group... - std::unique_ptr< Group > fem = Group::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< Group > fem = Group::CatalogInterface::factory( childKey, getDataContext(), + childName, this ); return &this->registerGroup( childName, std::move( fem ) ); } diff --git a/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp b/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp index 7c1bb141182..a455f2fc212 100644 --- a/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp +++ b/src/coreComponents/finiteVolume/FiniteVolumeManager.cpp @@ -49,7 +49,8 @@ Group * FiniteVolumeManager::createChild( string const & childKey, string const } else { - std::unique_ptr< FluxApproximationBase > approx = FluxApproximationBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< FluxApproximationBase > approx = FluxApproximationBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ); return &this->registerGroup< FluxApproximationBase >( childName, std::move( approx )); } } diff --git a/src/coreComponents/functions/FunctionManager.cpp b/src/coreComponents/functions/FunctionManager.cpp index 5cf652a8593..0da3fa38c52 100644 --- a/src/coreComponents/functions/FunctionManager.cpp +++ b/src/coreComponents/functions/FunctionManager.cpp @@ -54,7 +54,8 @@ Group * FunctionManager::createChild( string const & functionCatalogKey, string const & functionName ) { GEOS_LOG_RANK_0( " " << functionCatalogKey << ": " << functionName ); - std::unique_ptr< FunctionBase > function = FunctionBase::CatalogInterface::factory( functionCatalogKey, functionName, this ); + std::unique_ptr< FunctionBase > function = FunctionBase::CatalogInterface::factory( functionCatalogKey, getDataContext(), + 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 6f3669a0a19..8209c8a3bd7 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -77,7 +77,8 @@ Group * ElementRegionManager::createChild( string const & childKey, string const Group & elementRegions = this->getGroup( ElementRegionManager::groupKeyStruct::elementRegionsGroup() ); return &elementRegions.registerGroup( childName, - CatalogInterface::factory( childKey, childName, &elementRegions ) ); + CatalogInterface::factory( childKey, getDataContext(), + childName, &elementRegions ) ); } void ElementRegionManager::expandObjectCatalogs() diff --git a/src/coreComponents/mesh/MeshManager.cpp b/src/coreComponents/mesh/MeshManager.cpp index 3fa5ab4825a..75f614188b3 100644 --- a/src/coreComponents/mesh/MeshManager.cpp +++ b/src/coreComponents/mesh/MeshManager.cpp @@ -44,7 +44,8 @@ MeshManager::~MeshManager() Group * MeshManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Mesh: " << childKey << ", " << childName ); - std::unique_ptr< MeshGeneratorBase > solver = MeshGeneratorBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< MeshGeneratorBase > solver = MeshGeneratorBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ); return &this->registerGroup< MeshGeneratorBase >( childName, std::move( solver ) ); } diff --git a/src/coreComponents/mesh/ParticleManager.cpp b/src/coreComponents/mesh/ParticleManager.cpp index af1096d02c2..a07687635b4 100644 --- a/src/coreComponents/mesh/ParticleManager.cpp +++ b/src/coreComponents/mesh/ParticleManager.cpp @@ -92,7 +92,8 @@ Group * ParticleManager::createChild( string const & childKey, string const & ch Group & particleRegions = this->getGroup( ParticleManager::groupKeyStruct::particleRegionsGroup() ); return &particleRegions.registerGroup( childName, - CatalogInterface::factory( childKey, childName, &particleRegions ) ); + CatalogInterface::factory( childKey, getDataContext(), + childName, &particleRegions ) ); } diff --git a/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp b/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp index b4de9e8fc33..f2068300759 100644 --- a/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/MeshGeneratorBase.cpp @@ -30,7 +30,8 @@ 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 ); - std::unique_ptr< WellGeneratorBase > wellGen = WellGeneratorBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< WellGeneratorBase > wellGen = WellGeneratorBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ); return &this->registerGroup< WellGeneratorBase >( childName, std::move( wellGen ) ); } diff --git a/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp b/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp index a6824ff7fa8..68855dc86b6 100644 --- a/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp +++ b/src/coreComponents/mesh/simpleGeometricObjects/GeometricObjectManager.cpp @@ -54,7 +54,8 @@ GeometricObjectManager & GeometricObjectManager::getInstance() Group * GeometricObjectManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Geometric Object: " << childKey << ", " << childName ); - std::unique_ptr< SimpleGeometricObjectBase > geometriObject = SimpleGeometricObjectBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< SimpleGeometricObjectBase > geometriObject = SimpleGeometricObjectBase::CatalogInterface::factory( childKey, getDataContext(), + 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 6820cffbe84..e2f4e976d90 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp @@ -51,7 +51,8 @@ Group * PhysicsSolverManager::createChild( string const & childKey, string const { GEOS_LOG_RANK_0( "Adding Solver of type " << childKey << ", named " << childName ); rval = ®isterGroup( childName, - SolverBase::CatalogInterface::factory( childKey, childName, this ) ); + SolverBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ) ); } return rval; } From 24491390413e3fc15e0782cc2a25061645b9423e Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 16:39:27 +0200 Subject: [PATCH 06/27] added ability to get context from a cpp source file (typically for tests) --- .../dataRepository/DataContext.cpp | 17 +++++++++++++---- .../dataRepository/DataContext.hpp | 11 ++++++++--- .../dataRepository/GroupContext.cpp | 2 +- .../dataRepository/GroupContext.hpp | 2 +- .../dataRepositoryTests/testObjectCatalog.cpp | 9 ++++++--- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/coreComponents/dataRepository/DataContext.cpp b/src/coreComponents/dataRepository/DataContext.cpp index e20eab50e60..ea9021b8cff 100644 --- a/src/coreComponents/dataRepository/DataContext.cpp +++ b/src/coreComponents/dataRepository/DataContext.cpp @@ -25,7 +25,7 @@ namespace dataRepository { -DataContext::DataContext( string const & targetName ): +DataContext::DataContext( string_view targetName ): m_targetName( targetName ) {} @@ -35,12 +35,12 @@ std::ostream & operator<<( std::ostream & os, DataContext const & ctx ) return os; } -DataContext::ToStringInfo::ToStringInfo( string const & targetName, string const & filePath, size_t line ): +DataContext::ToStringInfo::ToStringInfo( string_view targetName, string_view filePath, size_t line ): m_targetName( targetName ), m_filePath( filePath ), m_line( line ) {} -DataContext::ToStringInfo::ToStringInfo( string const & targetName ): +DataContext::ToStringInfo::ToStringInfo( string_view targetName ): m_targetName( targetName ) {} @@ -83,6 +83,15 @@ DataFileContext::DataFileContext( xmlWrapper::xmlNode const & targetNode, m_offset( attPos.offset ) {} +DataFileContext::DataFileContext( string_view targetName, string_view file, size_t line ): + DataContext( targetName ), + m_typeName( "C++ Source File" ), + m_filePath( file ), + m_line( line ), + m_offsetInLine( 0 ), + m_offset( 0 ) +{} + string DataFileContext::toString() const { if( m_line != xmlWrapper::xmlDocument::npos ) @@ -95,7 +104,7 @@ string DataFileContext::toString() const } else { - return GEOS_FMT( "{} (Source file not found)", m_targetName ); + return GEOS_FMT( "{} ({})", m_targetName, ( m_filePath.empty() ? "Source file not found" : m_filePath ) ); } } diff --git a/src/coreComponents/dataRepository/DataContext.hpp b/src/coreComponents/dataRepository/DataContext.hpp index 16600e02f1b..f8d5be54197 100644 --- a/src/coreComponents/dataRepository/DataContext.hpp +++ b/src/coreComponents/dataRepository/DataContext.hpp @@ -47,7 +47,7 @@ class DataContext * @brief Construct a new DataContext object. * @param targetName the target object name */ - DataContext( string const & targetName ); + DataContext( string_view targetName ); /** * @brief Destroy the DataContext object @@ -95,12 +95,12 @@ class DataContext * @param filePath the input file path where the target is declared. * @param line the line in the file where the target is declared. */ - ToStringInfo( string const & targetName, string const & filePath, size_t line ); + ToStringInfo( string_view targetName, string_view filePath, size_t line ); /** * @brief Construct a new ToStringInfo object from a DataContext that has no input file info. * @param targetName the target name. */ - ToStringInfo( string const & targetName ); + ToStringInfo( string_view targetName ); /** * @return true if a location has been found to declare the target in an input file. */ @@ -142,6 +142,11 @@ class DataFileContext final : public DataContext DataFileContext( xmlWrapper::xmlNode const & targetNode, xmlWrapper::xmlAttribute const & att, xmlWrapper::xmlAttributePos const & attPos ); + /** + * @brief Construct the file context of a Group from an cpp source file. + */ + DataFileContext( string_view targetName, string_view file, size_t line ); + /** * @return the target object name followed by the the file and line declaring it. */ diff --git a/src/coreComponents/dataRepository/GroupContext.cpp b/src/coreComponents/dataRepository/GroupContext.cpp index e19a7358fa1..f1dc5eecee4 100644 --- a/src/coreComponents/dataRepository/GroupContext.cpp +++ b/src/coreComponents/dataRepository/GroupContext.cpp @@ -25,7 +25,7 @@ namespace dataRepository { -GroupContext::GroupContext( Group & group, string const & objectName ): +GroupContext::GroupContext( Group & group, string_view objectName ): DataContext( objectName ), m_group( group ) {} diff --git a/src/coreComponents/dataRepository/GroupContext.hpp b/src/coreComponents/dataRepository/GroupContext.hpp index d361bd26e58..81266a0792c 100644 --- a/src/coreComponents/dataRepository/GroupContext.hpp +++ b/src/coreComponents/dataRepository/GroupContext.hpp @@ -57,7 +57,7 @@ class GroupContext : public DataContext * @param group The reference to the Group related to this GroupContext. * @param objectName Target object name. */ - GroupContext( Group & group, string const & objectName ); + GroupContext( Group & group, string_view objectName ); /// The reference to the Group related to this GroupContext. Group & m_group; diff --git a/src/coreComponents/unitTests/dataRepositoryTests/testObjectCatalog.cpp b/src/coreComponents/unitTests/dataRepositoryTests/testObjectCatalog.cpp index e511c09a0e0..4c01e3c069b 100644 --- a/src/coreComponents/unitTests/dataRepositoryTests/testObjectCatalog.cpp +++ b/src/coreComponents/unitTests/dataRepositoryTests/testObjectCatalog.cpp @@ -17,6 +17,7 @@ // Source includes #include "dataRepository/ObjectCatalog.hpp" +#include "dataRepository/DataContext.hpp" #include "common/logger/Logger.hpp" #include "mainInterface/initialization.hpp" @@ -67,7 +68,6 @@ class Derived1 : public Base } static string catalogName() { return "derived1"; } string getCatalogName() { return catalogName(); } - }; REGISTER_CATALOG_ENTRY( Base, Derived1, int &, double const & ) //STOP_SPHINX @@ -99,14 +99,17 @@ TEST( testObjectCatalog, testRegistration ) GEOS_LOG( "EXECUTING MAIN" ); int junk = 1; double junk2 = 3.14; + dataRepository::DataFileContext const context = dataRepository::DataFileContext( "Base Test Class", __FILE__, __LINE__ ); // allocate a new Derived1 object std::unique_ptr< Base > - derived1 = Base::CatalogInterface::factory( "derived1", junk, junk2 ); + derived1 = Base::CatalogInterface::factory( "derived1", context, + junk, junk2 ); // allocate a new Derived2 object std::unique_ptr< Base > - derived2 = Base::CatalogInterface::factory( "derived2", junk, junk2 ); + derived2 = Base::CatalogInterface::factory( "derived2", context, + junk, junk2 ); EXPECT_STREQ( derived1->getCatalogName().c_str(), Derived1::catalogName().c_str() ); From eee2c11884bf502dea19364be55e88c1d2da0760 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 17:48:08 +0200 Subject: [PATCH 07/27] Updated ElementRegionManager error message + refactored how ElementRegionManager define possible child keys --- .../mesh/ElementRegionManager.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/coreComponents/mesh/ElementRegionManager.cpp b/src/coreComponents/mesh/ElementRegionManager.cpp index 8209c8a3bd7..327122b0615 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -67,12 +67,19 @@ void ElementRegionManager::setMaxGlobalIndex() m_maxGlobalIndex = MpiWrapper::max( m_localMaxGlobalIndex, MPI_COMM_GEOS ); } - +auto const & getUserAvailableKeys() { + static std::set< string > keys = { + CellElementRegion::catalogName(), + WellElementRegion::catalogName(), + SurfaceElementRegion::catalogName(), + }; + return keys; +} Group * ElementRegionManager::createChild( string const & childKey, string const & childName ) { - GEOS_ERROR_IF( !(CatalogInterface::hasKeyName( childKey )), - "KeyName ("<getGroup( ElementRegionManager::groupKeyStruct::elementRegionsGroup() ); @@ -83,16 +90,9 @@ Group * ElementRegionManager::createChild( string const & childKey, string const void ElementRegionManager::expandObjectCatalogs() { - ObjectManagerBase::CatalogInterface::CatalogType const & catalog = ObjectManagerBase::getCatalog(); - for( ObjectManagerBase::CatalogInterface::CatalogType::const_iterator iter = catalog.begin(); - iter!=catalog.end(); - ++iter ) + for( string const & key : getUserAvailableKeys() ) { - string const key = iter->first; - if( key.find( "ElementRegion" ) != string::npos ) - { - this->createChild( key, key ); - } + this->createChild( key, key ); } } From bbe8d7f0011cd0e6260788ec7a732493198b88ad Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 17:48:26 +0200 Subject: [PATCH 08/27] Updated WellSolverBase error message --- .../fluidFlow/wells/WellSolverBase.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp index 2b114b13f70..95d57ff4e29 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp @@ -57,17 +57,10 @@ WellSolverBase::WellSolverBase( string const & name, Group * WellSolverBase::createChild( string const & childKey, string const & childName ) { - Group * rval = nullptr; - - if( childKey == keys::wellControls ) - { - rval = ®isterGroup< WellControls >( childName ); - } - else - { - SolverBase::createChild( childKey, childName ); - } - return rval; + const auto childTypes = { keys::wellControls }; + GEOS_ERROR_IF( childKey != keys::wellControls, + CatalogInterface::unknownTypeError( getCatalogName(), getDataContext(), childTypes ) ); + return ®isterGroup< WellControls >( childName ); } void WellSolverBase::expandObjectCatalogs() From 0d26bb2f21b29f8927105fd9e371732e07ddab62 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 25 Oct 2024 17:50:52 +0200 Subject: [PATCH 09/27] =?UTF-8?q?=F0=9F=90=9B=20bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/mesh/ElementRegionManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/mesh/ElementRegionManager.cpp b/src/coreComponents/mesh/ElementRegionManager.cpp index 327122b0615..693700e0457 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -78,7 +78,7 @@ auto const & getUserAvailableKeys() { Group * ElementRegionManager::createChild( string const & childKey, string const & childName ) { - GEOS_ERROR_IF( !getUserAvailableKeys().count( childKey ) == 0, + GEOS_ERROR_IF( getUserAvailableKeys().count( childKey ) == 0, CatalogInterface::unknownTypeError( childKey, getDataContext(), getUserAvailableKeys() ) ); GEOS_LOG_RANK_0( "Adding Object " << childKey<<" named "<< childName<<" from ObjectManager::Catalog." ); From 549146f10464743d2b3a0dfdaeb2823d600c4bd4 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Wed, 30 Oct 2024 09:24:29 +0100 Subject: [PATCH 10/27] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20wrong=20&=20dead=20c?= =?UTF-8?q?ode=20removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/Group.hpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index 8b1c1d1f449..9ac5d190272 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -249,25 +249,6 @@ class Group return rval; } - /** - * @brief @copybrief registerGroup(string const &,std::unique_ptr) - * - * @tparam T The type of the Group to add/register. This should be a type that derives from Group. - * @tparam TBASE The type whose type catalog will be used to look up the new sub-group type - * @param[in] name The name of the group to use as a string key. - * @param[in] catalogName The catalog name of the new type. - * @return A pointer to the newly registered Group. - * - * Creates and registers a Group or class derived from Group as a subgroup of this Group. - */ - template< typename T = Group, typename TBASE = Group > - T & registerGroup( string const & name, string const & catalogName ) - { - std::unique_ptr< TBASE > newGroup = TBASE::CatalogInterface::Factory( catalogName, getDataContext(), - name, this ); - return registerGroup< T >( name, std::move( newGroup ) ); - } - /** * @brief Removes a child group from this group. * @param name the name of the child group to remove from this group. From 311c8678f00351e1d8017d87807ed1ad286f6736 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Wed, 30 Oct 2024 09:25:39 +0100 Subject: [PATCH 11/27] =?UTF-8?q?=F0=9F=93=9D=20object=20catalog=20factory?= =?UTF-8?q?=20docs=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/ObjectCatalog.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/dataRepository/ObjectCatalog.hpp b/src/coreComponents/dataRepository/ObjectCatalog.hpp index c9a832d6af7..ed9cfe5b985 100644 --- a/src/coreComponents/dataRepository/ObjectCatalog.hpp +++ b/src/coreComponents/dataRepository/ObjectCatalog.hpp @@ -174,8 +174,9 @@ class CatalogInterface * @param[in] objectTypeName the key to the catalog entry that is able to create the correct type. * @param args these are the arguments to the constructor of the target type * @return passes a unique_ptr to the newly allocated class. - * - * @note The simulation is killed if the builder is not found. + * @note Generate a fatal error: + * - if the object type to create is not found in this Catalog, + * - if the builder is not found. */ //START_SPHINX_2 static std::unique_ptr< BASETYPE > factory( std::string const & objectTypeName, From aa63944484c648389ed0e0cb6d2710fc38691166 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Wed, 30 Oct 2024 09:30:31 +0100 Subject: [PATCH 12/27] Prefering more contextualized catalog error over custom ones --- src/coreComponents/dataRepository/Group.cpp | 2 -- src/coreComponents/mesh/ParticleManager.cpp | 4 ---- .../physicsSolvers/PhysicsSolverManager.cpp | 13 ++++--------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index 7abb1fbc7a7..76b85c7ddd8 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -266,8 +266,6 @@ void Group::registerDataOnMeshRecursive( Group & meshBodies ) Group * Group::createChild( string const & childKey, string const & childName ) { - GEOS_ERROR_IF( !(CatalogInterface::hasKeyName( childKey )), - "KeyName ("<getGroup( ParticleManager::groupKeyStruct::particleRegionsGroup() ); return &particleRegions.registerGroup( childName, CatalogInterface::factory( childKey, getDataContext(), childName, &particleRegions ) ); - } void ParticleManager::expandObjectCatalogs() diff --git a/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp b/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp index e2f4e976d90..6fd63aef496 100644 --- a/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp +++ b/src/coreComponents/physicsSolvers/PhysicsSolverManager.cpp @@ -46,15 +46,10 @@ PhysicsSolverManager::~PhysicsSolverManager() //START_SPHINX_INCLUDE_00 Group * PhysicsSolverManager::createChild( string const & childKey, string const & childName ) { - Group * rval = nullptr; - if( SolverBase::CatalogInterface::hasKeyName( childKey ) ) - { - GEOS_LOG_RANK_0( "Adding Solver of type " << childKey << ", named " << childName ); - rval = ®isterGroup( childName, - SolverBase::CatalogInterface::factory( childKey, getDataContext(), - childName, this ) ); - } - return rval; + GEOS_LOG_RANK_0( "Adding Solver of type " << childKey << ", named " << childName ); + return ®isterGroup( childName, + SolverBase::CatalogInterface::factory( childKey, getDataContext(), + childName, this ) ); } From 9b4f59e11ec3e3b654556b0eaf5537df951e50a4 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Wed, 30 Oct 2024 09:34:43 +0100 Subject: [PATCH 13/27] Updated WellGeneratorBase error message --- .../mesh/generators/WellGeneratorBase.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp index 1617aa3fdb4..5a900a9ba4b 100644 --- a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp @@ -76,20 +76,15 @@ WellGeneratorBase::WellGeneratorBase( string const & name, Group * const parent Group * WellGeneratorBase::createChild( string const & childKey, string const & childName ) { - if( childKey == viewKeyStruct::perforationString() ) - { - ++m_numPerforations; + GEOS_LOG_RANK_0( "Adding Well attribute: " << childKey << ", " << childName ); + const auto childTypes = { viewKeyStruct::perforationString }; + GEOS_ERROR_IF( childKey != viewKeyStruct::perforationString, + CatalogInterface::unknownTypeError( getCatalogName(), getDataContext(), childTypes ) ); - // keep track of the perforations that have been added - m_perforationList.emplace_back( childName ); - GEOS_LOG_RANK_0( "Adding Well attribute: " << childKey << ", " << childName ); - return ®isterGroup< Perforation >( childName ); - } - else - { - GEOS_THROW( "Unrecognized node: " << childKey, InputError ); - } - return nullptr; + ++m_numPerforations; + m_perforationList.emplace_back( childName ); + + return ®isterGroup< Perforation >( childName ); } void WellGeneratorBase::expandObjectCatalogs() From 1f26cd413b0d7a35a794f4125198c176e322fadd Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 7 Nov 2024 12:13:15 +0100 Subject: [PATCH 14/27] standardize group name processing --- src/coreComponents/dataRepository/Group.cpp | 88 ++++++++++--------- src/coreComponents/dataRepository/Group.hpp | 8 +- .../mainInterface/ProblemManager.cpp | 73 +++++++-------- 3 files changed, 87 insertions(+), 82 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index 76b85c7ddd8..6a72cea92fd 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -135,21 +135,60 @@ string Group::getPath() const return noProblem.empty() ? "/" : noProblem; } +string Group::processInputName( xmlWrapper::xmlNode const & targetNode, + xmlWrapper::xmlNodePos const & targetNodePos, + string_view parentNodeName, + xmlWrapper::xmlNodePos const & parentNodePos, + std::set< string > & siblingNames ) +{ + GEOS_ERROR_IF( targetNode.type() != xmlWrapper::xmlNodeType::node_element, + GEOS_FMT( "Error in node named \"{}\" ({}): GEOS XML nodes cannot contain " + "text data nor anything but XML nodes.\nErroneous content: \"{}\"\n", + parentNodeName, parentNodePos.toString(), + stringutilities::trimSpaces( targetNode.value() ) )); + + string targetNodeName; + try + { // read & validate the name attribute + xmlWrapper::readAttributeAsType( targetNodeName, "name", + rtTypes::getTypeRegex< string >( rtTypes::CustomTypes::groupName ), + targetNode, string( "" ) ); + } catch( std::exception const & ex ) + { + xmlWrapper::processInputException( ex, "name", targetNode, targetNodePos ); + } + + if( targetNodeName.empty() ) + { // if there is no name attribute, we use the node tag as a node name + targetNodeName = targetNode.name(); + } + else + { // Make sure names are not duplicated by checking all previous siblings + GEOS_ERROR_IF( siblingNames.count( targetNodeName ) != 0, + GEOS_FMT( "Error at node named \"{}\" ({}): " + "An XML block cannot contain children with duplicated names.\n", + targetNodeName, targetNodePos.toString() ) ); + siblingNames.insert( targetNodeName ); + } + + return targetNodeName; +} + void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, xmlWrapper::xmlNode & targetNode ) { - xmlWrapper::xmlNodePos nodePos = xmlDocument.getNodePosition( targetNode ); - processInputFileRecursive( xmlDocument, targetNode, nodePos ); + xmlWrapper::xmlNodePos targetNodePos = xmlDocument.getNodePosition( targetNode ); + processInputFileRecursive( xmlDocument, targetNode, targetNodePos ); } void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, xmlWrapper::xmlNode & targetNode, - xmlWrapper::xmlNodePos const & nodePos ) + xmlWrapper::xmlNodePos const & targetNodePos ) { xmlDocument.addIncludedXML( targetNode ); - if( nodePos.isFound() ) + if( targetNodePos.isFound() ) { - m_dataContext = std::make_unique< DataFileContext >( targetNode, nodePos ); + m_dataContext = std::make_unique< DataFileContext >( targetNode, targetNodePos ); } // Handle the case where the node was imported from a different input file @@ -162,43 +201,12 @@ void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, } // Loop over the child nodes of the targetNode - array1d< string > childNames; + std::set< string > childNames; for( xmlWrapper::xmlNode childNode : targetNode.children() ) { xmlWrapper::xmlNodePos childNodePos = xmlDocument.getNodePosition( childNode ); - - GEOS_ERROR_IF( childNode.type() != xmlWrapper::xmlNodeType::node_element, - GEOS_FMT( "Error in {}: GEOS XML nodes cannot contain text data nor anything but XML nodes.", - getDataContext() )); - - // Get the child tag and name - string childName; - try - { - xmlWrapper::readAttributeAsType( childName, "name", - rtTypes::getTypeRegex< string >( rtTypes::CustomTypes::groupName ), - childNode, string( "" ) ); - } catch( std::exception const & ex ) - { - xmlWrapper::processInputException( ex, "name", childNode, childNodePos ); - } - - if( childName.empty() ) - { - childName = childNode.name(); - } - else - { - // Make sure child names are not duplicated - GEOS_ERROR_IF( std::find( childNames.begin(), childNames.end(), childName ) != childNames.end(), - GEOS_FMT( "Error: An XML block cannot contain children with duplicated names.\n" - "Error detected at node {} with name = {} ({}:l.{})", - childNode.path(), childName, xmlDocument.getFilePath(), - xmlDocument.getNodePosition( childNode ).line ) ); - - childNames.emplace_back( childName ); - } - + string const childName = processInputName( childNode, childNodePos, + getName(), targetNodePos, childNames ); // Create children Group * newChild = createChild( childNode.name(), childName ); if( newChild == nullptr ) @@ -211,7 +219,7 @@ void Group::processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, } } - processInputFile( targetNode, nodePos ); + processInputFile( targetNode, targetNodePos ); // Restore original prefix once the node is processed Path::setPathPrefix( oldPrefix ); diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index 9ac5d190272..88e8ad84295 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -751,6 +751,12 @@ class Group */ void postRestartInitializationRecursive(); + static string processInputName( xmlWrapper::xmlNode const & targetNode, + xmlWrapper::xmlNodePos const & targetNodePos, + string_view parentNodeName, + xmlWrapper::xmlNodePos const & parentNodePos, + std::set< string > & siblingNames ); + /** * @brief Recursively read values using ProcessInputFile() from the input * file and put them into the wrapped values for this group. @@ -769,7 +775,7 @@ class Group */ void processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, xmlWrapper::xmlNode & targetNode, - xmlWrapper::xmlNodePos const & nodePos ); + xmlWrapper::xmlNodePos const & targetNodePos ); /** * @brief Recursively call postInputInitialization() to apply post processing after diff --git a/src/coreComponents/mainInterface/ProblemManager.cpp b/src/coreComponents/mainInterface/ProblemManager.cpp index f9ef19ea92d..474a72d369d 100644 --- a/src/coreComponents/mainInterface/ProblemManager.cpp +++ b/src/coreComponents/mainInterface/ProblemManager.cpp @@ -455,52 +455,43 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument ) meshManager.generateMeshLevels( domain ); Group & meshBodies = domain.getMeshBodies(); - // Parse element regions - xmlWrapper::xmlNode elementRegionsNode = xmlProblemNode.child( MeshLevel::groupStructKeys::elemManagerString() ); - - for( xmlWrapper::xmlNode regionNode : elementRegionsNode.children() ) + auto parseRegions = [&]( string_view regionManagerKey, bool const hasParticles ) { - string const regionName = regionNode.attribute( "name" ).value(); - try + xmlWrapper::xmlNode regionsNode = xmlProblemNode.child( regionManagerKey ); + xmlWrapper::xmlNodePos regionsNodePos = xmlDocument.getNodePosition( regionsNode ); + std::set< string > regionNames; + + for( xmlWrapper::xmlNode regionNode : regionsNode.children() ) { - string const - regionMeshBodyName = ElementRegionBase::verifyMeshBodyName( meshBodies, - regionNode.attribute( "meshBody" ).value() ); + auto const regionNodePos = xmlDocument.getNodePosition( regionNode ); + string const regionName = Group::processInputName( regionNode, regionNodePos, + regionsNode.name(), regionsNodePos, regionNames ); + try + { + string const regionMeshBodyName = + ElementRegionBase::verifyMeshBodyName( meshBodies, + regionNode.attribute( "meshBody" ).value() ); - MeshBody & meshBody = domain.getMeshBody( regionMeshBodyName ); - meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) + MeshBody & meshBody = domain.getMeshBody( regionMeshBodyName ); + meshBody.setHasParticles( hasParticles ); + meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) + { + ObjectManagerBase & elementManager = hasParticles ? + meshLevel.getElemManager() : + meshLevel.getParticleManager(); + Group * newRegion = elementManager.createChild( regionNode.name(), regionName ); + newRegion->processInputFileRecursive( xmlDocument, regionNode ); + } ); + } + catch( InputError const & e ) { - ElementRegionManager & elementManager = meshLevel.getElemManager(); - Group * newRegion = elementManager.createChild( regionNode.name(), regionName ); - newRegion->processInputFileRecursive( xmlDocument, regionNode ); - } ); - } - catch( InputError const & e ) - { - string const nodePosString = xmlDocument.getNodePosition( regionNode ).toString(); - throw InputError( e, "Error while parsing region " + regionName + " (" + nodePosString + "):\n" ); + throw InputError( e, GEOS_FMT( "Error while parsing region {} ({}):\n", + regionName, regionNodePos.toString() ) ); + } } - } - - // Parse particle regions - xmlWrapper::xmlNode particleRegionsNode = xmlProblemNode.child( MeshLevel::groupStructKeys::particleManagerString() ); - - for( xmlWrapper::xmlNode regionNode : particleRegionsNode.children() ) - { - string const regionName = regionNode.attribute( "name" ).value(); - string const - regionMeshBodyName = ElementRegionBase::verifyMeshBodyName( meshBodies, - regionNode.attribute( "meshBody" ).value() ); - - MeshBody & meshBody = domain.getMeshBody( regionMeshBodyName ); - meshBody.setHasParticles( true ); - meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) - { - ParticleManager & particleManager = meshLevel.getParticleManager(); - Group * newRegion = particleManager.createChild( regionNode.name(), regionName ); - newRegion->processInputFileRecursive( xmlDocument, regionNode ); - } ); - } + }; + parseRegions( MeshLevel::groupStructKeys::elemManagerString(), false ); + parseRegions( MeshLevel::groupStructKeys::particleManagerString(), true ); } } From d39dde6ad44a6a4f9e908642c5daeefc258aa5ab Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 7 Nov 2024 12:20:41 +0100 Subject: [PATCH 15/27] regex validation fail message improvement --- .../dataRepository/xmlWrapper.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/coreComponents/dataRepository/xmlWrapper.cpp b/src/coreComponents/dataRepository/xmlWrapper.cpp index e2e7d85332c..38136874cee 100644 --- a/src/coreComponents/dataRepository/xmlWrapper.cpp +++ b/src/coreComponents/dataRepository/xmlWrapper.cpp @@ -32,18 +32,29 @@ using namespace dataRepository; namespace xmlWrapper { -void validateString( string const & value, Regex const & regex ) +void validateString( std::string const & value, const Regex & regex ) { - std::smatch m; - bool inputValidated = std::regex_match( value, m, std::regex( regex.m_regexStr ) ); - if( !inputValidated ) + std::regex regexInstance{ regex.m_regexStr }; + // if validation fails, let's try to find the error start & end to underline it. If it fails, underline the whole message. + if( !std::regex_match( value, regexInstance )) { - ptrdiff_t errorId = ( m.size()>0 && m.position( 0 )==0 ) ? m.length() : 0; + std::smatch m; + std::regex_search( value, m, regexInstance ); + ptrdiff_t const errorStart = ( m.size()>0 && m.position( 0 )==0 ) ? m.length() : 0; + + size_t errorLength; + for( errorLength = 1; errorStart + errorLength < value.length(); ++errorLength ) + { + if( std::regex_match( value.substr( errorStart + errorLength, 1 ), regexInstance ) ) + break; + } + + std::string const underline = std::string( errorStart, ' ' ) + std::string( errorLength, '^' ); GEOS_THROW( GEOS_FMT( "Input string validation failed at:\n" " \"{}\"\n" - " {:>{}}\n" + " {}\n" " Expected format: {}", - value, '^', errorId+1, regex.m_formatDescription ), + value, underline, regex.m_formatDescription ), InputError ); } } From 099c5360dc3155c83cdeb070dd2b99fd9c045798 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Thu, 7 Nov 2024 12:21:08 +0100 Subject: [PATCH 16/27] bugfix --- src/coreComponents/mesh/generators/WellGeneratorBase.cpp | 6 +++--- .../physicsSolvers/fluidFlow/wells/WellSolverBase.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp index 5a900a9ba4b..1a2619b338f 100644 --- a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp @@ -77,9 +77,9 @@ WellGeneratorBase::WellGeneratorBase( string const & name, Group * const parent Group * WellGeneratorBase::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( "Adding Well attribute: " << childKey << ", " << childName ); - const auto childTypes = { viewKeyStruct::perforationString }; - GEOS_ERROR_IF( childKey != viewKeyStruct::perforationString, - CatalogInterface::unknownTypeError( getCatalogName(), getDataContext(), childTypes ) ); + const auto childTypes = { viewKeyStruct::perforationString() }; + GEOS_ERROR_IF( childKey != viewKeyStruct::perforationString(), + CatalogInterface::unknownTypeError( childKey, getDataContext(), childTypes ) ); ++m_numPerforations; m_perforationList.emplace_back( childName ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp index 95d57ff4e29..914014e193d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp @@ -59,7 +59,7 @@ Group * WellSolverBase::createChild( string const & childKey, string const & chi { const auto childTypes = { keys::wellControls }; GEOS_ERROR_IF( childKey != keys::wellControls, - CatalogInterface::unknownTypeError( getCatalogName(), getDataContext(), childTypes ) ); + CatalogInterface::unknownTypeError( childKey, getDataContext(), childTypes ) ); return ®isterGroup< WellControls >( childName ); } From 263ee4cf83ad0d67dcfb4cf1783b03d22621b968 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 8 Nov 2024 10:08:44 +0100 Subject: [PATCH 17/27] uncrustify --- src/coreComponents/mesh/CellElementRegionSelector.cpp | 6 +++--- src/coreComponents/mesh/ElementRegionManager.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/coreComponents/mesh/CellElementRegionSelector.cpp b/src/coreComponents/mesh/CellElementRegionSelector.cpp index 54e9faed685..fc29375105b 100644 --- a/src/coreComponents/mesh/CellElementRegionSelector.cpp +++ b/src/coreComponents/mesh/CellElementRegionSelector.cpp @@ -67,9 +67,9 @@ CellElementRegionSelector::getMatchingCellblocks( CellElementRegion const & regi region.getWrapperDataContext( ViewKeys::sourceCellBlockNamesString() ), matchPattern, stringutilities::joinLambda( m_regionAttributesOwners, ", ", - []( auto pair ) { return pair->first; } ), + []( auto pair ) { return pair->first; } ), stringutilities::joinLambda( m_cellBlocksOwners, ", ", - []( auto pair ) { return pair->first; } ) ), + []( auto pair ) { return pair->first; } ) ), InputError ); return matchedCellBlocks; } @@ -86,7 +86,7 @@ CellElementRegionSelector::verifyRequestedCellBlocks( CellElementRegion const & region.getWrapperDataContext( ViewKeys::sourceCellBlockNamesString() ), requestedCellBlockName, stringutilities::joinLambda( m_cellBlocksOwners, ", ", - []( auto pair ) { return pair->first; } ) ), + []( auto pair ) { return pair->first; } ) ), InputError ); } } diff --git a/src/coreComponents/mesh/ElementRegionManager.cpp b/src/coreComponents/mesh/ElementRegionManager.cpp index 693700e0457..0c9af76fdcf 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -67,7 +67,8 @@ void ElementRegionManager::setMaxGlobalIndex() m_maxGlobalIndex = MpiWrapper::max( m_localMaxGlobalIndex, MPI_COMM_GEOS ); } -auto const & getUserAvailableKeys() { +auto const & getUserAvailableKeys() +{ static std::set< string > keys = { CellElementRegion::catalogName(), WellElementRegion::catalogName(), From b330a2fb013b25abe154757976e523bfba3848a6 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 8 Nov 2024 14:01:41 +0100 Subject: [PATCH 18/27] =?UTF-8?q?=F0=9F=93=9D=20Group::processInputName=20?= =?UTF-8?q?docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/Group.cpp | 10 ++++++---- src/coreComponents/dataRepository/Group.hpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index 6a72cea92fd..f28fe6ab606 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -141,11 +141,12 @@ string Group::processInputName( xmlWrapper::xmlNode const & targetNode, xmlWrapper::xmlNodePos const & parentNodePos, std::set< string > & siblingNames ) { - GEOS_ERROR_IF( targetNode.type() != xmlWrapper::xmlNodeType::node_element, + GEOS_THROW_IF( targetNode.type() != xmlWrapper::xmlNodeType::node_element, GEOS_FMT( "Error in node named \"{}\" ({}): GEOS XML nodes cannot contain " "text data nor anything but XML nodes.\nErroneous content: \"{}\"\n", parentNodeName, parentNodePos.toString(), - stringutilities::trimSpaces( targetNode.value() ) )); + stringutilities::trimSpaces( targetNode.value() ) ), + InputError ); string targetNodeName; try @@ -164,10 +165,11 @@ string Group::processInputName( xmlWrapper::xmlNode const & targetNode, } else { // Make sure names are not duplicated by checking all previous siblings - GEOS_ERROR_IF( siblingNames.count( targetNodeName ) != 0, + GEOS_THROW_IF( siblingNames.count( targetNodeName ) != 0, GEOS_FMT( "Error at node named \"{}\" ({}): " "An XML block cannot contain children with duplicated names.\n", - targetNodeName, targetNodePos.toString() ) ); + targetNodeName, targetNodePos.toString() ), + InputError ); siblingNames.insert( targetNodeName ); } diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index a2a0fce3185..2d9f6d702ab 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -751,6 +751,20 @@ class Group */ void postRestartInitializationRecursive(); + /** + * @return The validated name for a given Group from its xml value: If the node has a "name" + * attribute, it is validated after the `groupName` rtType regex, and its value is + * returned. Else if the Group name is not "Required", the node tag name is used. + * @param targetNode The XML node whose name is to be processed. It throws if not of element type. + * @param targetNodePos The position of the target node within the XML document. + * @param parentNodeName The name of the parent node, used for error reporting. + * @param parentNodePos The position of the parent node, used for error reporting. + * @param siblingNames A set containing the names of sibling nodes (to verify that there are no + * duplicates). The function will populate this set if the attribute name is + * used and if no error is found. + * @throws InputError if the node type is not an xml element or if there are duplicate names + * among xml siblings. + */ static string processInputName( xmlWrapper::xmlNode const & targetNode, xmlWrapper::xmlNodePos const & targetNodePos, string_view parentNodeName, From d7f334597f5ef05291cb11534d493eaaa904e516 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 8 Nov 2024 14:14:01 +0100 Subject: [PATCH 19/27] =?UTF-8?q?=F0=9F=93=9D=20doc=20add=20&=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/DataContext.hpp | 5 ++++- src/coreComponents/dataRepository/Group.hpp | 2 +- src/coreComponents/dataRepository/ObjectCatalog.hpp | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/dataRepository/DataContext.hpp b/src/coreComponents/dataRepository/DataContext.hpp index f8d5be54197..28390683af0 100644 --- a/src/coreComponents/dataRepository/DataContext.hpp +++ b/src/coreComponents/dataRepository/DataContext.hpp @@ -143,7 +143,10 @@ class DataFileContext final : public DataContext xmlWrapper::xmlAttributePos const & attPos ); /** - * @brief Construct the file context of a Group from an cpp source file. + * @brief Constructs the file context of a Group from a C++ source file. + * @param targetName The name of the target Group. + * @param file The name of the source file. + * @param line The line number in the source file. */ DataFileContext( string_view targetName, string_view file, size_t line ); diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index 2d9f6d702ab..52106f3aaf4 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -785,7 +785,7 @@ class Group * but allow to reuse an existing xmlNodePos. * @param[in] xmlDocument the XML document that contains the targetNode. * @param[in] targetNode the XML node that to extract input values from. - * @param[in] nodePos the target node position, typically obtained with xmlDocument::getNodePosition(). + * @param[in] targetNodePos the target node position, typically obtained with xmlDocument::getNodePosition(). */ void processInputFileRecursive( xmlWrapper::xmlDocument & xmlDocument, xmlWrapper::xmlNode & targetNode, diff --git a/src/coreComponents/dataRepository/ObjectCatalog.hpp b/src/coreComponents/dataRepository/ObjectCatalog.hpp index ed9cfe5b985..dfb3b7e6501 100644 --- a/src/coreComponents/dataRepository/ObjectCatalog.hpp +++ b/src/coreComponents/dataRepository/ObjectCatalog.hpp @@ -196,6 +196,13 @@ class CatalogInterface } //STOP_SPHINX + /** + * @return Generates a formatted error message for an unknown type for a catalog. + * @param objectTypeName The name of the object type that is invalid. + * @param context The data context of the Group for which the erroneous type creation was attempted. + * @param allowedKeys A container of allowed keys, which will be listed in the error message. + * @tparam KEYS_CONTAINER_T A container type holding the allowed keys. + */ template< typename KEYS_CONTAINER_T > static string unknownTypeError( std::string const & objectTypeName, DataContext const & context, KEYS_CONTAINER_T const & allowedKeys ) From 20f3620b10f09e53aea8da7c5f891fe553cc870a Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 8 Nov 2024 14:18:30 +0100 Subject: [PATCH 20/27] =?UTF-8?q?=F0=9F=93=9D=20doc=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/ObjectCatalog.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreComponents/dataRepository/ObjectCatalog.hpp b/src/coreComponents/dataRepository/ObjectCatalog.hpp index dfb3b7e6501..02060f3bfea 100644 --- a/src/coreComponents/dataRepository/ObjectCatalog.hpp +++ b/src/coreComponents/dataRepository/ObjectCatalog.hpp @@ -172,6 +172,7 @@ class CatalogInterface /** * @brief Static method to create a new object that derives from BASETYPE * @param[in] objectTypeName the key to the catalog entry that is able to create the correct type. + * @param context The data context of the Group for which we attempt to create a sub-group. * @param args these are the arguments to the constructor of the target type * @return passes a unique_ptr to the newly allocated class. * @note Generate a fatal error: From dd5d83d17b09dd5daae9daf9c2a4c421e59e1350 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 8 Nov 2024 15:11:46 +0100 Subject: [PATCH 21/27] uncrustify --- src/coreComponents/dataRepository/Group.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index 52106f3aaf4..0f1a12018f0 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -760,7 +760,7 @@ class Group * @param parentNodeName The name of the parent node, used for error reporting. * @param parentNodePos The position of the parent node, used for error reporting. * @param siblingNames A set containing the names of sibling nodes (to verify that there are no - * duplicates). The function will populate this set if the attribute name is + * duplicates). The function will populate this set if the attribute name is * used and if no error is found. * @throws InputError if the node type is not an xml element or if there are duplicate names * among xml siblings. From 1ad796f9c5821d57814e2c76a15d4f9ce1c326a4 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Wed, 18 Dec 2024 18:04:26 +0100 Subject: [PATCH 22/27] properly finishing merge with develop --- src/coreComponents/mesh/ElementRegionManager.cpp | 3 +-- src/coreComponents/mesh/ExternalDataSourceManager.cpp | 3 ++- src/coreComponents/mesh/generators/WellGeneratorBase.cpp | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coreComponents/mesh/ElementRegionManager.cpp b/src/coreComponents/mesh/ElementRegionManager.cpp index 3ff94a00560..2652103216e 100644 --- a/src/coreComponents/mesh/ElementRegionManager.cpp +++ b/src/coreComponents/mesh/ElementRegionManager.cpp @@ -81,10 +81,9 @@ auto const & getUserAvailableKeys() Group * ElementRegionManager::createChild( string const & childKey, string const & childName ) { + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); GEOS_ERROR_IF( getUserAvailableKeys().count( childKey ) == 0, CatalogInterface::unknownTypeError( childKey, getDataContext(), getUserAvailableKeys() ) ); - GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); - Group & elementRegions = this->getGroup( ElementRegionManager::groupKeyStruct::elementRegionsGroup() ); return &elementRegions.registerGroup( childName, CatalogInterface::factory( childKey, getDataContext(), diff --git a/src/coreComponents/mesh/ExternalDataSourceManager.cpp b/src/coreComponents/mesh/ExternalDataSourceManager.cpp index 8a22203af8e..969ab7a043d 100644 --- a/src/coreComponents/mesh/ExternalDataSourceManager.cpp +++ b/src/coreComponents/mesh/ExternalDataSourceManager.cpp @@ -36,7 +36,8 @@ ExternalDataSourceManager::~ExternalDataSourceManager() Group * ExternalDataSourceManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); - std::unique_ptr< ExternalDataSourceBase > externalDataSource = ExternalDataSourceBase::CatalogInterface::factory( childKey, childName, this ); + std::unique_ptr< ExternalDataSourceBase > externalDataSource = + ExternalDataSourceBase::CatalogInterface::factory( childKey, getDataContext(), childName, this ); return &this->registerGroup< ExternalDataSourceBase >( childName, std::move( externalDataSource ) ); } diff --git a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp index ed9d6a2aec5..af80ec09c8a 100644 --- a/src/coreComponents/mesh/generators/WellGeneratorBase.cpp +++ b/src/coreComponents/mesh/generators/WellGeneratorBase.cpp @@ -74,14 +74,13 @@ WellGeneratorBase::WellGeneratorBase( string const & name, Group * const parent Group * WellGeneratorBase::createChild( string const & childKey, string const & childName ) { - GEOS_LOG_RANK_0( "Adding Well attribute: " << childKey << ", " << childName ); + GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); const auto childTypes = { viewKeyStruct::perforationString() }; GEOS_ERROR_IF( childKey != viewKeyStruct::perforationString(), CatalogInterface::unknownTypeError( childKey, getDataContext(), childTypes ) ); ++m_numPerforations; m_perforationList.emplace_back( childName ); - GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); return ®isterGroup< Perforation >( childName ); } From cfeeb44fe7ae11f324dbf4a90e4bf96d38baba46 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Mon, 6 Jan 2025 16:59:54 +0100 Subject: [PATCH 23/27] std::string -> string --- src/coreComponents/dataRepository/ObjectCatalog.hpp | 2 +- src/coreComponents/dataRepository/xmlWrapper.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreComponents/dataRepository/ObjectCatalog.hpp b/src/coreComponents/dataRepository/ObjectCatalog.hpp index df42b09e1ca..2fd0762c97b 100644 --- a/src/coreComponents/dataRepository/ObjectCatalog.hpp +++ b/src/coreComponents/dataRepository/ObjectCatalog.hpp @@ -205,7 +205,7 @@ class CatalogInterface * @tparam KEYS_CONTAINER_T A container type holding the allowed keys. */ template< typename KEYS_CONTAINER_T > - static string unknownTypeError( std::string const & objectTypeName, DataContext const & context, + static string unknownTypeError( string const & objectTypeName, DataContext const & context, KEYS_CONTAINER_T const & allowedKeys ) { return GEOS_FMT( "The tag \"{}\" is invalid within {}. Please verify the keywords spelling and that " diff --git a/src/coreComponents/dataRepository/xmlWrapper.cpp b/src/coreComponents/dataRepository/xmlWrapper.cpp index 4ebec317bfe..c84439c874f 100644 --- a/src/coreComponents/dataRepository/xmlWrapper.cpp +++ b/src/coreComponents/dataRepository/xmlWrapper.cpp @@ -32,7 +32,7 @@ using namespace dataRepository; namespace xmlWrapper { -void validateString( std::string const & value, const Regex & regex ) +void validateString( string const & value, const Regex & regex ) { std::regex regexInstance{ regex.m_regexStr }; // if validation fails, let's try to find the error start & end to underline it. If it fails, underline the whole message. @@ -49,7 +49,7 @@ void validateString( std::string const & value, const Regex & regex ) break; } - std::string const underline = std::string( errorStart, ' ' ) + std::string( errorLength, '^' ); + string const underline = string( errorStart, ' ' ) + string( errorLength, '^' ); GEOS_THROW( GEOS_FMT( "Input string validation failed at:\n" " \"{}\"\n" " {}\n" From 1f36c8487d93ebe34e326a6026f9f456fdb82a9d Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Mon, 6 Jan 2025 17:00:07 +0100 Subject: [PATCH 24/27] merge fixes --- src/coreComponents/mainInterface/ProblemManager.cpp | 6 +++--- src/coreComponents/mesh/ExternalDataSourceBase.cpp | 5 +++-- .../physicsSolvers/fluidFlow/wells/WellSolverBase.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/coreComponents/mainInterface/ProblemManager.cpp b/src/coreComponents/mainInterface/ProblemManager.cpp index d4abd949f5c..685771247ff 100644 --- a/src/coreComponents/mainInterface/ProblemManager.cpp +++ b/src/coreComponents/mainInterface/ProblemManager.cpp @@ -460,7 +460,7 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument ) auto parseRegions = [&]( string_view regionManagerKey, bool const hasParticles ) { - xmlWrapper::xmlNode regionsNode = xmlProblemNode.child( regionManagerKey ); + xmlWrapper::xmlNode regionsNode = xmlProblemNode.child( regionManagerKey.data() ); xmlWrapper::xmlNodePos regionsNodePos = xmlDocument.getNodePosition( regionsNode ); std::set< string > regionNames; @@ -480,8 +480,8 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument ) meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) { ObjectManagerBase & elementManager = hasParticles ? - meshLevel.getElemManager() : - meshLevel.getParticleManager(); + static_cast< ObjectManagerBase & >( meshLevel.getElemManager() ): + static_cast< ObjectManagerBase & >( meshLevel.getParticleManager() ); Group * newRegion = elementManager.createChild( regionNode.name(), regionName ); newRegion->processInputFileRecursive( xmlDocument, regionNode ); } ); diff --git a/src/coreComponents/mesh/ExternalDataSourceBase.cpp b/src/coreComponents/mesh/ExternalDataSourceBase.cpp index 157fe3de31e..9c1285764d7 100644 --- a/src/coreComponents/mesh/ExternalDataSourceBase.cpp +++ b/src/coreComponents/mesh/ExternalDataSourceBase.cpp @@ -28,8 +28,9 @@ ExternalDataSourceBase::ExternalDataSourceBase( string const & name, Group * con Group * ExternalDataSourceBase::createChild( string const & childKey, string const & 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 ) ); + std::unique_ptr< ExternalDataSourceBase > event = + ExternalDataSourceBase::CatalogInterface::factory( childKey, getDataContext(), childName, this ); + return &this->registerGroup( childName, std::move( event ) ); } void ExternalDataSourceBase::expandObjectCatalogs() diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp index f848e753db1..1b7ed01bb4e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp @@ -69,7 +69,7 @@ Group *WellSolverBase::createChild( string const & childKey, string const & chil { const auto childTypes = { keys::wellControls }; GEOS_ERROR_IF( childKey != keys::wellControls, - PhysicsSolverBase::unknownTypeError( childKey, getDataContext(), childTypes ) ); + PhysicsSolverBase::CatalogInterface::unknownTypeError( childKey, getDataContext(), childTypes ) ); return ®isterGroup< WellControls >( childName ); } From 7aacc515867acefa2b4757857b1f540ecd2abed4 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Mon, 6 Jan 2025 17:04:58 +0100 Subject: [PATCH 25/27] schema file --- src/coreComponents/schema/schema.xsd | 4 +- src/coreComponents/schema/schema.xsd.other | 138 ++++++++++----------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index e130b1e56d4..27cb9f836a9 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -3245,7 +3245,7 @@ Level 0 outputs no specific information for this solver. Higher levels require m - + @@ -3268,7 +3268,7 @@ Local- Add jump stabilization on interior of macro elements--> - + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 3abf5b863f0..64384a62a01 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -486,7 +486,7 @@ - + @@ -572,7 +572,7 @@ - + @@ -609,7 +609,7 @@ - + @@ -660,7 +660,7 @@ - + @@ -701,7 +701,7 @@ - + @@ -734,7 +734,7 @@ - + @@ -745,7 +745,7 @@ - + @@ -758,7 +758,7 @@ - + @@ -771,7 +771,7 @@ - + @@ -787,7 +787,7 @@ - + @@ -821,7 +821,7 @@ - + @@ -884,7 +884,7 @@ - + @@ -915,7 +915,7 @@ - + @@ -928,7 +928,7 @@ - + @@ -941,7 +941,7 @@ - + @@ -954,7 +954,7 @@ - + @@ -967,7 +967,7 @@ - + @@ -982,7 +982,7 @@ - + @@ -993,7 +993,7 @@ - + @@ -1006,7 +1006,7 @@ - + @@ -1017,7 +1017,7 @@ - + @@ -1028,7 +1028,7 @@ - + @@ -1039,7 +1039,7 @@ - + @@ -1050,7 +1050,7 @@ - + @@ -1063,7 +1063,7 @@ - + @@ -1074,7 +1074,7 @@ - + @@ -1085,7 +1085,7 @@ - + @@ -1098,7 +1098,7 @@ - + @@ -1113,7 +1113,7 @@ - + @@ -1128,7 +1128,7 @@ - + @@ -1141,7 +1141,7 @@ - + @@ -1156,7 +1156,7 @@ - + @@ -1167,7 +1167,7 @@ - + @@ -1180,7 +1180,7 @@ - + @@ -1193,7 +1193,7 @@ - + @@ -1208,7 +1208,7 @@ - + @@ -1224,7 +1224,7 @@ - + @@ -1239,7 +1239,7 @@ - + @@ -1256,7 +1256,7 @@ - + @@ -1273,7 +1273,7 @@ - + @@ -1290,7 +1290,7 @@ - + @@ -1305,7 +1305,7 @@ - + @@ -1318,7 +1318,7 @@ - + @@ -1357,7 +1357,7 @@ - + @@ -1386,7 +1386,7 @@ - + @@ -1479,7 +1479,7 @@ - + @@ -3103,7 +3103,7 @@ - + @@ -3131,7 +3131,7 @@ - + @@ -3150,11 +3150,11 @@ - + - + @@ -3164,7 +3164,7 @@ - + @@ -3174,11 +3174,11 @@ - + - + @@ -3188,7 +3188,7 @@ - + @@ -3198,7 +3198,7 @@ - + @@ -3208,7 +3208,7 @@ - + @@ -3232,7 +3232,7 @@ - + @@ -3250,7 +3250,7 @@ - + @@ -3262,7 +3262,7 @@ - + @@ -3274,7 +3274,7 @@ - + @@ -3282,11 +3282,11 @@ - + - + @@ -3309,7 +3309,7 @@ - + @@ -3335,7 +3335,7 @@ - + @@ -3356,7 +3356,7 @@ - + @@ -3386,7 +3386,7 @@ - + @@ -3400,7 +3400,7 @@ - + @@ -3427,7 +3427,7 @@ - + @@ -3466,7 +3466,7 @@ - + From 0e2efa95a572819dceae6b88fbdd084597e2468d Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Mon, 6 Jan 2025 17:22:48 +0100 Subject: [PATCH 26/27] uncrustify --- src/coreComponents/constitutive/ConstitutiveManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/constitutive/ConstitutiveManager.cpp b/src/coreComponents/constitutive/ConstitutiveManager.cpp index ed79e9de5e8..913f0898971 100644 --- a/src/coreComponents/constitutive/ConstitutiveManager.cpp +++ b/src/coreComponents/constitutive/ConstitutiveManager.cpp @@ -44,7 +44,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 = + std::unique_ptr< ConstitutiveBase > material = ConstitutiveBase::CatalogInterface::factory( childKey, getDataContext(), childName, this ); return ®isterGroup< ConstitutiveBase >( childName, std::move( material ) ); } From 95659ad395019ce994b2433e75758057d387f6d0 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Tue, 7 Jan 2025 14:15:30 +0100 Subject: [PATCH 27/27] =?UTF-8?q?=F0=9F=90=9B=20oups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/mainInterface/ProblemManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/mainInterface/ProblemManager.cpp b/src/coreComponents/mainInterface/ProblemManager.cpp index 685771247ff..890f550c752 100644 --- a/src/coreComponents/mainInterface/ProblemManager.cpp +++ b/src/coreComponents/mainInterface/ProblemManager.cpp @@ -480,8 +480,8 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument ) meshBody.forMeshLevels( [&]( MeshLevel & meshLevel ) { ObjectManagerBase & elementManager = hasParticles ? - static_cast< ObjectManagerBase & >( meshLevel.getElemManager() ): - static_cast< ObjectManagerBase & >( meshLevel.getParticleManager() ); + static_cast< ObjectManagerBase & >( meshLevel.getParticleManager() ): + static_cast< ObjectManagerBase & >( meshLevel.getElemManager() ); Group * newRegion = elementManager.createChild( regionNode.name(), regionName ); newRegion->processInputFileRecursive( xmlDocument, regionNode ); } ); @@ -493,6 +493,7 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument ) } } }; + parseRegions( MeshLevel::groupStructKeys::elemManagerString(), false ); parseRegions( MeshLevel::groupStructKeys::particleManagerString(), true ); }