https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Moose::MFEM::TreeCotreeGauge Class Reference

Shared implementation of the tree-cotree gauge for an H(curl) (Nedelec) variable, used by both the real (MFEMTreeCotreeGaugeEssentialConstraint) and complex (MFEMComplexTreeCotreeGaugeEssentialConstraint) constraints. More...

#include <MFEMTreeCotreeGauge.h>

Public Member Functions

const mfem::Array< int > & trueDofs (const MFEMConstraint &constraint, mfem::ParFiniteElementSpace &pfes, const mfem::Array< int > &essential_tdofs, const mfem::Array< int > &gauge_block_markers)
 This rank's ND true-dof indices that the tree-cotree gauge must strongly set to zero, in addition to those already fixed by essential boundary conditions or other essential constraints on the variable.
 

Private Attributes

mfem::Array< int > _tdofs
 Gauged true dofs of the most recent trueDofs() call.
 
long _fespace_sequence = -1
 FE space sequence number _tdofs was built for.
 
mfem::Array< int > _essential_tdofs
 Already-fixed true dofs _tdofs was built for.
 

Detailed Description

Shared implementation of the tree-cotree gauge for an H(curl) (Nedelec) variable, used by both the real (MFEMTreeCotreeGaugeEssentialConstraint) and complex (MFEMComplexTreeCotreeGaugeEssentialConstraint) constraints.

Only the per-component grid-function bookkeeping differs between the two; the choice of degrees of freedom to fix is identical and lives here.

The gauge depends only on the mesh, the finite element space and the dofs already fixed, so the result is cached and only rebuilt when one of them changes. Held by value as a member of the constraint that uses it.

Definition at line 33 of file MFEMTreeCotreeGauge.h.

Member Function Documentation

◆ trueDofs()

const mfem::Array< int > & Moose::MFEM::TreeCotreeGauge::trueDofs ( const MFEMConstraint &  constraint,
mfem::ParFiniteElementSpace &  pfes,
const mfem::Array< int > &  essential_tdofs,
const mfem::Array< int > &  gauge_block_markers 
)

This rank's ND true-dof indices that the tree-cotree gauge must strongly set to zero, in addition to those already fixed by essential boundary conditions or other essential constraints on the variable.

Every dof of each spanning forest edge is fixed. In a higher order space, each other gauged edge, face and element also has fixed a selection of its own dofs that removes the gradients of the H1 bubbles on it.

The seeded spanning forest is grown by a distributed Boruvka pass, so no rank holds more than its own share of the mesh graph. Edges are weighted by their canonical global endpoint ids, which are derived from the endpoint coordinates held in the mesh nodes; because those weights are distinct the minimum spanning forest is unique and the result is independent of the MPI partitioning.

The returned reference stays valid until the next call on this object.

Parameters
constraintthe constraint requesting the gauge, used to report errors against the right input block
pfesthe ND space being solved on. Above SECOND order the mesh must have no triangular faces
essential_tdofsthis rank's true dofs already fixed by essential boundary conditions or other essential constraints on the variable. Those edges seed the forest so the gauge stays compatible with them
gauge_block_markerssubdomain attribute marker array of the subdomains to gauge, as returned by MFEMBlockRestrictable::getSubdomainMarkers; edges of the complementary subdomains seed the forest but are never gauged

Definition at line 660 of file MFEMTreeCotreeGauge.C.

