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"
131 template<
typename OBJECT_TYPE,
135 LAMBDA && lambda )
const
139 [&] ( OBJECT_TYPE & object )
144 for(
auto & setName : setNames )
149 lambda(
dynamic_cast< BC_TYPE
const &
>(*
this), setName, targetSet,
object,
getFieldName() );
166 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
170 Group & dataGroup )
const;
183 template<
typename FIELD_OP,
typename POLICY=parallelHostPolicy >
187 string const & fieldname )
const;
209 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
238 template<
typename FIELD_OP,
typename POLICY >
242 string const & fieldName,
243 string const & dofMapName,
270 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
279 LAMBDA && lambda )
const;
304 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
314 LAMBDA && lambda )
const;
345 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
356 LAMBDA && lambda )
const;
369 template<
typename POLICY >
415 return m_functionName;
488 return m_initialCondition;
506 m_fieldName = fieldName;
515 m_objectPath = objectPath;
533 m_initialCondition = isInitialCondition;
542 m_setNames.emplace_back( setName );
559 return *(m_meshObjectPaths.get());
575 std::unique_ptr< MeshObjectPath > m_meshObjectPaths;
589 int m_initialCondition;
592 string m_functionName;
604 string m_bcApplicationFunctionName;
611 template<
typename FIELD_OP,
typename POLICY,
typename T,
int N,
int USD >
615 Group & dataGroup )
const
620 if( m_functionName.empty() )
622 real64 const value = m_scale;
626 FIELD_OP::SpecifyFieldValue( field, a, component, value );
637 catch( std::exception
const & e )
639 throw InputError( e, GEOS_FMT(
"Error while reading {}:\n",
644 if(
function.isFunctionOfTime()==2 )
646 real64 const value = m_scale *
function.evaluate( &time );
650 FIELD_OP::SpecifyFieldValue( field, a, component, value );
656 function.evaluate( dataGroup, time, targetSet, result );
658 real64 const scale = m_scale;
662 FIELD_OP::SpecifyFieldValue( field, a, component, scale * resultView[i] );
669 template<
typename FIELD_OP,
typename POLICY >
673 string const & fieldName )
const
685 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
687 applyFieldValueKernel< FIELD_OP, POLICY >( wrapperT.reference().toView(), targetSet, time, dataGroup );
691 template<
typename FIELD_OP,
typename POLICY,
typename T,
int NDIM,
int USD >
702 this->applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet, time, dataGroup, dofMap, dofRankOffset, matrix, rhs,
711 template<
typename FIELD_OP,
typename POLICY >
715 string const & fieldName,
716 string const & dofMapName,
728 using ArrayType = camp::first< decltype( tupleOfTypes ) >;
730 applyBoundaryConditionToSystemKernel< FIELD_OP, POLICY >( targetSet,
737 wrapperT.reference() );
741 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
751 LAMBDA && lambda )
const
753 return applyBoundaryConditionToSystem< FIELD_OP, POLICY >( targetSet,
761 std::forward< LAMBDA >( lambda ) );
764 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
775 LAMBDA && lambda )
const
783 computeRhsContribution< FIELD_OP, POLICY, LAMBDA >( targetSet,
792 std::forward< LAMBDA >( lambda ) );
794 FIELD_OP::template prescribeRhsValues< POLICY >( rhs, dof, dofRankOffset, rhsContribution );
797 template<
typename FIELD_OP,
typename POLICY,
typename LAMBDA >
809 LAMBDA && lambda )
const
820 real64 value = m_scale * dt;
821 if( !functionName.empty() )
824 value *=
function.
evaluate( &time );
827 forAll< POLICY >( targetSet.size(),
828 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, value, lambda]
GEOS_HOST_DEVICE (
localIndex const i )
831 dof[ i ] = dofMap[ a ] + component;
832 FIELD_OP::SpecifyFieldValue( dof[ i ],
835 rhsContribution[ i ],
845 function.evaluate( dataGroup, time, targetSet, resultsArray );
847 real64 const value = m_scale * dt;
849 forAll< POLICY >( targetSet.size(),
850 [targetSet, dof, dofMap, dofRankOffset, component, matrix, rhsContribution, results, value, lambda]
GEOS_HOST_DEVICE (
854 dof[ i ] = dofMap[ a ] + component;
855 FIELD_OP::SpecifyFieldValue( dof[ i ],
858 rhsContribution[ i ],
859 value * results[ i ],
866 template<
typename POLICY >
879 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
SetErrorMode
Indicate the error handling mode.
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.
stdVector< string > string_array
A 1-dimensional array of geos::string types.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
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.
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
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.
int integer
Signed integer type.
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.
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "richardson", "preconditioner")
Declare strings associated with enumeration values.
constexpr static char const * initialConditionString()
constexpr static char const * errorSetModeString()
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()