From 0c79a66d653cd68d52f23b6b092e551cf8e4f78d Mon Sep 17 00:00:00 2001 From: kdrienCG Date: Fri, 27 Mar 2026 09:59:36 +0100 Subject: [PATCH 01/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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/22] 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(); +}