diff --git a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp index 4a9c99a7b2f..488519b0d10 100644 --- a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp @@ -25,7 +25,7 @@ namespace geos using namespace dataRepository; AquiferBoundaryCondition::AquiferBoundaryCondition( string const & name, Group * parent ) - : FieldSpecificationBase( name, parent ), + : FieldSpecification( name, parent ), m_waterPhaseIndex( -1 ), m_cumulativeFlux( 0.0 ) { @@ -99,15 +99,15 @@ AquiferBoundaryCondition::AquiferBoundaryCondition( string const & name, Group * registerWrapper( viewKeyStruct::cumulativeFluxString(), &m_cumulativeFlux ). setInputFlag( InputFlags::FALSE ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ). setInputFlag( InputFlags::FALSE ); setFieldName( catalogName() ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::objectPathString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::objectPathString() ). setInputFlag( InputFlags::FALSE ); setObjectPath( "faceManager" ); - getWrapper< int >( FieldSpecificationBase::viewKeyStruct::componentString() ). + getWrapper< int >( FieldSpecification::viewKeyStruct::componentString() ). setInputFlag( InputFlags::FALSE ); } @@ -300,7 +300,7 @@ AquiferBoundaryCondition::KernelWrapper AquiferBoundaryCondition::createKernelWr pressureInfluenceFunction.createKernelWrapper() ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, AquiferBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, AquiferBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.hpp b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.hpp index 275bc645ec4..8e726beed0e 100644 --- a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.hpp +++ b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.hpp @@ -21,7 +21,7 @@ #ifndef GEOS_FIELDSPECIFICATION_AQUIFERBOUNDARYCONDITION_HPP #define GEOS_FIELDSPECIFICATION_AQUIFERBOUNDARYCONDITION_HPP -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" #include "functions/TableFunction.hpp" namespace geos @@ -31,7 +31,7 @@ namespace geos * @class AquiferBoundaryCondition * Holds data and methods to apply a traction boundary condition */ -class AquiferBoundaryCondition : public FieldSpecificationBase +class AquiferBoundaryCondition : public FieldSpecification { public: @@ -118,7 +118,7 @@ class AquiferBoundaryCondition : public FieldSpecificationBase }; - /// @copydoc FieldSpecificationBase(string const &, dataRepository::Group *) + /// @copydoc FieldSpecification(string const &, dataRepository::Group *) AquiferBoundaryCondition( string const & name, Group * parent ); /// deleted default constructor @@ -202,7 +202,7 @@ class AquiferBoundaryCondition : public FieldSpecificationBase /** * @brief View keys */ - struct viewKeyStruct : public FieldSpecificationBase::viewKeyStruct + struct viewKeyStruct : public FieldSpecification::viewKeyStruct { // aquifer geological properties diff --git a/src/coreComponents/fieldSpecification/CMakeLists.txt b/src/coreComponents/fieldSpecification/CMakeLists.txt index 8dc6827d664..1ab2ae911b0 100644 --- a/src/coreComponents/fieldSpecification/CMakeLists.txt +++ b/src/coreComponents/fieldSpecification/CMakeLists.txt @@ -25,8 +25,9 @@ Contains: set( fieldSpecification_headers DirichletBoundaryCondition.hpp EquilibriumInitialCondition.hpp - FieldSpecificationBase.hpp + FieldSpecification.hpp FieldSpecificationManager.hpp + FieldSpecificationImpl.hpp SourceFluxBoundaryCondition.hpp TractionBoundaryCondition.hpp AquiferBoundaryCondition.hpp @@ -39,7 +40,7 @@ set( fieldSpecification_headers set( fieldSpecification_sources DirichletBoundaryCondition.cpp EquilibriumInitialCondition.cpp - FieldSpecificationBase.cpp + FieldSpecification.cpp FieldSpecificationManager.cpp SourceFluxBoundaryCondition.cpp TractionBoundaryCondition.cpp diff --git a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp index 19a62d921dd..31ce54725c0 100644 --- a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.cpp @@ -24,7 +24,7 @@ namespace geos using namespace dataRepository; DirichletBoundaryCondition::DirichletBoundaryCondition( string const & name, Group * const parent ): - FieldSpecificationBase( name, parent ) + FieldSpecification( name, parent ) { // TODO Auto-generated constructor stub @@ -37,6 +37,6 @@ DirichletBoundaryCondition::~DirichletBoundaryCondition() -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, DirichletBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, DirichletBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.hpp b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.hpp index 553ac23e7dc..0803fa289d2 100644 --- a/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.hpp +++ b/src/coreComponents/fieldSpecification/DirichletBoundaryCondition.hpp @@ -20,7 +20,7 @@ #ifndef GEOS_FIELDSPECIFICATION_DIRICHLETBOUNDARYCONDITION_HPP_ #define GEOS_FIELDSPECIFICATION_DIRICHLETBOUNDARYCONDITION_HPP_ -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" namespace geos { @@ -29,7 +29,7 @@ namespace geos * @class DirichletBoundaryCondition * A class to manage Dirichlet boundary conditions */ -class DirichletBoundaryCondition : public FieldSpecificationBase +class DirichletBoundaryCondition : public FieldSpecification { public: /// @copydoc geos::dataRepository::Group::Group( string const & name, Group * const parent ) diff --git a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp index 6e0f1181e6e..d29700f16b4 100644 --- a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp +++ b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp @@ -27,7 +27,7 @@ namespace geos using namespace dataRepository; EquilibriumInitialCondition::EquilibriumInitialCondition( string const & name, Group * parent ): - FieldSpecificationBase( name, parent ) + FieldSpecification( name, parent ) { registerWrapper( viewKeyStruct::datumElevationString(), &m_datumElevation ). setInputFlag( InputFlags::REQUIRED ). @@ -77,18 +77,18 @@ EquilibriumInitialCondition::EquilibriumInitialCondition( string const & name, G setInputFlag( InputFlags::OPTIONAL ). setDescription( "Phase contacts' elevations [m]" ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ). setInputFlag( InputFlags::FALSE ); setFieldName( catalogName() ); - getWrapper< int >( FieldSpecificationBase::viewKeyStruct::componentString() ). + getWrapper< int >( FieldSpecification::viewKeyStruct::componentString() ). setInputFlag( InputFlags::FALSE ); - getWrapper< int >( FieldSpecificationBase::viewKeyStruct::initialConditionString() ). + getWrapper< int >( FieldSpecification::viewKeyStruct::initialConditionString() ). setInputFlag( InputFlags::FALSE ); initialCondition( false ); // to make sure this is not called by applyInitialConditions - getWrapper< string_array >( FieldSpecificationBase::viewKeyStruct::setNamesString() ). + getWrapper< string_array >( FieldSpecification::viewKeyStruct::setNamesString() ). setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). setInputFlag( InputFlags::FALSE ); addSetName( "all" ); @@ -243,7 +243,7 @@ void EquilibriumInitialCondition::initializePreSubGroups() } } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, EquilibriumInitialCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, EquilibriumInitialCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.hpp b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.hpp index 08c91e96b2f..5d5c739f241 100644 --- a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.hpp +++ b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.hpp @@ -21,7 +21,7 @@ #ifndef GEOS_FIELDSPECIFICATION_EQUILIBRIUMINITIALCONDITION_HPP #define GEOS_FIELDSPECIFICATION_EQUILIBRIUMINITIALCONDITION_HPP -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" namespace geos { @@ -30,11 +30,11 @@ namespace geos * @class EquilibriumInitialCondition * Holds data to compute an hydrostatic equilibrium condition for flow problems */ -class EquilibriumInitialCondition : public FieldSpecificationBase +class EquilibriumInitialCondition : public FieldSpecification { public: - /// @copydoc FieldSpecificationBase(string const &, dataRepository::Group *) + /// @copydoc FieldSpecification(string const &, dataRepository::Group *) EquilibriumInitialCondition( string const & name, Group * parent ); /// deleted default constructor @@ -124,7 +124,7 @@ class EquilibriumInitialCondition : public FieldSpecificationBase /** * @brief View keys */ - struct viewKeyStruct : public FieldSpecificationBase::viewKeyStruct + struct viewKeyStruct : public FieldSpecification::viewKeyStruct { // equilibration parameters diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp b/src/coreComponents/fieldSpecification/FieldSpecification.cpp similarity index 91% rename from src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp rename to src/coreComponents/fieldSpecification/FieldSpecification.cpp index 94e78e7e06a..dd06d4ee0b2 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecification.cpp @@ -13,7 +13,7 @@ * ------------------------------------------------------------------------------------------------------------ */ -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" @@ -21,7 +21,7 @@ namespace geos { using namespace dataRepository; -FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * parent ): +FieldSpecification::FieldSpecification( string const & name, Group * parent ): Group( name, parent ) { setInputFlags( InputFlags::OPTIONAL_NONUNIQUE ); @@ -99,19 +99,19 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par } -FieldSpecificationBase::~FieldSpecificationBase() +FieldSpecification::~FieldSpecification() {} -FieldSpecificationBase::CatalogInterface::CatalogType & -FieldSpecificationBase::getCatalog() +FieldSpecification::CatalogInterface::CatalogType & +FieldSpecification::getCatalog() { - static FieldSpecificationBase::CatalogInterface::CatalogType catalog; + static FieldSpecification::CatalogInterface::CatalogType catalog; return catalog; } -void FieldSpecificationBase::setMeshObjectPath( Group const & meshBodies ) +void FieldSpecification::setMeshObjectPath( Group const & meshBodies ) { try { @@ -131,6 +131,6 @@ void FieldSpecificationBase::setMeshObjectPath( Group const & meshBodies ) -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, FieldSpecificationBase, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, FieldSpecification, string const &, Group * const ) } diff --git a/src/coreComponents/fieldSpecification/FieldSpecification.hpp b/src/coreComponents/fieldSpecification/FieldSpecification.hpp new file mode 100644 index 00000000000..08663f5e384 --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecification.hpp @@ -0,0 +1,368 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 FieldSpecification.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATION_HPP +#define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATION_HPP + + +#include "common/DataTypes.hpp" +#include "common/TypeDispatch.hpp" +#include "codingUtilities/traits.hpp" +#include "codingUtilities/Utilities.hpp" +#include "dataRepository/Group.hpp" +#include "functions/FunctionBase.hpp" +#include "common/FieldSpecificationOps.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "mesh/MeshObjectPath.hpp" +#include "functions/FunctionManager.hpp" +#include "common/GEOS_RAJA_Interface.hpp" + +namespace geos +{ +class Function; + + +/** + * @class FieldSpecification + * A class to hold values for and administer a single boundary condition + */ +class FieldSpecification : public dataRepository::Group +{ +public: + + /** + * @defgroup alias and functions to defined statically initialized catalog + * @{ + */ + + /** + * alias to define the catalog type for this base type + */ + using CatalogInterface = dataRepository::CatalogInterface< FieldSpecification, + string const &, + dataRepository::Group * const >; + /** + * @enum SetErrorMode + * @brief Indicate the error handling mode. + */ + enum class SetErrorMode : integer + { + silent, + error, + warning + }; + + /** + * @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 + */ + static string catalogName() { return "FieldSpecification"; } + + /** + * @brief return the catalog name + * @return the catalog name + */ + virtual const string getCatalogName() const + { + return FieldSpecification::catalogName(); + } + + /** + * @} + */ + + + /** + * @brief constructor + * @param name the name of the FieldSpecification in the data repository + * @param parent the parent group of this group. + */ + FieldSpecification( string const & name, dataRepository::Group * parent ); + + /** + * destructor + */ + virtual ~FieldSpecification() override; + + + /// Deleted copy constructor + FieldSpecification( FieldSpecification const & ) = delete; + + /// Defaulted move constructor + FieldSpecification( FieldSpecification && ) = default; + + /// deleted copy assignment + FieldSpecification & operator=( FieldSpecification const & ) = delete; + + /// deleted move assignement + FieldSpecification & operator=( FieldSpecification && ) = delete; + + /** + * @brief View keys + */ + struct viewKeyStruct + { + /// @return The key for setName + constexpr static char const * setNamesString() { return "setNames"; } + /// @return The key for constitutivePath + constexpr static char const * constitutivePathString() { return "constitutivePath"; } + /// @return The key for objectPath + constexpr static char const * objectPathString() { return "objectPath"; } + /// @return The key for fieldName + constexpr static char const * fieldNameString() { return "fieldName"; } + /// @return The key for dataType + constexpr static char const * dataTypeString() { return "dataType"; } + /// @return The key for component + constexpr static char const * componentString() { return "component"; } + /// @return The key for direction + constexpr static char const * directionString() { return "direction"; } + /// @return The key for bcApplicationTableName + constexpr static char const * bcApplicationTableNameString() { return "bcApplicationTableName"; } + /// @return The key for scale + constexpr static char const * scaleString() { return "scale"; } + /// @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 beginTime + constexpr static char const * beginTimeString() { return "beginTime"; } + /// @return The key for endTime + constexpr static char const * endTimeString() { return "endTime"; } + /// @return The key errorSetMode + constexpr static char const * errorSetModeString() { return "errorSetMode"; } + }; + + /** + * Accessor + * @return const reference to m_function + */ + string const & getFunctionName() const + { + return m_functionName; + } + + /** + * Accessor + * @return const reference to m_objectPath + */ + virtual const string & getObjectPath() const + { + return m_objectPath; + } + + /** + * Accessor + * @return const reference to m_fieldName + */ + virtual const string & getFieldName() const + { + return m_fieldName; + } + + /** + * Accessing the considered component. + * @return The component axis or a special value. + */ + virtual int getComponent() const + { + return m_component; + } + + /** + * Accessor + * @return const reference to m_direction + */ + virtual R1Tensor const & getDirection() const + { + GEOS_UNUSED_VAR( time ); + return m_direction; + } + + /** + * Accessor + * @return const m_beginTime + */ + real64 getStartTime() const + { + return m_beginTime; + } + + /** + * Accessor + * @return const m_endTime + */ + real64 getEndTime() const + { + return m_endTime; + } + + /** + * Accessor + * @return const reference to m_setNames + */ + string_array const & getSetNames() const + { + return m_setNames; + } + + /** + * Accessor + * @return const m_initialCondition + */ + int initialCondition() const + { + return m_initialCondition; + } + + /** + * Accessor + * @return const m_scale + */ + real64 getScale() const + { + return m_scale; + } + + /** + * Mutator + * @param[in] fieldName The name of the field + */ + void setFieldName( string const & fieldName ) + { + m_fieldName = fieldName; + } + + /** + * Mutator + * @param[in] objectPath The path for the object + */ + void setObjectPath( string const & objectPath ) + { + m_objectPath = objectPath; + } + + /** + * Mutator + * @param[in] scale Scaling factor + */ + void setScale( real64 const & scale ) + { + m_scale = scale; + } + + /** + * Mutator + * @param[in] isInitialCondition Logical value to indicate if it is an initial condition + */ + void initialCondition( bool isInitialCondition ) + { + m_initialCondition = isInitialCondition; + } + + /** + * Mutator + * @param[in] setName The name of the set + */ + void addSetName( string const & setName ) + { + m_setNames.emplace_back( setName ); + } + + /** + * @brief Set the Mesh Object Path object + * + * @param meshBodies The group containing all the MeshBody objects + */ + void setMeshObjectPath( Group const & meshBodies ); + + /** + * @brief Get the Mesh Object Paths object + * + * @return reference to const m_meshObjectPaths + */ + MeshObjectPath const & getMeshObjectPaths() const + { + return *(m_meshObjectPaths.get()); + } + + +protected: + + +private: + + + /// the names of the sets that the boundary condition is applied to + string_array m_setNames; + + /// the path to the object which contains the fields that the boundary condition is applied to + string m_objectPath; + + std::unique_ptr< MeshObjectPath > m_meshObjectPaths; + + /// 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 component the boundary condition acts on. Not used if field is a scalar. + int m_component; + + /// The direction the boundary condition acts in. + R1Tensor m_direction; + + /// Whether or not the boundary condition is an initial condition. + int m_initialCondition; + + /// The name of the function used to generate values for application. + string m_functionName; + + /// The scale factor to use on the value of the boundary condition. + real64 m_scale; + + /// 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; + + /// The name of a function used to turn on and off the boundary condition. + string m_bcApplicationFunctionName; + + /// Enum containing the possible output modes when an error occur + SetErrorMode m_emptySetErrorMode; +}; + +/** + * @brief Indicate the error handling mode + */ +ENUM_STRINGS( FieldSpecification::SetErrorMode, + "silent", + "error", + "warning" ); + +} + +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATION_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp deleted file mode 100644 index 1905a4e5c36..00000000000 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp +++ /dev/null @@ -1,904 +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 FieldSpecificationBase.hpp - */ - -#ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP -#define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP - -#include "common/DataTypes.hpp" -#include "common/TypeDispatch.hpp" -#include "codingUtilities/traits.hpp" -#include "codingUtilities/Utilities.hpp" -#include "dataRepository/Group.hpp" -#include "functions/FunctionBase.hpp" -#include "common/FieldSpecificationOps.hpp" -#include "mesh/ObjectManagerBase.hpp" -#include "mesh/MeshObjectPath.hpp" -#include "functions/FunctionManager.hpp" -#include "common/GEOS_RAJA_Interface.hpp" - -namespace geos -{ -class Function; - - -/** - * @class FieldSpecificationBase - * A class to hold values for and administer a single boundary condition - */ -class FieldSpecificationBase : public dataRepository::Group -{ -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. - */ - enum class SetErrorMode : integer - { - silent, - error, - warning - }; - - /** - * @brief static function to return static catalog. - * @return the static catalog to create derived types through the static factory methods. - */ - static CatalogInterface::CatalogType & getCatalog(); - - /** - * @brief Static Factory Catalog Functions - * @return the catalog name - */ - static string catalogName() { return "FieldSpecification"; } - - /** - * @brief return the catalog name - * @return the catalog name - */ - virtual const string getCatalogName() const - { - return FieldSpecificationBase::catalogName(); - } - - /** - * @} - */ - - - /** - * @brief constructor - * @param name the name of the FieldSpecificationBase in the data repository - * @param parent the parent group of this group. - */ - FieldSpecificationBase( string const & name, dataRepository::Group * parent ); - - /** - * destructor - */ - virtual ~FieldSpecificationBase() override; - - - /// Deleted copy constructor - FieldSpecificationBase( FieldSpecificationBase const & ) = delete; - - /// Defaulted move constructor - FieldSpecificationBase( FieldSpecificationBase && ) = default; - - /// deleted copy assignment - FieldSpecificationBase & operator=( FieldSpecificationBase const & ) = delete; - - /// deleted move assignement - FieldSpecificationBase & operator=( FieldSpecificationBase && ) = delete; - - /** - * @brief Apply this field specification to the discretization - * - * @tparam OBJECT_TYPE The type of discretization/mesh object that the - * specification is being applied to. - * @tparam BC_TYPE The type of BC being applied - * @tparam LAMBDA - * @param mesh The MeshLevel that the specification is applied to - * @param lambda The being executed - */ - template< typename OBJECT_TYPE, - typename BC_TYPE = FieldSpecificationBase, - typename LAMBDA > - void apply( MeshLevel & mesh, - LAMBDA && lambda ) const - { - MeshObjectPath const & meshObjectPaths = this->getMeshObjectPaths(); - meshObjectPaths.forObjectsInPath< OBJECT_TYPE >( mesh, - [&] ( OBJECT_TYPE & object ) - { - { - dataRepository::Group const & setGroup = object.getGroup( ObjectManagerBase::groupKeyStruct::setsString() ); - string_array setNames = this->getSetNames(); - for( auto & setName : setNames ) - { - if( setGroup.hasWrapper( setName ) ) - { - SortedArrayView< localIndex const > const & targetSet = setGroup.getReference< SortedArray< localIndex > >( setName ); - lambda( dynamic_cast< BC_TYPE const & >(*this), setName, targetSet, object, getFieldName() ); - } - } - } - } ); - } - - /** - * @tparam FIELD_OP type that contains static functions to apply the value to the field - * @param[in] field the field to apply the value to. - * @param[in] targetSet the set of indices which the value will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the value. - * @param[in] dataGroup the Group that contains the field to apply the value to. - * - * This function applies the value to a field variable. - */ - template< typename FIELD_OP, typename POLICY, typename T, int N, int USD > - void applyFieldValueKernel( ArrayView< T, N, USD > const & field, - SortedArrayView< localIndex const > const & targetSet, - real64 const time, - Group & dataGroup ) const; - - /** - * @tparam FIELD_OP type that contains static functions to apply the value to the field - * @param[in] targetSet the set of indices which the value will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the value. - * @param[in] dataGroup the Group that contains the field to apply the value to. - * @param[in] fieldname the name of the field to apply the value to. - * - * This function applies the value to a field variable. This function is typically - * called from within the lambda to a call to FieldSpecificationManager::applyFieldValue(). - */ - template< typename FIELD_OP, typename POLICY=parallelHostPolicy > - void applyFieldValue( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group & dataGroup, - string const & fieldname ) const; - - /** - * @brief Apply a boundary condition to a system of equations. - * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. - * Either \ref OpEqual or \ref OpAdd. - * @tparam POLICY Execution policy to use when iterating over the target set. - * @tparam T Data type of the field. - * @tparam NDIM Number of dimensions in the field array. - * @tparam USD Unit stride dimension of the field array. - * @param targetSet The set of indices which the boundary condition will be applied. - * @param time The time at which any time dependent functions are to be evaluated as part of the - * application of the boundary condition. - * @param dataGroup The Group that contains the field to apply the boundary condition to. - * @param dofMap The map from the local index of the primary field to the global degree of freedom number. - * @param dofRankOffset Offset of dof indices on current rank. - * @param matrix Local part of the system matrix. - * @param rhs Local part of the system rhs vector. - * @param fieldView Array view of the field data. - * - * @note This function is rarely used directly. More often it is called by other ApplyBoundaryCondition functions. - */ - template< typename FIELD_OP, typename POLICY, typename T, int NDIM, int USD > - void applyBoundaryConditionToSystemKernel( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - ArrayView< T const, NDIM, USD > const & fieldView ) const; - - /** - * @brief Apply a boundary condition to a system of equations. - * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. - * Either \ref OpEqual or \ref OpAdd. - * @tparam POLICY Execution policy to use when iterating over target set. - * @param[in] targetSet The set of indices which the boundary condition will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the boundary condition. - * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. - * @param[in] fieldName The name of the field to apply the boundary condition to. - * @param[in] dofMapName The name of the map from the local index of the primary field to the - * global degree of freedom number. - * @param[in] dofRankOffset Offset of dof indices on current rank. - * @param[in,out] matrix Local part of the system matrix. - * @param[in,out] rhs Local part of the system rhs vector. - * - * This function applies the boundary condition to a linear system of equations. This function is - * typically called from within the lambda to a call to BoundaryConditionManager::ApplyBoundaryCondition(). - */ - template< typename FIELD_OP, typename POLICY > - void applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - string const & fieldName, - string const & dofMapName, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs ) const; - - /** - * @brief Apply a boundary condition to a system of equations. - * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. - * Either \ref OpEqual or \ref OpAdd. - * @tparam POLICY Execution policy to use when iterating over target set. - * @tparam LAMBDA The type of lambda function passed into the parameter list. - * @param[in] targetSet The set of indices which the boundary condition will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the boundary condition. - * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. - * @param[in] dofMap The map from the local index of the primary field to the global degree of - * freedom number. - * @param[in] dofRankOffset Offset of dof indices on current rank. - * @param[inout] matrix Local part of the system matrix. - * @param[inout] rhs Local part of the system rhs vector. - * @param[in] lambda A lambda function which defines how the value that is passed into the functions - * provided by the FIELD_OP templated type. - * - * This function applies the boundary condition to a linear system of equations. This function is - * typically called from within the lambda to a call to - * BoundaryConditionManager::ApplyBoundaryCondition(). - */ - template< typename FIELD_OP, typename POLICY, typename LAMBDA > - void - applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - LAMBDA && lambda ) const; - - /** - * @brief Apply a boundary condition to a system of equations. - * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. - * Either \ref OpEqual or \ref OpAdd. - * @tparam POLICY Execution policy to use when iterating over target set. - * @tparam LAMBDA The type of lambda function passed into the parameter list. - * @param[in] targetSet The set of indices which the boundary condition will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the boundary condition. - * @param[in] dt time step size which is applied as a factor to bc values - * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. - * @param[in] dofMap The map from the local index of the primary field to the global degree of - * freedom number. - * @param[in] dofRankOffset Offset of dof indices on current rank. - * @param[inout] matrix Local part of the system matrix. - * @param[inout] rhs Local part of the system rhs vector. - * @param[in] lambda A lambda function which defines how the value that is passed into the functions - * provided by the FIELD_OP templated type. - * - * This function applies the boundary condition to a linear system of equations. This function is - * typically called from within the lambda to a call to - * BoundaryConditionManager::ApplyBoundaryCondition(). - */ - template< typename FIELD_OP, typename POLICY, typename LAMBDA > - void - applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - real64 const dt, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - LAMBDA && lambda ) const; - - /** - * @brief Compute the contributions that will be added/enforced to the right-hand side, and collect the corresponding dof numbers - * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. - * Either \ref OpEqual or \ref OpAdd. - * @tparam POLICY Execution policy to use when iterating over target set. - * @tparam LAMBDA The type of lambda function passed into the parameter list. - * @param[in] targetSet The set of indices which the boundary condition will be applied. - * @param[in] time The time at which any time dependent functions are to be evaluated as part of the - * application of the boundary condition. - * @param[in] dt time step size which is applied as a factor to bc values - * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. - * @param[in] dofMap The map from the local index of the primary field to the global degree of - * freedom number. - * @param[in] dofRankOffset Offset of dof indices on current rank. - * @param[inout] matrix Local part of the system matrix. - * @param[inout] dof array storing the degrees of freedom of the rhsContribution, to know where in the rhs they will be added/enforced - * @param[inout] rhsContribution array storing the values that will be added/enforced to the right-hand side - * @param[in] lambda A lambda function which defines how the value that is passed into the functions - * provided by the FIELD_OP templated type. - * - * Note that this function only computes the rhs contributions, but does not apply them to the right-hand side. - * The application of these rhs contributions is done in applyBoundaryConditionToSystem. - * - * Why did we have to extract the computation of the rhs contributions from applyBoundaryConditionToSystem? - * Because applyBoundaryConditionToSystem is not very well suited to apply the rhsContributions to the equation layout used in the - * compositional solvers. - * Therefore, the compositional solvers do not call applyBoundaryConditionToSystem, but instead call computeRhsContribution directly, and - * apply these rhs contributions "manually" according to the equation layout used in the solver - */ - template< typename FIELD_OP, typename POLICY, typename LAMBDA > - void - computeRhsContribution( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - real64 const dt, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< globalIndex > const & dof, - arrayView1d< real64 > const & rhsContribution, - LAMBDA && lambda ) const; - - - /** - * @brief Function to zero matrix rows to apply boundary conditions - * @tparam POLICY the execution policy to use when zeroing rows - * @param[in] targetSet The set of indices which the boundary condition will be applied. - * @param[in] dofMap The map from the local index of the primary field to the global degree of - * freedom number. - * @param[inout] matrix the local system matrix - * - * This function zeroes the rows of the matrix that correspond to boundary conditions. - */ - template< typename POLICY > - void zeroSystemRowsForBoundaryCondition( SortedArrayView< localIndex const > const & targetSet, - arrayView1d< globalIndex const > const & dofMap, - CRSMatrixView< real64, globalIndex const > const & matrix ) const; - - /** - * @brief View keys - */ - struct viewKeyStruct - { - /// @return The key for setName - constexpr static char const * setNamesString() { return "setNames"; } - /// @return The key for constitutivePath - constexpr static char const * constitutivePathString() { return "constitutivePath"; } - /// @return The key for objectPath - constexpr static char const * objectPathString() { return "objectPath"; } - /// @return The key for fieldName - constexpr static char const * fieldNameString() { return "fieldName"; } - /// @return The key for dataType - constexpr static char const * dataTypeString() { return "dataType"; } - /// @return The key for component - constexpr static char const * componentString() { return "component"; } - /// @return The key for direction - constexpr static char const * directionString() { return "direction"; } - /// @return The key for bcApplicationTableName - constexpr static char const * bcApplicationTableNameString() { return "bcApplicationTableName"; } - /// @return The key for scale - constexpr static char const * scaleString() { return "scale"; } - /// @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 beginTime - constexpr static char const * beginTimeString() { return "beginTime"; } - /// @return The key for endTime - constexpr static char const * endTimeString() { return "endTime"; } - /// @return The key errorSetMode - constexpr static char const * errorSetModeString() { return "errorSetMode"; } - }; - - /** - * Accessor - * @return const reference to m_function - */ - string const & getFunctionName() const - { - return m_functionName; - } - - /** - * Accessor - * @return const reference to m_objectPath - */ - virtual const string & getObjectPath() const - { - return m_objectPath; - } - - /** - * Accessor - * @return const reference to m_fieldName - */ - virtual const string & getFieldName() const - { - return m_fieldName; - } - - /** - * Accessing the considered component. - * @return The component axis or a special value. - */ - virtual int getComponent() const - { - return m_component; - } - - /** - * Accessor - * @return const reference to m_direction - */ - virtual R1Tensor const & getDirection() const - { - GEOS_UNUSED_VAR( time ); - return m_direction; - } - - /** - * Accessor - * @return const m_beginTime - */ - real64 getStartTime() const - { - return m_beginTime; - } - - /** - * Accessor - * @return const m_endTime - */ - real64 getEndTime() const - { - return m_endTime; - } - - /** - * Accessor - * @return const reference to m_setNames - */ - string_array const & getSetNames() const - { - return m_setNames; - } - - /** - * Accessor - * @return const m_initialCondition - */ - int initialCondition() const - { - return m_initialCondition; - } - - /** - * Accessor - * @return const m_scale - */ - real64 getScale() const - { - return m_scale; - } - - /** - * Mutator - * @param[in] fieldName The name of the field - */ - void setFieldName( string const & fieldName ) - { - m_fieldName = fieldName; - } - - /** - * Mutator - * @param[in] objectPath The path for the object - */ - void setObjectPath( string const & objectPath ) - { - m_objectPath = objectPath; - } - - /** - * Mutator - * @param[in] scale Scaling factor - */ - void setScale( real64 const & scale ) - { - m_scale = scale; - } - - /** - * Mutator - * @param[in] isInitialCondition Logical value to indicate if it is an initial condition - */ - void initialCondition( bool isInitialCondition ) - { - m_initialCondition = isInitialCondition; - } - - /** - * Mutator - * @param[in] setName The name of the set - */ - void addSetName( string const & setName ) - { - m_setNames.emplace_back( setName ); - } - - /** - * @brief Set the Mesh Object Path object - * - * @param meshBodies The group containing all the MeshBody objects - */ - void setMeshObjectPath( Group const & meshBodies ); - - /** - * @brief Get the Mesh Object Paths object - * - * @return reference to const m_meshObjectPaths - */ - MeshObjectPath const & getMeshObjectPaths() const - { - return *(m_meshObjectPaths.get()); - } - - -protected: - - -private: - - - /// the names of the sets that the boundary condition is applied to - string_array m_setNames; - - /// the path to the object which contains the fields that the boundary condition is applied to - string m_objectPath; - - std::unique_ptr< MeshObjectPath > m_meshObjectPaths; - - /// 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 component the boundary condition acts on. Not used if field is a scalar. - int m_component; - - /// The direction the boundary condition acts in. - R1Tensor m_direction; - - /// Whether or not the boundary condition is an initial condition. - int m_initialCondition; - - /// The name of the function used to generate values for application. - string m_functionName; - - /// The scale factor to use on the value of the boundary condition. - real64 m_scale; - - /// 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; - - /// The name of a function used to turn on and off the boundary condition. - string m_bcApplicationFunctionName; - - /// Enum containing the possible output modes when an error occur - SetErrorMode m_emptySetErrorMode; -}; - - -template< typename FIELD_OP, typename POLICY, typename T, int N, int USD > -void FieldSpecificationBase::applyFieldValueKernel( ArrayView< T, N, USD > const & field, - SortedArrayView< localIndex const > const & targetSet, - real64 const time, - Group & dataGroup ) const -{ - integer const component = getComponent(); - FunctionManager & functionManager = FunctionManager::getInstance(); - - if( m_functionName.empty() ) - { - real64 const value = m_scale; - forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - FIELD_OP::SpecifyFieldValue( field, a, component, value ); - } ); - } - else - { - FunctionBase const & function = [&]() -> FunctionBase const & - { - try - { - return functionManager.getGroup< FunctionBase >( m_functionName ); - } - catch( std::exception const & e ) - { - string const errorMsg = GEOS_FMT( "Error while reading {}:\n", - getWrapperDataContext( viewKeyStruct::functionNameString() ) ); - ErrorLogger::global().modifyCurrentExceptionMessage() - .addToMsg( errorMsg ) - .addContextInfo( getWrapperDataContext( viewKeyStruct::functionNameString() ).getContextInfo() - .setPriority( 1 ) ); - throw InputError( e, errorMsg ); - } - }(); - - if( function.isFunctionOfTime()==2 ) - { - real64 const value = m_scale * function.evaluate( &time ); - forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - FIELD_OP::SpecifyFieldValue( field, a, component, value ); - } ); - } - else - { - real64_array result( static_cast< localIndex >( targetSet.size() ) ); - function.evaluate( dataGroup, time, targetSet, result ); - arrayView1d< real64 const > const & resultView = result.toViewConst(); - real64 const scale = m_scale; - forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] ); - } ); - } - } -} - - -template< typename FIELD_OP, typename POLICY > -void FieldSpecificationBase::applyFieldValue( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group & dataGroup, - string const & fieldName ) const -{ - dataRepository::WrapperBase & wrapper = dataGroup.getWrapperBase( fieldName ); - - // // This function is used in setting boundary/initial conditions on simulation fields. - // // This is meaningful for 1/2/3D real arrays and sometimes 1D integer (indicator) arrays. - using FieldTypes = types::ListofTypeList< types::Join< types::ArrayTypes< types::RealTypes, types::DimsUpTo< 3 > >, - types::ArrayTypes< types::TypeList< integer >, types::DimsSingle< 1 > > > >; - - - types::dispatch( FieldTypes{}, [&]( auto tupleOfTypes ) - { - using ArrayType = camp::first< decltype( tupleOfTypes ) >; - auto & wrapperT = dataRepository::Wrapper< ArrayType >::cast( wrapper ); - applyFieldValueKernel< FIELD_OP, POLICY >( wrapperT.reference().toView(), targetSet, time, dataGroup ); - }, wrapper ); -} - -template< typename FIELD_OP, typename POLICY, typename T, int NDIM, int USD > -void FieldSpecificationBase::applyBoundaryConditionToSystemKernel( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - ArrayView< T const, NDIM, USD > const & fieldView ) const -{ - integer const component = getComponent(); - this->applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs, - [fieldView, component] GEOS_HOST_DEVICE ( localIndex const a ) - { - real64 value = 0.0; - FieldSpecificationEqual::readFieldValue( fieldView, a, component, value ); - return value; - } ); -} - -template< typename FIELD_OP, typename POLICY > -void FieldSpecificationBase::applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - string const & fieldName, - string const & dofMapName, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs ) const -{ - dataRepository::WrapperBase const & wrapper = dataGroup.getWrapperBase( fieldName ); - arrayView1d< globalIndex const > const & dofMap = dataGroup.getReference< array1d< globalIndex > >( dofMapName ); - - // We're reading values from a field, which is only well-defined for dims 1 and 2 - using FieldTypes = types::ListofTypeList< types::ArrayTypes< types::RealTypes, types::DimsUpTo< 2 > > >; - types::dispatch( FieldTypes{}, [&]( auto tupleOfTypes ) - { - using ArrayType = camp::first< decltype( tupleOfTypes ) >; - auto const & wrapperT = dataRepository::Wrapper< ArrayType >::cast( wrapper ); - applyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( targetSet, - time, - dataGroup, - dofMap, - dofRankOffset, - matrix, - rhs, - wrapperT.reference() ); - }, wrapper ); -} - -template< typename FIELD_OP, typename POLICY, typename LAMBDA > -void -FieldSpecificationBase:: - applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - LAMBDA && lambda ) const -{ - return applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, - time, - 1.0, - dataGroup, - dofMap, - dofRankOffset, - matrix, - rhs, - std::forward< LAMBDA >( lambda ) ); -} - -template< typename FIELD_OP, typename POLICY, typename LAMBDA > -void -FieldSpecificationBase:: - applyBoundaryConditionToSystem( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - real64 const dt, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< real64 > const & rhs, - LAMBDA && lambda ) const -{ - array1d< globalIndex > dofArray( targetSet.size() ); - arrayView1d< globalIndex > const & dof = dofArray.toView(); - - array1d< real64 > rhsContributionArray( targetSet.size() ); - arrayView1d< real64 > const & rhsContribution = rhsContributionArray.toView(); - - computeRhsContribution< FIELD_OP, POLICY, LAMBDA >( targetSet, - time, - dt, - dataGroup, - dofMap, - dofRankOffset, - matrix, - dof, - rhsContribution, - std::forward< LAMBDA >( lambda ) ); - - FIELD_OP::template prescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution ); -} - -template< typename FIELD_OP, typename POLICY, typename LAMBDA > -void -FieldSpecificationBase:: - computeRhsContribution( SortedArrayView< localIndex const > const & targetSet, - real64 const time, - real64 const dt, - dataRepository::Group const & dataGroup, - arrayView1d< globalIndex const > const & dofMap, - globalIndex const dofRankOffset, - CRSMatrixView< real64, globalIndex const > const & matrix, - arrayView1d< globalIndex > const & dof, - arrayView1d< real64 > const & rhsContribution, - LAMBDA && lambda ) const -{ - integer const component = ( getComponent() >=0 ) ? getComponent() : 0; - string const & functionName = getReference< string >( viewKeyStruct::functionNameString() ); - FunctionManager & functionManager = FunctionManager::getInstance(); - - // Compute the value of the rhs terms, and collect the dof numbers - // The rhs terms will be assembled in applyBoundaryConditionToSystem (or in the solver for CompositionalMultiphaseBase) - - if( functionName.empty() || functionManager.getGroup< FunctionBase >( functionName ).isFunctionOfTime() == 2 ) - { - real64 value = m_scale * dt; - if( !functionName.empty() ) - { - FunctionBase const & function = functionManager.getGroup< FunctionBase >( functionName ); - value *= function.evaluate( &time ); - } - - forAll< POLICY >( targetSet.size(), - [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda] GEOS_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - dof[ i ] = dofMap[ a ] + component; - FIELD_OP::SpecifyFieldValue( dof[ i ], - dofRankOffset, - matrix, - rhsContribution[ i ], - value, - lambda( a ) ); - } ); - } - else - { - FunctionBase const & function = functionManager.getGroup< FunctionBase >( functionName ); - - real64_array resultsArray( targetSet.size() ); - function.evaluate( dataGroup, time, targetSet, resultsArray ); - arrayView1d< real64 const > const & results = resultsArray.toViewConst(); - real64 const value = m_scale * dt; - - forAll< POLICY >( targetSet.size(), - [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda] GEOS_HOST_DEVICE ( - localIndex const i ) - { - localIndex const a = targetSet[ i ]; - dof[ i ] = dofMap[ a ] + component; - FIELD_OP::SpecifyFieldValue( dof[ i ], - dofRankOffset, - matrix, - rhsContribution[ i ], - value * results[ i ], - lambda( a ) ); - } ); - } -} - - -template< typename POLICY > -void FieldSpecificationBase::zeroSystemRowsForBoundaryCondition( SortedArrayView< localIndex const > const & targetSet, - arrayView1d< globalIndex const > const & dofMap, - CRSMatrixView< real64, globalIndex const > const & matrix ) const - -{ - integer const component = ( getComponent() >=0 ) ? getComponent() : 0; - forAll< POLICY >( targetSet.size(), [targetSet, dofMap, matrix, component] GEOS_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - globalIndex const dof = dofMap[ a ] + component; - - arraySlice1d< real64 > const entries = matrix.getEntries( dof ); - localIndex const numEntries = matrix.numNonZeros( dof ); - - for( localIndex j = 0; j < numEntries; ++j ) - { - entries[ j ] = 0; - } - } ); -} - - -/** - * @brief Indicate the error handling mode - */ -ENUM_STRINGS( FieldSpecificationBase::SetErrorMode, - "silent", - "error", - "warning" ); - -} - -#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp new file mode 100644 index 00000000000..2a565ba8206 --- /dev/null +++ b/src/coreComponents/fieldSpecification/FieldSpecificationImpl.hpp @@ -0,0 +1,534 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 FieldSpecificationImpl.hpp + */ + +#ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONIMPL_HPP +#define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONIMPL_HPP + +#include "FieldSpecification.hpp" +#include "common/DataTypes.hpp" +#include "common/TypeDispatch.hpp" +#include "codingUtilities/traits.hpp" +#include "codingUtilities/Utilities.hpp" +#include "dataRepository/Group.hpp" +#include "functions/FunctionBase.hpp" +#include "common/FieldSpecificationOps.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "mesh/MeshObjectPath.hpp" +#include "functions/FunctionManager.hpp" +#include "common/GEOS_RAJA_Interface.hpp" + +namespace geos +{ +class Function; + + +/** + * @class FieldSpecificationImpl + * @brief + * + * + */ +class FieldSpecificationImpl +{ + public: + + /** + * @brief Apply this field specification to the discretization + * + * @tparam OBJECT_TYPE The type of discretization/mesh object that the + * specification is being applied to. + * @tparam BC_TYPE The type of BC being applied + * @tparam LAMBDA + * @param fs The field specification data object + * @param mesh The MeshLevel that the specification is applied to + * @param lambda The being executed + */ + template< typename OBJECT_TYPE, + typename BC_TYPE = FieldSpecification, + typename LAMBDA > + static void apply( BC_TYPE const & fs, + MeshLevel & mesh, + LAMBDA && lambda ) + { + MeshObjectPath const & meshObjectPaths = fs.getMeshObjectPaths(); + meshObjectPaths.forObjectsInPath< OBJECT_TYPE >( mesh, + [&] ( OBJECT_TYPE & object ) + { + { + dataRepository::Group const & setGroup = object.getGroup( ObjectManagerBase::groupKeyStruct::setsString() ); + string_array setNames = fs.getSetNames(); + for( auto & setName : setNames ) + { + if( setGroup.hasWrapper( setName ) ) + { + SortedArrayView< localIndex const > const & targetSet = setGroup.getReference< SortedArray< localIndex > >( setName ); + lambda( fs, setName, targetSet, object, fs.getFieldName() ); + } + } + } + } ); + } + + /** + * @tparam FIELD_OP type that contains static functions to apply the value to the field + * @param[in] fs the field specfication data object. + * @param[in] field the field to apply the value to. + * @param[in] targetSet the set of indices which the value will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the value. + * @param[in] dataGroup the Group that contains the field to apply the value to. + * + * This function applies the value to a field variable. + */ + template< typename FIELD_OP, typename POLICY, typename T, int N, int USD > + static void applyFieldValueKernel( FieldSpecification const & fs, + ArrayView< T, N, USD > const & field, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + dataRepository::Group & dataGroup ) + { + integer const component = fs.getComponent(); + string const & functionName = fs.getFunctionName(); + FunctionManager & functionManager = FunctionManager::getInstance(); + + if( functionName.empty() ) + { + real64 const value = fs.getScale(); + forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + FIELD_OP::SpecifyFieldValue( field, a, component, value ); + } ); + } + else + { + FunctionBase const & function = [&]() -> FunctionBase const & + { + try + { + return functionManager.getGroup< FunctionBase >( functionName ); + } + catch( std::exception const & e ) + { + string const errorMsg = GEOS_FMT( "Error while reading {}:\n", + fs.getWrapperDataContext( FieldSpecification::viewKeyStruct::functionNameString() ) ); + ErrorLogger::global().modifyCurrentExceptionMessage() + .addToMsg( errorMsg ) + .addContextInfo( fs.getWrapperDataContext( FieldSpecification::viewKeyStruct::functionNameString() ) + .getContextInfo() + .setPriority( 1 ) ); + throw InputError( e, errorMsg ); + } + }(); + + if( function.isFunctionOfTime()==2 ) + { + real64 const value = fs.getScale() * function.evaluate( &time ); + forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + FIELD_OP::SpecifyFieldValue( field, a, component, value ); + } ); + } + else + { + real64_array result( static_cast< localIndex >( targetSet.size() ) ); + function.evaluate( dataGroup, time, targetSet, result ); + arrayView1d< real64 const > const & resultView = result.toViewConst(); + real64 const scale = fs.getScale(); + forAll< POLICY >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] ); + } ); + } + } + } + + + /** + * @tparam FIELD_OP type that contains static functions to apply the value to the field + * @param[in] fs the field specification data object + * @param[in] targetSet the set of indices which the value will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the value. + * @param[in] dataGroup the Group that contains the field to apply the value to. + * @param[in] fieldname the name of the field to apply the value to. + * + * This function applies the value to a field variable. This function is typically + * called from within the lambda to a call to FieldSpecificationManager::applyFieldValue(). + */ + template< typename FIELD_OP, typename POLICY=parallelHostPolicy > + static void applyFieldValue( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + dataRepository::Group & dataGroup, + string const & fieldName ) + { + dataRepository::WrapperBase & wrapper = dataGroup.getWrapperBase( fieldName ); + + // This function is used in setting boundary/initial conditions on simulation fields. + // This is meaningful for 1/2/3D real arrays and sometimes 1D integer (indicator) arrays. + using FieldTypes = types::ListofTypeList< types::Join< types::ArrayTypes< types::RealTypes, types::DimsUpTo< 3 > >, + types::ArrayTypes< types::TypeList< integer >, types::DimsSingle< 1 > > > >; + + + types::dispatch( FieldTypes{}, [&]( auto tupleOfTypes ) + { + using ArrayType = camp::first< decltype( tupleOfTypes ) >; + auto & wrapperT = dataRepository::Wrapper< ArrayType >::cast( wrapper ); + applyFieldValueKernel< FIELD_OP, POLICY >( fs, wrapperT.reference().toView(), targetSet, time, dataGroup ); + }, wrapper ); + } + + /** + * @brief Apply a boundary condition to a system of equations. + * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. + * Either \ref OpEqual or \ref OpAdd. + * @tparam POLICY Execution policy to use when iterating over the target set. + * @tparam T Data type of the field. + * @tparam NDIM Number of dimensions in the field array. + * @tparam USD Unit stride dimension of the field array. + * @param fs The field specification data object. + * @param targetSet The set of indices which the boundary condition will be applied. + * @param time The time at which any time dependent functions are to be evaluated as part of the + * application of the boundary condition. + * @param dataGroup The Group that contains the field to apply the boundary condition to. + * @param dofMap The map from the local index of the primary field to the global degree of freedom number. + * @param dofRankOffset Offset of dof indices on current rank. + * @param matrix Local part of the system matrix. + * @param rhs Local part of the system rhs vector. + * @param fieldView Array view of the field data. + * + * @note This function is rarely used directly. More often it is called by other ApplyBoundaryCondition functions. + */ + template< typename FIELD_OP, typename POLICY, typename T, int NDIM, int USD > + static void applyBoundaryConditionToSystemKernel( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + dataRepository::Group const & dataGroup, + arrayView1d< globalIndex const > const & dofMap, + globalIndex const dofRankOffset, + CRSMatrixView< real64, globalIndex const > const & matrix, + arrayView1d< real64 > const & rhs, + ArrayView< T const, NDIM, USD > const & fieldView ) + { + integer const component = fs.getComponent(); + applyBoundaryConditionToSystem< FIELD_OP, POLICY >( fs, targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs, + [fieldView, component] GEOS_HOST_DEVICE ( localIndex const a ) + { + real64 value = 0.0; + FieldSpecificationEqual::readFieldValue( fieldView, a, component, value ); + return value; + } ); + } + + /** + * @brief Apply a boundary condition to a system of equations. + * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. + * Either \ref OpEqual or \ref OpAdd. + * @tparam POLICY Execution policy to use when iterating over target set. + * @param[in] fs The field specification data object + * @param[in] targetSet The set of indices which the boundary condition will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the boundary condition. + * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. + * @param[in] fieldName The name of the field to apply the boundary condition to. + * @param[in] dofMapName The name of the map from the local index of the primary field to the + * global degree of freedom number. + * @param[in] dofRankOffset Offset of dof indices on current rank. + * @param[in,out] matrix Local part of the system matrix. + * @param[in,out] rhs Local part of the system rhs vector. + * + * This function applies the boundary condition to a linear system of equations. This function is + * typically called from within the lambda to a call to BoundaryConditionManager::ApplyBoundaryCondition(). + */ + template< typename FIELD_OP, typename POLICY > + static void applyBoundaryConditionToSystem( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + dataRepository::Group const & dataGroup, + string const & fieldName, + string const & dofMapName, + globalIndex const dofRankOffset, + CRSMatrixView< real64, globalIndex const > const & matrix, + arrayView1d< real64 > const & rhs ) + { + dataRepository::WrapperBase const & wrapper = dataGroup.getWrapperBase( fieldName ); + arrayView1d< globalIndex const > const & dofMap = dataGroup.getReference< array1d< globalIndex > >( dofMapName ); + + // We're reading values from a field, which is only well-defined for dims 1 and 2 + using FieldTypes = types::ListofTypeList< types::ArrayTypes< types::RealTypes, types::DimsUpTo< 2 > > >; + types::dispatch( FieldTypes{}, [&]( auto tupleOfTypes ) + { + using ArrayType = camp::first< decltype( tupleOfTypes ) >; + auto const & wrapperT = dataRepository::Wrapper< ArrayType >::cast( wrapper ); + applyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( fs, + targetSet, + time, + dataGroup, + dofMap, + dofRankOffset, + matrix, + rhs, + wrapperT.reference() ); + }, wrapper ); + } + + /** + * @brief Apply a boundary condition to a system of equations. + * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. + * Either \ref OpEqual or \ref OpAdd. + * @tparam POLICY Execution policy to use when iterating over target set. + * @tparam LAMBDA The type of lambda function passed into the parameter list. + * @param[in] fs The field specification data object. + * @param[in] targetSet The set of indices which the boundary condition will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the boundary condition. + * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. + * @param[in] dofMap The map from the local index of the primary field to the global degree of + * freedom number. + * @param[in] dofRankOffset Offset of dof indices on current rank. + * @param[inout] matrix Local part of the system matrix. + * @param[inout] rhs Local part of the system rhs vector. + * @param[in] lambda A lambda function which defines how the value that is passed into the functions + * provided by the FIELD_OP templated type. + * + * This function applies the boundary condition to a linear system of equations. This function is + * typically called from within the lambda to a call to + * BoundaryConditionManager::ApplyBoundaryCondition(). + */ + template< typename FIELD_OP, typename POLICY, typename LAMBDA > + static void + applyBoundaryConditionToSystem( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + dataRepository::Group const & dataGroup, + arrayView1d< globalIndex const > const & dofMap, + globalIndex const dofRankOffset, + CRSMatrixView< real64, globalIndex const > const & matrix, + arrayView1d< real64 > const & rhs, + LAMBDA && lambda ) + { + return applyBoundaryConditionToSystem< FIELD_OP, POLICY >( fs, + targetSet, + time, + 1.0, + dataGroup, + dofMap, + dofRankOffset, + matrix, + rhs, + std::forward< LAMBDA >( lambda ) ); + } + + /** + * @brief Apply a boundary condition to a system of equations. + * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. + * Either \ref OpEqual or \ref OpAdd. + * @tparam POLICY Execution policy to use when iterating over target set. + * @tparam LAMBDA The type of lambda function passed into the parameter list. + * @param[in] fs The field specification data object. + * @param[in] targetSet The set of indices which the boundary condition will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the boundary condition. + * @param[in] dt time step size which is applied as a factor to bc values + * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. + * @param[in] dofMap The map from the local index of the primary field to the global degree of + * freedom number. + * @param[in] dofRankOffset Offset of dof indices on current rank. + * @param[inout] matrix Local part of the system matrix. + * @param[inout] rhs Local part of the system rhs vector. + * @param[in] lambda A lambda function which defines how the value that is passed into the functions + * provided by the FIELD_OP templated type. + * + * This function applies the boundary condition to a linear system of equations. This function is + * typically called from within the lambda to a call to + * BoundaryConditionManager::ApplyBoundaryCondition(). + */ + template< typename FIELD_OP, typename POLICY, typename LAMBDA > + static void + applyBoundaryConditionToSystem( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + real64 const dt, + dataRepository::Group const & dataGroup, + arrayView1d< globalIndex const > const & dofMap, + globalIndex const dofRankOffset, + CRSMatrixView< real64, globalIndex const > const & matrix, + arrayView1d< real64 > const & rhs, + LAMBDA && lambda ) + { + array1d< globalIndex > dofArray( targetSet.size() ); + arrayView1d< globalIndex > const & dof = dofArray.toView(); + + array1d< real64 > rhsContributionArray( targetSet.size() ); + arrayView1d< real64 > const & rhsContribution = rhsContributionArray.toView(); + + computeRhsContribution< FIELD_OP, POLICY, LAMBDA >( fs, + targetSet, + time, + dt, + dataGroup, + dofMap, + dofRankOffset, + matrix, + dof, + rhsContribution, + std::forward< LAMBDA >( lambda ) ); + + FIELD_OP::template prescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution ); + } + + /** + * @brief Compute the contributions that will be added/enforced to the right-hand side, and collect the corresponding dof numbers + * @tparam FIELD_OP A wrapper struct to define how the boundary condition operates on the variables. + * Either \ref OpEqual or \ref OpAdd. + * @tparam POLICY Execution policy to use when iterating over target set. + * @tparam LAMBDA The type of lambda function passed into the parameter list. + * @param[in] fs The field specification data object. + * @param[in] targetSet The set of indices which the boundary condition will be applied. + * @param[in] time The time at which any time dependent functions are to be evaluated as part of the + * application of the boundary condition. + * @param[in] dt time step size which is applied as a factor to bc values + * @param[in] dataGroup The Group that contains the field to apply the boundary condition to. + * @param[in] dofMap The map from the local index of the primary field to the global degree of + * freedom number. + * @param[in] dofRankOffset Offset of dof indices on current rank. + * @param[inout] matrix Local part of the system matrix. + * @param[inout] dof array storing the degrees of freedom of the rhsContribution, to know where in the rhs they will be added/enforced + * @param[inout] rhsContribution array storing the values that will be added/enforced to the right-hand side + * @param[in] lambda A lambda function which defines how the value that is passed into the functions + * provided by the FIELD_OP templated type. + * + * Note that this function only computes the rhs contributions, but does not apply them to the right-hand side. + * The application of these rhs contributions is done in applyBoundaryConditionToSystem. + * + * Why did we have to extract the computation of the rhs contributions from applyBoundaryConditionToSystem? + * Because applyBoundaryConditionToSystem is not very well suited to apply the rhsContributions to the equation layout used in the + * compositional solvers. + * Therefore, the compositional solvers do not call applyBoundaryConditionToSystem, but instead call computeRhsContribution directly, and + * apply these rhs contributions "manually" according to the equation layout used in the solver + */ + template< typename FIELD_OP, typename POLICY, typename LAMBDA > + static void + computeRhsContribution( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + real64 const time, + real64 const dt, + dataRepository::Group const & dataGroup, + arrayView1d< globalIndex const > const & dofMap, + globalIndex const dofRankOffset, + CRSMatrixView< real64, globalIndex const > const & matrix, + arrayView1d< globalIndex > const & dof, + arrayView1d< real64 > const & rhsContribution, + LAMBDA && lambda ) + { + integer const component = ( fs.getComponent() >= 0 ) ? fs.getComponent() : 0; + // string const & functionName = fs.getReference< string >( fs.viewKeyStruct::functionNameString() ); + string const & functionName = fs.getFunctionName(); + FunctionManager & functionManager = FunctionManager::getInstance(); + + // Compute the value of the rhs terms, and collect the dof numbers + // The rhs terms will be assembled in applyBoundaryConditionToSystem (or in the solver for CompositionalMultiphaseBase) + + if( functionName.empty() || functionManager.getGroup< FunctionBase >( functionName ).isFunctionOfTime() == 2 ) + { + real64 value = fs.getScale() * dt; + if( !functionName.empty() ) + { + FunctionBase const & function = functionManager.getGroup< FunctionBase >( functionName ); + value *= function.evaluate( &time ); + } + + forAll< POLICY >( targetSet.size(), + [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + dof[ i ] = dofMap[ a ] + component; + FIELD_OP::SpecifyFieldValue( dof[ i ], + dofRankOffset, + matrix, + rhsContribution[ i ], + value, + lambda( a ) ); + } ); + } + else + { + FunctionBase const & function = functionManager.getGroup< FunctionBase >( functionName ); + + real64_array resultsArray( targetSet.size() ); + function.evaluate( dataGroup, time, targetSet, resultsArray ); + arrayView1d< real64 const > const & results = resultsArray.toViewConst(); + real64 const value = fs.getScale() * dt; + + forAll< POLICY >( targetSet.size(), + [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + dof[ i ] = dofMap[ a ] + component; + FIELD_OP::SpecifyFieldValue( dof[ i ], + dofRankOffset, + matrix, + rhsContribution[ i ], + value * results[ i ], + lambda( a ) ); + } ); + } + } + + /** + * @brief Function to zero matrix rows to apply boundary conditions + * @tparam POLICY the execution policy to use when zeroing rows + * @param[in] fs The field specification data object + * @param[in] targetSet The set of indices which the boundary condition will be applied. + * @param[in] dofMap The map from the local index of the primary field to the global degree of + * freedom number. + * @param[inout] matrix the local system matrix + * + * This function zeroes the rows of the matrix that correspond to boundary conditions. + */ + template< typename POLICY > + static void zeroSystemRowsForBoundaryCondition( FieldSpecification const & fs, + SortedArrayView< localIndex const > const & targetSet, + arrayView1d< globalIndex const > const & dofMap, + CRSMatrixView< real64, globalIndex const > const & matrix ) + { + integer const component = ( fs.getComponent() >= 0 ) ? fs.getComponent() : 0; + forAll< POLICY >( targetSet.size(), [targetSet, dofMap, matrix, component] GEOS_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + globalIndex const dof = dofMap[ a ] + component; + + arraySlice1d< real64 > const entries = matrix.getEntries( dof ); + localIndex const numEntries = matrix.numNonZeros( dof ); + + for( localIndex j = 0; j < numEntries; ++j ) + { + entries[ j ] = 0; + } + } ); + } + +}; + +} /* namespace geos */ + +#endif //GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONIMPL_HPP \ No newline at end of file diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index 6697c275715..f5fe8126991 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -53,8 +53,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< FieldSpecification > bc = + FieldSpecification::CatalogInterface::factory( childKey, getDataContext(), childName, this ); return &this->registerGroup( childName, std::move( bc ) ); } @@ -62,7 +62,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: FieldSpecification::getCatalog()) { createChild( catalogIter.first, catalogIter.first ); } @@ -73,7 +73,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c DomainPartition const & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" ); Group const & meshBodies = domain.getMeshBodies(); // loop over all the FieldSpecification of the XML file - this->forSubGroups< FieldSpecificationBase >( [&] ( FieldSpecificationBase const & fs ) + this->forSubGroups< FieldSpecification >( [&] ( FieldSpecification const & fs ) { localIndex isFieldNameFound = 0; // map from set name to a flag (1 if targetSet has been created, 0 otherwise) @@ -102,14 +102,15 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c // Step 2: apply the boundary condition - fs.apply< Group >( mesh, - [&]( FieldSpecificationBase const &, - string const & setName, - SortedArrayView< localIndex const > const & targetSet, - Group & targetGroup, - string const fieldName ) + FieldSpecificationImpl::apply< Group >( fs, + mesh, + [&]( FieldSpecification const &, + string const & setName, + SortedArrayView< localIndex const > const & targetSet, + Group & targetGroup, + string const fieldName ) { - InputFlags const flag = fs.getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ).getInputFlag(); + InputFlags const flag = fs.getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ).getInputFlag(); // 2.a) If we enter this loop, we know that the set has been created // Fracture/fault sets are created later and the "apply" call silently ignores them @@ -194,14 +195,14 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c std::ostringstream errorMessageBuilder; errorMessageBuilder << GEOS_FMT( "\n{}: there are no set(s) named `{}` under the {} `{}`.\n", - fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::objectPathString() ), + fs.getWrapperDataContext( FieldSpecification::viewKeyStruct::objectPathString() ), fmt::join( missingSetNames, ", " ), - FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); + FieldSpecification::viewKeyStruct::objectPathString(), fs.getObjectPath() ); errorMessageBuilder << ( !registeredSets.empty() ? GEOS_FMT( "Available set(s) are: {}", stringutilities::join( registeredSets, ", " ) ) : GEOS_FMT( "No set are available for the targeted `{}`", - FieldSpecificationBase::viewKeyStruct::objectPathString() ) ); + FieldSpecification::viewKeyStruct::objectPathString() ) ); GEOS_THROW( errorMessageBuilder.str(), InputError, getDataContext() ); } @@ -241,22 +242,22 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c message << GEOS_FMT( "Set '{}' does not capture anything in the mesh ", setName ); } } - auto errMode = fs.getReference< FieldSpecificationBase::SetErrorMode >( - FieldSpecificationBase::viewKeyStruct::errorSetModeString()); + auto errMode = fs.getReference< FieldSpecification::SetErrorMode >( + FieldSpecification::viewKeyStruct::errorSetModeString()); - if( errMode == FieldSpecificationBase::SetErrorMode::error && m_isSurfaceGenerationCase ) + if( errMode == FieldSpecification::SetErrorMode::error && m_isSurfaceGenerationCase ) { - errMode = FieldSpecificationBase::SetErrorMode::warning; + errMode = FieldSpecification::SetErrorMode::warning; } switch( errMode ) { - case FieldSpecificationBase::SetErrorMode::silent: + case FieldSpecification::SetErrorMode::silent: break; - case FieldSpecificationBase::SetErrorMode::error: + case FieldSpecification::SetErrorMode::error: GEOS_THROW( message.str(), InputError, getDataContext() ); break; - case FieldSpecificationBase::SetErrorMode::warning: + case FieldSpecification::SetErrorMode::warning: if( m_isSurfaceGenerationCase ) message << "As the simulation includes a SurfaceGenerator, the set may be modified later"; GEOS_WARNING( message.str() ); @@ -268,7 +269,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c { std::ostringstream errorMessageBuilder; errorMessageBuilder << GEOS_FMT( "\n{}: there are no field named `{}` under the region `{}`.\n", - fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ), + fs.getWrapperDataContext( FieldSpecification::viewKeyStruct::fieldNameString() ), fs.getFieldName(), fs.getObjectPath() ); std::set< string > registeredFields; @@ -295,18 +296,19 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c void FieldSpecificationManager::applyInitialConditions( MeshLevel & mesh ) const { - this->forSubGroups< FieldSpecificationBase >( [&] ( FieldSpecificationBase const & fs ) + this->forSubGroups< FieldSpecification >( [&] ( FieldSpecification const & fs ) { if( fs.initialCondition() ) { - fs.apply< dataRepository::Group >( mesh, - [&]( FieldSpecificationBase const & bc, - string const &, - SortedArrayView< localIndex const > const & targetObject, - Group & targetGroup, - string const fieldName ) + FieldSpecificationImpl::apply< dataRepository::Group >( fs, + mesh, + [&]( FieldSpecification const & bc, + string const &, + SortedArrayView< localIndex const > const & targetObject, + Group & targetGroup, + string const fieldName ) { - bc.applyFieldValue< FieldSpecificationEqual >( targetObject, 0.0, targetGroup, fieldName ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual >( bc, targetObject, 0.0, targetGroup, fieldName ); } ); } } ); diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp index b1d929e6561..9e22ad89214 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.hpp @@ -20,7 +20,8 @@ #ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONMANAGER_HPP_ #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONMANAGER_HPP_ -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" +#include "FieldSpecificationImpl.hpp" #include "common/format/StringUtilities.hpp" #include "common/DataTypes.hpp" @@ -64,9 +65,9 @@ class FieldSpecificationManager : public dataRepository::Group static FieldSpecificationManager & getInstance(); /** - * @brief Create a new FieldSpecificationBase object as a child of this group. - * @param childKey the catalog key of the new FieldSpecificationBase derived type to create - * @param childName the name of the new FieldSpecificationBase object in the repository + * @brief Create a new FieldSpecification object as a child of this group. + * @param childKey the catalog key of the new FieldSpecification derived type to create + * @param childName the name of the new FieldSpecification object in the repository * @return the group child */ virtual Group * createChild( string const & childKey, string const & childName ) override; @@ -86,11 +87,11 @@ class FieldSpecificationManager : public dataRepository::Group * name is used for comparing against the value given in the field specification. * * Interface function that applies a boundary condition directly to a field variable by looping - * through all FieldSpecificationBase objects present in the FieldSpecificationManager. Searches + * through all FieldSpecification objects present in the FieldSpecificationManager. Searches * for the string specified in fieldPath as a substring in the objectPath specified in the input * file, checks if fieldName is equal to the fieldName specified in the input file, and check if - * the time parameter falls within the beginTime and endTime of the FieldSpecificationBase object, - * and calls FieldSpecificationBase::applyFieldValue(). + * the time parameter falls within the beginTime and endTime of the FieldSpecification object, + * and calls FieldSpecification::applyFieldValue(). * */ template< typename POLICY=parallelHostPolicy > @@ -101,7 +102,7 @@ class FieldSpecificationManager : public dataRepository::Group GEOS_MARK_FUNCTION; applyFieldValue< POLICY >( time, mesh, fieldName, - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, SortedArrayView< localIndex const > const & ){} ); } @@ -121,11 +122,11 @@ class FieldSpecificationManager : public dataRepository::Group * after application of value to the field. * * Interface function that applies a value directly to a field by looping - * through all FieldSpecificationBase objects present in the FieldSpecificationManager. Searches + * through all FieldSpecification objects present in the FieldSpecificationManager. Searches * for the string specified in fieldPath as a substring in the objectPath specified in the input * file, checks if fieldName is equal to the fieldName specified in the input file, and check if - * the time parameter falls within the beginTime and endTime of the FieldSpecificationBase object, - * and calls FieldSpecificationBase::applyFieldValue(), and calls the lambda function + * the time parameter falls within the beginTime and endTime of the FieldSpecification object, + * and calls FieldSpecification::applyFieldValue(), and calls the lambda function * to apply any operations required for completing the application of the value to the field in addition to * setting the target field. */ @@ -154,13 +155,13 @@ class FieldSpecificationManager : public dataRepository::Group * after application of value to the field. * * Interface function that applies a value directly to a field by looping - * through all FieldSpecificationBase objects present in the FieldSpecificationManager. Calls the + * through all FieldSpecification objects present in the FieldSpecificationManager. Calls the * preLambda function to apply any operations required before the application of the value to the * field in addition to setting the target field. Searches for the string specified in fieldPath * as a substring in the objectPath specified in the input file, checks if fieldName is equal to * the fieldName specified in the input file, and check if the time parameter falls within the - * beginTime and endTime of the FieldSpecificationBase object, and calls - * FieldSpecificationBase::applyFieldValue(), and calls the postLambda function to apply any + * beginTime and endTime of the FieldSpecification object, and calls + * FieldSpecification::applyFieldValue(), and calls the postLambda function to apply any * operations required for completing the application of the value to the field in addition to * setting the target field. */ @@ -201,11 +202,11 @@ class FieldSpecificationManager : public dataRepository::Group * * This function loops through all available fields, checks to see if they * should be applied, and applies them. More specifically, this function simply checks - * values of fieldPath,fieldName, against each FieldSpecificationBase object contained in the + * values of fieldPath,fieldName, against each FieldSpecification object contained in the * FieldSpecificationManager and decides on whether or not to call the user defined lambda. */ template< typename OBJECT_TYPE=dataRepository::Group, - typename BCTYPE = FieldSpecificationBase, + typename BCTYPE = FieldSpecification, typename LAMBDA > void apply( real64 const time, MeshLevel & mesh, @@ -217,14 +218,14 @@ class FieldSpecificationManager : public dataRepository::Group string const meshBodyName = mesh.getParent().getParent().getName(); string const meshLevelName = mesh.getName(); - // loop over all FieldSpecificationBase objects + // loop over all FieldSpecification objects this->forSubGroups< BCTYPE >( [&] ( BCTYPE const & fs ) { integer const isInitialCondition = fs.initialCondition(); if( ( isInitialCondition && fieldName=="") || // this only use case for this line is in the unit test for field specification ( !isInitialCondition && time >= fs.getStartTime() && time < fs.getEndTime() && fieldName == fs.getFieldName() ) ) { - fs.template apply< OBJECT_TYPE, BCTYPE, LAMBDA >( mesh, std::forward< LAMBDA >( lambda ) ); + FieldSpecificationImpl::apply< OBJECT_TYPE, BCTYPE, LAMBDA >( fs, mesh, std::forward< LAMBDA >( lambda ) ); } } ); } @@ -256,13 +257,13 @@ FieldSpecificationManager:: GEOS_MARK_FUNCTION; apply( time, mesh, fieldName, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & targetSet, Group & targetGroup, string const & targetField ) { - fs.applyFieldValue< FieldSpecificationEqual, POLICY >( targetSet, time, targetGroup, targetField ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, POLICY >( fs, targetSet, time, targetGroup, targetField ); lambda( fs, targetSet ); } ); } @@ -279,14 +280,14 @@ FieldSpecificationManager:: GEOS_MARK_FUNCTION; apply( time, mesh, fieldName, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & targetSet, Group & targetGroup, string const & targetField ) { preLambda( fs, targetSet ); - fs.applyFieldValue< FieldSpecificationEqual, POLICY >( targetSet, time, targetGroup, targetField ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, POLICY >( fs, targetSet, time, targetGroup, targetField ); postLambda( fs, targetSet ); } ); } diff --git a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp index 7e71480536c..e8bfabcf5bd 100644 --- a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp +++ b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp @@ -25,7 +25,7 @@ namespace geos using namespace dataRepository; PerfectlyMatchedLayer::PerfectlyMatchedLayer( string const & name, Group * const parent ): - FieldSpecificationBase( name, parent ) + FieldSpecification( name, parent ) { registerWrapper( viewKeyStruct::xMinString(), &m_xMin ). setInputFlag( InputFlags::OPTIONAL ). @@ -66,11 +66,11 @@ PerfectlyMatchedLayer::PerfectlyMatchedLayer( string const & name, Group * const setApplyDefaultValue( {-1.0, -1.0, -1.0} ). setDescription( "Wave speed in the PML, at right, back, and bottom sides, used to compute the damping profile" ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ). setInputFlag( InputFlags::FALSE ); setFieldName( catalogName() ); - getWrapper< int >( FieldSpecificationBase::viewKeyStruct::initialConditionString() ). + getWrapper< int >( FieldSpecification::viewKeyStruct::initialConditionString() ). setInputFlag( InputFlags::FALSE ); initialCondition( false ); // to make sure this is not called by applyInitialConditions @@ -121,6 +121,6 @@ void PerfectlyMatchedLayer::postInputInitialization() } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, PerfectlyMatchedLayer, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, PerfectlyMatchedLayer, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.hpp b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.hpp index 802e2be9cc7..63bfe334d39 100644 --- a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.hpp +++ b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.hpp @@ -21,7 +21,7 @@ #ifndef GEOS_FIELDSPECIFICATION_PERFECTLYMATCHEDLAYER_HPP_ #define GEOS_FIELDSPECIFICATION_PERFECTLYMATCHEDLAYER_HPP_ -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" namespace geos { @@ -30,12 +30,12 @@ namespace geos * @class PerfectlyMatchedLayer * A class to manage Perfectly Matched Layer for wave propagation solvers */ -class PerfectlyMatchedLayer : public FieldSpecificationBase +class PerfectlyMatchedLayer : public FieldSpecification { public: /** * @brief constructor - * @param name the name of the FieldSpecificationBase in the data repository + * @param name the name of the FieldSpecification in the data repository * @param parent the parent group of this group. */ PerfectlyMatchedLayer( string const & name, dataRepository::Group * const parent ); @@ -101,7 +101,7 @@ class PerfectlyMatchedLayer : public FieldSpecificationBase /** * @brief View keys */ - struct viewKeyStruct : public FieldSpecificationBase::viewKeyStruct + struct viewKeyStruct : public FieldSpecification::viewKeyStruct { /// @return String key for the mininum (x,y,z) coordinates of inner PML boundaries static constexpr char const * xMinString() { return "xMin"; } diff --git a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp index 8a05108fe9d..08ce7843a75 100644 --- a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.cpp @@ -25,24 +25,24 @@ namespace geos using namespace dataRepository; SourceFluxBoundaryCondition::SourceFluxBoundaryCondition( string const & name, Group * const parent ): - FieldSpecificationBase( name, parent ) + FieldSpecification( name, parent ) { - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ). setInputFlag( InputFlags::FALSE ); setFieldName( catalogName() ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::functionNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::functionNameString() ). setDescription( GEOS_FMT( "Name of a function that specifies the variation of the production rate variations of this {}." "Multiplied by {}. If no function is provided, a constant value of 1 is used." "The produced fluid rate unit is in kg by default, or in mole if the flow solver uses moles.", catalogName(), - FieldSpecificationBase::viewKeyStruct::scaleString() ) ); + FieldSpecification::viewKeyStruct::scaleString() ) ); - getWrapper< real64 >( FieldSpecificationBase::viewKeyStruct::scaleString() ). + getWrapper< real64 >( FieldSpecification::viewKeyStruct::scaleString() ). setDescription( GEOS_FMT( "Multiplier of the {0} value. If no {0} is provided, this value is used directly.", - FieldSpecificationBase::viewKeyStruct::functionNameString() ) ); + FieldSpecification::viewKeyStruct::functionNameString() ) ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, SourceFluxBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, SourceFluxBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.hpp b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.hpp index 2ee5e258bef..5fb3c562f82 100644 --- a/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.hpp +++ b/src/coreComponents/fieldSpecification/SourceFluxBoundaryCondition.hpp @@ -21,7 +21,7 @@ #ifndef GEOS_FIELDSPECIFICATION_SOURCEFLUXBOUNDARYCONDITION_HPP_ #define GEOS_FIELDSPECIFICATION_SOURCEFLUXBOUNDARYCONDITION_HPP_ -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" namespace geos { @@ -30,12 +30,12 @@ namespace geos * @class SourceFluxBoundaryCondition * A class to manage Neumann boundary conditions */ -class SourceFluxBoundaryCondition : public FieldSpecificationBase +class SourceFluxBoundaryCondition : public FieldSpecification { public: /** * @brief constructor - * @param name the name of the FieldSpecificationBase in the data repository + * @param name the name of the FieldSpecification in the data repository * @param parent the parent group of this group. */ SourceFluxBoundaryCondition( string const & name, dataRepository::Group * const parent ); diff --git a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp index 49392b016f0..59b28aa1540 100644 --- a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp @@ -29,7 +29,7 @@ namespace geos using namespace dataRepository; TractionBoundaryCondition::TractionBoundaryCondition( string const & name, Group * parent ): - FieldSpecificationBase( name, parent ), + FieldSpecification( name, parent ), m_tractionType( TractionType::vector ), m_inputStress{}, m_scaleSet(), @@ -66,11 +66,11 @@ TractionBoundaryCondition::TractionBoundaryCondition( string const & name, Group setInputFlag( InputFlags::OPTIONAL ). setDescription( "The flag to indicate whether to apply the nodal scale on the traction magnitude" ); - getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ). + getWrapper< string >( FieldSpecification::viewKeyStruct::fieldNameString() ). setInputFlag( InputFlags::FALSE ); setFieldName( catalogName() ); - getWrapper< int >( FieldSpecificationBase::viewKeyStruct::componentString() ). + getWrapper< int >( FieldSpecification::viewKeyStruct::componentString() ). setInputFlag( InputFlags::FALSE ); } @@ -437,7 +437,7 @@ void TractionBoundaryCondition::reinitScaleSet( FaceManager const & faceManager, } ); } -REGISTER_CATALOG_ENTRY( FieldSpecificationBase, TractionBoundaryCondition, string const &, Group * const ) +REGISTER_CATALOG_ENTRY( FieldSpecification, TractionBoundaryCondition, string const &, Group * const ) } /* namespace geos */ diff --git a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.hpp b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.hpp index 9d32b2becc0..a4aeb779590 100644 --- a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.hpp +++ b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.hpp @@ -21,7 +21,7 @@ #ifndef GEOS_FIELDSPECIFICATION_TRACTIONBOUNDARYCONDITION_HPP #define GEOS_FIELDSPECIFICATION_TRACTIONBOUNDARYCONDITION_HPP -#include "FieldSpecificationBase.hpp" +#include "FieldSpecification.hpp" #include "mesh/FaceManager.hpp" #include "mesh/NodeManager.hpp" @@ -34,10 +34,10 @@ class TableFunction; * @class TractionBoundaryCondition * Holds data and methods to apply a traction boundary condition */ -class TractionBoundaryCondition : public FieldSpecificationBase +class TractionBoundaryCondition : public FieldSpecification { public: - /// @copydoc FieldSpecificationBase(string const &, dataRepository::Group *) + /// @copydoc FieldSpecification(string const &, dataRepository::Group *) TractionBoundaryCondition( string const & name, Group * parent ); /// deleted default constructor @@ -98,7 +98,7 @@ class TractionBoundaryCondition : public FieldSpecificationBase /** * @brief View keys */ - struct viewKeyStruct : public FieldSpecificationBase::viewKeyStruct + struct viewKeyStruct : public FieldSpecification::viewKeyStruct { /// @return The key for tractionType constexpr static char const * tractionTypeString() { return "tractionType"; } diff --git a/src/coreComponents/finiteVolume/FluxApproximationBase.cpp b/src/coreComponents/finiteVolume/FluxApproximationBase.cpp index 673d6f1b53c..4104ab292b9 100644 --- a/src/coreComponents/finiteVolume/FluxApproximationBase.cpp +++ b/src/coreComponents/finiteVolume/FluxApproximationBase.cpp @@ -143,7 +143,7 @@ void FluxApproximationBase::initializePostInitialConditionsPreSubGroups() fsManager.apply< FaceManager >( 0.0, // time = 0 mesh, fieldName, - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const & faceSet, FaceManager const &, diff --git a/src/coreComponents/integrationTests/fieldSpecificationTests/testRecursiveFieldApplication.cpp b/src/coreComponents/integrationTests/fieldSpecificationTests/testRecursiveFieldApplication.cpp index 0e948a64332..e257939aa0c 100644 --- a/src/coreComponents/integrationTests/fieldSpecificationTests/testRecursiveFieldApplication.cpp +++ b/src/coreComponents/integrationTests/fieldSpecificationTests/testRecursiveFieldApplication.cpp @@ -17,6 +17,7 @@ #include "mainInterface/ProblemManager.hpp" #include "mainInterface/GeosxState.hpp" #include "mainInterface/initialization.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/generators/CellBlockManager.hpp" @@ -40,7 +41,7 @@ void RegisterAndApplyField( DomainPartition & domain, { FieldSpecificationManager & fieldSpecificationManager = FieldSpecificationManager::getInstance(); - FieldSpecificationBase & fieldSpec = fieldSpecificationManager.registerGroup< FieldSpecificationBase >( fieldName ); + FieldSpecification & fieldSpec = fieldSpecificationManager.registerGroup< FieldSpecification >( fieldName ); fieldSpec.setFieldName( fieldName ); fieldSpec.setObjectPath( objectPath ); fieldSpec.setMeshObjectPath( domain.getMeshBodies() ); @@ -51,13 +52,13 @@ void RegisterAndApplyField( DomainPartition & domain, fieldSpecificationManager.apply( 0., domain.getMeshBody( 0 ).getBaseDiscretization(), "", - [&] ( FieldSpecificationBase const & bc, + [&] ( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, Group & targetGroup, string const name ) { - bc.applyFieldValue< FieldSpecificationEqual >( targetSet, 0.0, targetGroup, name ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual >( bc, targetSet, 0.0, targetGroup, name ); } ); } diff --git a/src/coreComponents/integrationTests/xmlTests/testXMLFile.cpp b/src/coreComponents/integrationTests/xmlTests/testXMLFile.cpp index 274a5d52e9b..a74fbdf00ff 100644 --- a/src/coreComponents/integrationTests/xmlTests/testXMLFile.cpp +++ b/src/coreComponents/integrationTests/xmlTests/testXMLFile.cpp @@ -18,7 +18,7 @@ #include "mainInterface/initialization.hpp" #include "mainInterface/GeosxState.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" -#include "fieldSpecification/FieldSpecificationBase.hpp" +#include "fieldSpecification/FieldSpecification.hpp" #include "dataRepository/Group.hpp" #include "dataRepository/DataContext.hpp" @@ -39,7 +39,7 @@ TEST( testXML, testXMLFile ) problemManager.parseInputFile(); // Check that we've read the full XML with all nested includes by inspecting boundary conditions - EXPECT_TRUE( problemManager.getFieldSpecificationManager().hasGroup< FieldSpecificationBase >( "v0" ) ); + EXPECT_TRUE( problemManager.getFieldSpecificationManager().hasGroup< FieldSpecification >( "v0" ) ); } /** diff --git a/src/coreComponents/mainInterface/ProblemManager.cpp b/src/coreComponents/mainInterface/ProblemManager.cpp index 3c2718b1955..4020a0da359 100644 --- a/src/coreComponents/mainInterface/ProblemManager.cpp +++ b/src/coreComponents/mainInterface/ProblemManager.cpp @@ -1149,7 +1149,7 @@ DomainPartition const & ProblemManager::getDomainPartition() const void ProblemManager::applyInitialConditions() { - m_fieldSpecificationManager->forSubGroups< FieldSpecificationBase >( [&]( FieldSpecificationBase & fs ) + m_fieldSpecificationManager->forSubGroups< FieldSpecification >( [&]( FieldSpecification & fs ) { fs.setMeshObjectPath( getDomainPartition().getMeshBodies() ); } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 48362c574a6..e0335b6f719 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -1867,7 +1867,7 @@ void CompositionalMultiphaseBase::applySourceFluxBC( real64 const time, arrayView1d< integer const > const ghostRank = subRegion.ghostRank(); // Step 3.1: get the values of the source boundary condition that need to be added to the rhs - // We don't use FieldSpecificationBase::applyConditionToSystem here because we want to account for the row permutation used in the + // We don't use FieldSpecificationImpl::applyConditionToSystem here because we want to account for the row permutation used in the // compositional solvers array1d< globalIndex > dofArray( targetSet.size() ); @@ -1878,17 +1878,18 @@ void CompositionalMultiphaseBase::applySourceFluxBC( real64 const time, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd( 0.0 ); // note that the dofArray will not be used after this step (simpler to use dofNumber instead) - fs.computeRhsContribution< FieldSpecificationAdd, - parallelDevicePolicy<> >( targetSet.toViewConst(), - time + dt, - dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - dofArray.toView(), - rhsContributionArrayView, - [] GEOS_HOST_DEVICE ( localIndex const ) + FieldSpecificationImpl::computeRhsContribution< FieldSpecificationAdd, + parallelDevicePolicy<> >( fs, + targetSet.toViewConst(), + time + dt, + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + dofArray.toView(), + rhsContributionArrayView, + [] GEOS_HOST_DEVICE ( localIndex const ) { return 0.0; } ); @@ -1973,7 +1974,7 @@ bool CompositionalMultiphaseBase::validateDirichletBC( DomainPartition & domain, fsManager.apply< ElementSubRegionBase >( time, mesh, flow::pressure::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -1999,7 +2000,7 @@ bool CompositionalMultiphaseBase::validateDirichletBC( DomainPartition & domain, fsManager.apply< ElementSubRegionBase >( time, mesh, flow::temperature::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -2024,7 +2025,7 @@ bool CompositionalMultiphaseBase::validateDirichletBC( DomainPartition & domain, fsManager.apply< ElementSubRegionBase >( time, mesh, flow::globalCompFraction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -2152,7 +2153,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, flow::pressure::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -2283,7 +2284,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, flow::temperature::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index 227055bf3ed..6e46bad4900 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -458,7 +458,7 @@ class CompositionalMultiphaseBase : public FlowSolverBase void initializeAquiferBC( constitutive::ConstitutiveManager const & cm ) const; /** - * @brief Utility function that encapsulates the call to FieldSpecificationBase::applyFieldValue in BC application + * @brief Utility function that encapsulates the call to FieldSpecificationImpl::applyFieldValue in BC application * @param[in] time_n the time at the beginning of the step * @param[in] dt the time step * @param[in] mesh the mesh level object @@ -577,7 +577,7 @@ void CompositionalMultiphaseBase::applyFieldValue( real64 const & time_n, fsManager.apply< OBJECT_TYPE >( time_n + dt, mesh, fieldKey, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & lset, OBJECT_TYPE & targetGroup, @@ -592,11 +592,12 @@ void CompositionalMultiphaseBase::applyFieldValue( real64 const & time_n, } // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - targetGroup, - boundaryFieldKey ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + targetGroup, + boundaryFieldKey ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 4d3f7ddbbbf..d8a98890142 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -1150,7 +1150,7 @@ bool CompositionalMultiphaseFVM::validateFaceDirichletBC( DomainPartition & doma fsManager.apply< FaceManager >( time, mesh, flow::pressure::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, @@ -1169,7 +1169,7 @@ bool CompositionalMultiphaseFVM::validateFaceDirichletBC( DomainPartition & doma fsManager.apply< FaceManager >( time, mesh, flow::temperature::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, @@ -1195,7 +1195,7 @@ bool CompositionalMultiphaseFVM::validateFaceDirichletBC( DomainPartition & doma fsManager.apply< FaceManager >( time, mesh, flow::globalCompFraction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, @@ -1309,7 +1309,7 @@ void CompositionalMultiphaseFVM::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, flow::pressure::key(), // we have required that pressure is always present - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp index c4f33665dd0..6fd5cba3a5c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp @@ -27,6 +27,7 @@ #include "constitutive/relativePermeability/RelativePermeabilityBase.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "finiteVolume/HybridMimeticDiscretization.hpp" #include "finiteVolume/MimeticInnerProductDispatch.hpp" #include "finiteVolume/FluxApproximationBase.hpp" @@ -207,7 +208,7 @@ void CompositionalMultiphaseHybridFVM::initializePostInitialConditionsPreSubGrou // isBoundaryFaceView is default-initialized to zero FieldSpecificationManager & fsManager = FieldSpecificationManager::getInstance(); - fsManager.forSubGroups< FieldSpecificationBase >( [&]( FieldSpecificationBase const & fs ) + fsManager.forSubGroups< FieldSpecification >( [&]( FieldSpecification const & fs ) { string const & fieldName = fs.getFieldName(); if( fieldName == flow::bcPressure::key() || @@ -740,7 +741,7 @@ void CompositionalMultiphaseHybridFVM::applyFaceDirichletBC( real64 const time_n // Get all face sets that have Dirichlet BCs std::set< string > bcFaceSets; - fsManager.forSubGroups< FieldSpecificationBase >( [&]( FieldSpecificationBase const & fs ) + fsManager.forSubGroups< FieldSpecification >( [&]( FieldSpecification const & fs ) { string const & fieldName = fs.getFieldName(); if( fieldName == flow::bcPressure::key() || @@ -953,19 +954,19 @@ void CompositionalMultiphaseHybridFVM::applyFaceDirichletBC( real64 const time_n fsManager.apply< FaceManager >( time_n + dt, mesh, flow::bcPressure::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, FaceManager & targetGroup, string const & ) { GEOS_UNUSED_VAR( setName ); - // Using the field specification functions to apply the boundary conditions to the system - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( targetSet, - time_n + dt, - targetGroup, - flow::bcPressure::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time_n + dt, + targetGroup, + flow::bcPressure::key() ); forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const a ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.cpp index 6bd4ead9e6b..0e9bea65019 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.cpp @@ -30,6 +30,7 @@ #include "constitutive/relativePermeability/RelativePermeabilitySelector.hpp" #include "fieldSpecification/EquilibriumInitialCondition.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "physicsSolvers/fluidFlow/SourceFluxStatistics.hpp" #include "physicsSolvers/LogLevelsInfo.hpp" @@ -685,7 +686,7 @@ bool ImmiscibleMultiphaseFlow::validateDirichletBC( DomainPartition & domain, fsManager.apply< ElementSubRegionBase >( time, mesh, fields::flow::pressure::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -708,7 +709,7 @@ bool ImmiscibleMultiphaseFlow::validateDirichletBC( DomainPartition & domain, fsManager.apply< ElementSubRegionBase >( time, mesh, fields::immiscibleMultiphaseFlow::phaseVolumeFraction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -742,7 +743,6 @@ bool ImmiscibleMultiphaseFlow::validateDirichletBC( DomainPartition & domain, fsManager.forSubGroups< EquilibriumInitialCondition >( [&] ( EquilibriumInitialCondition const & bc ) { string_array const & componentNames = bc.getComponentNames(); - GEOS_UNUSED_VAR( componentNames ); GEOS_WARNING( BCMessage::conflictingComposition( comp, componentNames[comp], regionName, subRegionName, setName, fields::immiscibleMultiphaseFlow::phaseVolumeFraction::key() ) @@ -822,7 +822,7 @@ void ImmiscibleMultiphaseFlow::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, fields::flow::pressure::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -977,17 +977,18 @@ void ImmiscibleMultiphaseFlow::applySourceFluxBC( real64 const time, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd( 0.0 ); // note that the dofArray will not be used after this step (simpler to use dofNumber instead) - fs.computeRhsContribution< FieldSpecificationAdd, - parallelDevicePolicy<> >( targetSet.toViewConst(), - time + dt, - dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - dofArray.toView(), - rhsContributionArrayView, - [] GEOS_HOST_DEVICE ( localIndex const ) + FieldSpecificationImpl::computeRhsContribution< FieldSpecificationAdd, + parallelDevicePolicy<> >( fs, + targetSet.toViewConst(), + time + dt, + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + dofArray.toView(), + rhsContributionArrayView, + [] GEOS_HOST_DEVICE ( localIndex const ) { return 0.0; } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.hpp index 7526130316c..5ccf6f7ef72 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.hpp @@ -21,6 +21,7 @@ #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_IMMISCIBLEMULTIPHASEFLOW_HPP_ #include "physicsSolvers/fluidFlow/FlowSolverBase.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "physicsSolvers/fluidFlow/kernels/immiscibleMultiphase/ImmiscibleMultiphaseKernels.hpp" @@ -263,7 +264,7 @@ class ImmiscibleMultiphaseFlow : public FlowSolverBase void updatePhaseMobility( ObjectManagerBase & dataGroup ) const; /** - * @brief Utility function that encapsulates the call to FieldSpecificationBase::applyFieldValue in BC application + * @brief Utility function that encapsulates the call to FieldSpecificationImpl::applyFieldValue in BC application * @param[in] time_n the time at the beginning of the step * @param[in] dt the time step * @param[in] mesh the mesh level object @@ -328,7 +329,7 @@ void ImmiscibleMultiphaseFlow::applyFieldValue( real64 const & time_n, fsManager.apply< OBJECT_TYPE >( time_n + dt, mesh, fieldKey, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & lset, OBJECT_TYPE & targetGroup, @@ -343,11 +344,12 @@ void ImmiscibleMultiphaseFlow::applyFieldValue( real64 const & time_n, } // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - targetGroup, - boundaryFieldKey ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + targetGroup, + boundaryFieldKey ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp b/src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp index 29bc7397087..4f5ca741847 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp @@ -22,6 +22,7 @@ #include "constitutive/solid/CoupledSolidBase.hpp" #include "dataRepository/Group.hpp" #include "discretizationMethods/NumericalMethodsManager.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "fieldSpecification/EquilibriumInitialCondition.hpp" @@ -843,17 +844,18 @@ void ReactiveCompositionalMultiphaseOBL::applySourceFluxBC( real64 const time, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd( 0.0 ); // note that the dofArray will not be used after this step (simpler to use dofNumber instead) - fs.computeRhsContribution< FieldSpecificationAdd, - parallelDevicePolicy<> >( targetSet.toViewConst(), - time + dt, - dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - dofArray.toView(), - rhsContributionArrayView, - [] GEOS_HOST_DEVICE ( localIndex const ) + FieldSpecificationImpl::computeRhsContribution< FieldSpecificationAdd, + parallelDevicePolicy<> >( fs, + targetSet.toViewConst(), + time + dt, + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + dofArray.toView(), + rhsContributionArrayView, + [] GEOS_HOST_DEVICE ( localIndex const ) { return 0.0; } ); @@ -923,7 +925,7 @@ bool ReactiveCompositionalMultiphaseOBL::validateDirichletBC( DomainPartition & fsManager.apply< ElementSubRegionBase >( time, mesh, flow::pressure::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -947,7 +949,7 @@ bool ReactiveCompositionalMultiphaseOBL::validateDirichletBC( DomainPartition & fsManager.apply< ElementSubRegionBase >( time, mesh, flow::globalCompFraction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -995,7 +997,7 @@ bool ReactiveCompositionalMultiphaseOBL::validateDirichletBC( DomainPartition & fsManager.apply< ElementSubRegionBase >( time, mesh, flow::temperature::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -1082,7 +1084,7 @@ void ReactiveCompositionalMultiphaseOBL::applyDirichletBC( real64 const time, fsManager.apply< ElementSubRegionBase >( time + dt, mesh, flow::pressure::key(), - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -1098,33 +1100,37 @@ void ReactiveCompositionalMultiphaseOBL::applyDirichletBC( real64 const time, fs ); } - fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, - time + dt, - subRegion, - flow::bcPressure::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time + dt, + subRegion, + flow::bcPressure::key() ); } ); // 2. Apply composition BC (global component fraction), store in a separate field fsManager.apply< ElementSubRegionBase >( time + dt, mesh, flow::globalCompFraction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, string const & ) { - fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, - time + dt, - subRegion, - flow::bcGlobalCompFraction::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time + dt, + subRegion, + flow::bcGlobalCompFraction::key() ); } ); // 3. Apply temperature Dirichlet BCs, store in a separate field fsManager.apply< ElementSubRegionBase >( time + dt, mesh, flow::temperature::key(), - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -1140,10 +1146,12 @@ void ReactiveCompositionalMultiphaseOBL::applyDirichletBC( real64 const time, fs ); } - fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, - time + dt, - subRegion, - flow::bcTemperature::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time + dt, + subRegion, + flow::bcTemperature::key() ); } ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -1154,7 +1162,7 @@ void ReactiveCompositionalMultiphaseOBL::applyDirichletBC( real64 const time, fsManager.apply< ElementSubRegionBase >( time + dt, mesh, flow::pressure::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp index 71288417c49..e3f7b67de2a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp @@ -29,6 +29,7 @@ #include "constitutive/thermalConductivity/SinglePhaseThermalConductivitySelector.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" #include "fieldSpecification/EquilibriumInitialCondition.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "physicsSolvers/fluidFlow/SourceFluxStatistics.hpp" @@ -894,18 +895,19 @@ void applyAndSpecifyFieldValue( real64 const & time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, fieldKey, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & lset, ElementSubRegionBase & subRegion, string const & ) { // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - subRegion, - boundaryFieldKey ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + subRegion, + boundaryFieldKey ); arrayView1d< integer const > const ghostRank = subRegion.ghostRank(); arrayView1d< globalIndex const > const dofNumber = @@ -1055,17 +1057,18 @@ void SinglePhaseBase::applySourceFluxBC( real64 const time_n, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd( 0.0 ); // note that the dofArray will not be used after this step (simpler to use dofNumber instead) - fs.computeRhsContribution< FieldSpecificationAdd, - parallelDevicePolicy<> >( targetSet.toViewConst(), - time_n + dt, - dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - dofArray.toView(), - rhsContributionArrayView, - [] GEOS_HOST_DEVICE ( localIndex const ) + FieldSpecificationImpl::computeRhsContribution< FieldSpecificationAdd, + parallelDevicePolicy<> >( fs, + targetSet.toViewConst(), + time_n + dt, + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + dofArray.toView(), + rhsContributionArrayView, + [] GEOS_HOST_DEVICE ( localIndex const ) { return 0.0; } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp index bff2fbd0f78..b507ea1b22c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp @@ -26,6 +26,7 @@ #include "finiteVolume/BoundaryStencil.hpp" #include "finiteVolume/FiniteVolumeManager.hpp" #include "finiteVolume/FluxApproximationBase.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" #include "linearAlgebra/multiscale/MultiscalePreconditioner.hpp" @@ -715,7 +716,7 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, flow::pressure::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, FaceManager & targetGroup, @@ -740,18 +741,19 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, pressureSets.insert( setName ); // first, evaluate BC to get primary field values (pressure) - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( targetSet, - time_n + dt, - targetGroup, - flow::facePressure::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time_n + dt, + targetGroup, + flow::facePressure::key() ); } ); // Take BCs defined for "temperature" field and apply values to "faceTemperature" fsManager.apply< FaceManager >( time_n + dt, mesh, flow::temperature::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, FaceManager & targetGroup, @@ -775,11 +777,12 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, temperatureSets.insert( setName ); // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( targetSet, - time_n + dt, - targetGroup, - flow::faceTemperature::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time_n + dt, + targetGroup, + flow::faceTemperature::key() ); } ); @@ -821,7 +824,7 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, flow::pressure::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, FaceManager & targetGroup, @@ -845,11 +848,12 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, } // first, evaluate BC to get primary field values (pressure) - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( targetSet, - time_n + dt, - targetGroup, - flow::facePressure::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time_n + dt, + targetGroup, + flow::facePressure::key() ); // TODO: currently we just use model from the first cell in this stencil diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp index 3c96ad83984..fdaf8496edb 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp @@ -23,6 +23,7 @@ #include "constitutive/ConstitutivePassThru.hpp" #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "discretizationMethods/NumericalMethodsManager.hpp" #include "finiteVolume/FiniteVolumeManager.hpp" @@ -371,7 +372,7 @@ void SinglePhaseHybridFVM::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, flow::bcPressure::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, FaceManager & targetGroup, @@ -392,11 +393,12 @@ void SinglePhaseHybridFVM::applyFaceDirichletBC( real64 const time_n, // next, we use the field specification functions to apply the boundary conditions to the system // Populate the face pressure vector at the boundaries of the domain - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( targetSet, - time_n + dt, - targetGroup, - flow::bcPressure::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + targetSet, + time_n + dt, + targetGroup, + flow::bcPressure::key() ); // Second, modify the residual/jacobian matrix as needed to impose the boundary conditions forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const a ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp index 5d543342aaa..6e75ae18ec3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp @@ -29,6 +29,7 @@ #include "constitutive/fluid/reactivefluid/ReactiveFluidSelector.hpp" #include "constitutive/solid/CoupledSolidBase.hpp" #include "constitutive/solid/ReactiveSolid.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "physicsSolvers/fluidFlow/SourceFluxStatistics.hpp" @@ -965,17 +966,18 @@ void SinglePhaseReactiveTransport::applySourceFluxBC( real64 const time_n, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd( 0.0 ); // note that the dofArray will not be used after this step (simpler to use dofNumber instead) - fs.computeRhsContribution< FieldSpecificationAdd, - parallelDevicePolicy<> >( targetSet.toViewConst(), - time_n + dt, - dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - dofArray.toView(), - rhsContributionArrayView, - [] GEOS_HOST_DEVICE ( localIndex const ) + FieldSpecificationImpl::computeRhsContribution< FieldSpecificationAdd, + parallelDevicePolicy<> >( fs, + targetSet.toViewConst(), + time_n + dt, + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + dofArray.toView(), + rhsContributionArrayView, + [] GEOS_HOST_DEVICE ( localIndex const ) { return 0.0; } ); @@ -1069,7 +1071,7 @@ void SinglePhaseReactiveTransport::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, fields::flow::pressure::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -1111,7 +1113,7 @@ void SinglePhaseReactiveTransport::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, fields::flow::logPrimarySpeciesConcentration::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -1163,7 +1165,7 @@ void SinglePhaseReactiveTransport::applyDirichletBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, fields::flow::temperature::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -1477,7 +1479,7 @@ void SinglePhaseReactiveTransport::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, fields::flow::pressure::key(), // we have required that pressure is always present - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, @@ -1528,7 +1530,7 @@ void SinglePhaseReactiveTransport::applyFaceDirichletBC( real64 const time_n, fsManager.apply< FaceManager >( time_n + dt, mesh, fields::flow::pressure::key(), // we have required that pressure is always present - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, FaceManager &, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.hpp index 8ed4b4d47e3..4e981edb7c4 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.hpp @@ -20,6 +20,7 @@ #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVETRANSPORT_HPP_ #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVETRANSPORT_HPP_ +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseFVM.hpp" @@ -243,7 +244,7 @@ class SinglePhaseReactiveTransport : public SinglePhaseBase arrayView1d< real64 > const & localRhs ) const override; /** - * @brief Utility function that encapsulates the call to FieldSpecificationBase::applyFieldValue in BC application + * @brief Utility function that encapsulates the call to FieldSpecificationImpl::applyFieldValue in BC application * @param[in] time_n the time at the beginning of the step * @param[in] dt the time step * @param[in] mesh the mesh level object @@ -347,7 +348,7 @@ void SinglePhaseReactiveTransport::applyFieldValue( real64 const & time_n, fsManager.apply< OBJECT_TYPE >( time_n + dt, mesh, fieldKey, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & lset, OBJECT_TYPE & targetGroup, @@ -362,11 +363,12 @@ void SinglePhaseReactiveTransport::applyFieldValue( real64 const & time_n, } // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - targetGroup, - boundaryFieldKey ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + targetGroup, + boundaryFieldKey ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp index c0718a19e35..3087c47b322 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp @@ -29,6 +29,7 @@ #include "constitutive/fluid/singlefluid/ParticleFluidFields.hpp" #include "constitutive/permeability/PermeabilityFields.hpp" #include "discretizationMethods/NumericalMethodsManager.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" @@ -661,7 +662,7 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, proppant::proppantConcentration::key(), - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & lset, ElementSubRegionBase & subRegion, @@ -673,15 +674,16 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, arrayView1d< real64 const > const proppantConc = subRegion.getReference< array1d< real64 > >( proppant::proppantConcentration::key() ); - fs.applyBoundaryConditionToSystem< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - subRegion, - dofNumber, - rankOffset, - localMatrix, - localRhs, - proppantConc ); + FieldSpecificationImpl::applyBoundaryConditionToSystem< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + subRegion, + dofNumber, + rankOffset, + localMatrix, + localRhs, + proppantConc ); } ); // Apply Dirichlet BC for component concentration @@ -692,7 +694,7 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, proppant::proppantConcentration::key(), - [&]( FieldSpecificationBase const &, + [&]( FieldSpecification const &, string const & setName, SortedArrayView< localIndex const > const &, ElementSubRegionBase & subRegion, @@ -711,7 +713,7 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, proppant::componentConcentration::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, @@ -729,10 +731,11 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, getDataContext() ); bcStatusMap[subRegionName][setName][comp] = true; - fs.applyFieldValue< FieldSpecificationEqual >( targetSet, - time_n + dt, - subRegion, - proppant::bcComponentConcentration::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual >( fs, + targetSet, + time_n + dt, + subRegion, + proppant::bcComponentConcentration::key() ); } ); @@ -760,7 +763,7 @@ void ProppantTransport::applyBoundaryConditions( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, proppant::proppantConcentration::key(), - [&] ( FieldSpecificationBase const &, + [&] ( FieldSpecification const &, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.hpp b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.hpp index 4b53d67075c..4345675794d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.hpp @@ -31,7 +31,7 @@ namespace dataRepository { class Group; } -class FieldSpecificationBase; +class FieldSpecification; class FiniteElementBase; class DomainPartition; diff --git a/src/coreComponents/physicsSolvers/inducedSeismicity/SeismicityRate.cpp b/src/coreComponents/physicsSolvers/inducedSeismicity/SeismicityRate.cpp index f614a96c67b..5be2a38d1e0 100644 --- a/src/coreComponents/physicsSolvers/inducedSeismicity/SeismicityRate.cpp +++ b/src/coreComponents/physicsSolvers/inducedSeismicity/SeismicityRate.cpp @@ -29,6 +29,7 @@ #include "physicsSolvers/fluidFlow/FlowSolverBase.hpp" #include "physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" @@ -360,7 +361,7 @@ real64 SeismicityRate::updateStresses( real64 const & time_n, fsManager.apply< ElementSubRegionBase >( time_n + dt, mesh, key, - [&]( FieldSpecificationBase const & fs, + [&]( FieldSpecification const & fs, string const & setName, SortedArrayView< localIndex const > const & lset, ElementSubRegionBase & subRegion, @@ -369,16 +370,17 @@ real64 SeismicityRate::updateStresses( real64 const & time_n, globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( lset.size() ); GEOS_LOG_LEVEL_RANK_0_ON_GROUP( logInfo::BoundaryConditions, GEOS_FMT( bcLogMessage, - this->getName(), time_n+dt, FieldSpecificationBase::catalogName(), + this->getName(), time_n+dt, FieldSpecification::catalogName(), fs.getName(), setName, subRegion.getName(), fs.getScale(), numTargetElems ), fs ); // Specify the bc value of the field - fs.applyFieldValue< FieldSpecificationEqual, - parallelDevicePolicy<> >( lset, - time_n + dt, - subRegion, - key ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelDevicePolicy<> >( fs, + lset, + time_n + dt, + subRegion, + key ); } ); } } ); diff --git a/src/coreComponents/physicsSolvers/simplePDE/LaplaceBaseH1.cpp b/src/coreComponents/physicsSolvers/simplePDE/LaplaceBaseH1.cpp index c0a49eb8bcc..1433c3ac6c0 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/LaplaceBaseH1.cpp +++ b/src/coreComponents/physicsSolvers/simplePDE/LaplaceBaseH1.cpp @@ -20,6 +20,7 @@ #include "LaplaceBaseH1.hpp" #include "dataRepository/InputFlags.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "mainInterface/GeosxState.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" #include "mesh/DomainPartition.hpp" @@ -210,21 +211,22 @@ void LaplaceBaseH1:: fsManager.apply< NodeManager >( time, mesh, m_fieldName, - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, NodeManager & targetGroup, string const & GEOS_UNUSED_PARAM( fieldName ) ) { - bc.applyBoundaryConditionToSystem< FieldSpecificationEqual, - parallelDevicePolicy< > >( targetSet, - time, - targetGroup, - m_fieldName, - dofManager.getKey( m_fieldName ), - dofManager.rankOffset(), - localMatrix, - localRhs ); + FieldSpecificationImpl::applyBoundaryConditionToSystem< FieldSpecificationEqual, + parallelDevicePolicy< > >( bc, + targetSet, + time, + targetGroup, + m_fieldName, + dofManager.getKey( m_fieldName ), + dofManager.rankOffset(), + localMatrix, + localRhs ); } ); } ); } diff --git a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp index aced6493e37..bfe09b66e6d 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp +++ b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp @@ -33,6 +33,7 @@ #include "constitutive/solid/Damage.hpp" #include "physicsSolvers/LogLevelsInfo.hpp" #include "constitutive/solid/SolidBase.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "finiteElement/FiniteElementDiscretization.hpp" #include "finiteElement/Kinematics.h" @@ -590,21 +591,22 @@ void PhaseFieldDamageFEM::applyDirichletBCImplicit( real64 const time, fsManager.template apply< NodeManager >( time, mesh, m_fieldName, - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, NodeManager & targetGroup, string const GEOS_UNUSED_PARAM( fieldName ) ) -> void { - bc.applyBoundaryConditionToSystem< FieldSpecificationEqual, - parallelDevicePolicy< > >( targetSet, - time, - targetGroup, - m_fieldName, - dofManager.getKey( m_fieldName ), - dofManager.rankOffset(), - localMatrix, - localRhs ); + FieldSpecificationImpl::applyBoundaryConditionToSystem< FieldSpecificationEqual, + parallelDevicePolicy< > >( bc, + targetSet, + time, + targetGroup, + m_fieldName, + dofManager.getKey( m_fieldName ), + dofManager.rankOffset(), + localMatrix, + localRhs ); } ); fsManager.applyFieldValue< serialPolicy >( time, mesh, viewKeyStruct::coeffNameString() ); diff --git a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.hpp b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.hpp index 2e69325e94d..d4d0bb5ad93 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.hpp +++ b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.hpp @@ -36,7 +36,7 @@ namespace dataRepository { class Group; } -class FieldSpecificationBase; +class FieldSpecification; class FiniteElementBase; class DomainPartition; diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp index a9439ff32f5..5b55ace5977 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp @@ -30,6 +30,7 @@ #include "constitutive/ConstitutiveManager.hpp" #include "common/GEOS_RAJA_Interface.hpp" #include "discretizationMethods/NumericalMethodsManager.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/TractionBoundaryCondition.hpp" #include "finiteElement/FiniteElementDiscretizationManager.hpp" @@ -619,7 +620,7 @@ real64 SolidMechanicsLagrangianFEM::explicitStep( real64 const & time_n, fsManager.applyFieldValue( time_n + dt, mesh, solidMechanics::totalDisplacement::key(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, SortedArrayView< localIndex const > const & targetSet ) { integer const component = bc.getComponent(); @@ -633,7 +634,7 @@ real64 SolidMechanicsLagrangianFEM::explicitStep( real64 const & time_n, vel( a, component ) = u( a, component ); } ); }, - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, SortedArrayView< localIndex const > const & targetSet ) { integer const component = bc.getComponent(); @@ -713,21 +714,22 @@ void SolidMechanicsLagrangianFEM::applyDisplacementBCImplicit( real64 const time fsManager.apply< NodeManager >( time, mesh, solidMechanics::totalDisplacement::key(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, NodeManager & targetGroup, string const fieldName ) { - bc.applyBoundaryConditionToSystem< FieldSpecificationEqual, - parallelDevicePolicy< > >( targetSet, - time, - targetGroup, - fieldName, - dofKey, - dofManager.rankOffset(), - localMatrix, - localRhs ); + FieldSpecificationImpl::applyBoundaryConditionToSystem< FieldSpecificationEqual, + parallelDevicePolicy< > >( bc, + targetSet, + time, + targetGroup, + fieldName, + dofKey, + dofManager.rankOffset(), + localMatrix, + localRhs ); if( targetSet.size() > 0 && bc.getComponent() == 0 ) { @@ -1244,22 +1246,23 @@ SolidMechanicsLagrangianFEM:: fsManager.apply< NodeManager >( time_n + dt, mesh, viewKeyStruct::forceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, NodeManager & targetGroup, string const & GEOS_UNUSED_PARAM( fieldName ) ) { // TODO: fix use of dummy name - bc.applyBoundaryConditionToSystem< FieldSpecificationAdd, - parallelDevicePolicy< > >( targetSet, - time_n + dt, - targetGroup, - solidMechanics::totalDisplacement::key(), - dofKey, - dofManager.rankOffset(), - localMatrix, - localRhs ); + FieldSpecificationImpl::applyBoundaryConditionToSystem< FieldSpecificationAdd, + parallelDevicePolicy< > >( bc, + targetSet, + time_n + dt, + targetGroup, + solidMechanics::totalDisplacement::key(), + dofKey, + dofManager.rankOffset(), + localMatrix, + localRhs ); } ); } ); diff --git a/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsEmbeddedFractures.cpp b/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsEmbeddedFractures.cpp index 0fe6810a514..4217dc33d98 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsEmbeddedFractures.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsEmbeddedFractures.cpp @@ -22,6 +22,7 @@ #include "common/TimingMacros.hpp" #include "common/GEOS_RAJA_Interface.hpp" #include "constitutive/contact/FrictionSelector.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "finiteElement/elementFormulations/FiniteElementBase.hpp" #include "linearAlgebra/utilities/LAIHelperFunctions.hpp" @@ -528,16 +529,18 @@ void SolidMechanicsEmbeddedFractures::applyTractionBC( real64 const time_n, fsManager.apply< ElementSubRegionBase >( time_n+ dt, mesh, contact::traction::key(), - [&] ( FieldSpecificationBase const & fs, + [&] ( FieldSpecification const & fs, string const &, SortedArrayView< localIndex const > const & targetSet, ElementSubRegionBase & subRegion, string const & ) { - fs.applyFieldValue< FieldSpecificationEqual, parallelHostPolicy >( targetSet, - time_n+dt, - subRegion, - contact::traction::key() ); + FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual, + parallelHostPolicy >( fs, + targetSet, + time_n+dt, + subRegion, + contact::traction::key() ); } ); } ); } diff --git a/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsLagrangeContactBubbleStab.cpp b/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsLagrangeContactBubbleStab.cpp index d73fb84619a..baae671183d 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsLagrangeContactBubbleStab.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsLagrangeContactBubbleStab.cpp @@ -29,6 +29,7 @@ #include "physicsSolvers/LogLevelsInfo.hpp" #include "finiteElement/FiniteElementDiscretization.hpp" #include "constitutive/contact/FrictionSelector.hpp" +#include "fieldSpecification/FieldSpecificationImpl.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" @@ -74,18 +75,19 @@ real64 SolidMechanicsLagrangeContactBubbleStab::solverStep( real64 const & time_ fieldSpecificationManager.applyInitialConditions( mesh ); // Would like to do it like this but it is not working. There is a cast in Object path that tries to cast // all objects that derive from ElementSubRegionBase to the specified type so this obviously fails. - // fieldSpecificationManager.forSubGroups< FieldSpecificationBase >( [&] ( FieldSpecificationBase const & fs ) + // fieldSpecificationManager.forSubGroups< FieldSpecification >( [&] ( FieldSpecification const & fs ) // { // if( fs.initialCondition() ) // { - // fs.apply< SurfaceElementSubRegion >( mesh, - // [&]( FieldSpecificationBase const & bc, - // string const &, - // SortedArrayView< localIndex const > const & targetSet, - // SurfaceElementSubRegion & targetGroup, - // string const fieldName ) + // FieldSpecificationImpl::apply< SurfaceElementSubRegion >( fs, + // mesh, + // [&]( FieldSpecification const & bc, + // string const &, + // SortedArrayView< localIndex const > const & targetSet, + // SurfaceElementSubRegion & targetGroup, + // string const fieldName ) // { - // bc.applyFieldValue< FieldSpecificationEqual >( targetSet, 0.0, targetGroup, fieldName ); + // FieldSpecificationImpl::applyFieldValue< FieldSpecificationEqual >( bc, targetSet, 0.0, targetGroup, fieldName ); // } ); // } // } ); diff --git a/src/coreComponents/physicsSolvers/wavePropagation/dg/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationDG.cpp b/src/coreComponents/physicsSolvers/wavePropagation/dg/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationDG.cpp index 51956b4a801..d2ed40b724b 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/dg/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationDG.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/dg/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationDG.cpp @@ -409,7 +409,7 @@ void AcousticWaveEquationDG::applyFreeSurfaceBC( real64 const time, DomainPartit // fsManager.apply< FaceManager >( time, // domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), // string( "FreeSurface" ), -// [&]( FieldSpecificationBase const & bc, +// [&]( FieldSpecification const & bc, // string const &, // SortedArrayView< localIndex const > const & targetSet, // FaceManager &, diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp index 1dbb298ceca..e56ca81c75c 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp @@ -379,7 +379,7 @@ void AcousticFirstOrderWaveEquationSEM::applyFreeSurfaceBC( real64 const time, D fsManager.apply< FaceManager >( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), WaveSolverBase::viewKeyStruct::freeSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, FaceManager &, diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp index a9a9206afdc..1cd6fafaa2f 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp @@ -389,7 +389,7 @@ void AcousticVTIWaveEquationSEM::precomputeSurfaceFieldIndicator( DomainPartitio fsManager.apply< FaceManager >( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), viewKeyStruct::lateralSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, FaceManager &, @@ -422,7 +422,7 @@ void AcousticVTIWaveEquationSEM::precomputeSurfaceFieldIndicator( DomainPartitio fsManager.apply< FaceManager >( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), viewKeyStruct::bottomSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, FaceManager &, @@ -479,7 +479,7 @@ void AcousticVTIWaveEquationSEM::applyFreeSurfaceBC( real64 time, DomainPartitio fsManager.apply< FaceManager >( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), WaveSolverBase::viewKeyStruct::freeSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, FaceManager &, diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp index f6613f6c4f4..69c5bdbd525 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp @@ -637,7 +637,7 @@ void AcousticWaveEquationSEM::applyFreeSurfaceBC( real64 time, DomainPartition & fsManager.apply< FaceManager >( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), string( "FreeSurface" ), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, FaceManager &, diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp index ffc9fc8b4d3..833d8a76c0d 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp @@ -444,7 +444,7 @@ void ElasticFirstOrderWaveEquationSEM::applyFreeSurfaceBC( real64 const time, Do fsManager.apply( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), WaveSolverBase::viewKeyStruct::freeSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, Group &, diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp index 52af88358e0..07f7c4ad5e4 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp @@ -729,7 +729,7 @@ void ElasticWaveEquationSEM::applyFreeSurfaceBC( real64 const time, DomainPartit fsManager.apply( time, domain.getMeshBody( 0 ).getMeshLevel( m_discretizationName ), WaveSolverBase::viewKeyStruct::freeSurfaceString(), - [&]( FieldSpecificationBase const & bc, + [&]( FieldSpecification const & bc, string const &, SortedArrayView< localIndex const > const & targetSet, Group &,