ConstraintMap

Read-only expansion map for value and identification constraints.

Defined in Rodin/Assembly/ConstraintMap.h

template <
  class Scalar>
class ConstraintMap;

Identification constraints are stored as rows of the expansion map $ x_s = \sum_k c_k x_{m_k} + d_s $ . For unconstrained DOFs, expand() returns the identity row { { i, 1 } }.

The map supports canonicalization of identification constraints:

  • duplicate masters are merged;
  • zero coefficients are pruned;
  • self-references are removed algebraically;
  • identity constraints are ignored;
  • constraints such as $ x_s = c x_s + d_s $ , $ c \ne 1 $ , are converted to fixed constraints;
  • transitive identifications are flattened by finalize.

After calling finalize, this object can be shared by OpenMP assembly loops as a read-only expansion map.

Public types

struct Entry
One master DOF contribution in an expansion row.
using Expansion = std::vector<Entry>
Expansion row for a constrained DOF.

Constructors, destructors, conversion operators

ConstraintMap(size_t size) explicit
Constructs an identity constraint map.

Public functions

void reset(size_t size)
Resets the map to the identity expansion on size DOFs.
auto size() const -> size_t
Gets the number of DOFs represented by the map.
auto isFixed(Index i) const -> bool
Tests whether a DOF is fixed to a value.
auto isIdentified(Index i) const -> bool
Tests whether a DOF is identified with master DOFs.
auto getFixedValue(Index i) const -> Scalar
Gets the prescribed value for a fixed DOF.
auto expand(Index i) const -> const Expansion&
Expands a DOF into its master DOF row.
auto getIdentifiedRows() const -> const std::vector<Index>&
Gets the indices of rows carrying identification constraints.
auto getIdentificationValue(Index i) const -> Scalar
Gets the affine defect value for an identified DOF.
void setFixed(Index i, Scalar value)
Marks a DOF as fixed to a prescribed value.
template<class Entries>
void setIdentification(Index slave, const Entries& entries)
Sets a homogeneous identification row.
template<class Entries>
void setIdentification(Index slave, const Entries& entries, Scalar value)
Sets an affine identification row.
void finalize()
Flattens transitive identification constraints.

Function documentation

ConstraintMap(size_t size) explicit

Constructs an identity constraint map.

Parameters
size Number of DOFs represented by the map.

void reset(size_t size)

Resets the map to the identity expansion on size DOFs.

Parameters
size Number of DOFs represented by the map.

size_t size() const

Gets the number of DOFs represented by the map.

Returns Number of expansion rows.

bool isFixed(Index i) const

Tests whether a DOF is fixed to a value.

Parameters
i DOF index.
Returns Whether the degree of freedom has a prescribed value.

bool isIdentified(Index i) const

Tests whether a DOF is identified with master DOFs.

Parameters
i DOF index.
Returns Whether the degree of freedom is identified with master degrees of freedom.

Scalar getFixedValue(Index i) const

Gets the prescribed value for a fixed DOF.

Parameters
i Fixed DOF index.
Returns Prescribed scalar value.

const Expansion& expand(Index i) const

Expands a DOF into its master DOF row.

Parameters
i DOF index.
Returns Expansion row for i.

const std::vector<Index>& getIdentifiedRows() const

Gets the indices of rows carrying identification constraints.

Returns Identified slave DOF indices.

Scalar getIdentificationValue(Index i) const

Gets the affine defect value for an identified DOF.

Parameters
i Identified slave DOF index.
Returns Constant term in the identification row.

void setFixed(Index i, Scalar value)

Marks a DOF as fixed to a prescribed value.

Parameters
i DOF index.
value Prescribed scalar value.

template<class Scalar> template<class Entries>
void setIdentification(Index slave, const Entries& entries)

Sets a homogeneous identification row.

Parameters
slave Slave DOF index.
entries Master expansion entries.

template<class Scalar> template<class Entries>
void setIdentification(Index slave, const Entries& entries, Scalar value)

Sets an affine identification row.

Parameters
slave Slave DOF index.
entries Master expansion entries.
value Constant term in the identification.

void finalize()

Flattens transitive identification constraints.

The following example illustrates this operation.

\[ x_1 = x_2, \qquad x_2 = x_3 \]

becomes

\[ x_1 = x_3, \qquad x_2 = x_3. \]

Cycles such as $ x_1 = x_2 $ , $ x_2 = x_1 $ are rejected.