20 #ifndef GEOS_LINEARALGEBRA_DOFMANAGER_HPP_
21 #define GEOS_LINEARALGEBRA_DOFMANAGER_HPP_
32 class DomainPartition;
34 class ObjectManagerBase;
35 class FluxApproximationBase;
177 std::vector< FieldSupport >
const & regions = {} );
237 string const & colFieldName,
239 std::vector< FieldSupport >
const & regions = {},
240 bool symmetric = true );
245 string const & colFieldName,
248 bool symmetric =
true );
290 string const &
getKey(
string const & fieldName )
const;
363 template<
typename CONTAINER >
367 typename CONTAINER::value_type labelStart = 0;
368 auto it = labels.begin();
369 for( FieldDescription
const & field : m_fields )
371 localIndex const numComp = field.numComponents;
372 localIndex const numSupp = field.numLocalDof / numComp;
373 for(
localIndex i = 0; i < numSupp; ++i, it += numComp )
375 std::iota( it, it + numComp, labelStart );
377 labelStart += numComp;
397 string const & srcFieldName,
398 string const & dstFieldName,
411 template<
typename SCALING_FACTOR_TYPE >
413 string const & srcFieldName,
414 string const & dstFieldName,
415 SCALING_FACTOR_TYPE
const & scalingFactor,
428 string const & srcFieldName,
429 string const & dstFieldName,
443 string const & srcFieldName,
444 string const & dstFieldName,
457 std::vector< SubComponent >
458 filterDofs( std::vector< SubComponent >
const & excluded )
const;
467 std::vector< SubComponent >
const & selection );
481 template<
typename MATRIX >
483 MPI_Comm
const & comm,
485 MATRIX & restrictor )
const;
499 struct FieldDescription
504 std::vector< FieldSupport > support;
520 struct CouplingDescription
523 std::vector< FieldSupport > support;
530 localIndex getFieldIndex(
string const & name )
const;
536 void computeFieldDimensions(
localIndex fieldIndex );
543 void createIndexArray( FieldDescription
const & field,
544 arrayView1d< localIndex const >
const permutation );
550 void removeIndexArray( FieldDescription
const & field );
557 array1d< localIndex > computePermutation( FieldDescription & field );
565 void computePermutation( FieldDescription
const & field,
566 arrayView1d< localIndex >
const permutation );
575 void countRowLengthsOneBlock( arrayView1d< localIndex >
const & rowLengths,
579 void countRowLengthsFromStencil( arrayView1d< localIndex >
const & rowLengths,
590 void setSparsityPatternOneBlock( SparsityPatternView< globalIndex >
const & pattern,
594 void setSparsityPatternFromStencil( SparsityPatternView< globalIndex >
const & pattern,
597 template<
int DIMS_PER_DOF >
598 void setFiniteElementSparsityPattern( SparsityPattern< globalIndex > & pattern,
611 template<
typename FIELD_OP,
typename POLICY,
typename SCALING_FACTOR_TYPE >
612 void vectorToField( arrayView1d< real64 const >
const & localVector,
613 string const & srcFieldName,
614 string const & dstFieldName,
615 SCALING_FACTOR_TYPE
const & scalingFactor,
628 template<
typename FIELD_OP,
typename POLICY >
629 void fieldToVector( arrayView1d< real64 >
const & localVector,
630 string const & srcFieldName,
631 string const & dstFieldName,
639 DomainPartition * m_domain =
nullptr;
642 std::vector< FieldDescription > m_fields;
645 std::map< std::pair< localIndex, localIndex >, CouplingDescription > m_coupling;
648 bool m_reordered =
false;
Utility class that represents a mask for included/excluded component of a mask.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
void setSparsityPattern(SparsityPattern< globalIndex > &pattern) const
Populate sparsity pattern of the entire system matrix.
void addVectorToField(arrayView1d< real64 const > const &localVector, string const &srcFieldName, string const &dstFieldName, SCALING_FACTOR_TYPE const &scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const
Add values from LA vectors to simulation data arrays.
void addField(string const &fieldName, FieldLocation location, integer components, map< std::pair< string, string >, array1d< string > > const ®ions)
Add a new field and enumerate its degrees-of-freedom.
void addFieldToVector(arrayView1d< real64 > const &localVector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const
Add values from a simulation data array to a DOF vector.
array1d< integer > numComponentsPerField() const
Return an array of number of components per field, sorted by field registration order.
void addCoupling(string const &rowFieldName, string const &colFieldName, Connector connectivity, std::vector< FieldSupport > const ®ions={}, bool symmetric=true)
Add coupling between two fields.
DofManager(DofManager const &)=delete
Deleted copy constructor.
globalIndex rankOffset(string const &fieldName) const
void copyFieldToVector(arrayView1d< real64 > const &localVector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const
Copy values from simulation data arrays to vectors.
void disableGlobalCouplingForEquations(string const &fieldName, arrayView1d< integer const > const components)
Disable the global coupling for a set of equations.
ComponentMask< MAX_COMP > CompMask
Type of component mask used by DofManager.
integer numComponents() const
localIndex numLocalDofs() const
void setLocalReorderingType(string const &fieldName, LocalReorderingType const reorderingType)
Set the local reodering of the dof numbers.
globalIndex numGlobalDofs(string const &fieldName) const
void addCoupling(string const &fieldName, FluxApproximationBase const &stencils)
Special interface for self-connectivity through a stencil.
static constexpr int MAX_COMP
Maximum number of components in a field.
void addCoupling(string const &rowFieldName, string const &colFieldName, Connector connectivity, map< std::pair< string, string >, array1d< string > > const ®ions, bool symmetric=true)
Add coupling between two fields.
DofManager(string name)
Constructor.
void getLocalDofComponentLabels(CONTAINER &labels) const
Fill a container with unique dof labels for each local dof.
void addField(string const &fieldName, FieldLocation location, integer components, std::vector< FieldSupport > const ®ions={})
Add a new field and enumerate its degrees-of-freedom.
void clear()
Remove all fields and couplings and re-enable addition of new fields.
void reorderByRank()
Finish populating fields and apply appropriate dof renumbering.
bool fieldExists(string const &name) const
Check if string key is already being used.
std::vector< SubComponent > filterDofs(std::vector< SubComponent > const &excluded) const
Create a dof selection by filtering out excluded components.
globalIndex rankOffset() const
globalIndex globalOffset(string const &fieldName) const
integer numComponents(string const &fieldName="") const
FieldLocation location(string const &fieldName) const
Get the support location type of the field.
DofManager & operator=(DofManager &&)=default
Defaulted move assignment.
LocalReorderingType
Indicates the type of (local to a rank) reordering applied to a given field.
@ ReverseCutHillMcKee
Use reverve CutHill-McKee reordering algorithm.
@ None
Do not reorder the variables.
void makeRestrictor(std::vector< SubComponent > const &selection, MPI_Comm const &comm, bool transpose, MATRIX &restrictor) const
Create a matrix that restricts vectors and matrices to a subset of DOFs.
globalIndex numGlobalDofs() const
localIndex numLocalDofs(string const &fieldName) const
void disableGlobalCouplingForEquation(string const &fieldName, integer const c)
Disable the global coupling for a given equation.
Connector
Enumeration of geometric objects for connectivity type. Note that this enum is nearly identical to Fi...
@ None
there is no connectivity (self connected field, like a lumped mass matrix)
@ Node
connectivity is node (like in finite volumes MPFA)
@ Face
connectivity is face (like in finite volumes TPFA)
@ Elem
connectivity is element (like in finite elements)
@ Stencil
connectivity is through a (set of) user-provided stencil(s)
@ Edge
connectivity is edge (like fracture element connectors)
DofManager & operator=(DofManager const &)=delete
Deleted copy assignment.
void setDomain(DomainPartition &domain)
Assign a domain.
void printFieldInfo(std::ostream &os=std::cout) const
Print the summary of declared fields and coupling.
void copyVectorToField(arrayView1d< real64 const > const &localVector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const
Copy values from LA vectors to simulation data arrays.
void setupFrom(DofManager const &source, std::vector< SubComponent > const &selection)
Populate this manager from another using a sub-selection of fields/components.
DofManager(DofManager &&)=default
Move constructor.
string const & getKey(string const &fieldName) const
Return the key used to record the field in the DofManager.
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Base template for ordered and unordered maps.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > SparsityPattern
Alias for Sparsity pattern class.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::int32_t integer
Signed integer type.
FieldLocation
Enum defining the possible location of a field on the mesh.
Array< T, 1 > array1d
Alias for 1D array.
Describes field support on a single mesh body/level.
std::set< string > regionNames
list of the region names
bool add(FieldSupport const &input)
add the regionNames contained in input if the meshBodyName and the meshLevelName of input match the o...
string meshLevelName
name of the mesh level
string meshBodyName
name of the mesh body
Describes a selection of components from a DoF field.
CompMask mask
Mask that defines component selection.
string fieldName
Name of the DOF field in DofManager.