19 #ifndef GEOSX_MANAGERS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP 20 #define GEOSX_MANAGERS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP 23 #include "codingUtilities/traits.hpp" 24 #include "codingUtilities/Utilities.hpp" 29 #include "rajaInterface/GEOS_RAJA_Interface.hpp" 106 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
110 Group * dataGroup )
const;
123 template<
typename FIELD_OP,
typename POLICY=parallelHostPolicy >
127 string const & fieldname )
const;
148 template<
typename FIELD_OP,
typename LAI >
152 string const & fieldName,
153 string const & dofMapName,
182 template<
typename FIELD_OP,
typename LAI,
typename LAMBDA >
191 LAMBDA && lambda )
const;
217 template<
typename FIELD_OP,
typename LAI,
typename LAMBDA >
227 LAMBDA && lambda )
const;
239 template<
typename LAI >
264 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
293 template<
typename FIELD_OP,
typename POLICY >
297 string const & fieldName,
298 string const & dofMapName,
325 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
334 LAMBDA && lambda )
const;
359 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
369 LAMBDA && lambda )
const;
381 template<
typename POLICY >
434 return m_functionName;
508 return m_initialCondition;
526 m_fieldName = fieldName;
535 m_objectPath = objectPath;
553 m_initialCondition = isInitialCondition;
562 m_setNames.emplace_back( setName );
595 int m_initialCondition;
598 string m_functionName;
610 string m_bcApplicationFunctionName;
618 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
622 Group * dataGroup )
const 627 if( m_functionName.empty() )
629 real64 const value = m_scale;
633 FIELD_OP::SpecifyFieldValue( field, a, component, value );
640 GEOSX_ERROR_IF(
function ==
nullptr,
"Function '" << m_functionName <<
"' not found" );
642 if( function->isFunctionOfTime()==2 )
644 real64 const value = m_scale *
function->Evaluate( &time );
648 FIELD_OP::SpecifyFieldValue( field, a, component, value );
654 function->Evaluate( dataGroup, time, targetSet, result );
660 FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] );
667 template<
typename FIELD_OP,
typename POLICY >
671 string const & fieldName )
const 674 std::type_index typeIndex = std::type_index( wrapper->
get_typeid());
680 using ArrayType = decltype(arrayInstance);
683 auto const & field = view.
reference().toView();
684 ApplyFieldValueKernel< FIELD_OP, POLICY >( field, targetSet, time, dataGroup );
688 template<
typename FIELD_OP,
typename LAI >
692 string const & fieldName,
693 string const & dofMapName,
699 std::type_index typeIndex = std::type_index( wrapperBase.
get_typeid());
705 using FieldType = decltype( type );
707 traits::ViewTypeConst< FieldType > fieldView = wrapper.
reference();
709 this->ApplyBoundaryConditionToSystem< FIELD_OP, LAI >( targetSet, time, dataGroup, dofMap, dofDim, matrix, rhs,
719 template<
typename FIELD_OP,
typename LAI,
typename LAMBDA >
729 LAMBDA && lambda )
const 739 real64 sizeScalingFactor = 0;
749 MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM,
MPI_COMM_GEOSX );
752 sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
756 sizeScalingFactor = 1;
759 if( m_functionName.empty() )
763 for(
auto a : targetSet )
765 dof( counter ) = dofMap[a]+component;
766 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
768 rhsContribution( counter ),
769 m_scale * sizeScalingFactor,
773 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
779 GEOSX_ERROR_IF(
function ==
nullptr,
"Function '" << m_functionName <<
"' not found" );
781 if( function->isFunctionOfTime()==2 )
783 real64 value = m_scale *
function->Evaluate( &time ) * sizeScalingFactor;
785 for(
auto a : targetSet )
787 dof( counter ) = dofMap[a] + component;
788 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
790 rhsContribution( counter ),
795 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
800 result.
resize( LvArray::integerConversion< localIndex >( targetSet.
size()));
801 function->Evaluate( dataGroup, time, targetSet, result );
803 for(
auto a : targetSet )
805 dof( counter ) = dofMap[a] + component;
806 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
808 rhsContribution( counter ),
809 m_scale * result[counter] * sizeScalingFactor,
813 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
818 template<
typename FIELD_OP,
typename LAI,
typename LAMBDA >
829 LAMBDA && lambda )
const 839 real64 sizeScalingFactor = 0.0;
849 MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM,
MPI_COMM_GEOSX );
852 sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
856 sizeScalingFactor = 1;
860 if( m_functionName.empty() )
864 for(
auto a : targetSet )
866 dof( counter ) = dofMap[a]+component;
867 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
869 rhsContribution( counter ),
870 m_scale * dt * sizeScalingFactor,
874 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
880 GEOSX_ERROR_IF(
function ==
nullptr,
"Function '" << m_functionName <<
"' not found" );
882 if( function->isFunctionOfTime()==2 )
884 real64 value = m_scale * dt *
function->Evaluate( &time ) * sizeScalingFactor;
886 for(
auto a : targetSet )
888 dof( counter ) = dofMap[a] + component;
889 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
891 rhsContribution( counter ),
896 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
901 result.
resize( LvArray::integerConversion< localIndex >( targetSet.
size()));
902 function->Evaluate( dataGroup, time, targetSet, result );
904 for(
auto a : targetSet )
906 dof( counter ) = dofMap[a] + component;
907 FIELD_OP::template SpecifyFieldValue< LAI >( dof( counter ),
909 rhsContribution( counter ),
910 m_scale * dt * result[counter] * sizeScalingFactor,
914 FIELD_OP::template PrescribeRhsValues< LAI >( rhs, counter, dof.data(), rhsContribution.data() );
919 template<
typename LAI >
926 for(
auto a : targetSet )
929 matrix.clearRow( dof );
933 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
944 this->ApplyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs,
953 template<
typename FIELD_OP,
typename POLICY >
957 string const & fieldName,
958 string const & dofMapName,
964 std::type_index typeIndex = std::type_index( wrapperBase.
get_typeid());
969 using FieldType = decltype( type );
971 ApplyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs, wrapper.
reference() );
975 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
985 LAMBDA && lambda )
const 987 return ApplyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet,
995 std::forward< LAMBDA >( lambda ) );
998 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
1009 LAMBDA && lambda )
const 1021 real64 sizeScalingFactor = 0.0;
1031 MpiWrapper::allReduce( &localSetSize, &globalSetSize, 1, MPI_SUM,
MPI_COMM_GEOSX );
1034 sizeScalingFactor = globalSetSize >= 1 ? 1.0 / globalSetSize : 1;
1038 sizeScalingFactor = 1;
1042 if( functionName.empty() || functionManager.getGroupReference<
FunctionBase >( functionName ).isFunctionOfTime() == 2 )
1044 real64 value = m_scale * dt * sizeScalingFactor;
1045 if( !functionName.empty() )
1048 value *=
function.
Evaluate( &time );
1051 forAll< POLICY >( targetSet.
size(),
1052 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda]
GEOSX_HOST_DEVICE (
localIndex const i )
1055 dof[ i ] = dofMap[ a ] + component;
1056 FIELD_OP::SpecifyFieldValue( dof[ i ],
1059 rhsContribution[ i ],
1069 function.Evaluate( dataGroup, time, targetSet, resultsArray );
1071 real64 const value = m_scale * dt * sizeScalingFactor;
1073 forAll< POLICY >( targetSet.
size(),
1074 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda]
GEOSX_HOST_DEVICE (
1078 dof[ i ] = dofMap[ a ] + component;
1079 FIELD_OP::SpecifyFieldValue( dof[ i ],
1082 rhsContribution[ i ],
1083 value * results[ i ],
1088 FIELD_OP::template PrescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution );
1091 template<
typename POLICY >
1104 localIndex const numEntries = matrix.numNonZeros( dof );
#define GEOSX_HOST_DEVICE
Marks a host-device function.
static constexpr auto objectPathString
The key for objectPath.
void SetObjectPath(string const &objectPath)
void ApplyFieldValue(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group *dataGroup, string const &fieldname) const
static constexpr auto beginTimeString
The key for beginTime.
int initialCondition() const
virtual const string getCatalogName() const
return the catalog name
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
constexpr void scale(VECTOR &&vector, std::remove_reference_t< decltype(vector[0]) > const scale)
Multiply the entries of vector by scale.
void ApplyBoundaryConditionToSystemKernel(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const *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
Apply a boundary condition to a system of equations.
virtual const string & GetObjectPath() const
void SetScale(real64 const &scale)
static constexpr auto constitutivePathString
The key for constitutivePath.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
static TypeIDs typeID(std::type_index typeIndex)
Return a TypeID enum given a std::type_index.
static constexpr auto componentString
The key for component.
static Wrapper< T > * cast(WrapperBase *const base)
Static function to cast a Wrapper base to a derived Wrapper<T>
static constexpr auto bcApplicationTableNameString
The key for bcApplicationTableName.
LAInterface::ParallelVector ParallelVector
Alias for ParallelVector.
static auto ApplyArrayTypeLambda1(const TypeIDs type, LAMBDA lambda)
this function provides a switchyard for the intrinsic supported GEOSX array types which calls a gener...
bool m_normalizeBySetSize
The flag used to decide if the BC value is normalized by the size of the set on which it is applied...
string_array const & GetSetNames() const
static string CatalogName()
Static Factory Catalog Functions.
static constexpr auto directionString
The key for direction.
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &
constexpr ArrayView< T const, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > toViewConst() const &&=delete
Overload for rvalues that is deleted.
This class serves to provide a "view" of a multidimensional array.
void ApplyFieldValueKernel(ArrayView< T, N, USD > const &field, SortedArrayView< localIndex const > const &targetSet, real64 const time, Group *dataGroup) const
struct geosx::FieldSpecificationBase::groupKeyStruct groupKeys
groupKeys
string const & GetFunctionName() const
static FunctionManager & Instance()
Return the function manager instance.
double real64
64-bit floating point type.
virtual ~FieldSpecificationBase() override
void ZeroSystemRowsForBoundaryCondition(SortedArrayView< localIndex const > const &targetSet, arrayView1d< globalIndex const > const &dofMap, typename LAI::ParallelMatrix &matrix) const
Zero matrix rows to apply boundary conditions.
static CatalogInterface::CatalogType & GetCatalog()
static function to return static catalog.
FieldSpecificationBase(string const &name, dataRepository::Group *parent)
constructor
constexpr ArrayView toView() const &
constexpr INDEX_TYPE size() const
virtual const string & GetFieldName() const
static constexpr auto functionNameString
The key for functionName.
GEOSX_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
int MPI_COMM_GEOSX
Global MPI communicator used by GEOSX.
Base class for all wrappers containing common operations.
virtual void Evaluate(dataRepository::Group const *const group, real64 const time, SortedArrayView< localIndex const > const &set, real64_array &result) const =0
Method to evaluate a function on a target object.
real64 GetStartTime() const
static constexpr auto dataTypeString
The key for dataType.
static constexpr auto setNamesString
The key for setName.
std::int32_t integer
Signed integer type.
static constexpr auto endTimeString
The key for endTime.
void InitialCondition(bool isInitialCondition)
This class provides the base class/interface for the catalog value objects.
static GEOSX_HOST_DEVICE std::enable_if< !traits::is_tensorT< T >, void >::type ReadFieldValue(arrayView1d< T const > const &field, localIndex const index, integer const component, real64 &value)
Read a field value.
static constexpr auto initialConditionString
The key for initialCondition.
void PostProcessInput() override final
#define GEOSX_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
virtual std::type_info const & get_typeid() const =0
Get the typeid of T.
virtual const R1Tensor & GetDirection(real64 time)
T & reference()
Accessor for m_data.
void resize(int const numDims, DIMS_TYPE const *const dims)
Resize the dimensions of the Array to match the given dimensions.
void AddSetName(string const &setName)
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
static constexpr auto fieldNameString
The key for fieldName.
static constexpr auto scaleString
The key for scale.
static auto ApplyArrayTypeLambda2(const TypeIDs type, bool const errorIfTypeNotFound, LAMBDA &&lambda)
Provides a switchyard for the intrinsic supported GEOSX array types which calls a generic lambda that...
real64 GetEndTime() const
LAInterface::ParallelMatrix ParallelMatrix
Alias for ParallelMatrix.
static constexpr auto fluxBoundaryConditionString
The key for fluxBoundaryCondition.
#define GEOSX_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
void ApplyBoundaryConditionToSystem(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group const *const dataGroup, string const &fieldName, string const &dofMapName, integer const &dofDim, typename LAI::ParallelMatrix &matrix, typename LAI::ParallelVector &rhs) const
Function to apply a boundary condition to a system of equations.
void SetFieldName(string const &fieldName)
struct geosx::FieldSpecificationBase::viewKeyStruct viewKeys
viewKeys
WrapperBase const * getWrapperBase(indexType const index) const
Retrieve a WrapperBase stored in this group.
virtual int GetComponent() const
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
T * GetGroup(localIndex index)
Retrieve a sub-group from the current Group using an index.
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...
#define GEOSX_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
T & getGroupReference(string const &key)