From 53751b065a3eeb3ef19e1d2a5009ad18b3702ee9 Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 1 Aug 2025 11:03:09 +0200 Subject: [PATCH 01/13] 1st patch --- .../common/format/StringUtilities.cpp | 14 +++++ .../common/format/StringUtilities.hpp | 8 +++ .../FieldSpecificationManager.cpp | 53 +++++++++++++------ 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/coreComponents/common/format/StringUtilities.cpp b/src/coreComponents/common/format/StringUtilities.cpp index f93b461c0f6..88519bcb078 100644 --- a/src/coreComponents/common/format/StringUtilities.cpp +++ b/src/coreComponents/common/format/StringUtilities.cpp @@ -250,5 +250,19 @@ stdVector< STRING_T > wrapTextToMaxLength( stdVector< STRING_T > const & lines, template stdVector< string > wrapTextToMaxLength( stdVector< string > const &, size_t & ); template stdVector< string_view > wrapTextToMaxLength( stdVector< string_view > const &, size_t & ); +string_array splitStringWithDelim( string const & s, char const delim ) +{ + string_array result; + std::stringstream ss ( s ); + string item; + + while( getline ( ss, item, delim )) + { + result.push_back ( item ); + } + + return result; +} + } } diff --git a/src/coreComponents/common/format/StringUtilities.hpp b/src/coreComponents/common/format/StringUtilities.hpp index c9ff9a05161..8a6d43dc5f1 100644 --- a/src/coreComponents/common/format/StringUtilities.hpp +++ b/src/coreComponents/common/format/StringUtilities.hpp @@ -267,6 +267,14 @@ template< typename STRING_T > stdVector< STRING_T > wrapTextToMaxLength( stdVector< STRING_T > const & lines, size_t & maxLineLength ); +/** + * @brief Splits a string into a vector of substrings using a specified delimiter. + * @param s The input string to be split. + * @param delim The character used as the delimiter for splitting the string. + * @return A vector containing the substrings obtained from the input string. + */ +string_array splitStringWithDelim( string const & s, char const delim ); + /** * @brief Take a string, and return a array1d with the cast values * @tparam T the type to which the string will be cast diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index d7535e79a41..10462b7bb27 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -192,15 +192,6 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c { mapEntry.second = MpiWrapper::min( mapEntry.second ); } - bool areAllSetsEmpty = true; - for( std::pair< string const, localIndex > & mapEntry : isTargetSetEmpty ) - { - if( mapEntry.second == 0 ) // target set is not empty - { - areAllSetsEmpty = false; - break; - } - } for( std::pair< string const, localIndex > & mapEntry : isTargetSetCreated ) { @@ -227,7 +218,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c missingSetNames.emplace_back( mapEntry.first ); } - string setNamesError = GEOS_FMT( "\n{}: there is/are no set(s) named `{}` under the {} `{}`.\n", + string setNamesError = GEOS_FMT( "\n{}: there are no set(s) named `{}` under the {} `{}`.\n", fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::objectPathString() ), fmt::join( missingSetNames, ", " ), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); @@ -251,24 +242,52 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c { std::ostringstream fieldNameNotFoundMessage; std::string fieldNamePath = - GEOS_FMT( "\n{}: there is no {} named `{}` under the region `{}`.\n", + GEOS_FMT( "\n{}: there are no {} named `{}` under the region `{}`.\n", fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ), FieldSpecificationBase::viewKeyStruct::fieldNameString(), fs.getFieldName(), fs.getObjectPath() ); fieldNameNotFoundMessage << fieldNamePath; - if( areAllSetsEmpty ) + + string_array const splitPath = stringutilities::splitStringWithDelim( fs.getObjectPath(), '/' ); + string_array availableRegion; + string const targetRegion = splitPath.size() > 1 ? splitPath.at( 1 ) : splitPath.at( 0 ); + bool foundMaterialInTargetRegion = false; + mesh.getElemManager().forElementRegions< CellElementRegion >( [&]( CellElementRegion const & elemRegion ) { - GEOS_LOG_RANK_0( fieldNameNotFoundMessage.str() ); + availableRegion.push_back( elemRegion.getName()); + if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty()) + { + fieldNameNotFoundMessage << GEOS_FMT( "Available fieldname in {} are:\n", fs.getObjectPath() ); + fieldNameNotFoundMessage << stringutilities::join( allPresentFieldsName[invalidRegion], ", " ); + foundMaterialInTargetRegion = true; + } + } ); + if( splitPath.size()==1 ) + { + std::set< std::string > set; + for( const auto & pair : allPresentFieldsName ) + { + const auto & vec = pair.second; // Obtenir le vecteur + set.insert( vec.begin(), vec.end()); // Insérer les éléments du vecteur + } + fieldNameNotFoundMessage << GEOS_FMT( " {} contain the following fields : {}\n", fs.getObjectPath(), + stringutilities::join( set, ", " ) ); + fieldNameNotFoundMessage << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : {}.", + availableRegion.size(), fs.getObjectPath(), + stringutilities::join( availableRegion, ", " ) ); } else { - fieldNameNotFoundMessage << GEOS_FMT( "Available fields in {} are:\n", fs.getObjectPath() ); - fieldNameNotFoundMessage << stringutilities::join( allPresentFieldsName[invalidRegion], ", " ); + if( !foundMaterialInTargetRegion ) + { + fieldNameNotFoundMessage << GEOS_FMT( "No material found under {}.\n", fs.getObjectPath() ); + } + } - GEOS_THROW( fieldNameNotFoundMessage.str(), InputError ); - }; + GEOS_THROW( fieldNameNotFoundMessage.str(), InputError ); } + ; } ); } From 541959d77cd0522ce601dad0ad0c3c0795ccd26f Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 1 Aug 2025 11:48:15 +0200 Subject: [PATCH 02/13] clean refacto --- .../FieldSpecificationManager.cpp | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 10462b7bb27..ded34d247a5 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -240,54 +240,49 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c if( isFieldNameFound == 0 ) { - std::ostringstream fieldNameNotFoundMessage; - std::string fieldNamePath = - GEOS_FMT( "\n{}: there are no {} named `{}` under the region `{}`.\n", - fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ), - FieldSpecificationBase::viewKeyStruct::fieldNameString(), - fs.getFieldName(), fs.getObjectPath() ); - - fieldNameNotFoundMessage << fieldNamePath; + std::ostringstream errorMessageBuilder; + errorMessageBuilder << GEOS_FMT( "\n{}: there are no {} named `{}` under the region `{}`.\n", + fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ), + FieldSpecificationBase::viewKeyStruct::fieldNameString(), + fs.getFieldName(), fs.getObjectPath() );; string_array const splitPath = stringutilities::splitStringWithDelim( fs.getObjectPath(), '/' ); - string_array availableRegion; string const targetRegion = splitPath.size() > 1 ? splitPath.at( 1 ) : splitPath.at( 0 ); + + string_array availableRegions; bool foundMaterialInTargetRegion = false; mesh.getElemManager().forElementRegions< CellElementRegion >( [&]( CellElementRegion const & elemRegion ) { - availableRegion.push_back( elemRegion.getName()); + availableRegions.push_back( elemRegion.getName()); if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty()) { - fieldNameNotFoundMessage << GEOS_FMT( "Available fieldname in {} are:\n", fs.getObjectPath() ); - fieldNameNotFoundMessage << stringutilities::join( allPresentFieldsName[invalidRegion], ", " ); + errorMessageBuilder << GEOS_FMT( "Available fieldname in {} are:\n", fs.getObjectPath() ); + errorMessageBuilder << stringutilities::join( allPresentFieldsName[invalidRegion], ", " ); foundMaterialInTargetRegion = true; } } ); + if( splitPath.size()==1 ) { - std::set< std::string > set; + std::set< std::string > uniqueFields; for( const auto & pair : allPresentFieldsName ) { - const auto & vec = pair.second; // Obtenir le vecteur - set.insert( vec.begin(), vec.end()); // Insérer les éléments du vecteur + const auto & vec = pair.second; + uniqueFields.insert( vec.begin(), vec.end()); } - fieldNameNotFoundMessage << GEOS_FMT( " {} contain the following fields : {}\n", fs.getObjectPath(), - stringutilities::join( set, ", " ) ); - fieldNameNotFoundMessage << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : {}.", - availableRegion.size(), fs.getObjectPath(), - stringutilities::join( availableRegion, ", " ) ); + errorMessageBuilder << GEOS_FMT( " {} contain the following fields : {}\n", fs.getObjectPath(), + stringutilities::join( uniqueFields, ", " ) ); + errorMessageBuilder << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : {}.", + availableRegions.size(), fs.getObjectPath(), + stringutilities::join( availableRegions, ", " ) ); } - else + else if( !foundMaterialInTargetRegion ) { - if( !foundMaterialInTargetRegion ) - { - fieldNameNotFoundMessage << GEOS_FMT( "No material found under {}.\n", fs.getObjectPath() ); - } + errorMessageBuilder << GEOS_FMT( "No material found under {}.\n", fs.getObjectPath() ); } - GEOS_THROW( fieldNameNotFoundMessage.str(), InputError ); + GEOS_THROW( errorMessageBuilder.str(), InputError ); } - ; } ); } From e0ec0482223e978d211446ba0ad7cd0062d14802 Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 1 Aug 2025 14:24:03 +0200 Subject: [PATCH 03/13] xsd --- src/coreComponents/schema/schema.xsd | 2 +- src/coreComponents/schema/schema.xsd.other | 108 +++++++++++++++++++-- 2 files changed, 100 insertions(+), 10 deletions(-) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index aca2fe256fa..1872c78a1fb 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1399,7 +1399,7 @@ Information output from lower logLevels is added with the desired log level - + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 90bd4aacb07..7e346b0e2c0 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -574,6 +574,8 @@ + + @@ -607,6 +609,8 @@ + + @@ -656,6 +660,8 @@ + + @@ -695,6 +701,8 @@ + + @@ -726,6 +734,8 @@ + + @@ -733,6 +743,8 @@ + + @@ -742,6 +754,8 @@ + + @@ -751,6 +765,8 @@ + + @@ -761,6 +777,8 @@ + + @@ -791,6 +809,8 @@ + + @@ -852,6 +872,8 @@ + + @@ -881,6 +903,8 @@ + + @@ -888,6 +912,8 @@ + + @@ -895,6 +921,8 @@ + + @@ -904,6 +932,8 @@ + + @@ -913,6 +943,8 @@ + + @@ -920,6 +952,8 @@ + + @@ -927,6 +961,8 @@ + + @@ -934,6 +970,8 @@ + + @@ -941,6 +979,8 @@ + + @@ -950,6 +990,8 @@ + + @@ -959,6 +1001,8 @@ + + @@ -968,6 +1012,8 @@ + + @@ -977,6 +1023,8 @@ + + @@ -984,6 +1032,8 @@ + + @@ -993,6 +1043,8 @@ + + @@ -1002,6 +1054,8 @@ + + @@ -1009,6 +1063,8 @@ + + @@ -1016,6 +1072,8 @@ + + @@ -1025,6 +1083,8 @@ + + @@ -1032,6 +1092,8 @@ + + @@ -1039,6 +1101,8 @@ + + @@ -1048,6 +1112,8 @@ + + @@ -1057,6 +1123,8 @@ + + @@ -1066,6 +1134,8 @@ + + @@ -1075,6 +1145,8 @@ + + @@ -1084,6 +1156,8 @@ + + @@ -1091,6 +1165,8 @@ + + @@ -1100,6 +1176,8 @@ + + @@ -1109,6 +1187,8 @@ + + @@ -1118,6 +1198,8 @@ + + @@ -1128,6 +1210,8 @@ + + @@ -1139,6 +1223,8 @@ + + @@ -1152,6 +1238,8 @@ + + @@ -1165,6 +1253,8 @@ + + @@ -1178,6 +1268,8 @@ + + @@ -1189,6 +1281,8 @@ + + @@ -1232,6 +1326,8 @@ + + @@ -1249,6 +1345,8 @@ + + @@ -1886,8 +1984,6 @@ - - @@ -1938,8 +2034,6 @@ - - @@ -1990,8 +2084,6 @@ - - @@ -2042,8 +2134,6 @@ - - @@ -3221,7 +3311,7 @@ - + From 2d58bb6d9fd95d3e6b1306914fb28f904e2549f0 Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 1 Aug 2025 15:48:08 +0200 Subject: [PATCH 04/13] update format --- .../fieldSpecification/FieldSpecificationManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index ded34d247a5..774c6715125 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -256,8 +256,8 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c availableRegions.push_back( elemRegion.getName()); if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty()) { - errorMessageBuilder << GEOS_FMT( "Available fieldname in {} are:\n", fs.getObjectPath() ); - errorMessageBuilder << stringutilities::join( allPresentFieldsName[invalidRegion], ", " ); + errorMessageBuilder << GEOS_FMT( "Available fieldname in {} are:\n{{ {} }}", fs.getObjectPath(), + stringutilities::join( allPresentFieldsName[invalidRegion], ", " )); foundMaterialInTargetRegion = true; } } ); @@ -270,9 +270,9 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c const auto & vec = pair.second; uniqueFields.insert( vec.begin(), vec.end()); } - errorMessageBuilder << GEOS_FMT( " {} contain the following fields : {}\n", fs.getObjectPath(), + errorMessageBuilder << GEOS_FMT( "{} contain the following fields :\n{{ {} }}\n", fs.getObjectPath(), stringutilities::join( uniqueFields, ", " ) ); - errorMessageBuilder << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : {}.", + errorMessageBuilder << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : [{}].", availableRegions.size(), fs.getObjectPath(), stringutilities::join( availableRegions, ", " ) ); } From 456830adaf34f9ab15ca8628b382be21dfea15ad Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 1 Aug 2025 17:59:28 +0200 Subject: [PATCH 05/13] replace stringsplit with tokenize --- .../common/format/StringUtilities.cpp | 15 --------------- .../common/format/StringUtilities.hpp | 8 -------- .../FieldSpecificationManager.cpp | 2 +- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/coreComponents/common/format/StringUtilities.cpp b/src/coreComponents/common/format/StringUtilities.cpp index 88519bcb078..52b5e14a962 100644 --- a/src/coreComponents/common/format/StringUtilities.cpp +++ b/src/coreComponents/common/format/StringUtilities.cpp @@ -249,20 +249,5 @@ stdVector< STRING_T > wrapTextToMaxLength( stdVector< STRING_T > const & lines, } template stdVector< string > wrapTextToMaxLength( stdVector< string > const &, size_t & ); template stdVector< string_view > wrapTextToMaxLength( stdVector< string_view > const &, size_t & ); - -string_array splitStringWithDelim( string const & s, char const delim ) -{ - string_array result; - std::stringstream ss ( s ); - string item; - - while( getline ( ss, item, delim )) - { - result.push_back ( item ); - } - - return result; -} - } } diff --git a/src/coreComponents/common/format/StringUtilities.hpp b/src/coreComponents/common/format/StringUtilities.hpp index 8a6d43dc5f1..c9ff9a05161 100644 --- a/src/coreComponents/common/format/StringUtilities.hpp +++ b/src/coreComponents/common/format/StringUtilities.hpp @@ -267,14 +267,6 @@ template< typename STRING_T > stdVector< STRING_T > wrapTextToMaxLength( stdVector< STRING_T > const & lines, size_t & maxLineLength ); -/** - * @brief Splits a string into a vector of substrings using a specified delimiter. - * @param s The input string to be split. - * @param delim The character used as the delimiter for splitting the string. - * @return A vector containing the substrings obtained from the input string. - */ -string_array splitStringWithDelim( string const & s, char const delim ); - /** * @brief Take a string, and return a array1d with the cast values * @tparam T the type to which the string will be cast diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 774c6715125..7c6117fe7d7 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -246,7 +246,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c FieldSpecificationBase::viewKeyStruct::fieldNameString(), fs.getFieldName(), fs.getObjectPath() );; - string_array const splitPath = stringutilities::splitStringWithDelim( fs.getObjectPath(), '/' ); + string_array const splitPath = stringutilities::tokenize( fs.getObjectPath(), "/" ); string const targetRegion = splitPath.size() > 1 ? splitPath.at( 1 ) : splitPath.at( 0 ); string_array availableRegions; From 850ab66ad69bce0519b2c879130dd33a3d85533f Mon Sep 17 00:00:00 2001 From: arng40 Date: Mon, 4 Aug 2025 10:59:42 +0200 Subject: [PATCH 06/13] update to elementRegionBase --- .../fieldSpecification/FieldSpecificationManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 7c6117fe7d7..868bc15abb7 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -251,7 +251,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c string_array availableRegions; bool foundMaterialInTargetRegion = false; - mesh.getElemManager().forElementRegions< CellElementRegion >( [&]( CellElementRegion const & elemRegion ) + mesh.getElemManager().forElementRegions< CellElementRegion >( [&]( ElementRegionBase const & elemRegion ) { availableRegions.push_back( elemRegion.getName()); if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty()) From 45ee0561bcdc7163ee4089a03583468c890703eb Mon Sep 17 00:00:00 2001 From: arng40 Date: Mon, 4 Aug 2025 11:00:01 +0200 Subject: [PATCH 07/13] xsd --- src/coreComponents/schema/schema.xsd | 13 +++++++++++++ src/coreComponents/schema/schema.xsd.other | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 1872c78a1fb..09e5b146167 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -595,6 +595,10 @@ + + + + @@ -5456,6 +5460,7 @@ Information output from lower logLevels is added with the desired log level + @@ -5548,6 +5553,14 @@ Information output from lower logLevels is added with the desired log level + + + + + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 7e346b0e2c0..6ce6bc1a450 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -1447,6 +1447,7 @@ + @@ -1539,6 +1540,7 @@ + From 80ac70fb6270bbaa29a1e438054743a70eb59dda Mon Sep 17 00:00:00 2001 From: arng40 Date: Tue, 5 Aug 2025 10:21:30 +0200 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=8E=A8=20please=20don't=20look?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fieldSpecification/FieldSpecificationManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 868bc15abb7..9138a10e546 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -251,7 +251,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c string_array availableRegions; bool foundMaterialInTargetRegion = false; - mesh.getElemManager().forElementRegions< CellElementRegion >( [&]( ElementRegionBase const & elemRegion ) + mesh.getElemManager().forElementRegions< ElementRegionBase >( [&]( ElementRegionBase const & elemRegion ) { availableRegions.push_back( elemRegion.getName()); if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty()) From 25c4645bd21f0a7d369a322d956ceb9744b8097d Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Tue, 5 Aug 2025 12:17:14 -0500 Subject: [PATCH 09/13] revert --- src/coreComponents/common/format/StringUtilities.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreComponents/common/format/StringUtilities.cpp b/src/coreComponents/common/format/StringUtilities.cpp index 52b5e14a962..f93b461c0f6 100644 --- a/src/coreComponents/common/format/StringUtilities.cpp +++ b/src/coreComponents/common/format/StringUtilities.cpp @@ -249,5 +249,6 @@ stdVector< STRING_T > wrapTextToMaxLength( stdVector< STRING_T > const & lines, } template stdVector< string > wrapTextToMaxLength( stdVector< string > const &, size_t & ); template stdVector< string_view > wrapTextToMaxLength( stdVector< string_view > const &, size_t & ); + } } From 85afa5bf07627624e2659470edd53a5cb1bd47c7 Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Tue, 5 Aug 2025 12:19:41 -0500 Subject: [PATCH 10/13] also revert --- src/coreComponents/schema/schema.xsd | 15 +-- src/coreComponents/schema/schema.xsd.other | 110 ++------------------- 2 files changed, 10 insertions(+), 115 deletions(-) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 09e5b146167..aca2fe256fa 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -595,10 +595,6 @@ - - - - @@ -1403,7 +1399,7 @@ Information output from lower logLevels is added with the desired log level - + @@ -5460,7 +5456,6 @@ Information output from lower logLevels is added with the desired log level - @@ -5553,14 +5548,6 @@ Information output from lower logLevels is added with the desired log level - - - - - - - - diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 6ce6bc1a450..90bd4aacb07 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -574,8 +574,6 @@ - - @@ -609,8 +607,6 @@ - - @@ -660,8 +656,6 @@ - - @@ -701,8 +695,6 @@ - - @@ -734,8 +726,6 @@ - - @@ -743,8 +733,6 @@ - - @@ -754,8 +742,6 @@ - - @@ -765,8 +751,6 @@ - - @@ -777,8 +761,6 @@ - - @@ -809,8 +791,6 @@ - - @@ -872,8 +852,6 @@ - - @@ -903,8 +881,6 @@ - - @@ -912,8 +888,6 @@ - - @@ -921,8 +895,6 @@ - - @@ -932,8 +904,6 @@ - - @@ -943,8 +913,6 @@ - - @@ -952,8 +920,6 @@ - - @@ -961,8 +927,6 @@ - - @@ -970,8 +934,6 @@ - - @@ -979,8 +941,6 @@ - - @@ -990,8 +950,6 @@ - - @@ -1001,8 +959,6 @@ - - @@ -1012,8 +968,6 @@ - - @@ -1023,8 +977,6 @@ - - @@ -1032,8 +984,6 @@ - - @@ -1043,8 +993,6 @@ - - @@ -1054,8 +1002,6 @@ - - @@ -1063,8 +1009,6 @@ - - @@ -1072,8 +1016,6 @@ - - @@ -1083,8 +1025,6 @@ - - @@ -1092,8 +1032,6 @@ - - @@ -1101,8 +1039,6 @@ - - @@ -1112,8 +1048,6 @@ - - @@ -1123,8 +1057,6 @@ - - @@ -1134,8 +1066,6 @@ - - @@ -1145,8 +1075,6 @@ - - @@ -1156,8 +1084,6 @@ - - @@ -1165,8 +1091,6 @@ - - @@ -1176,8 +1100,6 @@ - - @@ -1187,8 +1109,6 @@ - - @@ -1198,8 +1118,6 @@ - - @@ -1210,8 +1128,6 @@ - - @@ -1223,8 +1139,6 @@ - - @@ -1238,8 +1152,6 @@ - - @@ -1253,8 +1165,6 @@ - - @@ -1268,8 +1178,6 @@ - - @@ -1281,8 +1189,6 @@ - - @@ -1326,8 +1232,6 @@ - - @@ -1345,8 +1249,6 @@ - - @@ -1447,7 +1349,6 @@ - @@ -1540,7 +1441,6 @@ - @@ -1986,6 +1886,8 @@ + + @@ -2036,6 +1938,8 @@ + + @@ -2086,6 +1990,8 @@ + + @@ -2136,6 +2042,8 @@ + + @@ -3313,7 +3221,7 @@ - + From fce83c8987de8c269ed79a2d9d376fe328ca5c99 Mon Sep 17 00:00:00 2001 From: arng40 Date: Mon, 25 Aug 2025 10:20:23 +0200 Subject: [PATCH 11/13] add prefix message for set --- .../fieldSpecification/FieldSpecificationManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 9138a10e546..947f1c159f1 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -223,7 +223,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c fmt::join( missingSetNames, ", " ), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); - setNamesError.append( stringutilities::join( allPresentSets, ", " )); + GEOS_FMT( "Available set(s) are: {}", setNamesError.append( stringutilities::join( allPresentSets, ", " ))); GEOS_THROW( setNamesError, InputError ); } @@ -237,7 +237,6 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c "\nIf the simulation does not involve the SurfaceGenerator, check the content of the set `{}` in `{}`. \n", fs.getDataContext(), mapEntry.first, fs.getObjectPath() ) ); } - if( isFieldNameFound == 0 ) { std::ostringstream errorMessageBuilder; From 5dcc81a019b6d9bda2afd38dd9e8c7b69c67e8de Mon Sep 17 00:00:00 2001 From: arng40 Date: Mon, 25 Aug 2025 10:20:33 +0200 Subject: [PATCH 12/13] xsd --- src/coreComponents/schema/schema.xsd | 21 ++++++++++ src/coreComponents/schema/schema.xsd.other | 47 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 875611d0423..5a51e9784de 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -775,6 +775,10 @@ + + + + @@ -5645,6 +5649,7 @@ Information output from lower logLevels is added with the desired log level + @@ -6670,6 +6675,22 @@ For instance, if "oil" is before "gas" in "phaseNames", the table order should b + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c467665d3393e9cd80d5e284c029566d75cbe6ec Mon Sep 17 00:00:00 2001 From: arng40 Date: Fri, 29 Aug 2025 11:16:59 +0200 Subject: [PATCH 13/13] add test for validBoundaryCondition --- .../FieldSpecificationManager.cpp | 9 +- .../fieldSpecificationTests/CMakeLists.txt | 1 + .../testIncorrectFieldSpecification.cpp | 376 ++++++++++++++++++ 3 files changed, 381 insertions(+), 5 deletions(-) create mode 100644 src/coreComponents/unitTests/fieldSpecificationTests/testIncorrectFieldSpecification.cpp diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 947f1c159f1..962c27213b1 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -185,7 +185,6 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c } ); // Step 3: MPI synchronization - isFieldNameFound = MpiWrapper::max( isFieldNameFound ); for( std::pair< string const, localIndex > & mapEntry : isTargetSetEmpty ) @@ -218,14 +217,14 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c missingSetNames.emplace_back( mapEntry.first ); } - string setNamesError = GEOS_FMT( "\n{}: there are no set(s) named `{}` under the {} `{}`.\n", + std::ostringstream errorMessageBuilder; + errorMessageBuilder << GEOS_FMT( "\n{}: there are no set(s) named `{}` under the {} `{}`.\n", fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::objectPathString() ), fmt::join( missingSetNames, ", " ), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); + errorMessageBuilder << GEOS_FMT( "Available set(s) are: {}", stringutilities::join( allPresentSets, ", " )); - GEOS_FMT( "Available set(s) are: {}", setNamesError.append( stringutilities::join( allPresentSets, ", " ))); - - GEOS_THROW( setNamesError, InputError ); + GEOS_THROW( errorMessageBuilder.str(), InputError ); } // if a target set is empty, we issue a warning diff --git a/src/coreComponents/unitTests/fieldSpecificationTests/CMakeLists.txt b/src/coreComponents/unitTests/fieldSpecificationTests/CMakeLists.txt index d66f6661e22..a4c077ca88d 100644 --- a/src/coreComponents/unitTests/fieldSpecificationTests/CMakeLists.txt +++ b/src/coreComponents/unitTests/fieldSpecificationTests/CMakeLists.txt @@ -2,6 +2,7 @@ set( gtest_geosx_tests testAquiferBoundaryCondition.cpp testFieldSpecificationsEnums.cpp + testIncorrectFieldSpecification.cpp testRecursiveFieldApplication.cpp ) diff --git a/src/coreComponents/unitTests/fieldSpecificationTests/testIncorrectFieldSpecification.cpp b/src/coreComponents/unitTests/fieldSpecificationTests/testIncorrectFieldSpecification.cpp new file mode 100644 index 00000000000..a9bdd83b7ad --- /dev/null +++ b/src/coreComponents/unitTests/fieldSpecificationTests/testIncorrectFieldSpecification.cpp @@ -0,0 +1,376 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2024 TotalEnergies + * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2023-2024 Chevron + * Copyright (c) 2019- GEOS/GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +#include "mainInterface/ProblemManager.hpp" +#include "mainInterface/initialization.hpp" +#include "mainInterface/GeosxState.hpp" +#include "codingUtilities/Parsing.hpp" +#include "physicsSolvers/PhysicsSolverBase.hpp" + +#include "physicsSolvers/SolverStatistics.hpp" +#include + +#include + +using namespace geos; + +static const string header = + R"xml( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + )xml"; + +static const string footer = + R"xml( + + + + + + + + + + + + + +)xml"; + +static const string xmlWrongSetNames = + R"xml( + +)xml"; + +static const string xmlWrongFieldNames = + R"xml( + +)xml"; + +static const string xmlWrongTargetAllRegion = + R"xml( + +)xml"; + +static const string xmlWrongNoMaterial = + R"xml( + +)xml"; + + + +CommandLineOptions g_commandLineOptions; + +void setupAndPlayWrongFieldSpecification( string const & wrongXml, + string const & expectedMsg1, string const & expectedMsg2 ) +{ + GeosxState state( std::make_unique< CommandLineOptions >( g_commandLineOptions ) ); + ProblemManager & problem = state.getProblemManager(); + std::ostringstream xmlInput; + xmlInput << header << wrongXml << footer; + problem.parseInputString( xmlInput.str() ); + problem.problemSetup(); + + bool trowHappened = false; + + try + { + problem.applyInitialConditions(); + } + catch( std::exception const & e ) + { + // checks if the exception contains the expected message + GEOS_ERROR_IF_EQ_MSG( string( e.what() ).find( expectedMsg1 ), string::npos, + "The error message was not containing the expected sequence.\n" << + " Error message :\n" << e.what() << + " expected sequence :\n" << expectedMsg1 ); + GEOS_ERROR_IF_EQ_MSG( string( e.what() ).find( expectedMsg2 ), string::npos, + "The error message was not containing the expected sequence.\n" << + " Error message :\n" << e.what() << + " expected sequence :\n" << expectedMsg2 ); + trowHappened = true; + } + ASSERT_TRUE( trowHappened ); +} + +void setupAndCheckFieldSpecification( string const & xml ) +{ + GeosxState state( std::make_unique< CommandLineOptions >( g_commandLineOptions ) ); + ProblemManager & problem = state.getProblemManager(); + std::ostringstream xmlInput; + xmlInput << header << xml << footer; + problem.parseInputString( xmlInput.str() ); + problem.problemSetup(); + + EXPECT_NO_THROW( problem.applyInitialConditions() ); +} + +std::vector< string > splitStringByDelimiter( string const & s, string const & delimiter ) +{ + string cpyTokens = s; + std::vector< string > tokens; + size_t pos = 0; + string token; + while((pos = cpyTokens.find( delimiter )) != string::npos ) + { + token = cpyTokens.substr( 0, pos ); + tokens.push_back( token ); + cpyTokens.erase( 0, pos + delimiter.length()); + } + tokens.push_back( cpyTokens ); + + return tokens; +} + +TEST( testIncorrectFieldSpecification, testWrongSetNames ) +{ + static constexpr auto expectedMsg1 = "there are no set(s) named `s` under the objectPath `faceManager`"; + static constexpr auto expectedMsg2 = "all, aquifer, externalSet, sink, source, xneg, xpos, yneg, ypos, zneg, zpos"; + setupAndPlayWrongFieldSpecification( xmlWrongSetNames, expectedMsg1, expectedMsg2 ); +} + +TEST( testIncorrectFieldSpecification, testSetNames ) +{ + static constexpr auto tokens = "all, aquifer, externalSet, sink, source, xneg, xpos, yneg, ypos, zneg, zpos"; + std::vector< string > const splitToken = splitStringByDelimiter( tokens, "," ); + for( auto const & token : splitToken ) + { + string const xmlTemplate = R"xml( + + )xml"; + setupAndCheckFieldSpecification( xmlTemplate ); + } +} + +TEST( testIncorrectFieldSpecification, testWrongFieldNames ) +{ + static constexpr auto expectedMsg1 = "Available fieldname in ElementRegions/Channel1 are:"; + static constexpr auto expectedMsg2 = "{ bcPressure, bcTemperature, dMass, dMobility, deltaPressure, deltaVolume, gravityCoefficient, " + "initialPressure, initialTemperature, mass, mass_n, mobility, netToGross, pressure, pressure_n, temperature, temperature_n, water_density, " + "water_dDensity, water_viscosity, water_dViscosity, water_internalEnergy, water_dInternalEnergy, water_enthalpy, water_dEnthalpy, " + "rockPorosity_porosity, rockPorosity_initialPorosity, rockPorosity_referencePorosity, channelPerm_permeability, channelPerm_dPerm_dPressure }"; + setupAndPlayWrongFieldSpecification( xmlWrongFieldNames, expectedMsg1, expectedMsg2 ); +} + +TEST( testIncorrectFieldSpecification, testFieldSpecification ) +{ + static constexpr auto tokens = "bcPressure, bcTemperature, dMass, dMobility, deltaPressure, deltaVolume, gravityCoefficient, " + "initialPressure, initialTemperature, mass, mass_n, mobility, netToGross, pressure, pressure_n, temperature, temperature_n, water_density, " + "water_dDensity, water_viscosity, water_dViscosity, water_internalEnergy, water_dInternalEnergy, water_enthalpy, water_dEnthalpy, " + "rockPorosity_porosity, rockPorosity_initialPorosity, rockPorosity_referencePorosity, channelPerm_permeability, channelPerm_dPerm_dPressure"; + std::vector< string > const splitToken = splitStringByDelimiter( tokens, "," ); + for( auto const & token : splitToken ) + { + string const xmlTemplate = R"xml( + + )xml"; + setupAndCheckFieldSpecification( xmlTemplate ); + } +} + +TEST( testIncorrectFieldSpecification, testWrongFieldAndTargetAllRegion ) +{ + static constexpr auto expectedMsg1 = " "; + static constexpr auto expectedMsg2 = "There are also 3 CellElementsRegions that can be appended under ElementRegions : [Channel1, Channel2, Barrier]"; + setupAndPlayWrongFieldSpecification( xmlWrongTargetAllRegion, expectedMsg1, expectedMsg2 ); +} + +TEST( testIncorrectFieldSpecification, testWrongNoMaterialFound ) +{ + static constexpr auto expectedMsg1 = " "; + static constexpr auto expectedMsg2 = "No material found under ElementRegions/Channel2"; + setupAndPlayWrongFieldSpecification( xmlWrongNoMaterial, expectedMsg1, expectedMsg2 ); +} + +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + g_commandLineOptions = *geos::basicSetup( argc, argv ); + + int const result = RUN_ALL_TESTS(); + + basicCleanup(); + return result; +}