20 #ifndef GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP
21 #define GEOS_FIELDSPECIFICATION_FIELDSPECIFICATIONBASE_HPP
25 #include "codingUtilities/traits.hpp"
26 #include "codingUtilities/Utilities.hpp"
33 #include "common/GEOS_RAJA_Interface.hpp"
121 template<
typename OBJECT_TYPE,
125 LAMBDA && lambda )
const
129 [&] ( OBJECT_TYPE & object )
134 for(
auto & setName : setNames )
139 lambda(
dynamic_cast< BC_TYPE
const &
>(*
this), setName, targetSet,
object,
getFieldName() );
156 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
160 Group & dataGroup )
const;
173 template<
typename FIELD_OP,
typename POLICY=parallelHostPolicy >
177 string const & fieldname )
const;
199 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
228 template<
typename FIELD_OP,
typename POLICY >
232 string const & fieldName,
233 string const & dofMapName,
260 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
269 LAMBDA && lambda )
const;
294 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
304 LAMBDA && lambda )
const;
335 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
346 LAMBDA && lambda )
const;
359 template<
typename POLICY >
403 return m_functionName;
476 return m_initialCondition;
494 m_fieldName = fieldName;
503 m_objectPath = objectPath;
521 m_initialCondition = isInitialCondition;
530 m_setNames.emplace_back( setName );
547 return *(m_meshObjectPaths.get());
563 std::unique_ptr< MeshObjectPath > m_meshObjectPaths;
577 int m_initialCondition;
580 string m_functionName;
592 string m_bcApplicationFunctionName;
597 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
601 Group & dataGroup )
const
606 if( m_functionName.empty() )
608 real64 const value = m_scale;
612 FIELD_OP::SpecifyFieldValue( field, a, component, value );
623 catch( std::exception
const & e )
625 throw InputError( e, GEOS_FMT(
"Error while reading {}:\n",
630 if(
function.isFunctionOfTime()==2 )
632 real64 const value = m_scale *
function.evaluate( &time );
636 FIELD_OP::SpecifyFieldValue( field, a, component, value );
642 function.evaluate( dataGroup, time, targetSet, result );
644 real64 const scale = m_scale;
648 FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] );
655 template<
typename FIELD_OP,
typename POLICY >
659 string const & fieldName )
const
671 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
673 applyFieldValueKernel< FIELD_OP, POLICY >( wrapperT.reference().toView(), targetSet, time, dataGroup );
677 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
688 this->applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs,
697 template<
typename FIELD_OP,
typename POLICY >
701 string const & fieldName,
702 string const & dofMapName,
714 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
716 applyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( targetSet,
723 wrapperT.reference() );
727 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
737 LAMBDA && lambda )
const
739 return applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet,
747 std::forward< LAMBDA >( lambda ) );
750 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
761 LAMBDA && lambda )
const
769 computeRhsContribution< FIELD_OP, POLICY, LAMBDA >( targetSet,
778 std::forward< LAMBDA >( lambda ) );
780 FIELD_OP::template prescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution );
783 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
795 LAMBDA && lambda )
const
806 real64 value = m_scale * dt;
807 if( !functionName.empty() )
810 value *=
function.
evaluate( &time );
813 forAll< POLICY >( targetSet.size(),
814 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda]
GEOS_HOST_DEVICE (
localIndex const i )
817 dof[ i ] = dofMap[ a ] + component;
818 FIELD_OP::SpecifyFieldValue( dof[ i ],
821 rhsContribution[ i ],
831 function.evaluate( dataGroup, time, targetSet, resultsArray );
833 real64 const value = m_scale * dt;
835 forAll< POLICY >( targetSet.size(),
836 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda]
GEOS_HOST_DEVICE (
840 dof[ i ] = dofMap[ a ] + component;
841 FIELD_OP::SpecifyFieldValue( dof[ i ],
844 rhsContribution[ i ],
845 value * results[ i ],
852 template<
typename POLICY >
865 localIndex const numEntries = matrix.numNonZeros( dof );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
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
Compute the contributions that will be added/enforced to the right-hand side, and collect the corresp...
void applyFieldValueKernel(ArrayView< T, N, USD > const &field, SortedArrayView< localIndex const > const &targetSet, real64 const time, Group &dataGroup) const
void zeroSystemRowsForBoundaryCondition(SortedArrayView< localIndex const > const &targetSet, arrayView1d< globalIndex const > const &dofMap, CRSMatrixView< real64, globalIndex const > const &matrix) const
Function to zero matrix rows to apply boundary conditions.
FieldSpecificationBase(FieldSpecificationBase &&)=default
Defaulted move constructor.
real64 getStartTime() const
real64 getEndTime() const
void addSetName(string const &setName)
virtual ~FieldSpecificationBase() override
virtual const string & getFieldName() const
void setMeshObjectPath(Group const &meshBodies)
Set the Mesh Object Path object.
string_array const & getSetNames() const
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
Apply a boundary condition to a system of equations.
virtual R1Tensor const & getDirection() const
void initialCondition(bool isInitialCondition)
void setObjectPath(string const &objectPath)
FieldSpecificationBase(FieldSpecificationBase const &)=delete
Deleted copy constructor.
void setScale(real64 const &scale)
string const & getFunctionName() const
void applyFieldValue(SortedArrayView< localIndex const > const &targetSet, real64 const time, dataRepository::Group &dataGroup, string const &fieldname) const
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
Apply a boundary condition to a system of equations.
void setFieldName(string const &fieldName)
FieldSpecificationBase & operator=(FieldSpecificationBase const &)=delete
deleted copy assignment
int initialCondition() const
void apply(MeshLevel &mesh, LAMBDA &&lambda) const
Apply this field specification to the discretization.
MeshObjectPath const & getMeshObjectPaths() const
Get the Mesh Object Paths object.
virtual int getComponent() const
virtual const string & getObjectPath() const
FieldSpecificationBase & operator=(FieldSpecificationBase &&)=delete
deleted move assignement
FieldSpecificationBase(string const &name, dataRepository::Group *parent)
constructor
integer isFunctionOfTime() const
Test to see if the function is a 1D function of time.
virtual void evaluate(dataRepository::Group const &group, real64 const time, SortedArrayView< localIndex const > const &set, arrayView1d< real64 > const &result) const =0
Method to evaluate a function on a target object.
static FunctionManager & getInstance()
Class facilitating the representation of a multi-level discretization of a MeshBody.
Class to hold the path to a collection of mesh objects.
void forObjectsInPath(dataRepository::Group &meshBodies, FUNC &&func) const
LLoop over objects in the path and execute a callback function.
This class provides the base class/interface for the catalog value objects.
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...
bool hasWrapper(LOOKUP_TYPE const &lookup) const
Check if a wrapper exists.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
WrapperBase const & getWrapperBase(KEY const &key) const
Return a reference to a WrapperBase stored in this group.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
DataContext const & getWrapperDataContext(KEY key) const
Base class for all wrappers containing common operations.
static Wrapper & cast(WrapperBase &wrapper)
Downcast base to a typed wrapper.
static string catalogName()
Static Factory Catalog Functions.
virtual const string getCatalogName() const
return the catalog name
static CatalogInterface::CatalogType & getCatalog()
static function to return static catalog.
internal::Apply< internal::ArrayType, camp::cartesian_product< TYPES, internal::AddLayouts< NDIMS > > > ArrayTypes
Construct a list of GEOSX multidimensional array types (geos::Array), containing all value types in t...
DimsRange< N, N > DimsSingle
Generate a list of types representing array dimensionality exactly N.
bool dispatch(LIST const combinations, LAMBDA &&lambda, Ts &&... objects)
Dispatch a generic worker function lambda based on runtime type.
internal::Apply< camp::list, LIST > ListofTypeList
Construct a list of list type.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
array1d< string > string_array
A 1-dimensional array of geos::string types.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
std::int32_t integer
Signed integer type.
array1d< real64 > real64_array
A 1-dimensional array of geos::real64 types.
LvArray::SortedArray< T, localIndex, LvArray::ChaiBuffer > SortedArray
A sorted array of local indices.
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Array< T, 1 > array1d
Alias for 1D array.
LvArray::ArrayView< T, NDIM, USD, localIndex, LvArray::ChaiBuffer > ArrayView
Multidimensional array view type. See LvArray:ArrayView for details.
constexpr static char const * initialConditionString()
constexpr static char const * constitutivePathString()
constexpr static char const * bcApplicationTableNameString()
constexpr static char const * setNamesString()
constexpr static char const * functionNameString()
constexpr static char const * beginTimeString()
constexpr static char const * objectPathString()
constexpr static char const * directionString()
constexpr static char const * dataTypeString()
constexpr static char const * fieldNameString()
constexpr static char const * endTimeString()
constexpr static char const * componentString()
constexpr static char const * scaleString()
static GEOS_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 char const * setsString()