GEOSX
|
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns, and generally simplifying the interaction between PhysicsSolvers and linear algebra operations. More...
#include <DofManager.hpp>
Classes | |
struct | SubComponent |
Describes a selection of components from a DoF field. More... | |
Public Types | |
enum | Location { Location::Elem, Location::Face, Location::Edge, Location::Node } |
Enumeration of geometric objects for support location. Note that this enum is nearly identical to Connectivity, but we keep both for code readability in function calls. More... | |
enum | Connector { Connector::Elem, Connector::Face, Connector::Edge, Connector::Node, Connector::None, Connector::Stencil } |
Enumeration of geometric objects for connectivity type. Note that this enum is nearly identical to Location, but we keep both for code readability in function calls. More... | |
using | CompMask = ComponentMask< MAX_COMP > |
Type of component mask used by DofManager. | |
Public Member Functions | |
DofManager (string name) | |
Constructor. More... | |
DofManager (DofManager const &)=delete | |
Deleted copy constructor. | |
DofManager (DofManager &&)=default | |
Move constructor. | |
DofManager & | operator= (DofManager const &)=delete |
Deleted copy assignment. More... | |
DofManager & | operator= (DofManager &&)=default |
Defaulted move assignment. More... | |
~DofManager ()=default | |
Destructor. | |
void | clear () |
Remove all fields and couplings and re-enable addition of new fields. | |
void | setMesh (MeshLevel &mesh) |
Assign a mesh. More... | |
void | addField (string const &fieldName, Location location, integer components, std::vector< string > const ®ions={}) |
Add a new field and enumerate its degrees-of-freedom. More... | |
void | addField (string const &fieldName, Location location, integer components, arrayView1d< string const > const ®ions) |
Add a new field and enumerate its degrees-of-freedom. More... | |
void | addCoupling (string const &rowFieldName, string const &colFieldName, Connector connectivity, std::vector< string > const ®ions={}, bool symmetric=true) |
Add coupling between two fields. More... | |
void | addCoupling (string const &rowFieldName, string const &colFieldName, Connector connectivity, arrayView1d< string const > const ®ions, bool symmetric=true) |
Add coupling between two fields. More... | |
void | addCoupling (string const &fieldName, FluxApproximationBase const &stencils) |
Special interface for self-connectivity through a stencil. More... | |
void | reorderByRank () |
Finish populating fields and apply appropriate dof renumbering. More... | |
bool | fieldExists (string const &name) const |
Check if string key is already being used. More... | |
string const & | getKey (string const &fieldName) const |
Return the key used to record the field in the DofManager. More... | |
globalIndex | numGlobalDofs (string const &fieldName) const |
globalIndex | numGlobalDofs () const |
localIndex | numLocalDofs (string const &fieldName) const |
localIndex | numLocalDofs () const |
globalIndex | rankOffset (string const &fieldName) const |
globalIndex | rankOffset () const |
integer | numComponents (string const &fieldName="") const |
integer | numComponents () const |
Location | location (string const &fieldName) const |
Get the support location type of the field. More... | |
std::vector< string > const & | regions (string const &fieldName) const |
globalIndex | globalOffset (string const &fieldName) const |
array1d< integer > | numComponentsPerField () const |
Return an array of number of components per field, sorted by field registration order. More... | |
template<typename CONTAINER > | |
void | getLocalDofComponentLabels (CONTAINER &labels) const |
Fill a container with unique dof labels for each local dof. More... | |
void | setSparsityPattern (SparsityPattern< globalIndex > &pattern) const |
Populate sparsity pattern of the entire system matrix. More... | |
template<typename VECTOR > | |
void | copyVectorToField (VECTOR const &vector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const |
Copy values from LA vectors to simulation data arrays. More... | |
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. More... | |
template<typename VECTOR > | |
void | addVectorToField (VECTOR const &vector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const |
Add values from LA vectors to simulation data arrays. More... | |
void | addVectorToField (arrayView1d< real64 const > const &localVector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const |
Add values from LA vectors to simulation data arrays. More... | |
template<typename VECTOR > | |
void | copyFieldToVector (VECTOR &vector, string const &srcFieldName, string const &dstFieldName, real64 scalingFactor, CompMask mask=CompMask(MAX_COMP, true)) const |
Copy values from nodes to DOFs. More... | |
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. More... | |
template<typename VECTOR > | |
void | addFieldToVector (VECTOR &vector, 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. More... | |
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. More... | |
std::vector< SubComponent > | filterDofs (std::vector< SubComponent > const &excluded) const |
Create a dof selection by filtering out excluded components. More... | |
void | setupFrom (DofManager const &source, std::vector< SubComponent > const &selection) |
Populate this manager from another using a sub-selection of fields/components. More... | |
template<typename MATRIX > | |
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. More... | |
void | printFieldInfo (std::ostream &os=std::cout) const |
Print the summary of declared fields and coupling. More... | |
Static Public Attributes | |
static int constexpr | MAX_COMP = 32 |
Maximum number of components in a field. | |
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns, and generally simplifying the interaction between PhysicsSolvers and linear algebra operations.
Definition at line 41 of file DofManager.hpp.
|
strong |
Enumeration of geometric objects for connectivity type. Note that this enum is nearly identical to Location, but we keep both for code readability in function calls.
Definition at line 80 of file DofManager.hpp.
|
strong |
Enumeration of geometric objects for support location. Note that this enum is nearly identical to Connectivity, but we keep both for code readability in function calls.
Definition at line 67 of file DofManager.hpp.
|
explicit |
Constructor.
[in] | name | a unique name for this DoF manager |
void geosx::DofManager::addCoupling | ( | string const & | rowFieldName, |
string const & | colFieldName, | ||
Connector | connectivity, | ||
std::vector< string > const & | regions = {} , |
||
bool | symmetric = true |
||
) |
Add coupling between two fields.
The connectivity argument defines how the two fields couple. If the first field has support location A, the second field has support location B, and the connecting object is C, the sparsity pattern will be defined as (AC)(CB). The final argument indicates if the coupling is symmetric, in the sense that there is a two-way coupling between the fields. Without this argument, a nonzero block will be added to the system matrix for block AB, but block BA will remain zero (one-way coupling).
When the number of components is greater than one, we always assume they are tightly coupled to one another and form a dense block. The sparsity pattern LC*CL is then interpreted as the super-node pattern, containing dense sub-blocks.
[in] | rowFieldName | string the name of the row field. |
[in] | colFieldName | string the name of the col field. |
[in] | connectivity | Connectivity through what they are connected. |
[in] | regions | names of regions where this coupling is defined. |
[in] | symmetric | bool is it symmetric, i.e., both row-col and col-row? |
void geosx::DofManager::addCoupling | ( | string const & | rowFieldName, |
string const & | colFieldName, | ||
Connector | connectivity, | ||
arrayView1d< string const > const & | regions, | ||
bool | symmetric = true |
||
) |
Add coupling between two fields.
The connectivity argument defines how the two fields couple. If the first field has support location A, the second field has support location B, and the connecting object is C, the sparsity pattern will be defined as (AC)(CB). The final argument indicates if the coupling is symmetric, in the sense that there is a two-way coupling between the fields. Without this argument, a nonzero block will be added to the system matrix for block AB, but block BA will remain zero (one-way coupling).
When the number of components is greater than one, we always assume they are tightly coupled to one another and form a dense block. The sparsity pattern LC*CL is then interpreted as the super-node pattern, containing dense sub-blocks.
[in] | rowFieldName | string the name of the row field. |
[in] | colFieldName | string the name of the col field. |
[in] | connectivity | Connectivity through what they are connected. |
[in] | regions | names of regions where this coupling is defined. |
[in] | symmetric | bool is it symmetric, i.e., both row-col and col-row? |
Overload for arrayView1d<string> input used by physics solvers.
void geosx::DofManager::addCoupling | ( | string const & | fieldName, |
FluxApproximationBase const & | stencils | ||
) |
Special interface for self-connectivity through a stencil.
[in] | fieldName | name of the field (this is only for diagonal blocks) |
[in] | stencils | a pointer to FluxApproximation storing the stencils |
The field must be defined on element support. The set of regions is taken automatically from the field definition.
void geosx::DofManager::addField | ( | string const & | fieldName, |
Location | location, | ||
integer | components, | ||
std::vector< string > const & | regions = {} |
||
) |
Add a new field and enumerate its degrees-of-freedom.
[in] | fieldName | the name of the field |
[in] | location | type of mesh objects the field is defined on |
[in] | components | number of components |
[in] | regions | list of region names the field is defined on (if empty, selects all regions) |
void geosx::DofManager::addField | ( | string const & | fieldName, |
Location | location, | ||
integer | components, | ||
arrayView1d< string const > const & | regions | ||
) |
Add a new field and enumerate its degrees-of-freedom.
[in] | fieldName | the name of the field |
[in] | location | type of mesh objects the field is defined on |
[in] | components | number of components |
[in] | regions | list of region names the field is defined on (if empty, selects all regions) |
Overload for arrayView1d<string> input used by physics solvers.
void geosx::DofManager::addFieldToVector | ( | VECTOR & | vector, |
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.
VECTOR | type of LA vector |
vector | target LA vector |
srcFieldName | name of the source field (view wrapper key on the manager) |
dstFieldName | name of the destination field (as defined in DofManager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::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.
localVector | target vector |
srcFieldName | name of the source field (view wrapper key on the manager) |
dstFieldName | name of the destination field (as defined in DofManager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::addVectorToField | ( | VECTOR const & | vector, |
string const & | srcFieldName, | ||
string const & | dstFieldName, | ||
real64 | scalingFactor, | ||
CompMask | mask = CompMask(MAX_COMP, true) |
||
) | const |
Add values from LA vectors to simulation data arrays.
VECTOR | type of LA vector |
vector | source LA vector |
srcFieldName | name of the source field (as defined in DofManager) |
dstFieldName | name of the destination field (view wrapper key on the manager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::addVectorToField | ( | arrayView1d< real64 const > const & | localVector, |
string const & | srcFieldName, | ||
string const & | dstFieldName, | ||
real64 | scalingFactor, | ||
CompMask | mask = CompMask(MAX_COMP, true) |
||
) | const |
Add values from LA vectors to simulation data arrays.
localVector | source local vector |
srcFieldName | name of the source field (as defined in DofManager) |
dstFieldName | name of the destination field (view wrapper key on the manager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::copyFieldToVector | ( | VECTOR & | vector, |
string const & | srcFieldName, | ||
string const & | dstFieldName, | ||
real64 | scalingFactor, | ||
CompMask | mask = CompMask(MAX_COMP, true) |
||
) | const |
Copy values from nodes to DOFs.
VECTOR | type of LA vector |
vector | target LA vector |
srcFieldName | name of the source field (view wrapper key on the manager) |
dstFieldName | name of the destination field (as defined in DofManager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::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.
localVector | target LA vector |
srcFieldName | name of the source field (view wrapper key on the manager) |
dstFieldName | name of the destination field (as defined in DofManager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::copyVectorToField | ( | VECTOR const & | vector, |
string const & | srcFieldName, | ||
string const & | dstFieldName, | ||
real64 | scalingFactor, | ||
CompMask | mask = CompMask(MAX_COMP, true) |
||
) | const |
Copy values from LA vectors to simulation data arrays.
VECTOR | type of LA vector |
vector | source LA vector |
srcFieldName | name of the source field (as defined in DofManager) |
dstFieldName | name of the destination field (view wrapper key on the manager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
void geosx::DofManager::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.
localVector | source local vector |
srcFieldName | name of the source field (as defined in DofManager) |
dstFieldName | name of the destination field (view wrapper key on the manager) |
scalingFactor | a factor to scale vector values by |
mask | component selection mask |
bool geosx::DofManager::fieldExists | ( | string const & | name | ) | const |
Check if string key is already being used.
name | field key to check |
std::vector< SubComponent > geosx::DofManager::filterDofs | ( | std::vector< SubComponent > const & | excluded | ) | const |
Create a dof selection by filtering out excluded components.
excluded | a list of dof components to exclude |
Return the key used to record the field in the DofManager.
[in] | fieldName | string the name of the field. |
|
inline |
Fill a container with unique dof labels for each local dof.
CONTAINER | type of container to fill |
labels | the container to fill |
The labels are assigned starting from zero in increasing order of field registration. Labels are repeated for each support point of a field.
Definition at line 322 of file DofManager.hpp.
globalIndex geosx::DofManager::globalOffset | ( | string const & | fieldName | ) | const |
[in] | fieldName | name of the field. |
Get the support location type of the field.
[in] | fieldName | name of the field |
void geosx::DofManager::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.
MATRIX | type of matrix used for restrictor |
selection | a list of fields to select; each entry is a struct containing the name of the field and low and high selected component indices |
comm | the MPI communicator to use in the operator |
transpose | if true , the transpose (prolongation) operator will be created |
restrictor | resulting operator |
fieldName | name of the field |
integer geosx::DofManager::numComponents | ( | ) | const |
Return an array of number of components per field, sorted by field registration order.
globalIndex geosx::DofManager::numGlobalDofs | ( | string const & | fieldName | ) | const |
fieldName | the name of the field |
globalIndex geosx::DofManager::numGlobalDofs | ( | ) | const |
localIndex geosx::DofManager::numLocalDofs | ( | string const & | fieldName | ) | const |
fieldName | name of the field |
localIndex geosx::DofManager::numLocalDofs | ( | ) | const |
|
delete |
Deleted copy assignment.
|
default |
Defaulted move assignment.
void geosx::DofManager::printFieldInfo | ( | std::ostream & | os = std::cout | ) | const |
Print the summary of declared fields and coupling.
os | output stream |
globalIndex geosx::DofManager::rankOffset | ( | string const & | fieldName | ) | const |
fieldName | name of the field |
globalIndex geosx::DofManager::rankOffset | ( | ) | const |
fieldName | name of the field |
void geosx::DofManager::reorderByRank | ( | ) |
Finish populating fields and apply appropriate dof renumbering.
This function must be called after all field and coupling information has been added. It adjusts DoF index arrays to account for presence of other fields (in a global monolithic fashion).
void geosx::DofManager::setMesh | ( | MeshLevel & | mesh | ) |
Assign a mesh.
mesh | the target mesh (non-const access required for allocating index arrays) |
void geosx::DofManager::setSparsityPattern | ( | SparsityPattern< globalIndex > & | pattern | ) | const |
Populate sparsity pattern of the entire system matrix.
[out] | pattern | the target sparsity pattern |
void geosx::DofManager::setupFrom | ( | DofManager const & | source, |
std::vector< SubComponent > const & | selection | ||
) |
Populate this manager from another using a sub-selection of fields/components.
source | source dof manager |
selection | selection of fields/components |