From 0c79a66d653cd68d52f23b6b092e551cf8e4f78d Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 27 Mar 2026 09:59:36 +0100 Subject: [PATCH 01/39] add FieldSpecificationABC abstract class --- .../fieldSpecification/CMakeLists.txt | 2 + .../FieldSpecificationABC.cpp | 36 +++++++ .../FieldSpecificationABC.hpp | 99 +++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp create mode 100644 src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index 8dc6827d664..0795623b42c 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -25,6 +25,7 @@ Contains: set( fieldSpecification_headers DirichletBoundaryCondition.hpp EquilibriumInitialCondition.hpp + FieldSpecificationABC.hpp FieldSpecificationBase.hpp FieldSpecificationManager.hpp SourceFluxBoundaryCondition.hpp @@ -39,6 +40,7 @@ set( fieldSpecification_headers set( fieldSpecification_sources DirichletBoundaryCondition.cpp EquilibriumInitialCondition.cpp + FieldSpecificationABC.cpp FieldSpecificationBase.cpp FieldSpecificationManager.cpp SourceFluxBoundaryCondition.cpp diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp new file mode 100644 index 00000000000..4f4b3ba3da4 --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp @@ -0,0 +1,36 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 "FieldSpecificationABC.hpp" + +namespace geos +{ +using namespace dataRepository; + +FieldSpecificationABC::FieldSpecificationABC( string const & name, Group * parent ): + Group( name, parent ) +{} + +FieldSpecificationABC::~FieldSpecificationABC() +{} + +FieldSpecificationABC::CatalogInterface::CatalogType & +FieldSpecificationABC::getCatalog() +{ + static FieldSpecificationABC::CatalogInterface::CatalogType catalog; + return catalog; +} + +} \ No newline at end of file diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp new file mode 100644 index 00000000000..12dc00580d2 --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -0,0 +1,99 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file FieldSpecificationABC.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP +#define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP + + +#include "common/DataTypes.hpp" +#include "dataRepository/Group.hpp" +#include "functions/FunctionBase.hpp" +#include "functions/FunctionManager.hpp" + +namespace geos +{ +class Function; + + +/** + * @class FieldSpecificationABC + */ +class FieldSpecificationABC : public dataRepository::Group +{ +public: + + /** + * @defgroup alias and functions to defined statically initialized catalog + * @{ + */ + + /** + * alias to define the catalog type for this abstract type + */ + using CatalogInterface = dataRepository::CatalogInterface< FieldSpecificationABC, + string const &, + dataRepository::Group * const >; + + /** + * @brief static function to return static catalog. + * @return the static catalog to create derived types through the static factory methods. + */ + static CatalogInterface::CatalogType & getCatalog(); + + /** + * @} + */ + + + /** + * @brief constructor + * @param name the name of the FieldSpecificationABC in the data repository + * @param parent the parent group of this group. + */ + FieldSpecificationABC( string const & name, dataRepository::Group * parent ); + + /** + * destructor + */ + virtual ~FieldSpecificationABC() override; + + + /// Deleted copy constructor + FieldSpecificationABC( FieldSpecificationABC const & ) = delete; + + /// Defaulted move constructor + FieldSpecificationABC( FieldSpecificationABC && ) = default; + + /// deleted copy assignment + FieldSpecificationABC & operator=( FieldSpecificationABC const & ) = delete; + + /// deleted move assignement + FieldSpecificationABC & operator=( FieldSpecificationABC && ) = delete; + + /** + * @brief View keys + */ + struct viewKeyStruct + {}; + +}; + +} + +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP \ No newline at end of file From f234750b67c6e97ae5f0d7ea5e16f0edeb76f4d4 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 27 Mar 2026 10:01:31 +0100 Subject: [PATCH 02/39] Move FieldSpecificationBase catalog to FieldSpecificationABC --- .../AquiferBoundaryCondition.cpp | 2 +- .../DirichletBoundaryCondition.cpp | 2 +- .../EquilibriumInitialCondition.cpp | 2 +- .../FieldSpecificationBase.cpp | 11 ++------- .../FieldSpecificationBase.hpp | 24 ++----------------- .../FieldSpecificationManager.cpp | 7 +++--- .../PerfectlyMatchedLayer.cpp | 2 +- .../SourceFluxBoundaryCondition.cpp | 2 +- .../TractionBoundaryCondition.cpp | 2 +- 9 files changed, 14 insertions(+), 40 deletions(-) diff --git a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp index 4a9c99a7b2f..01d10959ab7 100644 --- a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp @@ -300,7 +300,7 @@ AquiferBoundaryCondition::KernelWrapper AquiferBoundaryCondition::createKernelWr pressureInfluenceFunction.createKernelWrapper() ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, AquiferBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, AquiferBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp index 19a62d921dd..99cfd1bbe04 100644 --- a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp @@ -37,6 +37,6 @@ DirichletBoundaryCondition::~DirichletBoundaryCondition() -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, DirichletBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, DirichletBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp index 6e0f1181e6e..2d1caf3a0d1 100644 --- a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp +++ b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp @@ -243,7 +243,7 @@ void EquilibriumInitialCondition::initializePreSubGroups() } } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, EquilibriumInitialCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, EquilibriumInitialCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp index 94e78e7e06a..fbbbce616ee 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp @@ -22,7 +22,7 @@ namespace geos using namespace dataRepository; FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * parent ): - Group( name, parent ) + FieldSpecificationABC( name, parent ) { setInputFlags( InputFlags::OPTIONAL_NONUNIQUE ); @@ -102,13 +102,6 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par FieldSpecificationBase::~FieldSpecificationBase() {} -FieldSpecificationBase::CatalogInterface::CatalogType & -FieldSpecificationBase::getCatalog() -{ - static FieldSpecificationBase::CatalogInterface::CatalogType catalog; - return catalog; -} - void FieldSpecificationBase::setMeshObjectPath( Group const & meshBodies ) @@ -131,6 +124,6 @@ void FieldSpecificationBase::setMeshObjectPath( Group const & meshBodies ) -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, FieldSpecificationBase, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, FieldSpecificationBase, string const &, Group * const ) } diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp index 1905a4e5c36..41d9b895120 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp @@ -31,6 +31,7 @@ #include "mesh/MeshObjectPath.hpp" #include "functions/FunctionManager.hpp" #include "common/GEOS_RAJA_Interface.hpp" +#include "FieldSpecificationABC.hpp" namespace geos { @@ -41,21 +42,10 @@ class Function; * @class FieldSpecificationBase * A class to hold values for and administer a single boundary condition */ -class FieldSpecificationBase : public dataRepository::Group +class FieldSpecificationBase : public FieldSpecificationABC { public: - /** - * @defgroup alias and functions to defined statically initialized catalog - * @{ - */ - - /** - * alias to define the catalog type for this base type - */ - using CatalogInterface = dataRepository::CatalogInterface< FieldSpecificationBase, - string const &, - dataRepository::Group * const >; /** * @enum SetErrorMode * @brief Indicate the error handling mode. @@ -67,12 +57,6 @@ class FieldSpecificationBase : public dataRepository::Group warning }; - /** - * @brief static function to return static catalog. - * @return the static catalog to create derived types through the static factory methods. - */ - static CatalogInterface::CatalogType & getCatalog(); - /** * @brief Static Factory Catalog Functions * @return the catalog name @@ -88,10 +72,6 @@ class FieldSpecificationBase : public dataRepository::Group return FieldSpecificationBase::catalogName(); } - /** - * @} - */ - /** * @brief constructor diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 6697c275715..9c0c5af7b5b 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -14,6 +14,7 @@ */ #include "FieldSpecificationManager.hpp" +#include "FieldSpecificationABC.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/MeshBody.hpp" #include "mesh/MeshObjectPath.hpp" @@ -53,8 +54,8 @@ FieldSpecificationManager & FieldSpecificationManager::getInstance() Group * FieldSpecificationManager::createChild( string const & childKey, string const & childName ) { GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); - std::unique_ptr< FieldSpecificationBase > bc = - FieldSpecificationBase::CatalogInterface::factory( childKey, getDataContext(), childName, this ); + std::unique_ptr< FieldSpecificationABC > bc = + FieldSpecificationABC::CatalogInterface::factory( childKey, getDataContext(), childName, this ); return &this->registerGroup( childName, std::move( bc ) ); } @@ -62,7 +63,7 @@ Group * FieldSpecificationManager::createChild( string const & childKey, string void FieldSpecificationManager::expandObjectCatalogs() { // During schema generation, register one of each type derived from BoundaryConditionBase here - for( auto & catalogIter: FieldSpecificationBase::getCatalog()) + for( auto & catalogIter: FieldSpecificationABC::getCatalog()) { createChild( catalogIter.first, catalogIter.first ); } diff --git a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp index 7e71480536c..1a946c97c23 100644 --- a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp +++ b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp @@ -121,6 +121,6 @@ void PerfectlyMatchedLayer::postInputInitialization() } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, PerfectlyMatchedLayer, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PerfectlyMatchedLayer, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp index 8a05108fe9d..0aad1e3102d 100644 --- a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp @@ -43,6 +43,6 @@ SourceFluxBoundaryCondition::SourceFluxBoundaryCondition( string const & name, G FieldSpecificationBase::viewKeyStruct::functionNameString() ) ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, SourceFluxBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, SourceFluxBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp index 49392b016f0..a66dd9f4f8f 100644 --- a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp @@ -437,7 +437,7 @@ void TractionBoundaryCondition::reinitScaleSet( FaceManager const & faceManager, } ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, TractionBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, TractionBoundaryCondition, string const &, Group * const ) } /* namespace geos */ From cf11e8fd2f310ef838c9d05e5b872f97ecf32d66 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 31 Mar 2026 14:43:35 +0200 Subject: [PATCH 03/39] add PermeabilitySpecification --- .../fieldSpecification/CMakeLists.txt | 2 + .../PermeabilitySpecification.cpp | 73 ++++++++ .../PermeabilitySpecification.hpp | 170 ++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp create mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index 0795623b42c..e6b6c94495b 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -32,6 +32,7 @@ set( fieldSpecification_headers TractionBoundaryCondition.hpp AquiferBoundaryCondition.hpp PerfectlyMatchedLayer.hpp + PermeabilitySpecification.hpp ) # @@ -47,6 +48,7 @@ set( fieldSpecification_sources TractionBoundaryCondition.cpp AquiferBoundaryCondition.cpp PerfectlyMatchedLayer.cpp + PermeabilitySpecification.cpp ) set( dependencyList ${parallelDeps} mesh ) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp new file mode 100644 index 00000000000..96ae605ffae --- /dev/null +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -0,0 +1,73 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 "PermeabilitySpecification.hpp" + +namespace geos +{ +using namespace dataRepository; + +PermeabilitySpecification::PermeabilitySpecification( string const & name, Group * parent ): + FieldSpecificationABC( name, parent ) +{ + setInputFlags( InputFlags::OPTIONAL_NONUNIQUE ); + + registerWrapper( viewKeyStruct::setNamesString(), &m_setNames ). + setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). + setInputFlag( InputFlags::REQUIRED ). + setSizedFromParent( 0 ). + setDescription( "Names of sets that the boundary condition is applied to.\n" + "A set can contain heterogeneous elements in the mesh (volumes, nodes, faces, edges).\n" + "A set can be be defined by a 'Geometry' component, or correspond to imported sets in case of an external mesh" ); + + registerWrapper( viewKeyStruct::regionNamesString(), &m_regionNames ). + setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "" ); + + registerWrapper( viewKeyStruct::fieldNameString(), &m_fieldName ). + setRTTypeName( rtTypes::CustomTypes::groupNameRef ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Name of field that boundary condition is applied to.\n" + "A field can represent a physical variable. (pressure, temperature, global composition fraction of the fluid, ...)" ); + + registerWrapper( viewKeyStruct::functionNameString(), &m_functionName ). + setRTTypeName( rtTypes::CustomTypes::groupNameRef ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Name of function that specifies variation of the boundary condition." ); + + registerWrapper( viewKeyStruct::scalesString(), &m_scales ). + // setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Apply a scaling factor for the value of the boundary condition." ); +} + + +PermeabilitySpecification::~PermeabilitySpecification() +{} + + +void PermeabilitySpecification::postInputInitialization() +{ + GEOS_THROW_IF( m_scales.size() != 3, + getWrapperDataContext( viewKeyStruct::scalesString() ) << + ": expected 3 components, got " << m_scales.size(), + InputError ); +} + + +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) + +} \ No newline at end of file diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp new file mode 100644 index 00000000000..6796db78a20 --- /dev/null +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -0,0 +1,170 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PermeabilitySpecification.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP +#define GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP + + +#include "common/DataTypes.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "mesh/MeshObjectPath.hpp" +#include "FieldSpecificationABC.hpp" + +namespace geos +{ + +/** + * @class PermeabilitySpecification + */ +class PermeabilitySpecification : public FieldSpecificationABC +{ +public: + + /** + * @brief Static Factory Catalog Functions + * @return the catalog name + */ + static string catalogName() { return "PermeabilitySpecification"; } + + /** + * @brief return the catalog name + * @return the catalog name + */ + virtual const string getCatalogName() const + { + return PermeabilitySpecification::catalogName(); + } + + + /** + * @brief constructor + * @param name the name of the PermeabilitySpecification in the data repository + * @param parent the parent group of this group. + */ + PermeabilitySpecification( string const & name, dataRepository::Group * parent ); + + /** + * destructor + */ + virtual ~PermeabilitySpecification() override; + + + /// Deleted copy constructor + PermeabilitySpecification( PermeabilitySpecification const & ) = delete; + + /// Defaulted move constructor + PermeabilitySpecification( PermeabilitySpecification && ) = default; + + /// deleted copy assignment + PermeabilitySpecification & operator=( PermeabilitySpecification const & ) = delete; + + /// deleted move assignement + PermeabilitySpecification & operator=( PermeabilitySpecification && ) = delete; + + /** + * @brief View keys + */ + struct viewKeyStruct + { + /// @return The key for setName + constexpr static char const * setNamesString() { return "setNames"; } + /// @return The key for regionNames + constexpr static char const * regionNamesString() { return "regionNames"; } + /// @return The key for fieldName + constexpr static char const * fieldNameString() { return "fieldName"; } + /// @return The key for functionName + constexpr static char const * functionNameString() { return "functionName"; } + /// @return The key for scales + constexpr static char const * scalesString() { return "scales"; } + }; + + /** + * Accessor + * @return const reference to m_function + */ + string const & getFunctionName() const + { + return m_functionName; + } + + /** + * Accessor + * @return const reference to m_regionNames + */ + string_array const & getRegionNames() const + { + return m_regionNames; + } + + /** + * Accessor + * @return const reference to m_fieldName + */ + virtual const string & getFieldName() const + { + return m_fieldName; + } + + /** + * Accessor + * @return const reference to m_setNames + */ + string_array const & getSetNames() const + { + return m_setNames; + } + + /** + * Accessor + * @return const m_scales + */ + arrayView1d< real64 const > getScales() const + { + return m_scales; + } + + +protected: + + virtual void postInputInitialization() override; + +private: + + + /// the names of the sets that the boundary condition is applied to + string_array m_setNames; + + /// the names of the regions that the boundary condition is applied to + string_array m_regionNames; + + /// the name of the field the boundary condition is applied to or a key string to use for + /// determining whether or not to apply the boundary condition. + string m_fieldName; + + /// The name of the function used to generate values for application. + string m_functionName; + + /// The scale factors to use on the value of the boundary condition. + array1d< real64 > m_scales; + +}; + +} + +#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP \ No newline at end of file From 35d9a46bf2d5a6dd864ac01ab57ab169527989a5 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 31 Mar 2026 14:53:00 +0200 Subject: [PATCH 04/39] add FieldSpecificationFactory interface --- .../fieldSpecification/CMakeLists.txt | 1 + .../FieldSpecificationFactory.hpp | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index e6b6c94495b..28994da4d14 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -27,6 +27,7 @@ set( fieldSpecification_headers EquilibriumInitialCondition.hpp FieldSpecificationABC.hpp FieldSpecificationBase.hpp + FieldSpecificationFactory.hpp FieldSpecificationManager.hpp SourceFluxBoundaryCondition.hpp TractionBoundaryCondition.hpp diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp new file mode 100644 index 00000000000..d77841afb7d --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -0,0 +1,55 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file FieldSpecificationFactory.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP +#define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP + + +#include "common/DataTypes.hpp" +#include "dataRepository/Group.hpp" +#include "FieldSpecificationABC.hpp" + +namespace geos +{ + +/** + * @class FieldSpecificationFactory + */ +class FieldSpecificationFactory +{ +public: + + /// @brief Generate FieldSpecifications based on the given "higher-level" + /// specification + /// @param specification The higher-level specification used as a blueprint + /// to create FieldSpecification + /// @param manager The parent to store the created FieldSpecifications + virtual void generate( FieldSpecificationABC const & specification, + dataRepository::Group & manager ) const = 0; + + /// @return The key that represents the element this factory is about. + /// Purpose: link the factory to the specification it uses. + virtual string const getKey() const = 0; + +}; + +} + + +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP \ No newline at end of file From a5ddb585bb6244e8263498a8682d8b7ca76f2c3b Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 31 Mar 2026 14:55:56 +0200 Subject: [PATCH 05/39] Add PermeabilitySpecificationFactory --- .../fieldSpecification/CMakeLists.txt | 2 + .../FieldSpecificationBase.hpp | 18 +++++ .../PermeabilitySpecificationFactory.cpp | 73 +++++++++++++++++++ .../PermeabilitySpecificationFactory.hpp | 54 ++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp create mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index 28994da4d14..a2cb7bec632 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -34,6 +34,7 @@ set( fieldSpecification_headers AquiferBoundaryCondition.hpp PerfectlyMatchedLayer.hpp PermeabilitySpecification.hpp + PermeabilitySpecificationFactory.hpp ) # @@ -50,6 +51,7 @@ set( fieldSpecification_sources AquiferBoundaryCondition.cpp PerfectlyMatchedLayer.cpp PermeabilitySpecification.cpp + PermeabilitySpecificationFactory.cpp ) set( dependencyList ${parallelDeps} mesh ) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp index 41d9b895120..909731e3e33 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp @@ -504,6 +504,24 @@ class FieldSpecificationBase : public FieldSpecificationABC m_scale = scale; } + /** + * Mutator + * @param[in] component The component index + */ + void setComponent( int component ) + { + m_component = component; + } + + /** + * Mutator + * @param[in] functionName The name of the function + */ + void setFunctionName( string const & functionName ) + { + m_functionName = functionName; + } + /** * Mutator * @param[in] isInitialCondition Logical value to indicate if it is an initial condition diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp new file mode 100644 index 00000000000..eae986ea9ae --- /dev/null +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp @@ -0,0 +1,73 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PermeabilitySpecificationFactory.cpp + */ + +#include "PermeabilitySpecificationFactory.hpp" +#include "common/DataTypes.hpp" +#include "dataRepository/Group.hpp" +#include "PermeabilitySpecification.hpp" +#include "FieldSpecificationABC.hpp" +#include "FieldSpecificationBase.hpp" + +namespace geos +{ + +/** + * @class PermeabilitySpecificationFactory + */ + +void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & spec, + dataRepository::Group & manager ) const +{ + auto ps = dynamic_cast< PermeabilitySpecification const * >( &spec ); + + stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; + + arrayView1d< real64 const > scales = ps->getScales(); + + for ( string const & regionName : ps->getRegionNames() ) + { + string const objectPath = "ElementRegions/" + regionName; + + for ( int comp = 0; comp < 3; ++comp ) + { + string const childName = ps->getName() + "_" + regionName + suffixes[ comp ]; + + FieldSpecificationBase & fs = manager.registerGroup< FieldSpecificationBase >( childName ); + fs.setFieldName( ps->getFieldName() ); + fs.setObjectPath( objectPath ); + fs.setScale( scales[ comp ] ); + fs.initialCondition( true ); + fs.setComponent( comp ); + + for ( auto const & setName : ps->getSetNames() ) + { + fs.addSetName( setName ); + } + + if ( !ps->getFunctionName().empty() ) + { + fs.setFunctionName( ps->getFunctionName() ); + } + + } + } + +} + +} \ No newline at end of file diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp new file mode 100644 index 00000000000..653f2b85c22 --- /dev/null +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp @@ -0,0 +1,54 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PermeabilitySpecificationFactory.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP +#define GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP + + +#include "common/DataTypes.hpp" +#include "dataRepository/Group.hpp" +#include "PermeabilitySpecification.hpp" +#include "FieldSpecificationABC.hpp" +#include "FieldSpecificationBase.hpp" +#include "FieldSpecificationFactory.hpp" + +namespace geos +{ + +/** + * @class PermeabilitySpecificationFactory + */ +class PermeabilitySpecificationFactory : public FieldSpecificationFactory +{ +public: + + /// @copydoc geos::FieldSpecificationFactory::generate() + void generate( FieldSpecificationABC const & spec, + dataRepository::Group & manager ) const; + + /// @copydoc geos::FieldSpecificationFactory::getKey() + string const getKey() const + { + return PermeabilitySpecification::catalogName(); + } +}; + +} + +#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP \ No newline at end of file From 7098e09a49e2ee84c35abada6c26352a22b71f9d Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 31 Mar 2026 15:01:14 +0200 Subject: [PATCH 06/39] Add specifications factory creation logic to FieldSpecificationManager Implement methods to add factories to the manager to handle the creation of FieldSpecificationBase object via higher-level specifications (like PermeabilitySpecification) --- .../FieldSpecificationABC.hpp | 6 ++++++ .../FieldSpecificationManager.cpp | 21 +++++++++++++++++++ .../FieldSpecificationManager.hpp | 13 ++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 12dc00580d2..5ec287c3837 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -56,6 +56,12 @@ class FieldSpecificationABC : public dataRepository::Group */ static CatalogInterface::CatalogType & getCatalog(); + /** + * @brief return the catalog name + * @return the catalog name + */ + virtual const string getCatalogName() const = 0; + /** * @} */ diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 9c0c5af7b5b..5c3c54d035f 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -18,6 +18,9 @@ #include "mesh/DomainPartition.hpp" #include "mesh/MeshBody.hpp" #include "mesh/MeshObjectPath.hpp" +#include "PermeabilitySpecification.hpp" +#include "FieldSpecificationFactory.hpp" +#include "PermeabilitySpecificationFactory.hpp" namespace geos { @@ -35,6 +38,7 @@ FieldSpecificationManager::FieldSpecificationManager( string const & name, Group GEOS_ERROR_IF( m_instance != nullptr, "Only one FieldSpecificationManager can exist at a time." ); m_instance = this; + registerFactory( std::make_unique< PermeabilitySpecificationFactory >() ); } FieldSpecificationManager::~FieldSpecificationManager() @@ -69,6 +73,23 @@ void FieldSpecificationManager::expandObjectCatalogs() } } +void FieldSpecificationManager::registerFactory( std::unique_ptr< FieldSpecificationFactory > factory ) +{ + m_factories.emplace( factory->getKey(), std::move( factory ) ); +} + +void FieldSpecificationManager::postInputInitialization() +{ + forSubGroups< FieldSpecificationABC >( [&]( FieldSpecificationABC const & spec ) + { + auto it = m_factories.find( spec.getCatalogName() ); + if ( it != m_factories.end() ) + { + it->second->generate( spec, *this ); + } + } ); +} + void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) const { DomainPartition const & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" ); diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp index b1d929e6561..459480a2ef4 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp @@ -21,6 +21,7 @@ #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONMANAGER_HPP_ #include "FieldSpecificationBase.hpp" +#include "FieldSpecificationFactory.hpp" #include "common/format/StringUtilities.hpp" #include "common/DataTypes.hpp" @@ -238,11 +239,23 @@ class FieldSpecificationManager : public dataRepository::Group m_isSurfaceGenerationCase = isSurfaceGenerationCase; } + void registerFactory( std::unique_ptr< FieldSpecificationFactory > factory ); + + +protected: + + virtual void postInputInitialization() override; + + private: + static FieldSpecificationManager * m_instance; + /// Indicate if the SurfaceGenerator element is present bool m_isSurfaceGenerationCase = false; + std::unordered_map< string, std::unique_ptr< FieldSpecificationFactory > > m_factories; + }; template< typename POLICY, typename LAMBDA > From dca1b4a80dc346f85bc390d80460535e63b6dfce Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 7 Apr 2026 17:44:15 +0200 Subject: [PATCH 07/39] set description for scales wrapper --- .../fieldSpecification/PermeabilitySpecification.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 96ae605ffae..672dc816c82 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -35,7 +35,7 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group registerWrapper( viewKeyStruct::regionNamesString(), &m_regionNames ). setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). setInputFlag( InputFlags::REQUIRED ). - setDescription( "" ); + setDescription( "Names of the regions that boundary condition is applied to." ); registerWrapper( viewKeyStruct::fieldNameString(), &m_fieldName ). setRTTypeName( rtTypes::CustomTypes::groupNameRef ). From 1efaccf1a93cf2858b97673be996cc0c3d3b76f7 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 7 Apr 2026 17:46:05 +0200 Subject: [PATCH 08/39] change type of m_scales to R1Tensor --- .../fieldSpecification/PermeabilitySpecification.cpp | 11 +++-------- .../fieldSpecification/PermeabilitySpecification.hpp | 4 ++-- .../PermeabilitySpecificationFactory.cpp | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 672dc816c82..38bcb2b7943 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -49,8 +49,8 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setDescription( "Name of function that specifies variation of the boundary condition." ); registerWrapper( viewKeyStruct::scalesString(), &m_scales ). - // setApplyDefaultValue( 0.0 ). - setInputFlag( InputFlags::REQUIRED ). + setApplyDefaultValue( { 0.0, 0.0, 0.0 } ). + setInputFlag( InputFlags::OPTIONAL ). setDescription( "Apply a scaling factor for the value of the boundary condition." ); } @@ -60,12 +60,7 @@ PermeabilitySpecification::~PermeabilitySpecification() void PermeabilitySpecification::postInputInitialization() -{ - GEOS_THROW_IF( m_scales.size() != 3, - getWrapperDataContext( viewKeyStruct::scalesString() ) << - ": expected 3 components, got " << m_scales.size(), - InputError ); -} +{} REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 6796db78a20..eb2847ce887 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -134,7 +134,7 @@ class PermeabilitySpecification : public FieldSpecificationABC * Accessor * @return const m_scales */ - arrayView1d< real64 const > getScales() const + R1Tensor getScales() const { return m_scales; } @@ -161,7 +161,7 @@ class PermeabilitySpecification : public FieldSpecificationABC string m_functionName; /// The scale factors to use on the value of the boundary condition. - array1d< real64 > m_scales; + R1Tensor m_scales; }; diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp index eae986ea9ae..7ea83372194 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp @@ -38,7 +38,7 @@ void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & s stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; - arrayView1d< real64 const > scales = ps->getScales(); + R1Tensor scales = ps->getScales(); for ( string const & regionName : ps->getRegionNames() ) { From e40b8c945ec88eab64a515cdaf2fd97e8aca4973 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 8 Apr 2026 09:28:01 +0200 Subject: [PATCH 09/39] modify for loop type to integer --- .../fieldSpecification/PermeabilitySpecificationFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp index 7ea83372194..ee5574edf28 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp @@ -44,9 +44,9 @@ void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & s { string const objectPath = "ElementRegions/" + regionName; - for ( int comp = 0; comp < 3; ++comp ) + for ( integer comp = 0; comp < 3; ++comp ) { - string const childName = ps->getName() + "_" + regionName + suffixes[ comp ]; + string const childName = ps->getName() + "_" + regionName + suffixes[ comp ]; FieldSpecificationBase & fs = manager.registerGroup< FieldSpecificationBase >( childName ); fs.setFieldName( ps->getFieldName() ); From c736a7d6d249e5480f73c076f26e6648afff4c35 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 8 Apr 2026 09:38:44 +0200 Subject: [PATCH 10/39] add RST documentation for PermeabilitySpecification --- .../docs/FieldSpecification.rst | 2 + .../docs/PermeabilitySpecification.rst | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst diff --git a/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst b/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst index 7752ed84863..b52ebee4449 100644 --- a/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst +++ b/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst @@ -9,4 +9,6 @@ Initial and Boundary Conditions EquilibriumInitialCondition AquiferBoundaryCondition + + PermeabilitySpecification diff --git a/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst b/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst new file mode 100644 index 00000000000..55f324f5c02 --- /dev/null +++ b/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst @@ -0,0 +1,49 @@ +.. _PermeabilitySpecification: + +#################################################### +Permeability specification +#################################################### + +Overview +====================== + +**PermeabilitySpecification** is an optional, higher-level XML tag that you can place in the **FieldSpecifications** block. +It describes a 3-axis permeability on one or more element regions. +After the input deck is read, GEOS expands each **PermeabilitySpecification** into several **FieldSpecification** objects (one per region and per axis) that the rest of the code already understands. + +This is convenient when you want the same **setNames**, **fieldName**, and other attributes for all three permeability components, instead of repeating three nearly identical **FieldSpecification**. + +Examples +=============== + +The following illustrates a **PermeabilitySpecification** for a single region. + +.. code-block:: xml + + + ... + + ... + + +The following illustrates a **PermeabilitySpecification** for multiple regions. + +.. code-block:: xml + + + ... + + ... + From 42f7c62f2b9b43d0fff0407fd39f27533dc52b60 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 10 Apr 2026 15:06:56 +0200 Subject: [PATCH 11/39] uncrustify --- .../fieldSpecification/FieldSpecificationABC.cpp | 2 +- .../fieldSpecification/FieldSpecificationABC.hpp | 2 +- .../fieldSpecification/FieldSpecificationBase.hpp | 2 +- .../fieldSpecification/FieldSpecificationFactory.hpp | 2 +- .../fieldSpecification/FieldSpecificationManager.cpp | 2 +- .../fieldSpecification/FieldSpecificationManager.hpp | 4 ++-- .../fieldSpecification/PermeabilitySpecification.cpp | 2 +- .../fieldSpecification/PermeabilitySpecification.hpp | 2 +- .../PermeabilitySpecificationFactory.cpp | 12 ++++++------ .../PermeabilitySpecificationFactory.hpp | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp index 4f4b3ba3da4..5d5a38d6704 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp @@ -33,4 +33,4 @@ FieldSpecificationABC::getCatalog() return catalog; } -} \ No newline at end of file +} diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 5ec287c3837..3b413da7db4 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -102,4 +102,4 @@ class FieldSpecificationABC : public dataRepository::Group } -#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP \ No newline at end of file +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp index 909731e3e33..6231bf2b1f2 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp @@ -506,7 +506,7 @@ class FieldSpecificationBase : public FieldSpecificationABC /** * Mutator - * @param[in] component The component index + * @param[in] component The component index */ void setComponent( int component ) { diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp index d77841afb7d..6e402463c75 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -52,4 +52,4 @@ class FieldSpecificationFactory } -#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP \ No newline at end of file +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 5c3c54d035f..2fb9d7e90b1 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -83,7 +83,7 @@ void FieldSpecificationManager::postInputInitialization() forSubGroups< FieldSpecificationABC >( [&]( FieldSpecificationABC const & spec ) { auto it = m_factories.find( spec.getCatalogName() ); - if ( it != m_factories.end() ) + if( it != m_factories.end() ) { it->second->generate( spec, *this ); } diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp index 459480a2ef4..db43bc9d8bb 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp @@ -248,9 +248,9 @@ class FieldSpecificationManager : public dataRepository::Group private: - + static FieldSpecificationManager * m_instance; - + /// Indicate if the SurfaceGenerator element is present bool m_isSurfaceGenerationCase = false; diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 38bcb2b7943..22a5c6ec77f 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -65,4 +65,4 @@ void PermeabilitySpecification::postInputInitialization() REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) -} \ No newline at end of file +} diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index eb2847ce887..cbb51e7abc4 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -167,4 +167,4 @@ class PermeabilitySpecification : public FieldSpecificationABC } -#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP \ No newline at end of file +#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp index ee5574edf28..b50b2c67df4 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp @@ -34,17 +34,17 @@ namespace geos void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & spec, dataRepository::Group & manager ) const { - auto ps = dynamic_cast< PermeabilitySpecification const * >( &spec ); + auto ps = dynamic_cast< PermeabilitySpecification const * >( &spec ); stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; R1Tensor scales = ps->getScales(); - for ( string const & regionName : ps->getRegionNames() ) + for( string const & regionName : ps->getRegionNames() ) { string const objectPath = "ElementRegions/" + regionName; - for ( integer comp = 0; comp < 3; ++comp ) + for( integer comp = 0; comp < 3; ++comp ) { string const childName = ps->getName() + "_" + regionName + suffixes[ comp ]; @@ -55,12 +55,12 @@ void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & s fs.initialCondition( true ); fs.setComponent( comp ); - for ( auto const & setName : ps->getSetNames() ) + for( auto const & setName : ps->getSetNames() ) { fs.addSetName( setName ); } - if ( !ps->getFunctionName().empty() ) + if( !ps->getFunctionName().empty() ) { fs.setFunctionName( ps->getFunctionName() ); } @@ -70,4 +70,4 @@ void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & s } -} \ No newline at end of file +} diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp index 653f2b85c22..612b86c1429 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp @@ -51,4 +51,4 @@ class PermeabilitySpecificationFactory : public FieldSpecificationFactory } -#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP \ No newline at end of file +#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP From 16f7e43a09c7f03908bdfce5599df22c8859d3ad Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 14 Apr 2026 14:03:51 +0200 Subject: [PATCH 12/39] add missing documentation --- .../fieldSpecification/FieldSpecificationABC.hpp | 2 ++ .../fieldSpecification/FieldSpecificationFactory.hpp | 4 ++++ .../fieldSpecification/FieldSpecificationManager.hpp | 5 +++++ .../fieldSpecification/PermeabilitySpecification.hpp | 2 ++ .../fieldSpecification/PermeabilitySpecificationFactory.hpp | 3 +++ 5 files changed, 16 insertions(+) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 3b413da7db4..9efab02e82f 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -33,6 +33,8 @@ class Function; /** * @class FieldSpecificationABC + * + * Abstract Base Class grouping multiple types of field specifications. */ class FieldSpecificationABC : public dataRepository::Group { diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp index 6e402463c75..32fc2d8aa34 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -30,6 +30,10 @@ namespace geos /** * @class FieldSpecificationFactory + * + * This class provides a way to create FieldSpecification objects using + * other type of specifications. One could think of those types of + * specification to blueprints or "high-level" specification */ class FieldSpecificationFactory { diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp index db43bc9d8bb..1ec2e387515 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp @@ -239,6 +239,11 @@ class FieldSpecificationManager : public dataRepository::Group m_isSurfaceGenerationCase = isSurfaceGenerationCase; } + /** + * @brief Register a factory in the manager to create FieldSpecification + * via "high-level" field specifications data + * @param factory The factory to add to the manager + */ void registerFactory( std::unique_ptr< FieldSpecificationFactory > factory ); diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index cbb51e7abc4..86cd7bec59b 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -31,6 +31,8 @@ namespace geos /** * @class PermeabilitySpecification + * + * Data class representing a permeability field specification */ class PermeabilitySpecification : public FieldSpecificationABC { diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp index 612b86c1429..325cf0affa0 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp @@ -33,6 +33,9 @@ namespace geos /** * @class PermeabilitySpecificationFactory + * + * @copydoc geos::FieldSpecificationFactory + * Field specification factory implementation for the PermeabilitySpecification */ class PermeabilitySpecificationFactory : public FieldSpecificationFactory { From 74cda9c572ceff50c2e336790c75d58fd251a999 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 14 Apr 2026 14:04:33 +0200 Subject: [PATCH 13/39] fix parameter name Modify the specification parameter name in PermeabilitySpecificationFactory to match the parent class method definition (FieldSpecificationFactory) --- .../fieldSpecification/PermeabilitySpecificationFactory.cpp | 4 ++-- .../fieldSpecification/PermeabilitySpecificationFactory.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp index b50b2c67df4..d1791a03046 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp @@ -31,10 +31,10 @@ namespace geos * @class PermeabilitySpecificationFactory */ -void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & spec, +void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & specification, dataRepository::Group & manager ) const { - auto ps = dynamic_cast< PermeabilitySpecification const * >( &spec ); + auto ps = dynamic_cast< PermeabilitySpecification const * >( &specification ); stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp index 325cf0affa0..d8f85b16fb3 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp @@ -42,7 +42,7 @@ class PermeabilitySpecificationFactory : public FieldSpecificationFactory public: /// @copydoc geos::FieldSpecificationFactory::generate() - void generate( FieldSpecificationABC const & spec, + void generate( FieldSpecificationABC const & specification, dataRepository::Group & manager ) const; /// @copydoc geos::FieldSpecificationFactory::getKey() From 0db9276ba48bf54cd52514b3ab2555a872f38e71 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 2 Jun 2026 16:45:49 +0200 Subject: [PATCH 14/39] update schema --- src/coreComponents/schema/schema.xsd | 22 ++++++++++++++++++++++ src/coreComponents/schema/schema.xsd.other | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index bd776c2bac0..fab934c7223 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -212,6 +212,10 @@ + + + + @@ -1307,6 +1311,7 @@ Information output from lower logLevels is added with the desired log level + @@ -1539,6 +1544,23 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set + + + + + + + + + + + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 355f061e7f5..a26f5aab06f 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -297,6 +297,7 @@ + @@ -336,6 +337,7 @@ A field can represent a physical variable. (pressure, temperature, global compos + From 24728115dc6446df2913ab13b3b0a936ba6f654a Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 2 Jun 2026 16:51:35 +0200 Subject: [PATCH 15/39] correct documentation in PermeabilitySpecification.rst Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com> --- .../fieldSpecification/docs/PermeabilitySpecification.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst b/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst index 55f324f5c02..1a5c370d17f 100644 --- a/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst +++ b/src/coreComponents/fieldSpecification/docs/PermeabilitySpecification.rst @@ -7,8 +7,8 @@ Permeability specification Overview ====================== -**PermeabilitySpecification** is an optional, higher-level XML tag that you can place in the **FieldSpecifications** block. -It describes a 3-axis permeability on one or more element regions. +**PermeabilitySpecification** is a XML tag that you can place in the **FieldSpecifications** block to describe a 3-axis permeability on one or more element regions. +It is an higher-level component than **FieldSpecification**, specialized on permeability. After the input deck is read, GEOS expands each **PermeabilitySpecification** into several **FieldSpecification** objects (one per region and per axis) that the rest of the code already understands. This is convenient when you want the same **setNames**, **fieldName**, and other attributes for all three permeability components, instead of repeating three nearly identical **FieldSpecification**. From 6cd3a4053806e6111134cd65f2c9dca89ced40ff Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 2 Jun 2026 16:52:54 +0200 Subject: [PATCH 16/39] fix typo in FieldSpecificationABC.hpp Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com> --- src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 9efab02e82f..b6262004884 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -41,7 +41,7 @@ class FieldSpecificationABC : public dataRepository::Group public: /** - * @defgroup alias and functions to defined statically initialized catalog + * @defgroup alias and functions to define statically initialized catalog * @{ */ From 588cc9006652df838f20bdb079667cbbaf2b8d6e Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 2 Jun 2026 17:28:36 +0200 Subject: [PATCH 17/39] add non-negative validation --- .../fieldSpecification/PermeabilitySpecification.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 22a5c6ec77f..ad6891b908a 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -14,6 +14,7 @@ */ #include "PermeabilitySpecification.hpp" +#include "common/logger/Logger.hpp" namespace geos { @@ -60,7 +61,15 @@ PermeabilitySpecification::~PermeabilitySpecification() void PermeabilitySpecification::postInputInitialization() -{} +{ + R1Tensor scales = getScales(); + for( int axis = 0; axis < 3; ++axis ) + { + GEOS_ERROR_IF( scales[ axis ] < 0, + GEOS_FMT( "Scale values for a permeability must be non-negative\nA value of {} was given in {} '{}'.", + scales[ axis ], catalogName(), getName() ) ); + } +} REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) From 3ab20c6fd01cf9d7be7d65b0bb723c130df0a689 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Mon, 29 Jun 2026 17:40:32 +0200 Subject: [PATCH 18/39] modify to a lighter implementation with type dispatch --- .../fieldSpecification/CMakeLists.txt | 3 +- .../FieldSpecificationFactory.cpp | 47 ++++++++++++ .../FieldSpecificationFactory.hpp | 44 ++++++----- .../FieldSpecificationManager.cpp | 20 +---- .../FieldSpecificationManager.hpp | 10 --- .../PermeabilitySpecification.cpp | 40 ++++++++++ .../PermeabilitySpecification.hpp | 7 ++ .../PermeabilitySpecificationFactory.cpp | 73 ------------------- .../PermeabilitySpecificationFactory.hpp | 56 -------------- 9 files changed, 118 insertions(+), 182 deletions(-) create mode 100644 src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp delete mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp delete mode 100644 src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index c55da6d1282..07c83728d5e 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -35,7 +35,6 @@ set( fieldSpecification_headers AquiferBoundaryCondition.hpp PerfectlyMatchedLayer.hpp PermeabilitySpecification.hpp - PermeabilitySpecificationFactory.hpp ) # @@ -46,13 +45,13 @@ set( fieldSpecification_sources EquilibriumInitialCondition.cpp FieldSpecification.cpp FieldSpecificationABC.cpp + FieldSpecificationFactory.cpp FieldSpecificationManager.cpp SourceFluxBoundaryCondition.cpp TractionBoundaryCondition.cpp AquiferBoundaryCondition.cpp PerfectlyMatchedLayer.cpp PermeabilitySpecification.cpp - PermeabilitySpecificationFactory.cpp ) set( dependencyList ${parallelDeps} mesh ) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp new file mode 100644 index 00000000000..c8440e7df5d --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp @@ -0,0 +1,47 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file FieldSpecificationFactory.cpp + */ + +#include "FieldSpecificationFactory.hpp" +#include "PermeabilitySpecification.hpp" + +namespace geos +{ + +namespace +{ + +template< typename ... SPEC_TYPES, typename LAMBDA > +void forExpandableSpecifications( dataRepository::Group & manager, + types::TypeList< SPEC_TYPES... >, + LAMBDA && lambda ) +{ + manager.template forSubGroups< SPEC_TYPES... >( std::forward< LAMBDA >( lambda ) ); +} + +} + +void expandFieldSpecifications( dataRepository::Group & manager ) +{ + forExpandableSpecifications( manager, ExpandableSpecTypes{}, [&]( auto const & spec ) + { + generateFieldSpecifications( spec, manager ); + } ); +} + +} // namespace geos diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp index 32fc2d8aa34..c11e50357f0 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -21,39 +21,37 @@ #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP -#include "common/DataTypes.hpp" +#include "common/TypeDispatch.hpp" #include "dataRepository/Group.hpp" -#include "FieldSpecificationABC.hpp" namespace geos { +class PermeabilitySpecification; + /** - * @class FieldSpecificationFactory - * - * This class provides a way to create FieldSpecification objects using - * other type of specifications. One could think of those types of - * specification to blueprints or "high-level" specification + * @brief List of high-level field specifications to expand into FieldSpecification objects. */ -class FieldSpecificationFactory -{ -public: - - /// @brief Generate FieldSpecifications based on the given "higher-level" - /// specification - /// @param specification The higher-level specification used as a blueprint - /// to create FieldSpecification - /// @param manager The parent to store the created FieldSpecifications - virtual void generate( FieldSpecificationABC const & specification, - dataRepository::Group & manager ) const = 0; +using ExpandableSpecTypes = types::TypeList< PermeabilitySpecification >; - /// @return The key that represents the element this factory is about. - /// Purpose: link the factory to the specification it uses. - virtual string const getKey() const = 0; +/** + * @brief Generate FieldSpecifications based on the given "higher-level" specification + * @tparam SPEC_TYPE The type of the high-level specification + * @param specification The high-level specification used as a blueprint + * to create FieldSpecification + * @param manager The parent to store the created FieldSpecifications + */ +template< typename SPEC_TYPE > +void generateFieldSpecifications( SPEC_TYPE const & specification, dataRepository::Group & manager ) = delete; -}; +/** + * @brief Expand high-level field specifications + * @param manager The manager group + * Expand all field specificiation listed in ExpandableSpecTypes + */ +void expandFieldSpecifications( dataRepository::Group & manager ); -} +} // namespace geos #endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONFACTORY_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 9537791d4ca..0ccc911b822 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -15,12 +15,10 @@ #include "FieldSpecificationManager.hpp" #include "FieldSpecificationABC.hpp" +#include "FieldSpecificationFactory.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/MeshBody.hpp" #include "mesh/MeshObjectPath.hpp" -#include "PermeabilitySpecification.hpp" -#include "FieldSpecificationFactory.hpp" -#include "PermeabilitySpecificationFactory.hpp" namespace geos { @@ -37,8 +35,6 @@ FieldSpecificationManager::FieldSpecificationManager( string const & name, Group GEOS_ERROR_IF( m_instance != nullptr, "Only one FieldSpecificationManager can exist at a time." ); m_instance = this; - - registerFactory( std::make_unique< PermeabilitySpecificationFactory >() ); } FieldSpecificationManager::~FieldSpecificationManager() @@ -73,21 +69,9 @@ void FieldSpecificationManager::expandObjectCatalogs() } } -void FieldSpecificationManager::registerFactory( std::unique_ptr< FieldSpecificationFactory > factory ) -{ - m_factories.emplace( factory->getKey(), std::move( factory ) ); -} - void FieldSpecificationManager::postInputInitialization() { - forSubGroups< FieldSpecificationABC >( [&]( FieldSpecificationABC const & spec ) - { - auto it = m_factories.find( spec.getCatalogName() ); - if( it != m_factories.end() ) - { - it->second->generate( spec, *this ); - } - } ); + expandFieldSpecifications( *this ); } void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) const diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp index 545a4557a5c..7358370b0cf 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp @@ -21,7 +21,6 @@ #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONMANAGER_HPP_ #include "FieldSpecification.hpp" -#include "FieldSpecificationFactory.hpp" #include "FieldSpecificationImpl.hpp" #include "common/format/StringUtilities.hpp" @@ -239,13 +238,6 @@ class FieldSpecificationManager : public dataRepository::Group m_isSurfaceGenerationCase = isSurfaceGenerationCase; } - /** - * @brief Register a factory in the manager to create FieldSpecification - * via "high-level" field specifications data - * @param factory The factory to add to the manager - */ - void registerFactory( std::unique_ptr< FieldSpecificationFactory > factory ); - protected: @@ -259,8 +251,6 @@ class FieldSpecificationManager : public dataRepository::Group /// Indicate if the SurfaceGenerator element is present bool m_isSurfaceGenerationCase = false; - std::unordered_map< string, std::unique_ptr< FieldSpecificationFactory > > m_factories; - }; template< typename POLICY, typename LAMBDA > diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index ad6891b908a..c5139959f70 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -14,6 +14,8 @@ */ #include "PermeabilitySpecification.hpp" +#include "FieldSpecification.hpp" +#include "FieldSpecificationFactory.hpp" #include "common/logger/Logger.hpp" namespace geos @@ -74,4 +76,42 @@ void PermeabilitySpecification::postInputInitialization() REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) +template<> +void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpecification const & ps, + dataRepository::Group & manager ) +{ + stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; + + R1Tensor scales = ps.getScales(); + + for( string const & regionName : ps.getRegionNames() ) + { + string const objectPath = "ElementRegions/" + regionName; + + for( integer comp = 0; comp < 3; ++comp ) + { + string const childName = ps.getName() + "_" + regionName + suffixes[ comp ]; + + FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); + fs.setFieldName( ps.getFieldName() ); + fs.setObjectPath( objectPath ); + fs.setScale( scales[ comp ] ); + fs.initialCondition( true ); + fs.setComponent( comp ); + + for( auto const & setName : ps.getSetNames() ) + { + fs.addSetName( setName ); + } + + if( !ps.getFunctionName().empty() ) + { + fs.setFunctionName( ps.getFunctionName() ); + } + + } + } + +} + } diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 86cd7bec59b..687ddeb94d9 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -25,6 +25,7 @@ #include "mesh/ObjectManagerBase.hpp" #include "mesh/MeshObjectPath.hpp" #include "FieldSpecificationABC.hpp" +#include "FieldSpecificationFactory.hpp" namespace geos { @@ -167,6 +168,12 @@ class PermeabilitySpecification : public FieldSpecificationABC }; +/// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications +template<> +void +generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpecification const & specification, + dataRepository::Group & manager ); + } #endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATION_HPP diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp deleted file mode 100644 index 49d525e7a63..00000000000 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * 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. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file PermeabilitySpecificationFactory.cpp - */ - -#include "PermeabilitySpecificationFactory.hpp" -#include "common/DataTypes.hpp" -#include "dataRepository/Group.hpp" -#include "PermeabilitySpecification.hpp" -#include "FieldSpecificationABC.hpp" -#include "FieldSpecification.hpp" - -namespace geos -{ - -/** - * @class PermeabilitySpecificationFactory - */ - -void PermeabilitySpecificationFactory::generate( FieldSpecificationABC const & specification, - dataRepository::Group & manager ) const -{ - auto ps = dynamic_cast< PermeabilitySpecification const * >( &specification ); - - stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; - - R1Tensor scales = ps->getScales(); - - for( string const & regionName : ps->getRegionNames() ) - { - string const objectPath = "ElementRegions/" + regionName; - - for( integer comp = 0; comp < 3; ++comp ) - { - string const childName = ps->getName() + "_" + regionName + suffixes[ comp ]; - - FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); - fs.setFieldName( ps->getFieldName() ); - fs.setObjectPath( objectPath ); - fs.setScale( scales[ comp ] ); - fs.initialCondition( true ); - fs.setComponent( comp ); - - for( auto const & setName : ps->getSetNames() ) - { - fs.addSetName( setName ); - } - - if( !ps->getFunctionName().empty() ) - { - fs.setFunctionName( ps->getFunctionName() ); - } - - } - } - -} - -} diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp deleted file mode 100644 index 426162f2988..00000000000 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecificationFactory.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * 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. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file PermeabilitySpecificationFactory.hpp - */ - -#ifndef GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP -#define GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP - - -#include "common/DataTypes.hpp" -#include "dataRepository/Group.hpp" -#include "PermeabilitySpecification.hpp" -#include "FieldSpecificationABC.hpp" -#include "FieldSpecificationFactory.hpp" - -namespace geos -{ - -/** - * @class PermeabilitySpecificationFactory - * - * @copydoc geos::FieldSpecificationFactory - * Field specification factory implementation for the PermeabilitySpecification - */ -class PermeabilitySpecificationFactory : public FieldSpecificationFactory -{ -public: - - /// @copydoc geos::FieldSpecificationFactory::generate() - void generate( FieldSpecificationABC const & specification, - dataRepository::Group & manager ) const; - - /// @copydoc geos::FieldSpecificationFactory::getKey() - string const getKey() const - { - return PermeabilitySpecification::catalogName(); - } -}; - -} - -#endif //GEOS_FIELDSPECIFICATION_PERMEABILITYSPECIFICATIONFACTORY_HPP From 2a604b1879794088013bf95d5598987ebb9860ba Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 17 Jul 2026 08:51:45 +0200 Subject: [PATCH 19/39] Merge remote-tracking branch 'upstream/feature/kdrienCG/nonScalarFieldSpecification' into feature/kdrienCG/permeabilitySpecification --- .../fieldSpecification/FieldSpecification.hpp | 7 --- .../FieldSpecificationImpl.hpp | 2 +- .../FieldSpecificationManager.cpp | 2 +- .../PermeabilitySpecification.cpp | 57 ++++++++----------- .../PermeabilitySpecification.hpp | 50 ++++++++-------- src/coreComponents/schema/schema.xsd | 10 ++-- src/coreComponents/schema/schema.xsd.other | 4 +- 7 files changed, 60 insertions(+), 72 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp index 22231140ef0..b72e8710da8 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -255,13 +255,6 @@ class FieldSpecification : public FieldSpecificationABC void setComponent( int component ) { m_component = component; } - /** - * Mutator - * @param[in] functionName The name of the function - */ - void setFunctionName( string const & functionName ) - { m_functionName = functionName; } - /** * Mutator * @param[in] objectPath The path for the object diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp index 3ed8f6d005f..7f25aaa5916 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp @@ -400,7 +400,7 @@ class FieldSpecificationImpl template< typename LAMBDA > void FieldSpecificationImpl::forEachComponent( FieldSpecification const & fs, LAMBDA && lambda ) { - if( fs.getComponent() == -1 ) + if( fs.getComponent() == -1 && !fs.getScales().empty() ) { for( localIndex comp = 0; comp < fs.getScales().size(); ++comp ) { diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 7b158cbe995..af30af68166 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -74,7 +74,7 @@ void FieldSpecificationManager::postInputInitialization() expandFieldSpecifications( *this ); } -void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) const +void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) { DomainPartition const & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" ); Group const & meshBodies = domain.getMeshBodies(); diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index c5139959f70..867a3d4910d 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -46,15 +46,21 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setDescription( "Name of field that boundary condition is applied to.\n" "A field can represent a physical variable. (pressure, temperature, global composition fraction of the fluid, ...)" ); - registerWrapper( viewKeyStruct::functionNameString(), &m_functionName ). - setRTTypeName( rtTypes::CustomTypes::groupNameRef ). + registerWrapper( viewKeyStruct::initialConditionString(), &m_initialCondition ). + setApplyDefaultValue( 1 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Boundary condition is applied as an initial condition." ); + + registerWrapper( viewKeyStruct::functionNamesString(), &m_functionNames ). + setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Name of function that specifies variation of the boundary condition." ); + setDescription( "Name(s) of function(s) that specifies variation of the boundary condition." ); registerWrapper( viewKeyStruct::scalesString(), &m_scales ). - setApplyDefaultValue( { 0.0, 0.0, 0.0 } ). + setApplyDefaultValue( 0.0 ). setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Apply a scaling factor for the value of the boundary condition." ); + setSizedFromParent( 0 ). + setDescription( "Apply scaling factor(s) for the value(s) of the boundary condition." ); } @@ -64,12 +70,11 @@ PermeabilitySpecification::~PermeabilitySpecification() void PermeabilitySpecification::postInputInitialization() { - R1Tensor scales = getScales(); - for( int axis = 0; axis < 3; ++axis ) + for( real64 scale : getScales() ) { - GEOS_ERROR_IF( scales[ axis ] < 0, + GEOS_ERROR_IF( scale < 0, GEOS_FMT( "Scale values for a permeability must be non-negative\nA value of {} was given in {} '{}'.", - scales[ axis ], catalogName(), getName() ) ); + scale, catalogName(), getName() ) ); } } @@ -80,38 +85,24 @@ template<> void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpecification const & ps, dataRepository::Group & manager ) { - stdArray< string, 3 > suffixes = {{ "_x", "_y", "_z" }}; - - R1Tensor scales = ps.getScales(); - for( string const & regionName : ps.getRegionNames() ) { string const objectPath = "ElementRegions/" + regionName; - for( integer comp = 0; comp < 3; ++comp ) - { - string const childName = ps.getName() + "_" + regionName + suffixes[ comp ]; - - FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); - fs.setFieldName( ps.getFieldName() ); - fs.setObjectPath( objectPath ); - fs.setScale( scales[ comp ] ); - fs.initialCondition( true ); - fs.setComponent( comp ); + string const childName = ps.getName() + "_" + regionName; - for( auto const & setName : ps.getSetNames() ) - { - fs.addSetName( setName ); - } - - if( !ps.getFunctionName().empty() ) - { - fs.setFunctionName( ps.getFunctionName() ); - } + FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); + fs.setFieldName( ps.getFieldName() ); + fs.setObjectPath( objectPath ); + fs.initialCondition( ps.initialCondition() ); + fs.setScales( ps.getScales() ); + fs.setFunctionNames( ps.getFunctionNames() ); + for( auto const & setName : ps.getSetNames() ) + { + fs.addSetName( setName ); } } - } } diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 687ddeb94d9..fe7aaf942ca 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -91,56 +91,55 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * regionNamesString() { return "regionNames"; } /// @return The key for fieldName constexpr static char const * fieldNameString() { return "fieldName"; } - /// @return The key for functionName - constexpr static char const * functionNameString() { return "functionName"; } + /// @return The key for initialCondition + constexpr static char const * initialConditionString() { return "initialCondition"; } + /// @return The key for functionNames + constexpr static char const * functionNamesString() { return "functionNames"; } /// @return The key for scales constexpr static char const * scalesString() { return "scales"; } }; /** * Accessor - * @return const reference to m_function + * @return const reference to m_functionNames */ - string const & getFunctionName() const - { - return m_functionName; - } + string_array const & getFunctionNames() const + { return m_functionNames; } /** * Accessor * @return const reference to m_regionNames */ string_array const & getRegionNames() const - { - return m_regionNames; - } + { return m_regionNames; } /** * Accessor * @return const reference to m_fieldName */ virtual const string & getFieldName() const - { - return m_fieldName; - } + { return m_fieldName; } /** * Accessor * @return const reference to m_setNames */ string_array const & getSetNames() const - { - return m_setNames; - } + { return m_setNames; } /** * Accessor * @return const m_scales */ - R1Tensor getScales() const - { - return m_scales; - } + array1d< real64 > getScales() const + { return m_scales; } + + /** + * Accessor + * @return const m_initialCondition + */ + int initialCondition() const + { return m_initialCondition; } protected: @@ -160,11 +159,14 @@ class PermeabilitySpecification : public FieldSpecificationABC /// determining whether or not to apply the boundary condition. string m_fieldName; - /// The name of the function used to generate values for application. - string m_functionName; + /// Whether or not the boundary condition is an initial condition. + int m_initialCondition; + + /// Name(s) of the function used to generate values for application. + string_array m_functionNames; - /// The scale factors to use on the value of the boundary condition. - R1Tensor m_scales; + /// Scale factor(s) to use on the value of the boundary condition. + array1d< real64 > m_scales; }; diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 1974b18bd9a..4dfa684b360 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1538,12 +1538,14 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set - - + + + + - - + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index fc8ca31f841..f63803784d3 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -528,7 +528,7 @@ A field can represent a physical variable. (pressure, temperature, global compos - + @@ -1611,7 +1611,7 @@ A field can represent a physical variable. (pressure, temperature, global compos - + From 9f93127f706d35d45a87780571402e02c1669b0a Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 17 Jul 2026 10:06:47 +0200 Subject: [PATCH 20/39] add optional beginTime and endTime support --- .../fieldSpecification/FieldSpecification.hpp | 14 ++++++++++ .../PermeabilitySpecification.cpp | 26 +++++++++++++++++-- .../PermeabilitySpecification.hpp | 23 ++++++++++++++++ src/coreComponents/schema/schema.xsd | 4 +++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp index b72e8710da8..e686c56ed56 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -310,6 +310,20 @@ class FieldSpecification : public FieldSpecificationABC */ void setMeshObjectPath( Group const & meshBodies ); + /** + * Mutator + * @param[in] beginTime Time after which the bc is allowed to be applied + */ + void setStartTime( real64 beginTime ) + { m_beginTime = beginTime; } + + /** + * Mutator + * @param[in] endTime Time after which the bc will no longer be applied. + */ + void setEndTime( real64 endTime ) + { m_endTime = endTime; } + /** * @brief Get the Mesh Object Paths object * diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 867a3d4910d..34f11e58aed 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -61,6 +61,16 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setInputFlag( InputFlags::OPTIONAL ). setSizedFromParent( 0 ). setDescription( "Apply scaling factor(s) for the value(s) of the boundary condition." ); + + registerWrapper( viewKeyStruct::beginTimeString(), &m_beginTime ). + setApplyDefaultValue( -1.0e99 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Time at which the boundary condition will start being applied." ); + + registerWrapper( viewKeyStruct::endTimeString(), &m_endTime ). + setApplyDefaultValue( 1.0e99 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Time at which the boundary condition will stop being applied." ); } @@ -72,10 +82,20 @@ void PermeabilitySpecification::postInputInitialization() { for( real64 scale : getScales() ) { - GEOS_ERROR_IF( scale < 0, + GEOS_THROW_IF( scale < 0, GEOS_FMT( "Scale values for a permeability must be non-negative\nA value of {} was given in {} '{}'.", - scale, catalogName(), getName() ) ); + scale, catalogName(), getName() ), + InputError, + getDataContext() ); } + + GEOS_THROW_IF( m_beginTime > m_endTime, + GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", + viewKeyStruct::beginTimeString(), m_beginTime, + viewKeyStruct::endTimeString(), m_endTime, + catalogName(), getName() ), + InputError, + getDataContext() ); } @@ -97,6 +117,8 @@ void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpeci fs.initialCondition( ps.initialCondition() ); fs.setScales( ps.getScales() ); fs.setFunctionNames( ps.getFunctionNames() ); + fs.setStartTime( ps.getStartTime() ); + fs.setEndTime( ps.getEndTime() ); for( auto const & setName : ps.getSetNames() ) { diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index fe7aaf942ca..af1a9e82e61 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -97,6 +97,10 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * functionNamesString() { return "functionNames"; } /// @return The key for scales constexpr static char const * scalesString() { return "scales"; } + /// @return The key for beginTime + constexpr static char const * beginTimeString() { return "beginTime"; } + /// @return The key for endTime + constexpr static char const * endTimeString() { return "endTime"; } }; /** @@ -141,6 +145,19 @@ class PermeabilitySpecification : public FieldSpecificationABC int initialCondition() const { return m_initialCondition; } + /** + * Accessor + * @return const m_beginTime + */ + real64 getStartTime() const + { return m_beginTime; } + + /** + * Accessor + * @return const m_endTime + */ + real64 getEndTime() const + { return m_endTime; } protected: @@ -168,6 +185,12 @@ class PermeabilitySpecification : public FieldSpecificationABC /// Scale factor(s) to use on the value of the boundary condition. array1d< real64 > m_scales; + /// Time after which the bc is allowed to be applied + real64 m_beginTime; + + /// Time after which the bc will no longer be applied. + real64 m_endTime; + }; /// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 4dfa684b360..2835ff92c31 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1535,6 +1535,10 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set + + + + From 067f986806dd8cceaeb6a54537884bd94d457eb1 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 17 Jul 2026 10:11:28 +0200 Subject: [PATCH 21/39] add functionName size validation --- .../fieldSpecification/PermeabilitySpecification.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 34f11e58aed..00fe9f34a67 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -89,6 +89,17 @@ void PermeabilitySpecification::postInputInitialization() getDataContext() ); } + GEOS_THROW_IF( !m_functionNames.empty() && + m_functionNames.size() != 1 && + m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), + GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " + "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", + viewKeyStruct::functionNamesString(), m_functionNames.size(), + viewKeyStruct::scalesString(), m_scales.size(), + viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), + InputError, + getDataContext() ); + GEOS_THROW_IF( m_beginTime > m_endTime, GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", viewKeyStruct::beginTimeString(), m_beginTime, From 996a13d02a39400626e4f2c6712f98ef8746481d Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 17 Jul 2026 12:14:06 +0200 Subject: [PATCH 22/39] add tests --- .../unitTests/CMakeLists.txt | 3 +- .../testPermeabilitySpecification.cpp | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp diff --git a/src/coreComponents/fieldSpecification/unitTests/CMakeLists.txt b/src/coreComponents/fieldSpecification/unitTests/CMakeLists.txt index 5a0f5dc9ad7..ea8999ddc4a 100644 --- a/src/coreComponents/fieldSpecification/unitTests/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/unitTests/CMakeLists.txt @@ -1,6 +1,7 @@ # Specify list of tests set( gtest_geosx_tests - testFieldSpecificationsEnums.cpp ) + testFieldSpecificationsEnums.cpp + testPermeabilitySpecification.cpp ) # Basic dependency list: fieldSpecification library plus gtest and parallel deps set( dependencyList ${parallelDeps} fieldSpecification gtest ) diff --git a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp new file mode 100644 index 00000000000..633af5cb2bb --- /dev/null +++ b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp @@ -0,0 +1,65 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 "fieldSpecification/PermeabilitySpecification.hpp" +#include "fieldSpecification/FieldSpecification.hpp" + +#include +#include + +using namespace geos; +using namespace dataRepository; + +namespace +{ + +void fillValidInput( PermeabilitySpecification & ps ) +{ + ps.getReference< string_array >( PermeabilitySpecification::viewKeyStruct::setNamesString() ) = { "all" }; + ps.getReference< string_array >( PermeabilitySpecification::viewKeyStruct::regionNamesString() ) = { "region1", "region2" }; + ps.getReference< string >( PermeabilitySpecification::viewKeyStruct::fieldNameString() ) = "rockPerm_permeability"; + array1d< real64 > & scales = ps.getReference< array1d< real64 > >( PermeabilitySpecification::viewKeyStruct::scalesString() ); + scales.resize( 3 ); + scales[0] = 9.869233e-16; + scales[1] = 9.869233e-16; + scales[2] = 9.869233e-16; +} + +} + +TEST( PermeabilitySpecificationTest, ExpansionPropagatesAttributes ) +{ + conduit::Node node; + Group rootGroup( "root", node ); + PermeabilitySpecification ps( "perm", &rootGroup ); + + fillValidInput( ps ); + + EXPECT_NO_THROW( ps.postInputInitializationRecursive() ); + + Group manager( "FieldSpecifications", &rootGroup ); + generateFieldSpecifications( ps, manager ); + + FieldSpecification const & fs = manager.getGroup< FieldSpecification >( "perm_region2" ); + + EXPECT_DOUBLE_EQ( fs.getScales()[0], 9.869233e-16 ); +} + + +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + return RUN_ALL_TESTS(); +} From 3e32d5705cf6adb70e2f5e332a648f07914f34eb Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Mon, 20 Jul 2026 09:34:11 +0200 Subject: [PATCH 23/39] add errorSetMode --- .../fieldSpecification/FieldSpecification.hpp | 7 ++++++ .../PermeabilitySpecification.cpp | 22 ++++++++++++++----- .../PermeabilitySpecification.hpp | 13 +++++++++++ src/coreComponents/schema/schema.xsd | 6 +++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp index e686c56ed56..8df1b265c7f 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -324,6 +324,13 @@ class FieldSpecification : public FieldSpecificationABC void setEndTime( real64 endTime ) { m_endTime = endTime; } + /** + * Mutator + * @param[in] errorSetMode Time after which the bc will no longer be applied. + */ + void setErrorSetMode( SetErrorMode const & errorSetMode ) + { m_emptySetErrorMode = errorSetMode; } + /** * @brief Get the Mesh Object Paths object * diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 00fe9f34a67..39742654b15 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -71,6 +71,17 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setApplyDefaultValue( 1.0e99 ). setInputFlag( InputFlags::OPTIONAL ). setDescription( "Time at which the boundary condition will stop being applied." ); + + registerWrapper( viewKeyStruct::errorSetModeString(), &m_emptySetErrorMode ). + setInputFlag( InputFlags::OPTIONAL ). + setApplyDefaultValue( FieldSpecification::SetErrorMode::error ). + setDescription( GEOS_FMT( "Set the log state when a “set” does not target any region\n" + "When set to \"{}\", no output.\n" + "When set to \"{}\", output a warning.\n" + "When set to \"{}\", output a throw.\n", + EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::silent ), + EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::warning ), + EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::error ) )); } @@ -90,15 +101,15 @@ void PermeabilitySpecification::postInputInitialization() } GEOS_THROW_IF( !m_functionNames.empty() && - m_functionNames.size() != 1 && - m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), - GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " + m_functionNames.size() != 1 && + m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), + GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", viewKeyStruct::functionNamesString(), m_functionNames.size(), viewKeyStruct::scalesString(), m_scales.size(), viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); + InputError, + getDataContext() ); GEOS_THROW_IF( m_beginTime > m_endTime, GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", @@ -130,6 +141,7 @@ void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpeci fs.setFunctionNames( ps.getFunctionNames() ); fs.setStartTime( ps.getStartTime() ); fs.setEndTime( ps.getEndTime() ); + fs.setErrorSetMode( ps.getErrorSetMode() ); for( auto const & setName : ps.getSetNames() ) { diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index af1a9e82e61..d64eb41dbf5 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -24,6 +24,7 @@ #include "common/DataTypes.hpp" #include "mesh/ObjectManagerBase.hpp" #include "mesh/MeshObjectPath.hpp" +#include "FieldSpecification.hpp" #include "FieldSpecificationABC.hpp" #include "FieldSpecificationFactory.hpp" @@ -101,6 +102,8 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * beginTimeString() { return "beginTime"; } /// @return The key for endTime constexpr static char const * endTimeString() { return "endTime"; } + /// @return The key errorSetMode + constexpr static char const * errorSetModeString() { return "errorSetMode"; } }; /** @@ -159,6 +162,13 @@ class PermeabilitySpecification : public FieldSpecificationABC real64 getEndTime() const { return m_endTime; } + /** + * Accessor + * @return const m_emptySetErrorMode + */ + FieldSpecification::SetErrorMode getErrorSetMode() const + { return m_emptySetErrorMode; } + protected: virtual void postInputInitialization() override; @@ -191,6 +201,9 @@ class PermeabilitySpecification : public FieldSpecificationABC /// Time after which the bc will no longer be applied. real64 m_endTime; + /// Enum containing the possible output modes when an error occur + FieldSpecification::SetErrorMode m_emptySetErrorMode; + }; /// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 2835ff92c31..2b8333f33e9 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1539,6 +1539,12 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set + + From 653bca12702ec66954bf0725ffd2ea563160ba90 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 24 Jul 2026 11:23:48 +0200 Subject: [PATCH 24/39] =?UTF-8?q?=F0=9F=9A=A7=20new=20design=20proposal=20?= =?UTF-8?q?"ProcessorRegistry":=20more=20scalable=20(no=20static=20list=20?= =?UTF-8?q?of=20types,=20only=20one=20REGISTER=5F*=20macro)=20+=20renaming?= =?UTF-8?q?=20generate->expand=20in=20case=20of=20more=20processing=20proc?= =?UTF-8?q?edures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FieldSpecificationFactory.cpp | 22 +---- .../FieldSpecificationFactory.hpp | 84 +++++++++++++++---- .../FieldSpecificationManager.cpp | 20 ++++- .../PermeabilitySpecification.cpp | 10 +-- .../PermeabilitySpecification.hpp | 5 +- .../testPermeabilitySpecification.cpp | 30 +++++-- 6 files changed, 119 insertions(+), 52 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp index c8440e7df5d..1599cc67a82 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.cpp @@ -18,30 +18,12 @@ */ #include "FieldSpecificationFactory.hpp" -#include "PermeabilitySpecification.hpp" namespace geos { -namespace -{ - -template< typename ... SPEC_TYPES, typename LAMBDA > -void forExpandableSpecifications( dataRepository::Group & manager, - types::TypeList< SPEC_TYPES... >, - LAMBDA && lambda ) -{ - manager.template forSubGroups< SPEC_TYPES... >( std::forward< LAMBDA >( lambda ) ); -} +using Registry = FieldSpecificationProcessorRegistry; -} - -void expandFieldSpecifications( dataRepository::Group & manager ) -{ - forExpandableSpecifications( manager, ExpandableSpecTypes{}, [&]( auto const & spec ) - { - generateFieldSpecifications( spec, manager ); - } ); -} +stdMap< string, Registry::ProcessorBase const * > Registry::s_processors; } // namespace geos diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp index c11e50357f0..adda1575d65 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -23,17 +23,11 @@ #include "common/TypeDispatch.hpp" #include "dataRepository/Group.hpp" +#include "FieldSpecificationABC.hpp" namespace geos { -class PermeabilitySpecification; - -/** - * @brief List of high-level field specifications to expand into FieldSpecification objects. - */ -using ExpandableSpecTypes = types::TypeList< PermeabilitySpecification >; - /** * @brief Generate FieldSpecifications based on the given "higher-level" specification * @tparam SPEC_TYPE The type of the high-level specification @@ -42,14 +36,76 @@ using ExpandableSpecTypes = types::TypeList< PermeabilitySpecification >; * @param manager The parent to store the created FieldSpecifications */ template< typename SPEC_TYPE > -void generateFieldSpecifications( SPEC_TYPE const & specification, dataRepository::Group & manager ) = delete; +void expandFieldSpecification( SPEC_TYPE const & fs, + dataRepository::Group & manager ) = delete; -/** - * @brief Expand high-level field specifications - * @param manager The manager group - * Expand all field specificiation listed in ExpandableSpecTypes - */ -void expandFieldSpecifications( dataRepository::Group & manager ); +class FieldSpecificationProcessorRegistry +{ +public: + + /** + * @brief + */ + class ProcessorBase + { +public: + /** + * @brief + * @param fs + * @param manager + */ + virtual void expandFieldSpecification( FieldSpecificationABC const & fs, + dataRepository::Group & GEOS_UNUSED_PARAM( manager ) ) const + { GEOS_ERROR( GEOS_FMT( "Processor not implemented for field specification of type '{}'.", fs.getCatalogName() ), fs.getDataContext() ); } +protected: + ProcessorBase() {} + }; + + /** + * @brief + */ + template< typename SPEC_TYPE > + class Processor final : public ProcessorBase + { +public: + + /** + * @brief Add the processors to the static list. Called before main() when a + * REGISTER_FIELD_SPECIFICATION_PROCESSOR( SPEC_TYPE ) is in a cpp. + */ + Processor(): ProcessorBase() + { s_processors.emplace( SPEC_TYPE::catalogName(), this ); } + + /** + * @brief Call the specialized geos::expandFieldSpecification() template function + * @param fs + * @param manager + */ + void expandFieldSpecification( FieldSpecificationABC const & fs, + dataRepository::Group & manager ) const override + { geos::expandFieldSpecification( dynamic_cast< SPEC_TYPE const & >(fs), manager ); } + }; + + /** + * @return the list of field specification processors. + */ + static stdMap< string, ProcessorBase const * > const & getProcessors() + { return s_processors; } + + +private: + + /** + * @brief Storage of field specification processors. + */ + static stdMap< string, ProcessorBase const * > s_processors; + +}; + +#define REGISTER_FIELD_SPECIFICATION_PROCESSOR( SPEC_TYPE ) \ + namespace { \ + GEOS_MAYBE_UNUSED FieldSpecificationProcessorRegistry::Processor< SPEC_TYPE > g_processorOf ## SPEC_TYPE; \ + } } // namespace geos diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index af30af68166..b7ad418b832 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -71,7 +71,25 @@ void FieldSpecificationManager::expandObjectCatalogs() void FieldSpecificationManager::postInputInitialization() { - expandFieldSpecifications( *this ); + using ProcessorRegistry = FieldSpecificationProcessorRegistry; + + // as the subgroup list can change during expansion, we need an immutable list + stdVector< FieldSpecificationABC const * > fieldSpecifications; + this->forSubGroups< FieldSpecificationABC >( [&] ( FieldSpecificationABC const & fs ) + { + fieldSpecifications.push_back( &fs ); + } ); + + for( FieldSpecificationABC const * fs : fieldSpecifications ) + { + auto const & processors = ProcessorRegistry::getProcessors(); + auto it = processors.find( fs->getCatalogName()); + if( it != processors.end()) + { + ProcessorRegistry::ProcessorBase const & processor = *it->second; + processor.expandFieldSpecification( *fs, *this ); + } + } } void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 39742654b15..0c17fd4b7e8 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -120,12 +120,9 @@ void PermeabilitySpecification::postInputInitialization() getDataContext() ); } - -REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) - template<> -void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpecification const & ps, - dataRepository::Group & manager ) +void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecification const & ps, + dataRepository::Group & manager ) { for( string const & regionName : ps.getRegionNames() ) { @@ -150,4 +147,7 @@ void generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpeci } } +REGISTER_CATALOG_ENTRY( FieldSpecificationABC, PermeabilitySpecification, string const &, Group * const ) +REGISTER_FIELD_SPECIFICATION_PROCESSOR( PermeabilitySpecification ) + } diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index d64eb41dbf5..4b818baba2f 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -208,9 +208,8 @@ class PermeabilitySpecification : public FieldSpecificationABC /// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications template<> -void -generateFieldSpecifications< PermeabilitySpecification >( PermeabilitySpecification const & specification, - dataRepository::Group & manager ); +void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecification const & fs, + dataRepository::Group & manager ); } diff --git a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp index 633af5cb2bb..3f390efd06a 100644 --- a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp @@ -14,7 +14,7 @@ */ #include "fieldSpecification/PermeabilitySpecification.hpp" -#include "fieldSpecification/FieldSpecification.hpp" +#include "fieldSpecification/FieldSpecificationManager.hpp" #include #include @@ -41,20 +41,32 @@ void fillValidInput( PermeabilitySpecification & ps ) TEST( PermeabilitySpecificationTest, ExpansionPropagatesAttributes ) { + using ProcessorRegistry = FieldSpecificationProcessorRegistry; + conduit::Node node; - Group rootGroup( "root", node ); - PermeabilitySpecification ps( "perm", &rootGroup ); + Group root( "root", node ); + + FieldSpecificationManager manager( "FieldSpecifications", &root ); + root.registerGroup( manager.getName(), &manager ); + + PermeabilitySpecification permSpec( "permSpec", &manager ); + manager.registerGroup( permSpec.getName(), &permSpec ); - fillValidInput( ps ); - EXPECT_NO_THROW( ps.postInputInitializationRecursive() ); + fillValidInput( permSpec ); - Group manager( "FieldSpecifications", &rootGroup ); - generateFieldSpecifications( ps, manager ); + // verify that the permeability specification processor exists + EXPECT_NE( ProcessorRegistry::getProcessors().find( PermeabilitySpecification::catalogName() ), + ProcessorRegistry::getProcessors().end() ) << GEOS_FMT( "Processor of {} does not exist", PermeabilitySpecification::catalogName() ); - FieldSpecification const & fs = manager.getGroup< FieldSpecification >( "perm_region2" ); + // indirectly call postInputInitialization() -> expandFieldSpecification() on permSpec + EXPECT_NO_THROW( root.postInputInitializationRecursive() ); - EXPECT_DOUBLE_EQ( fs.getScales()[0], 9.869233e-16 ); + FieldSpecification const * generatedFS = manager.getGroupPointer< FieldSpecification >( "permSpec_region2" ); + // verify that the generated ("expanded") field specification exists + EXPECT_NE( generatedFS, nullptr ) << "Field specification has not been generated."; + // verify that the scale values have been well applied on the generated ("expanded") field specification + EXPECT_DOUBLE_EQ( generatedFS->getScales()[0], 9.869233e-16 ); } From 5b5851d48f6770448ffae77118e2339d7f636128 Mon Sep 17 00:00:00 2001 From: MelReyCG Date: Fri, 24 Jul 2026 11:30:50 +0200 Subject: [PATCH 25/39] =?UTF-8?q?=F0=9F=9A=A7=20proposal=20to=20reference?= =?UTF-8?q?=20the=20original=20DataContext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coreComponents/dataRepository/Group.cpp | 5 ++++ src/coreComponents/dataRepository/Group.hpp | 6 +++++ .../dataRepository/GroupContext.cpp | 4 +-- .../dataRepository/GroupContext.hpp | 20 +++++++------- .../FieldSpecificationManager.cpp | 8 ++++-- .../PermeabilitySpecification.cpp | 26 ++++++++++--------- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/src/coreComponents/dataRepository/Group.cpp b/src/coreComponents/dataRepository/Group.cpp index a0ef81eac96..ee2d6d26574 100644 --- a/src/coreComponents/dataRepository/Group.cpp +++ b/src/coreComponents/dataRepository/Group.cpp @@ -140,6 +140,11 @@ string Group::getPath() const return noProblem.empty() ? "/" : noProblem; } +void Group::setDataContextReference( Group const & referencedGroup ) +{ + m_dataContext = std::make_unique< GroupContext >( referencedGroup, getName() ); +} + string Group::processInputName( xmlWrapper::xmlNode const & targetNode, xmlWrapper::xmlNodePos const & targetNodePos, string_view parentNodeName, diff --git a/src/coreComponents/dataRepository/Group.hpp b/src/coreComponents/dataRepository/Group.hpp index 54460ef9713..2823ce630f9 100644 --- a/src/coreComponents/dataRepository/Group.hpp +++ b/src/coreComponents/dataRepository/Group.hpp @@ -1343,6 +1343,12 @@ class Group DataContext const & getDataContext() const { return *m_dataContext; } + /** + * @brief Allow to define a different data context for the instance, typically when we want to show another + * group when an error occurs. + */ + void setDataContextReference( Group const & referencedGroup ); + /** * @return DataContext object that that stores contextual information on a wrapper contained by * this group that can be used in output messages. diff --git a/src/coreComponents/dataRepository/GroupContext.cpp b/src/coreComponents/dataRepository/GroupContext.cpp index 04e1fa1f2a3..c359531cdf1 100644 --- a/src/coreComponents/dataRepository/GroupContext.cpp +++ b/src/coreComponents/dataRepository/GroupContext.cpp @@ -25,11 +25,11 @@ namespace dataRepository { -GroupContext::GroupContext( Group & group, string_view objectName ): +GroupContext::GroupContext( Group const & group, string_view objectName ): DataContext( objectName ), m_group( group ) {} -GroupContext::GroupContext( Group & group ): +GroupContext::GroupContext( Group const & group ): GroupContext( group, group.getName() ) {} diff --git a/src/coreComponents/dataRepository/GroupContext.hpp b/src/coreComponents/dataRepository/GroupContext.hpp index abdc1199e7d..fbbef67f56b 100644 --- a/src/coreComponents/dataRepository/GroupContext.hpp +++ b/src/coreComponents/dataRepository/GroupContext.hpp @@ -43,7 +43,14 @@ class GroupContext : public DataContext * @brief Construct a new GroupContext object * @param group The reference to the Group related to this GroupContext. */ - GroupContext( Group & group ); + GroupContext( Group const & group ); + + /** + * @brief Construct a new GroupContext object + * @param group The reference to the Group related to this GroupContext. + * @param objectName Target object name. + */ + GroupContext( Group const & group, string_view objectName ); /** * @return the reference to the Group related to this GroupContext. @@ -52,15 +59,10 @@ class GroupContext : public DataContext protected: - /** - * @brief Construct a new GroupContext object - * @param group The reference to the Group related to this GroupContext. - * @param objectName Target object name. - */ - GroupContext( Group & group, string_view objectName ); - /// The reference to the Group related to this GroupContext. - Group & m_group; + Group const & m_group; + + // TODO : DataContext const * referencedDataContext private: diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index b7ad418b832..7d8a583d5db 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -77,17 +77,21 @@ void FieldSpecificationManager::postInputInitialization() stdVector< FieldSpecificationABC const * > fieldSpecifications; this->forSubGroups< FieldSpecificationABC >( [&] ( FieldSpecificationABC const & fs ) { - fieldSpecifications.push_back( &fs ); + fieldSpecifications.push_back(&fs); } ); - for( FieldSpecificationABC const * fs : fieldSpecifications ) + for (FieldSpecificationABC const * fs : fieldSpecifications) { + GEOS_LOG( GEOS_FMT( "----- Processing {}", fs->getName())); auto const & processors = ProcessorRegistry::getProcessors(); auto it = processors.find( fs->getCatalogName()); if( it != processors.end()) { + GEOS_LOG( GEOS_FMT( " - Found Processor {}", it->first )); ProcessorRegistry::ProcessorBase const & processor = *it->second; processor.expandFieldSpecification( *fs, *this ); + } else { + GEOS_LOG( GEOS_FMT( " - NO PROCESSOR !! {}", it->first )); } } } diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 0c17fd4b7e8..aaab30c062d 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -121,26 +121,28 @@ void PermeabilitySpecification::postInputInitialization() } template<> -void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecification const & ps, +void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecification const & permSpec, dataRepository::Group & manager ) { - for( string const & regionName : ps.getRegionNames() ) + for( string const & regionName : permSpec.getRegionNames() ) { string const objectPath = "ElementRegions/" + regionName; - string const childName = ps.getName() + "_" + regionName; + // todo encapsulate in a function + string const childName = permSpec.getName() + "_" + regionName; FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); - fs.setFieldName( ps.getFieldName() ); + fs.setDataContextReference( permSpec ); + fs.setFieldName( permSpec.getFieldName() ); fs.setObjectPath( objectPath ); - fs.initialCondition( ps.initialCondition() ); - fs.setScales( ps.getScales() ); - fs.setFunctionNames( ps.getFunctionNames() ); - fs.setStartTime( ps.getStartTime() ); - fs.setEndTime( ps.getEndTime() ); - fs.setErrorSetMode( ps.getErrorSetMode() ); - - for( auto const & setName : ps.getSetNames() ) + fs.initialCondition( permSpec.initialCondition() ); + fs.setScales( permSpec.getScales() ); + fs.setFunctionNames( permSpec.getFunctionNames() ); + fs.setStartTime( permSpec.getStartTime() ); + fs.setEndTime( permSpec.getEndTime() ); + fs.setErrorSetMode( permSpec.getErrorSetMode() ); + + for( auto const & setName : permSpec.getSetNames() ) { fs.addSetName( setName ); } From b3c9a8cb1e3b8c00bc08e1f78044538a8f3648de Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 28 Jul 2026 15:49:22 +0200 Subject: [PATCH 26/39] fix/accept new design proposal "ProcessorRegistry" --- .../FieldSpecificationFactory.hpp | 22 +++++++++---------- .../FieldSpecificationManager.cpp | 4 ++-- .../PermeabilitySpecification.cpp | 1 - .../testPermeabilitySpecification.cpp | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp index adda1575d65..09c31d5d88b 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationFactory.hpp @@ -31,8 +31,7 @@ namespace geos /** * @brief Generate FieldSpecifications based on the given "higher-level" specification * @tparam SPEC_TYPE The type of the high-level specification - * @param specification The high-level specification used as a blueprint - * to create FieldSpecification + * @param fs The high-level specification used as a blueprint to create FieldSpecification * @param manager The parent to store the created FieldSpecifications */ template< typename SPEC_TYPE > @@ -44,15 +43,17 @@ class FieldSpecificationProcessorRegistry public: /** - * @brief + * @brief Base Processor class for transforming "high-level" specification + * into FieldSpecification(s) */ class ProcessorBase { public: /** - * @brief - * @param fs - * @param manager + * @brief Generate FieldSpecifications based on the given "higher-level" specification + * @tparam SPEC_TYPE The type of the high-level specification + * @param fs The high-level specification used as a blueprint to create FieldSpecification + * @param manager The parent to store the created FieldSpecifications */ virtual void expandFieldSpecification( FieldSpecificationABC const & fs, dataRepository::Group & GEOS_UNUSED_PARAM( manager ) ) const @@ -62,7 +63,8 @@ class FieldSpecificationProcessorRegistry }; /** - * @brief + * @brief Class for a specific "high-level" specification type to process its objects + * into one or multiple equivalent FieldSpecification */ template< typename SPEC_TYPE > class Processor final : public ProcessorBase @@ -77,13 +79,11 @@ class FieldSpecificationProcessorRegistry { s_processors.emplace( SPEC_TYPE::catalogName(), this ); } /** - * @brief Call the specialized geos::expandFieldSpecification() template function - * @param fs - * @param manager + * @copydoc ProcessorBase::expandFieldSpecification */ void expandFieldSpecification( FieldSpecificationABC const & fs, dataRepository::Group & manager ) const override - { geos::expandFieldSpecification( dynamic_cast< SPEC_TYPE const & >(fs), manager ); } + { geos::expandFieldSpecification( dynamic_cast< SPEC_TYPE const & >( fs ), manager ); } }; /** diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 7d8a583d5db..1f4808e039a 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -77,13 +77,13 @@ void FieldSpecificationManager::postInputInitialization() stdVector< FieldSpecificationABC const * > fieldSpecifications; this->forSubGroups< FieldSpecificationABC >( [&] ( FieldSpecificationABC const & fs ) { - fieldSpecifications.push_back(&fs); + fieldSpecifications.push_back( &fs ); } ); + auto const & processors = ProcessorRegistry::getProcessors(); for (FieldSpecificationABC const * fs : fieldSpecifications) { GEOS_LOG( GEOS_FMT( "----- Processing {}", fs->getName())); - auto const & processors = ProcessorRegistry::getProcessors(); auto it = processors.find( fs->getCatalogName()); if( it != processors.end()) { diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index aaab30c062d..0cd20f8d452 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -128,7 +128,6 @@ void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecific { string const objectPath = "ElementRegions/" + regionName; - // todo encapsulate in a function string const childName = permSpec.getName() + "_" + regionName; FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); diff --git a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp index 3f390efd06a..20cdc6499c7 100644 --- a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp @@ -48,7 +48,7 @@ TEST( PermeabilitySpecificationTest, ExpansionPropagatesAttributes ) FieldSpecificationManager manager( "FieldSpecifications", &root ); root.registerGroup( manager.getName(), &manager ); - + PermeabilitySpecification permSpec( "permSpec", &manager ); manager.registerGroup( permSpec.getName(), &permSpec ); From fc40a838a35d692c07eddb791c75876990e3f53d Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Tue, 28 Jul 2026 16:46:45 +0200 Subject: [PATCH 27/39] add component attribute --- .../PermeabilitySpecification.cpp | 14 ++++++++++++++ .../PermeabilitySpecification.hpp | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 0cd20f8d452..76be833e78b 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -46,6 +46,12 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setDescription( "Name of field that boundary condition is applied to.\n" "A field can represent a physical variable. (pressure, temperature, global composition fraction of the fluid, ...)" ); + registerWrapper( viewKeyStruct::componentString(), &m_component ). + setApplyDefaultValue( -1 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Component of field (if tensor) to apply boundary condition to.\n" + "The component must use the order in which the phaseNames have been defined in the Constitutive Element." ); + registerWrapper( viewKeyStruct::initialConditionString(), &m_initialCondition ). setApplyDefaultValue( 1 ). setInputFlag( InputFlags::OPTIONAL ). @@ -111,6 +117,13 @@ void PermeabilitySpecification::postInputInitialization() InputError, getDataContext() ); + GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, + GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", + viewKeyStruct::componentString(), + viewKeyStruct::scalesString() ), + InputError, + getDataContext() ); + GEOS_THROW_IF( m_beginTime > m_endTime, GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", viewKeyStruct::beginTimeString(), m_beginTime, @@ -133,6 +146,7 @@ void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecific FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); fs.setDataContextReference( permSpec ); fs.setFieldName( permSpec.getFieldName() ); + fs.setComponent( permSpec.getComponent() ); fs.setObjectPath( objectPath ); fs.initialCondition( permSpec.initialCondition() ); fs.setScales( permSpec.getScales() ); diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 4b818baba2f..456172d49b7 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -92,6 +92,8 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * regionNamesString() { return "regionNames"; } /// @return The key for fieldName constexpr static char const * fieldNameString() { return "fieldName"; } + /// @return The key for component + constexpr static char const * componentString() { return "component"; } /// @return The key for initialCondition constexpr static char const * initialConditionString() { return "initialCondition"; } /// @return The key for functionNames @@ -127,6 +129,13 @@ class PermeabilitySpecification : public FieldSpecificationABC virtual const string & getFieldName() const { return m_fieldName; } + /** + * Accessing the considered component. + * @return The component axis or a special value. + */ + virtual int getComponent() const + { return m_component; } + /** * Accessor * @return const reference to m_setNames @@ -186,6 +195,9 @@ class PermeabilitySpecification : public FieldSpecificationABC /// determining whether or not to apply the boundary condition. string m_fieldName; + /// The component the boundary condition acts on. Not used if field is a scalar. + int m_component; + /// Whether or not the boundary condition is an initial condition. int m_initialCondition; From 59c31c56ddd1d3e9d26943ac9aa38de2f25c4ebe Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 10:46:10 +0200 Subject: [PATCH 28/39] fix/accept reference to original DataContext --- src/coreComponents/dataRepository/GroupContext.hpp | 2 -- .../fieldSpecification/FieldSpecificationManager.cpp | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/coreComponents/dataRepository/GroupContext.hpp b/src/coreComponents/dataRepository/GroupContext.hpp index fbbef67f56b..d46867289f6 100644 --- a/src/coreComponents/dataRepository/GroupContext.hpp +++ b/src/coreComponents/dataRepository/GroupContext.hpp @@ -62,8 +62,6 @@ class GroupContext : public DataContext /// The reference to the Group related to this GroupContext. Group const & m_group; - // TODO : DataContext const * referencedDataContext - private: /** diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 1f4808e039a..888478ec1ff 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -81,17 +81,13 @@ void FieldSpecificationManager::postInputInitialization() } ); auto const & processors = ProcessorRegistry::getProcessors(); - for (FieldSpecificationABC const * fs : fieldSpecifications) + for( FieldSpecificationABC const * fs : fieldSpecifications ) { - GEOS_LOG( GEOS_FMT( "----- Processing {}", fs->getName())); auto it = processors.find( fs->getCatalogName()); if( it != processors.end()) { - GEOS_LOG( GEOS_FMT( " - Found Processor {}", it->first )); ProcessorRegistry::ProcessorBase const & processor = *it->second; processor.expandFieldSpecification( *fs, *this ); - } else { - GEOS_LOG( GEOS_FMT( " - NO PROCESSOR !! {}", it->first )); } } } From de243978933f122701b1834863220ed26619cd9c Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 11:16:19 +0200 Subject: [PATCH 29/39] modify a case with a PermeabilitySpecification --- ...eTwoPhase_SPE10_layer84_base_iterative.xml | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml index 3413d47ef4d..408124daae4 100644 --- a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml +++ b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml @@ -91,33 +91,13 @@ - - - + functionNames="{ permxFunc, permyFunc, permzFunc }" + scales="{ 9.869233e-16, 9.869233e-16, 9.869233e-16 }"/> Date: Wed, 29 Jul 2026 14:08:40 +0200 Subject: [PATCH 30/39] update FieldSpecificationABC description Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com> --- src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index b6262004884..2f920f40af0 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -34,7 +34,7 @@ class Function; /** * @class FieldSpecificationABC * - * Abstract Base Class grouping multiple types of field specifications. + * Abstract Base Class for concrete field modifiers (`FieldSpecification`) and high-level user-defined field specification. */ class FieldSpecificationABC : public dataRepository::Group { From 5d1644aa415efdc124e5eab3bd86fc3941997f08 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 15:34:48 +0200 Subject: [PATCH 31/39] add check for valid cell region --- .../PermeabilitySpecification.cpp | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 76be833e78b..4a92948963d 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -17,6 +17,7 @@ #include "FieldSpecification.hpp" #include "FieldSpecificationFactory.hpp" #include "common/logger/Logger.hpp" +#include "mesh/DomainPartition.hpp" namespace geos { @@ -38,7 +39,7 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group registerWrapper( viewKeyStruct::regionNamesString(), &m_regionNames ). setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). setInputFlag( InputFlags::REQUIRED ). - setDescription( "Names of the regions that boundary condition is applied to." ); + setDescription( "Names of the cell regions that boundary condition is applied to." ); registerWrapper( viewKeyStruct::fieldNameString(), &m_fieldName ). setRTTypeName( rtTypes::CustomTypes::groupNameRef ). @@ -133,14 +134,74 @@ void PermeabilitySpecification::postInputInitialization() getDataContext() ); } +namespace +{ + +/** + * @brief @return The element region named @p regionName in the domain if it exists, or a nullptr + */ +ElementRegionBase const * findElementRegion( DomainPartition const & domain, + string const & regionName ) +{ + ElementRegionBase const * region = nullptr; + domain.forMeshBodies( [&]( MeshBody const & meshBody ) + { + meshBody.forMeshLevels( [&]( MeshLevel const & meshLevel ) + { + if( region == nullptr && meshLevel.getElemManager().hasRegion( regionName ) ) + { + region = &meshLevel.getElemManager().getRegion( regionName ); + } + } ); + } ); + return region; +} + +/** + * @brief Validate that a region with the name @p regionName exists and is a valid cell region + * @param domain The domain + * @param regionName The name of the region to validated + * @param permSpec Reference to the current object to print its DataContext + * @note Throws if the region doesn't exists or isn't a cell region + */ +void expectValidCellRegion( DomainPartition const & domain, + string const & fullRegionName, + PermeabilitySpecification const & permSpec ) +{ + // get only region from "region/subregion" + string const regionName = fullRegionName.substr( 0, fullRegionName.find( '/' ) ); + + ElementRegionBase const * const region = findElementRegion( domain, regionName ); + + GEOS_THROW_IF( region == nullptr, + GEOS_FMT( "Region '{}' does not exist.", regionName ), + InputError, + permSpec.getDataContext() ); + + GEOS_THROW_IF( dynamic_cast< CellElementRegion const * >( region ) == nullptr, + GEOS_FMT( "Region '{}' is a '{}', but must be a '{}'", + regionName, + region->getCatalogName(), + CellElementRegion::catalogName() ), + InputError, + permSpec.getDataContext() ); +} + +} + + template<> void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecification const & permSpec, dataRepository::Group & manager ) { + Group const & problem = manager.getParent(); + DomainPartition const & domain = problem.getGroup< DomainPartition >( "domain" ); + for( string const & regionName : permSpec.getRegionNames() ) { - string const objectPath = "ElementRegions/" + regionName; + expectValidCellRegion( domain, regionName, permSpec ); + string const objectPath = "ElementRegions/" + regionName; string const childName = permSpec.getName() + "_" + regionName; FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); From 9cfecaf8d2fdb4b63c10361d1eeb741ee9b671cf Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 16:48:16 +0200 Subject: [PATCH 32/39] move common methods to FieldSpecificationABC --- ...eTwoPhase_SPE10_layer84_base_iterative.xml | 4 +- .../fieldSpecification/FieldSpecification.cpp | 63 +----- .../fieldSpecification/FieldSpecification.hpp | 173 +---------------- .../FieldSpecificationABC.cpp | 62 +++++- .../FieldSpecificationABC.hpp | 180 +++++++++++++++++- .../PermeabilitySpecification.cpp | 59 +----- .../PermeabilitySpecification.hpp | 74 +------ src/coreComponents/schema/schema.xsd | 31 +-- 8 files changed, 276 insertions(+), 370 deletions(-) diff --git a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml index 408124daae4..b2d17b5d132 100644 --- a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml +++ b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml @@ -96,8 +96,8 @@ setNames="{ all }" regionNames="reservoir/block" fieldName="rockPerm_permeability" - functionNames="{ permxFunc, permyFunc, permzFunc }" - scales="{ 9.869233e-16, 9.869233e-16, 9.869233e-16 }"/> + functionName="{ permxFunc, permyFunc, permzFunc }" + scale="{ 9.869233e-16, 9.869233e-16, 9.869233e-16 }"/> ::toString( SetErrorMode::silent ), - EnumStrings< SetErrorMode >::toString( SetErrorMode::warning ), - EnumStrings< SetErrorMode >::toString( SetErrorMode::error ) )); } @@ -106,25 +70,14 @@ FieldSpecification::getCatalog() void FieldSpecification::postInputInitialization() { - { // both conditions work together - GEOS_THROW_IF( !m_functionNames.empty() && - m_functionNames.size() != 1 && - m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), - GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " - "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", - viewKeyStruct::functionNamesString(), m_functionNames.size(), - viewKeyStruct::scalesString(), m_scales.size(), - viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); - - GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, - GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", - viewKeyStruct::componentString(), - viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); - } + FieldSpecificationABC::postInputInitialization(); + + GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, + GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", + viewKeyStruct::componentString(), + viewKeyStruct::scalesString() ), + InputError, + getDataContext() ); } void FieldSpecification::validateNumArrayComp( localIndex numComp ) diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp index 8df1b265c7f..deef45de9c5 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -22,8 +22,6 @@ #include "common/DataTypes.hpp" -#include "common/format/EnumStrings.hpp" -#include "dataRepository/Group.hpp" #include "fieldSpecification/FieldSpecificationABC.hpp" #include "mesh/MeshObjectPath.hpp" @@ -51,16 +49,9 @@ class FieldSpecification : public FieldSpecificationABC using CatalogInterface = dataRepository::CatalogInterface< FieldSpecification, string const &, dataRepository::Group * const >; - /** - * @enum SetErrorMode - * @brief Indicate the error handling mode. - */ - enum class SetErrorMode : integer - { - silent, - error, - warning - }; + + // @copydoc FieldSpecificationABC::SetErrorMode + using SetErrorMode = FieldSpecificationABC::SetErrorMode; /** * @brief static function to return static catalog. @@ -114,7 +105,7 @@ class FieldSpecification : public FieldSpecificationABC /** * @brief View keys */ - struct viewKeyStruct + struct viewKeyStruct : public FieldSpecificationABC::viewKeyStruct { /// @return The key for setName constexpr static char const * setNamesString() { return "setNames"; } @@ -130,43 +121,8 @@ class FieldSpecification : public FieldSpecificationABC constexpr static char const * componentString() { return "component"; } /// @return The key for direction constexpr static char const * directionString() { return "direction"; } - /// @return The key for scale - constexpr static char const * scalesString() { return "scale"; } - /// @return The key for functionName - constexpr static char const * functionNamesString() { return "functionName"; } - /// @return The key for initialCondition - constexpr static char const * initialConditionString() { return "initialCondition"; } - /// @return The key for beginTime - constexpr static char const * beginTimeString() { return "beginTime"; } - /// @return The key for endTime - constexpr static char const * endTimeString() { return "endTime"; } - /// @return The key errorSetMode - constexpr static char const * errorSetModeString() { return "errorSetMode"; } }; - /** - * Accessor - * @return first entry of m_functionNames, or an empty string if empty - * - * @note Legacy scalar accessor. - * Use getFunctionNames() to access the full list of function names when using non-scalar - * field specifications (eg. functionName="{ f1, f2, f3 }") - */ - string const & getFunctionName() const - { - static string const emptyName; - return m_functionNames.empty() ? emptyName : m_functionNames.front(); - } - - /** - * Accessor - * @return const reference to m_functionNames - */ - string_array const & getFunctionNames() const - { - return m_functionNames; - } - /** * Accessor * @return const reference to m_objectPath @@ -195,20 +151,6 @@ class FieldSpecification : public FieldSpecificationABC virtual R1Tensor const & getDirection() const { return m_direction; } - /** - * Accessor - * @return const m_beginTime - */ - real64 getStartTime() const - { return m_beginTime; } - - /** - * Accessor - * @return const m_endTime - */ - real64 getEndTime() const - { return m_endTime; } - /** * Accessor * @return const reference to m_setNames @@ -216,31 +158,6 @@ class FieldSpecification : public FieldSpecificationABC string_array const & getSetNames() const { return m_setNames; } - /** - * Accessor - * @return const m_initialCondition - */ - int initialCondition() const - { return m_initialCondition; } - - /** - * Accessor - * @return first entry of m_scales, or 0 if m_scales is empty - * - * @note Legacy scalar accessor. - * Use getScales() to access the full list of scales when using non-scalar - * field specifications (eg. scales="{ 1, 2, 3 }") - */ - real64 getScale() const - { return m_scales.empty() ? 0.0 : m_scales.front(); } - - /** - * Accessor - * @return const m_scales - */ - arrayView1d< real64 const > getScales() const - { return m_scales.toViewConst(); } - /** * Mutator * @param[in] fieldName The name of the field @@ -262,40 +179,6 @@ class FieldSpecification : public FieldSpecificationABC void setObjectPath( string const & objectPath ) { m_objectPath = objectPath; } - /** - * Mutator - * @param[in] scale Scaling factor - */ - void setScale( real64 const & scale ) - { - m_scales.resize( 1 ); - m_scales[ 0 ] = scale; - } - - /** - * Mutator - * @brief Set the per-component scale factors - * @param[in] scales The tensor-valued scale - */ - void setScales( array1d< real64 > const & scales ) - { m_scales = scales; } - - /** - * Mutator - * @brief Set the per-component function names - * @param[in] functionNames The per-component function names. Must either be empty, - * have a single entry, or be sized exactly as @p m_scales - */ - void setFunctionNames( string_array const & functionNames ) - { m_functionNames = functionNames; } - - /** - * Mutator - * @param[in] isInitialCondition Logical value to indicate if it is an initial condition - */ - void initialCondition( bool isInitialCondition ) - { m_initialCondition = isInitialCondition; } - /** * Mutator * @param[in] setName The name of the set @@ -310,27 +193,6 @@ class FieldSpecification : public FieldSpecificationABC */ void setMeshObjectPath( Group const & meshBodies ); - /** - * Mutator - * @param[in] beginTime Time after which the bc is allowed to be applied - */ - void setStartTime( real64 beginTime ) - { m_beginTime = beginTime; } - - /** - * Mutator - * @param[in] endTime Time after which the bc will no longer be applied. - */ - void setEndTime( real64 endTime ) - { m_endTime = endTime; } - - /** - * Mutator - * @param[in] errorSetMode Time after which the bc will no longer be applied. - */ - void setErrorSetMode( SetErrorMode const & errorSetMode ) - { m_emptySetErrorMode = errorSetMode; } - /** * @brief Get the Mesh Object Paths object * @@ -374,40 +236,13 @@ class FieldSpecification : public FieldSpecificationABC /// determining whether or not to apply the boundary condition. string m_fieldName; - /// The component the boundary condition acts on. Not used if field is a scalar. int m_component; /// The direction the boundary condition acts in. R1Tensor m_direction; - - /// Whether or not the boundary condition is an initial condition. - int m_initialCondition; - - /// Name(s) of the function used to generate values for application. - string_array m_functionNames; - - /// Scale factor(s) to use on the value of the boundary condition. - array1d< real64 > m_scales; - - /// Time after which the bc is allowed to be applied - real64 m_beginTime; - - /// Time after which the bc will no longer be applied. - real64 m_endTime; - - /// Enum containing the possible output modes when an error occur - SetErrorMode m_emptySetErrorMode; }; -/** - * @brief Indicate the error handling mode - */ -ENUM_STRINGS( FieldSpecification::SetErrorMode, - "silent", - "error", - "warning" ); - } #endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATION_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp index 5d5a38d6704..fd287de5ea3 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp @@ -21,7 +21,44 @@ using namespace dataRepository; FieldSpecificationABC::FieldSpecificationABC( string const & name, Group * parent ): Group( name, parent ) -{} +{ + registerWrapper( viewKeyStruct::functionNamesString(), &m_functionNames ). + setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Name(s) of function(s) that specifies variation of the boundary condition." ); + + registerWrapper( viewKeyStruct::scalesString(), &m_scales ). + setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::OPTIONAL ). + setSizedFromParent( 0 ). + setDescription( "Apply scaling factor(s) for the value(s) of the boundary condition." ); + + registerWrapper( viewKeyStruct::initialConditionString(), &m_initialCondition ). + setApplyDefaultValue( 0 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Boundary condition is applied as an initial condition." ); + + registerWrapper( viewKeyStruct::beginTimeString(), &m_beginTime ). + setApplyDefaultValue( -1.0e99 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Time at which the boundary condition will start being applied." ); + + registerWrapper( viewKeyStruct::endTimeString(), &m_endTime ). + setApplyDefaultValue( 1.0e99 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Time at which the boundary condition will stop being applied." ); + + registerWrapper( viewKeyStruct::errorSetModeString(), &m_emptySetErrorMode ). + setInputFlag( InputFlags::OPTIONAL ). + setApplyDefaultValue( SetErrorMode::error ). + setDescription( GEOS_FMT( "Set the log state when a “set” does not target any region\n" + "When set to \"{}\", no output.\n" + "When set to \"{}\", output a warning.\n" + "When set to \"{}\", output a throw.\n", + EnumStrings< SetErrorMode >::toString( SetErrorMode::silent ), + EnumStrings< SetErrorMode >::toString( SetErrorMode::warning ), + EnumStrings< SetErrorMode >::toString( SetErrorMode::error ) )); +} FieldSpecificationABC::~FieldSpecificationABC() {} @@ -33,4 +70,27 @@ FieldSpecificationABC::getCatalog() return catalog; } + +void FieldSpecificationABC::postInputInitialization() +{ + GEOS_THROW_IF( !m_functionNames.empty() && + m_functionNames.size() != 1 && + m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), + GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " + "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", + viewKeyStruct::functionNamesString(), m_functionNames.size(), + viewKeyStruct::scalesString(), m_scales.size(), + viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), + InputError, + getDataContext() ); + + GEOS_THROW_IF( m_beginTime > m_endTime, + GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", + viewKeyStruct::beginTimeString(), m_beginTime, + viewKeyStruct::endTimeString(), m_endTime, + getCatalogName(), getName() ), + InputError, + getDataContext() ); +} + } diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 2f920f40af0..05555eddc02 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -22,6 +22,7 @@ #include "common/DataTypes.hpp" +#include "common/format/EnumStrings.hpp" #include "dataRepository/Group.hpp" #include "functions/FunctionBase.hpp" #include "functions/FunctionManager.hpp" @@ -52,6 +53,17 @@ class FieldSpecificationABC : public dataRepository::Group string const &, dataRepository::Group * const >; + /** + * @enum SetErrorMode + * @brief Indicate the error handling mode. + */ + enum class SetErrorMode : integer + { + silent, + error, + warning + }; + /** * @brief static function to return static catalog. * @return the static catalog to create derived types through the static factory methods. @@ -98,10 +110,176 @@ class FieldSpecificationABC : public dataRepository::Group * @brief View keys */ struct viewKeyStruct - {}; + { + /// @return The key for scale + constexpr static char const * scalesString() { return "scale"; } + /// @return The key for functionName + constexpr static char const * functionNamesString() { return "functionName"; } + /// @return The key for initialCondition + constexpr static char const * initialConditionString() { return "initialCondition"; } + /// @return The key for beginTime + constexpr static char const * beginTimeString() { return "beginTime"; } + /// @return The key for endTime + constexpr static char const * endTimeString() { return "endTime"; } + /// @return The key errorSetMode + constexpr static char const * errorSetModeString() { return "errorSetMode"; } + }; + + /** + * Accessor + * @return first entry of m_functionNames, or an empty string if empty + * + * @note Legacy scalar accessor. + * Use getFunctionNames() to access the full list of function names when using non-scalar + * field specifications (eg. functionName="{ f1, f2, f3 }") + */ + string const & getFunctionName() const + { + static string const emptyName; + return m_functionNames.empty() ? emptyName : m_functionNames.front(); + } + + /** + * Accessor + * @return const reference to m_functionNames + */ + string_array const & getFunctionNames() const + { + return m_functionNames; + } + + /** + * Accessor + * @return const m_beginTime + */ + real64 getStartTime() const + { return m_beginTime; } + + /** + * Accessor + * @return const m_endTime + */ + real64 getEndTime() const + { return m_endTime; } + + /** + * Accessor + * @return const m_initialCondition + */ + int initialCondition() const + { return m_initialCondition; } + + /** + * Accessor + * @return first entry of m_scales, or 0 if m_scales is empty + * + * @note Legacy scalar accessor. + * Use getScales() to access the full list of scales when using non-scalar + * field specifications (eg. scales="{ 1, 2, 3 }") + */ + real64 getScale() const + { return m_scales.empty() ? 0.0 : m_scales.front(); } + + /** + * Accessor + * @return const m_scales + */ + array1d< real64 > getScales() const + { return m_scales; } + + /** + * Accessor + * @return const m_emptySetErrorMode + */ + SetErrorMode getErrorSetMode() const + { return m_emptySetErrorMode; } + + /** + * Mutator + * @param[in] scale Scaling factor + */ + void setScale( real64 const & scale ) + { + m_scales.resize( 1 ); + m_scales[ 0 ] = scale; + } + + /** + * Mutator + * @brief Set the per-component scale factors + * @param[in] scales The tensor-valued scale + */ + void setScales( array1d< real64 > const & scales ) + { m_scales = scales; } + /** + * Mutator + * @brief Set the per-component function names + * @param[in] functionNames The per-component function names. Must either be empty, + * have a single entry, or be sized exactly as @p m_scales + */ + void setFunctionNames( string_array const & functionNames ) + { m_functionNames = functionNames; } + + /** + * Mutator + * @param[in] isInitialCondition Logical value to indicate if it is an initial condition + */ + void initialCondition( bool isInitialCondition ) + { m_initialCondition = isInitialCondition; } + + /** + * Mutator + * @param[in] beginTime Time after which the bc is allowed to be applied + */ + void setStartTime( real64 beginTime ) + { m_beginTime = beginTime; } + + /** + * Mutator + * @param[in] endTime Time after which the bc will no longer be applied. + */ + void setEndTime( real64 endTime ) + { m_endTime = endTime; } + + /** + * Mutator + * @param[in] errorSetMode Time after which the bc will no longer be applied. + */ + void setErrorSetMode( SetErrorMode const & errorSetMode ) + { m_emptySetErrorMode = errorSetMode; } + +protected: + + virtual void postInputInitialization() override; + + /// Whether or not the boundary condition is an initial condition. + int m_initialCondition; + + /// Name(s) of the function used to generate values for application. + string_array m_functionNames; + + /// Scale factor(s) to use on the value of the boundary condition. + array1d< real64 > m_scales; + + /// Time after which the bc is allowed to be applied + real64 m_beginTime; + + /// Time after which the bc will no longer be applied. + real64 m_endTime; + + /// Enum containing the possible output modes when an error occur + SetErrorMode m_emptySetErrorMode; }; +/** + * @brief Indicate the error handling mode + */ +ENUM_STRINGS( FieldSpecificationABC::SetErrorMode, + "silent", + "error", + "warning" ); + } #endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONABC_HPP diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 4a92948963d..2a1b188296d 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -53,42 +53,8 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setDescription( "Component of field (if tensor) to apply boundary condition to.\n" "The component must use the order in which the phaseNames have been defined in the Constitutive Element." ); - registerWrapper( viewKeyStruct::initialConditionString(), &m_initialCondition ). - setApplyDefaultValue( 1 ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Boundary condition is applied as an initial condition." ); - - registerWrapper( viewKeyStruct::functionNamesString(), &m_functionNames ). - setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Name(s) of function(s) that specifies variation of the boundary condition." ); - - registerWrapper( viewKeyStruct::scalesString(), &m_scales ). - setApplyDefaultValue( 0.0 ). - setInputFlag( InputFlags::OPTIONAL ). - setSizedFromParent( 0 ). - setDescription( "Apply scaling factor(s) for the value(s) of the boundary condition." ); - - registerWrapper( viewKeyStruct::beginTimeString(), &m_beginTime ). - setApplyDefaultValue( -1.0e99 ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Time at which the boundary condition will start being applied." ); - - registerWrapper( viewKeyStruct::endTimeString(), &m_endTime ). - setApplyDefaultValue( 1.0e99 ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Time at which the boundary condition will stop being applied." ); - - registerWrapper( viewKeyStruct::errorSetModeString(), &m_emptySetErrorMode ). - setInputFlag( InputFlags::OPTIONAL ). - setApplyDefaultValue( FieldSpecification::SetErrorMode::error ). - setDescription( GEOS_FMT( "Set the log state when a “set” does not target any region\n" - "When set to \"{}\", no output.\n" - "When set to \"{}\", output a warning.\n" - "When set to \"{}\", output a throw.\n", - EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::silent ), - EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::warning ), - EnumStrings< FieldSpecification::SetErrorMode >::toString( FieldSpecification::SetErrorMode::error ) )); + getWrapper< int >( viewKeyStruct::initialConditionString() ). + setApplyDefaultValue( 1 ); } @@ -98,6 +64,8 @@ PermeabilitySpecification::~PermeabilitySpecification() void PermeabilitySpecification::postInputInitialization() { + FieldSpecificationABC::postInputInitialization(); + for( real64 scale : getScales() ) { GEOS_THROW_IF( scale < 0, @@ -107,31 +75,12 @@ void PermeabilitySpecification::postInputInitialization() getDataContext() ); } - GEOS_THROW_IF( !m_functionNames.empty() && - m_functionNames.size() != 1 && - m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), - GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " - "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", - viewKeyStruct::functionNamesString(), m_functionNames.size(), - viewKeyStruct::scalesString(), m_scales.size(), - viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); - GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", viewKeyStruct::componentString(), viewKeyStruct::scalesString() ), InputError, getDataContext() ); - - GEOS_THROW_IF( m_beginTime > m_endTime, - GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", - viewKeyStruct::beginTimeString(), m_beginTime, - viewKeyStruct::endTimeString(), m_endTime, - catalogName(), getName() ), - InputError, - getDataContext() ); } namespace diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 456172d49b7..ebf0108ba44 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -84,7 +84,7 @@ class PermeabilitySpecification : public FieldSpecificationABC /** * @brief View keys */ - struct viewKeyStruct + struct viewKeyStruct : public FieldSpecificationABC::viewKeyStruct { /// @return The key for setName constexpr static char const * setNamesString() { return "setNames"; } @@ -94,27 +94,8 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * fieldNameString() { return "fieldName"; } /// @return The key for component constexpr static char const * componentString() { return "component"; } - /// @return The key for initialCondition - constexpr static char const * initialConditionString() { return "initialCondition"; } - /// @return The key for functionNames - constexpr static char const * functionNamesString() { return "functionNames"; } - /// @return The key for scales - constexpr static char const * scalesString() { return "scales"; } - /// @return The key for beginTime - constexpr static char const * beginTimeString() { return "beginTime"; } - /// @return The key for endTime - constexpr static char const * endTimeString() { return "endTime"; } - /// @return The key errorSetMode - constexpr static char const * errorSetModeString() { return "errorSetMode"; } }; - /** - * Accessor - * @return const reference to m_functionNames - */ - string_array const & getFunctionNames() const - { return m_functionNames; } - /** * Accessor * @return const reference to m_regionNames @@ -143,41 +124,6 @@ class PermeabilitySpecification : public FieldSpecificationABC string_array const & getSetNames() const { return m_setNames; } - /** - * Accessor - * @return const m_scales - */ - array1d< real64 > getScales() const - { return m_scales; } - - /** - * Accessor - * @return const m_initialCondition - */ - int initialCondition() const - { return m_initialCondition; } - - /** - * Accessor - * @return const m_beginTime - */ - real64 getStartTime() const - { return m_beginTime; } - - /** - * Accessor - * @return const m_endTime - */ - real64 getEndTime() const - { return m_endTime; } - - /** - * Accessor - * @return const m_emptySetErrorMode - */ - FieldSpecification::SetErrorMode getErrorSetMode() const - { return m_emptySetErrorMode; } - protected: virtual void postInputInitialization() override; @@ -198,24 +144,6 @@ class PermeabilitySpecification : public FieldSpecificationABC /// The component the boundary condition acts on. Not used if field is a scalar. int m_component; - /// Whether or not the boundary condition is an initial condition. - int m_initialCondition; - - /// Name(s) of the function used to generate values for application. - string_array m_functionNames; - - /// Scale factor(s) to use on the value of the boundary condition. - array1d< real64 > m_scales; - - /// Time after which the bc is allowed to be applied - real64 m_beginTime; - - /// Time after which the bc will no longer be applied. - real64 m_endTime; - - /// Enum containing the possible output modes when an error occur - FieldSpecification::SetErrorMode m_emptySetErrorMode; - }; /// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 2b8333f33e9..fcf8f2df882 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1359,7 +1359,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1376,7 +1376,7 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set - + @@ -1396,7 +1396,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1430,7 +1430,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1473,7 +1473,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1506,7 +1506,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1537,6 +1537,9 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set + + - + - - + + - + - - + + @@ -1578,7 +1581,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + @@ -1606,7 +1609,7 @@ When set to "silent", no output. When set to "warning", output a warning. When set to "error", output a throw. --> - + From b18352b384a74cae36012fba6b426407ee713d84 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 16:54:32 +0200 Subject: [PATCH 33/39] remove redundant copy/move constructor declarations --- .../fieldSpecification/PermeabilitySpecification.hpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index ebf0108ba44..78035567610 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -69,18 +69,6 @@ class PermeabilitySpecification : public FieldSpecificationABC virtual ~PermeabilitySpecification() override; - /// Deleted copy constructor - PermeabilitySpecification( PermeabilitySpecification const & ) = delete; - - /// Defaulted move constructor - PermeabilitySpecification( PermeabilitySpecification && ) = default; - - /// deleted copy assignment - PermeabilitySpecification & operator=( PermeabilitySpecification const & ) = delete; - - /// deleted move assignement - PermeabilitySpecification & operator=( PermeabilitySpecification && ) = delete; - /** * @brief View keys */ From 2bfc5df5beea01cc605e12d6624fcb2c5145d588 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Wed, 29 Jul 2026 18:01:20 +0200 Subject: [PATCH 34/39] (WIP) remove fieldName Removes fieldName attribute as fieldKey is always "permeability" but introduces a new attribute "permeabilityModelName" for the constitutive model, as a complete fieldName for permeability is "constitutive_fieldkey" --- ...eTwoPhase_SPE10_layer84_base_iterative.xml | 2 +- .../fieldSpecification/FieldSpecification.cpp | 6 ++-- .../fieldSpecification/FieldSpecification.hpp | 2 +- .../FieldSpecificationABC.cpp | 10 +++--- .../FieldSpecificationABC.hpp | 6 ++++ .../PermeabilitySpecification.cpp | 36 ++++++++++++++++--- .../PermeabilitySpecification.hpp | 24 +++++++++---- .../testPermeabilitySpecification.cpp | 2 +- src/coreComponents/schema/schema.xsd | 5 ++- 9 files changed, 67 insertions(+), 26 deletions(-) diff --git a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml index b2d17b5d132..91cd28b0496 100644 --- a/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml +++ b/inputFiles/immiscibleMultiphaseFlow/immiscibleTwoPhase_SPE10_layer84/immiscibleTwoPhase_SPE10_layer84_base_iterative.xml @@ -95,7 +95,7 @@ name="perm" setNames="{ all }" regionNames="reservoir/block" - fieldName="rockPerm_permeability" + permeabilityModelName="rockPerm" functionName="{ permxFunc, permyFunc, permzFunc }" scale="{ 9.869233e-16, 9.869233e-16, 9.869233e-16 }"/> diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.cpp b/src/coreComponents/fieldSpecification/FieldSpecification.cpp index a818d7f3de8..d41001667d0 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.cpp @@ -73,11 +73,11 @@ void FieldSpecification::postInputInitialization() FieldSpecificationABC::postInputInitialization(); GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, - GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", + GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", viewKeyStruct::componentString(), viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); + InputError, + getDataContext() ); } void FieldSpecification::validateNumArrayComp( localIndex numComp ) diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp index deef45de9c5..892928c69a4 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecification.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -134,7 +134,7 @@ class FieldSpecification : public FieldSpecificationABC * Accessor * @return const reference to m_fieldName */ - virtual const string & getFieldName() const + virtual const string & getFieldName() const override { return m_fieldName; } /** diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp index fd287de5ea3..6568e44be4a 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.cpp @@ -74,15 +74,15 @@ FieldSpecificationABC::getCatalog() void FieldSpecificationABC::postInputInitialization() { GEOS_THROW_IF( !m_functionNames.empty() && - m_functionNames.size() != 1 && - m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), - GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " + m_functionNames.size() != 1 && + m_functionNames.size() != static_cast< string_array::size_type >( m_scales.size() ), + GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", viewKeyStruct::functionNamesString(), m_functionNames.size(), viewKeyStruct::scalesString(), m_scales.size(), viewKeyStruct::functionNamesString(), viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); + InputError, + getDataContext() ); GEOS_THROW_IF( m_beginTime > m_endTime, GEOS_FMT( "{} ({}) must be less than {} ({}) in {} '{}'", diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp index 05555eddc02..64d4e7452ff 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationABC.hpp @@ -125,6 +125,12 @@ class FieldSpecificationABC : public dataRepository::Group constexpr static char const * errorSetModeString() { return "errorSetMode"; } }; + /** + * Accessor + * @return const reference to the field name + */ + virtual const string & getFieldName() const = 0; + /** * Accessor * @return first entry of m_functionNames, or an empty string if empty diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index 2a1b188296d..e1c8b699841 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -17,11 +17,13 @@ #include "FieldSpecification.hpp" #include "FieldSpecificationFactory.hpp" #include "common/logger/Logger.hpp" +#include "constitutive/permeability/PermeabilityBase.hpp" #include "mesh/DomainPartition.hpp" namespace geos { using namespace dataRepository; +using namespace constitutive; PermeabilitySpecification::PermeabilitySpecification( string const & name, Group * parent ): FieldSpecificationABC( name, parent ) @@ -41,11 +43,10 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setInputFlag( InputFlags::REQUIRED ). setDescription( "Names of the cell regions that boundary condition is applied to." ); - registerWrapper( viewKeyStruct::fieldNameString(), &m_fieldName ). + registerWrapper( viewKeyStruct::permeabilityModelNameString(), &m_permeabilityModelName ). setRTTypeName( rtTypes::CustomTypes::groupNameRef ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Name of field that boundary condition is applied to.\n" - "A field can represent a physical variable. (pressure, temperature, global composition fraction of the fluid, ...)" ); + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Name of the constitutive permeability model." ); registerWrapper( viewKeyStruct::componentString(), &m_component ). setApplyDefaultValue( -1 ). @@ -136,6 +137,27 @@ void expectValidCellRegion( DomainPartition const & domain, permSpec.getDataContext() ); } +/** + * @brief Validate that a certain permeability model name exists in the domain + * @param domain The domain + * @param permeabilityModelName The name of the permeability model to validated + * @param permSpec Reference to the current object to print its DataContext + * @note Throws if the permeability model doesn't exists + */ +void expectValidPermeabilityModel( DomainPartition const & domain, + string const & modelName, + PermeabilitySpecification const & permSpec ) +{ + ConstitutiveManager const & constitutiveManager = domain.getConstitutiveManager(); + + GEOS_THROW_IF( constitutiveManager.getGroupPointer< PermeabilityBase >( modelName ) == nullptr, + GEOS_FMT( "{} '{}' doesn't name a valid permeability constitutive model", + PermeabilitySpecification::viewKeyStruct::permeabilityModelNameString(), + modelName ), + InputError, + permSpec.getDataContext() ); +} + } @@ -146,6 +168,10 @@ void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecific Group const & problem = manager.getParent(); DomainPartition const & domain = problem.getGroup< DomainPartition >( "domain" ); + expectValidPermeabilityModel( domain, permSpec.getPermeabilityModelName(), permSpec ); + string const fieldName = ConstitutiveBase::makeFieldName( permSpec.getPermeabilityModelName(), + permSpec.getFieldName() ); + for( string const & regionName : permSpec.getRegionNames() ) { expectValidCellRegion( domain, regionName, permSpec ); @@ -155,7 +181,7 @@ void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecific FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); fs.setDataContextReference( permSpec ); - fs.setFieldName( permSpec.getFieldName() ); + fs.setFieldName( fieldName ); fs.setComponent( permSpec.getComponent() ); fs.setObjectPath( objectPath ); fs.initialCondition( permSpec.initialCondition() ); diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index 78035567610..e2813b06c28 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -22,6 +22,7 @@ #include "common/DataTypes.hpp" +#include "constitutive/permeability/PermeabilityFields.hpp" #include "mesh/ObjectManagerBase.hpp" #include "mesh/MeshObjectPath.hpp" #include "FieldSpecification.hpp" @@ -78,8 +79,8 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * setNamesString() { return "setNames"; } /// @return The key for regionNames constexpr static char const * regionNamesString() { return "regionNames"; } - /// @return The key for fieldName - constexpr static char const * fieldNameString() { return "fieldName"; } + /// @return The key for permeabilityModelName + constexpr static char const * permeabilityModelNameString() { return "permeabilityModelName"; } /// @return The key for component constexpr static char const * componentString() { return "component"; } }; @@ -91,12 +92,22 @@ class PermeabilitySpecification : public FieldSpecificationABC string_array const & getRegionNames() const { return m_regionNames; } + /** + * Accessor + * @return const reference to m_permeabilityModelName + */ + string const & getPermeabilityModelName() const + { return m_permeabilityModelName; } + /** * Accessor * @return const reference to m_fieldName */ - virtual const string & getFieldName() const - { return m_fieldName; } + virtual string const & getFieldName() const override + { + static string const fieldName = fields::permeability::permeability::key(); + return fieldName; + } /** * Accessing the considered component. @@ -125,9 +136,8 @@ class PermeabilitySpecification : public FieldSpecificationABC /// the names of the regions that the boundary condition is applied to string_array m_regionNames; - /// the name of the field the boundary condition is applied to or a key string to use for - /// determining whether or not to apply the boundary condition. - string m_fieldName; + /// the name of the constitutive permeability model + string m_permeabilityModelName; /// The component the boundary condition acts on. Not used if field is a scalar. int m_component; diff --git a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp index 20cdc6499c7..1234972c8a6 100644 --- a/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/unitTests/testPermeabilitySpecification.cpp @@ -29,7 +29,7 @@ void fillValidInput( PermeabilitySpecification & ps ) { ps.getReference< string_array >( PermeabilitySpecification::viewKeyStruct::setNamesString() ) = { "all" }; ps.getReference< string_array >( PermeabilitySpecification::viewKeyStruct::regionNamesString() ) = { "region1", "region2" }; - ps.getReference< string >( PermeabilitySpecification::viewKeyStruct::fieldNameString() ) = "rockPerm_permeability"; + ps.getReference< string >( PermeabilitySpecification::viewKeyStruct::permeabilityModelNameString() ) = "rockPerm"; array1d< real64 > & scales = ps.getReference< array1d< real64 > >( PermeabilitySpecification::viewKeyStruct::scalesString() ); scales.resize( 3 ); scales[0] = 9.869233e-16; diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index fcf8f2df882..1d8964e94f1 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1548,13 +1548,12 @@ When set to "warning", output a warning. When set to "error", output a throw. --> - - + + From ddfd8a85d6c06d8cfc66e9503380734630f98fb1 Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Thu, 30 Jul 2026 10:21:17 +0200 Subject: [PATCH 35/39] remove component --- .../PermeabilitySpecification.cpp | 14 -------------- .../PermeabilitySpecification.hpp | 16 +++------------- src/coreComponents/schema/schema.xsd | 3 --- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp index e1c8b699841..65a49939bd2 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.cpp @@ -48,12 +48,6 @@ PermeabilitySpecification::PermeabilitySpecification( string const & name, Group setInputFlag( InputFlags::REQUIRED ). setDescription( "Name of the constitutive permeability model." ); - registerWrapper( viewKeyStruct::componentString(), &m_component ). - setApplyDefaultValue( -1 ). - setInputFlag( InputFlags::OPTIONAL ). - setDescription( "Component of field (if tensor) to apply boundary condition to.\n" - "The component must use the order in which the phaseNames have been defined in the Constitutive Element." ); - getWrapper< int >( viewKeyStruct::initialConditionString() ). setApplyDefaultValue( 1 ); } @@ -75,13 +69,6 @@ void PermeabilitySpecification::postInputInitialization() InputError, getDataContext() ); } - - GEOS_THROW_IF( m_component != -1 && m_scales.size() > 1, - GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", - viewKeyStruct::componentString(), - viewKeyStruct::scalesString() ), - InputError, - getDataContext() ); } namespace @@ -182,7 +169,6 @@ void expandFieldSpecification< PermeabilitySpecification >( PermeabilitySpecific FieldSpecification & fs = manager.registerGroup< FieldSpecification >( childName ); fs.setDataContextReference( permSpec ); fs.setFieldName( fieldName ); - fs.setComponent( permSpec.getComponent() ); fs.setObjectPath( objectPath ); fs.initialCondition( permSpec.initialCondition() ); fs.setScales( permSpec.getScales() ); diff --git a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp index e2813b06c28..336f558a681 100644 --- a/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp +++ b/src/coreComponents/fieldSpecification/PermeabilitySpecification.hpp @@ -81,8 +81,6 @@ class PermeabilitySpecification : public FieldSpecificationABC constexpr static char const * regionNamesString() { return "regionNames"; } /// @return The key for permeabilityModelName constexpr static char const * permeabilityModelNameString() { return "permeabilityModelName"; } - /// @return The key for component - constexpr static char const * componentString() { return "component"; } }; /** @@ -109,13 +107,6 @@ class PermeabilitySpecification : public FieldSpecificationABC return fieldName; } - /** - * Accessing the considered component. - * @return The component axis or a special value. - */ - virtual int getComponent() const - { return m_component; } - /** * Accessor * @return const reference to m_setNames @@ -129,19 +120,18 @@ class PermeabilitySpecification : public FieldSpecificationABC private: - /// the names of the sets that the boundary condition is applied to string_array m_setNames; /// the names of the regions that the boundary condition is applied to string_array m_regionNames; + // Currently only supports cell regions + // TODO: support faces + /// the name of the constitutive permeability model string m_permeabilityModelName; - /// The component the boundary condition acts on. Not used if field is a scalar. - int m_component; - }; /// @copydoc geos::FieldSpecificationFactory::generateFieldSpecifications diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 1d8964e94f1..6321175f0cd 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1537,9 +1537,6 @@ A set can be be defined by a 'Geometry' component, or correspond to imported set - -