664{
665 mfem::ParMesh & pmesh = *pfes.GetParMesh();
666
667 // The graph is built from the mesh edges and the lowest-order dof on each, which
668 // is only meaningful for a Nedelec space: an H1 space would hand back vertex dofs
669 // and an RT space none at all.
670 if (!dynamic_cast<const mfem::ND_FECollection *>(pfes.FEColl()))
671 constraint.paramError("variable",
672 "The tree-cotree gauge requires an H(curl) (Nedelec) variable, but '",
673 constraint.getTrialVariableName(),
674 "' uses the finite element collection '",
675 pfes.FEColl()->Name(),
676 "'.");
677
678 // From THIRD order on, a triangular face carries H1 bubbles whose gradients the
679 // gauge must remove with a selection of the face's dofs. MFEM relates the dofs of
680 // a triangular face in different frames by a 2x2 transformation per point, not a
681 // permutation, so no selection is the same in every frame, and the frame of a
682 // shared face depends on the partitioning. Checked on every rank, since only some
683 // ranks may hold such faces.
684 int has_triangles = pmesh.Dimension() == 3 && pmesh.HasGeometry(mfem::Geometry::TRIANGLE);
685 MPI_Allreduce(MPI_IN_PLACE, &has_triangles, 1, MPI_INT, MPI_LOR, pmesh.GetComm());
686 if (pfes.GetMaxElementOrder() > 2 && has_triangles)
687 constraint.paramError(
688 "variable",
689 "The tree-cotree gauge supports H(curl) spaces above SECOND order only on meshes "
690 "without triangular faces, since the gauge on such a face could not be chosen "
691 "independently of the mesh partitioning; the space of variable '",
692 constraint.getTrialVariableName(),
693 "' is order ",
694 pfes.GetMaxElementOrder(),
695 ".");
696
697 // Vertices are identified by their coordinates, read from the mesh nodes. A
698 // discontinuous nodal space, as carried by a periodic mesh, has no single node per
699 // vertex, and periodically identified vertices have no single coordinate.
700 if (pmesh.GetNodes() && pmesh.GetNodalFESpace()->IsDGSpace())
701 constraint.mooseError("The tree-cotree gauge identifies mesh vertices by their coordinates, "
702 "which is not possible on a mesh with discontinuous nodes, such as a "
703 "periodic mesh.");
704
705 // The gauge is a property of the mesh, the space and the dofs already fixed
706 // alone, so it only has to be rebuilt when one of them changes. Rebuilding it
707 // every time the linear forms are assembled would repeat a global graph
708 // computation on every time step.
709 if (_fespace_sequence == pfes.GetSequence() && _essential_tdofs == essential_tdofs)
710 return _tdofs;
711
712 // Local dof marker of the dofs of every element outside the gauged subdomains, the
713 // regions the gauge must not reach because some other term of the weak form already
714 // removes the gradient null space there. Edges carrying such dofs seed the spanning
715 // forest, and no dof of such an edge, face or element is ever gauged. The boundary
716 // of these regions is included, but dofs of a gauged region that merely touch them
717 // are not, so the gauge still reaches the vertices next to them.
718 mfem::Array<int> excluded_markers(gauge_block_markers.Size());
719 for (const auto i : make_range(gauge_block_markers.Size()))
720 excluded_markers[i] = !gauge_block_markers[i];
721 mfem::Array<int> excluded, excluded_tdofs;
723 pfes, excluded_markers, /*include_boundary=*/true, excluded, excluded_tdofs);
724
725 _tdofs = buildTreeCotreeGaugeTDofs(pfes, essential_tdofs, excluded);
726
727 _fespace_sequence = pfes.GetSequence();
728 _essential_tdofs = essential_tdofs;
729 return _tdofs;
730}
virtual const std::string & getTrialVariableName() const
Name of the trial variable (gridfunction) the constraint acts on.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:466
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
mfem::Array< int > _essential_tdofs
Already-fixed true dofs _tdofs was built for.
long _fespace_sequence
FE space sequence number _tdofs was built for.
mfem::Array< int > _tdofs
Gauged true dofs of the most recent trueDofs() call.
void subdomainTDofs(mfem::ParFiniteElementSpace &pfes, const mfem::Array< int > &subdomain_markers, bool include_boundary, mfem::Array< int > &ldof_marker, mfem::Array< int > &tdofs)
Degrees of freedom of pfes belonging to elements whose mesh attribute is set in the attribute marker ...
IntRange< T > make_range(T beg, T end)

Referenced by MFEMComplexTreeCotreeGaugeEssentialConstraint::ApplyConstraint(), and MFEMTreeCotreeGaugeEssentialConstraint::ApplyConstraint().

Member Data Documentation

◆ _essential_tdofs

mfem::Array<int> Moose::MFEM::TreeCotreeGauge::_essential_tdofs
private

Already-fixed true dofs _tdofs was built for.

Definition at line 82 of file MFEMTreeCotreeGauge.h.

Referenced by trueDofs().

◆ _fespace_sequence

long Moose::MFEM::TreeCotreeGauge::_fespace_sequence = -1
private

FE space sequence number _tdofs was built for.

MFEM bumps it whenever the space is updated after h- or p-refinement, including refinement of the mesh, so comparing it invalidates the cache exactly when the gauge could have changed. -1 marks "never built".

Definition at line 80 of file MFEMTreeCotreeGauge.h.

Referenced by trueDofs().

◆ _tdofs

mfem::Array<int> Moose::MFEM::TreeCotreeGauge::_tdofs
private

Gauged true dofs of the most recent trueDofs() call.

Definition at line 75 of file MFEMTreeCotreeGauge.h.

Referenced by trueDofs().


The documentation for this class was generated from the following files: