15 #include "../config/config.hpp" 16 #include "../linalg/sparsemat.hpp" 17 #include "../mesh/mesh.hpp" 20 #include "restriction.hpp" 22 #include <unordered_map> 44 static inline int Map(
int ndofs,
int vdim,
int dof,
int vd);
58 template <>
inline int 59 Ordering::Map<Ordering::byNODES>(
int ndofs,
int vdim,
int dof,
int vd)
61 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
62 return (dof >= 0) ? dof+ndofs*vd : dof-ndofs*vd;
65 template <>
inline int 66 Ordering::Map<Ordering::byVDIM>(
int ndofs,
int vdim,
int dof,
int vd)
68 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
69 return (dof >= 0) ? vd+vdim*dof : -1-(vd+vdim*(-1-dof));
88 class BilinearFormIntegrator;
89 class QuadratureSpace;
90 class QuadratureInterpolator;
91 class FaceQuadratureInterpolator;
170 using key_face = std::tuple<bool, ElementDofOrdering, FaceType, L2FaceValues>;
175 return std::get<0>(k)
176 + 2 * (
int)std::get<1>(k)
177 + 4 * (
int)std::get<2>(k)
178 + 8 * (
int)std::get<3>(k);
181 using map_L2F = std::unordered_map<const key_face,FaceRestriction*,key_hash>;
240 int FindDofs(
const Table &var_dof_table,
int row,
int ndof)
const;
259 {
return (idx >= 0) ? (entity_base + idx) : (-1-(entity_base + (-1-idx))); }
263 {
return (dof >= 0) ? dof : (-1 - dof); }
266 {
return (dof >= 0) ? (sign = 1, dof) : (sign = -1, (-1 - dof)); }
271 int variant = 0)
const;
308 void ConstructDoFTrans();
315 Table *old_elem_fos,
int old_ndofs);
328 Table *coarse_elem_dof;
330 Table coarse_to_fine;
350 const Table &coarse_elem_dof,
351 const Table *coarse_elem_fos,
363 const Table* old_elem_fos);
367 const Table* old_elem_fos);
806 int component = -1)
const;
894 virtual void Update(
bool want_transform =
true);
947 void Save(std::ostream &
out)
const;
SparseMatrix * RefinementMatrix(int old_ndofs, const Table *old_elem_dof, const Table *old_elem_fos)
Abstract class for all finite elements.
VDofTransformation VDoFTrans
int GetBdrElementType(int i) const
Returns the type of boundary element i.
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
Abstract base class for LORDiscretization and ParLORDiscretization classes, which construct low-order...
int ndofs
Number of degrees of freedom. Number of unknowns is ndofs * vdim.
Class for an integration rule - an Array of IntegrationPoint.
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
int * bdofs
internal DOFs of elements if mixed/var-order; NULL otherwise
static void AddDependencies(SparseMatrix &deps, Array< int > &master_dofs, Array< int > &slave_dofs, DenseMatrix &I, int skipfirst=0)
int GetConformingVSize() const
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
static int Map(int ndofs, int vdim, int dof, int vd)
SparseMatrix * DerefinementMatrix(int old_ndofs, const Table *old_elem_dof, const Table *old_elem_fos)
Calculate GridFunction restriction matrix after mesh derefinement.
int MakeDofTable(int ent_dim, const Array< int > &entity_orders, Table &entity_dofs, Array< char > *var_ent_order)
const Table & GetBdrElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each boundary mesh...
DerefinementOperator(const FiniteElementSpace *f_fes, const FiniteElementSpace *c_fes, BilinearFormIntegrator *mass_integ)
TODO: Implement DofTransformation support.
bool Nonconforming() const
Matrix-free transfer operator between finite element spaces on the same mesh.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
static int DecodeDof(int dof, double &sign)
int GetElementType(int i) const
Returns the type of element i.
void GetEdgeInteriorVDofs(int i, Array< int > &vdofs) const
void GetVertexVDofs(int i, Array< int > &vdofs) const
void SetElementOrder(int i, int p)
Sets the order of the i'th finite element.
static int DecodeDof(int dof)
Helpers to remove encoded sign from a DOF.
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th face element (2D and 3D).
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
static int MinOrder(VarOrderBits bits)
Return the minimum order (least significant bit set) in the bit mask.
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
Pointer to an Operator of a specified type.
virtual DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'.
static constexpr int MaxVarOrder
virtual ~DerefinementOperator()
void AddEdgeFaceDependencies(SparseMatrix &deps, Array< int > &master_dofs, const FiniteElement *master_fe, Array< int > &slave_dofs, int slave_face, const DenseMatrix *pm) const
bool Nonconforming() const
virtual const Operator * GetRestrictionOperator() const
An abstract operator that performs the same action as GetRestrictionMatrix.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Data type dense matrix using column-major storage.
const NURBSExtension * GetNURBSext() const
int vdim
Vector dimension (number of unknowns per degree of freedom).
int GetDegenerateFaceDofs(int index, Array< int > &dofs, Geometry::Type master_geom, int variant) const
int GetNDofs() const
Returns number of degrees of freedom.
void BuildBdrElementToDofTable() const
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
const FiniteElement * GetTraceElement(int i, Geometry::Type geom_type) const
Return the trace element from element 'i' to the given 'geom_type'.
MFEM_DEPRECATED void RebuildElementToDofTable()
(
void CalcEdgeFaceVarOrders(Array< VarOrderBits > &edge_orders, Array< VarOrderBits > &face_orders) const
void BuildConformingInterpolation() const
Calculate the cP and cR matrices for a nonconforming mesh.
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller...
virtual const Operator * GetRestrictionTransposeOperator() const
Return an operator that performs the transpose of GetRestrictionOperator.
void GetVDofs(int vd, Array< int > &dofs, int ndofs=-1) const
Returns the indices of all of the VDofs for the specified dimension 'vd'.
bool UsesTensorBasis(const FiniteElementSpace &fes)
Return true if the mesh contains only one topology and the elements are tensor elements.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual void CopyProlongationAndRestriction(const FiniteElementSpace &fes, const Array< int > *perm)
Copies the prolongation and restriction matrices from fes.
const FiniteElementCollection * fec
Associated FE collection (not owned).
OperatorHandle Th
Transformation to apply to GridFunctions after space Update().
void GetVertexDofs(int i, Array< int > &dofs) const
NURBSExtension * GetNURBSext()
const SparseMatrix * GetHpConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
int GetNBE() const
Returns number of boundary elements.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
std::unordered_map< const key_face, FaceRestriction *, key_hash > map_L2F
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
std::uint64_t VarOrderBits
Bit-mask representing a set of orders needed by an edge/face.
int FindFaceDof(int face, int ndof) const
Similar to FindEdgeDof, but used for mixed meshes too.
Array< int > dof_elem_array
static void MarkerToList(const Array< int > &marker, Array< int > &list)
Convert a Boolean marker array to a list containing all marked indices.
Derefinement operator, used by the friend class InterpolationGridTransfer.
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type.
ElementTransformation * GetBdrElementTransformation(int i)
virtual void UpdateMeshPointer(Mesh *new_mesh)
void ConvertFromConformingVDofs(const Array< int > &cdofs, Array< int > &dofs)
For a partially conforming FE space, convert a marker array (nonzero entries are true) on the conform...
void GetElementInteriorVDofs(int i, Array< int > &vdofs) const
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int uni_fdof
of single face DOFs if all faces uniform; -1 otherwise
int GetAttribute(int i) const
Return the attribute of element i.
void BuildFaceToDofTable() const
const Table * GetElementToFaceOrientationTable() const
int GetNEDofs() const
Number of all scalar edge-interior dofs.
void BuildElementToDofTable() const
Array< DofTransformation * > DoFTrans
int GetMaxElementOrder() const
Return the maximum polynomial order.
bool orders_changed
True if at least one element order changed (variable-order space only).
Native ordering as defined by the FiniteElement.
const FiniteElementCollection * FEColl() const
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
A class that performs interpolation from an E-vector to quadrature point values and/or derivatives (Q...
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
SparseMatrix * cR
Conforming restriction matrix such that cR.cP=I.
SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Generate the global restriction matrix from a discontinuous FE space to the piecewise constant FE spa...
SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Generate the global restriction matrix from a discontinuous FE space to the continuous FE space of th...
int GetNumBorderDofs(Geometry::Type geom, int order) const
void GetBoundaryTrueDofs(Array< int > &boundary_dofs, int component=-1)
Get a list of all boundary true dofs, boundary_dofs. For spaces with 'vdim' > 1, the 'component' para...
NURBSExtension * StealNURBSext()
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
virtual ~RefinementOperator()
const FaceQuadratureInterpolator * GetFaceQuadratureInterpolator(const IntegrationRule &ir, FaceType type) const
Return a FaceQuadratureInterpolator that interpolates E-vectors to quadrature point values and/or der...
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
FiniteElementSpace & operator=(const FiniteElementSpace &)=delete
Copy assignment not supported.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Returns the transformation defining the i-th element in the user-defined variable ElTr...
Array< int > dof_ldof_array
int FindEdgeDof(int edge, int ndof) const
static int EncodeDof(int entity_base, int idx)
Helper to encode a sign flip into a DOF index (for Hcurl/Hdiv shapes).
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
int GetNE() const
Returns number of elements in the mesh.
void GetFaceInteriorDofs(int i, Array< int > &dofs) const
Array< QuadratureInterpolator * > E2Q_array
A class that performs interpolation from a face E-vector to quadrature point values and/or derivative...
Abstract base class that defines an interface for element restrictions.
OperatorHandle L2E_nat
The element restriction operators, see GetElementRestriction().
static void DofsToVDofs(int ndofs, int vdim, Array< int > &dofs)
int GetVDim() const
Returns vector dimension.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Type
Enumeration defining IDs for some classes derived from Operator.
Mesh * GetMesh() const
Returns the mesh.
double p(const Vector &x, double t)
std::size_t operator()(const key_face &k) const
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
SparseMatrix * RefinementMatrix_main(const int coarse_ndofs, const Table &coarse_elem_dof, const Table *coarse_elem_fos, const DenseTensor localP[]) const
Transfer data between a coarse mesh and an embedded refined mesh using interpolation.
virtual ~FiniteElementSpace()
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
SparseMatrix * H2L_GlobalRestrictionMatrix(FiniteElementSpace *lfes)
Construct the restriction matrix from the FE space given by (*this) to the lower degree FE space give...
int GetNumElementInteriorDofs(int i) const
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_vdofs, int component=-1) const
Mark degrees of freedom associated with boundary elements with the specified boundary attributes (mar...
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
int GetElementForDof(int i) const
Return the index of the first element that contains dof i.
int GetEdgeOrder(int edge, int variant=0) const
void GetUpdateOperator(OperatorHandle &T)
Return the update operator in the given OperatorHandle, T.
int GetEdgeDofs(int edge, Array< int > &dofs, int variant=0) const
Returns the indices of the degrees of freedom for the specified edge, including the DOFs for the vert...
RefinementOperator(const FiniteElementSpace *fespace, Table *old_elem_dof, Table *old_elem_fos, int old_ndofs)
int FindDofs(const Table &var_dof_table, int row, int ndof) const
Search row of a DOF table for a DOF set of size 'ndof', return first DOF.
Array< char > var_face_orders
int GetFaceOrder(int face, int variant=0) const
Returns the polynomial degree of the i'th face finite element.
void Clear()
Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged...
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
int GetNVDofs() const
Number of all scalar vertex dofs.
The ordering method used when the number of unknowns per mesh node (vector dimension) is bigger than ...
void SetRelaxedHpConformity(bool relaxed=true)
int GetAttribute(int i) const
virtual void GetTrueTransferOperator(const FiniteElementSpace &coarse_fes, OperatorHandle &T) const
Construct and return an Operator that can be used to transfer true-dof data from coarse_fes, defined on a coarse mesh, to this FE space, defined on a refined mesh.
FiniteElementSpace(Mesh *mesh, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
int GetNE() const
Returns number of elements.
QVectorLayout
Type describing possible layouts for Q-vectors.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
void ConvertToConformingVDofs(const Array< int > &dofs, Array< int > &cdofs)
For a partially conforming FE space, convert a marker array (nonzero entries are true) on the partial...
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
Element::Type GetElementType(int i) const
Returns the type of element i.
const QuadratureInterpolator * GetQuadratureInterpolator(const IntegrationRule &ir) const
Return a QuadratureInterpolator that interpolates E-vectors to quadrature point values and/or derivat...
void Swap(Mesh &other, bool non_geometry)
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
Mesh * mesh
The mesh that FE space lives on (not owned).
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void ReorderElementToDofTable()
Reorder the scalar DOFs based on the element ordering.
GridFunction interpolation operator applicable after mesh refinement.
virtual int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type, does not count master nonconforming face...
Array< FaceQuadratureInterpolator * > E2BFQ_array
int GetBdrAttribute(int i) const
int GetElementOrderImpl(int i) const
Return element order: internal version of GetElementOrder without checks.
Ordering::Type GetOrdering() const
Return the ordering method.
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
Table var_face_dofs
NOTE: also used for spaces with mixed faces.
void Save(std::ostream &out) const
Save finite element space to output stream out.
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Array< FaceQuadratureInterpolator * > E2IFQ_array
void UpdateElementOrders()
Resize the elem_order array on mesh change.
int GetEntityDofs(int entity, int index, Array< int > &dofs, Geometry::Type master_geom=Geometry::INVALID, int variant=0) const
Helper to get vertex, edge or face DOFs (entity=0,1,2 resp.).
void GetLocalDerefinementMatrices(Geometry::Type geom, DenseTensor &localR) const
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th edge.
int GetNBE() const
Returns number of boundary elements in the mesh.
void MakeVDimMatrix(SparseMatrix &mat) const
Replicate 'mat' in the vector dimension, according to vdim ordering mode.
int index(int i, int j, int nx, int ny)
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
int FirstFaceDof(int face, int variant=0) const
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Array< char > var_edge_orders
Lexicographic ordering for tensor-product FiniteElements.
FiniteElementSpace()
Default constructor: the object is invalid until initialized using the method Load().
void Constructor(Mesh *mesh, NURBSExtension *ext, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
Help function for constructors + Load().
Operator * Ptr() const
Access the underlying Operator pointer.
void SetUpdateOperatorOwner(bool own)
Set the ownership of the update operator: if set to false, the Operator returned by GetUpdateOperator...
int Size() const
Return the logical size of the array.
NQPT x VDIM x NE (values) / NQPT x VDIM x DIM x NE (grads)
static void ListToMarker(const Array< int > &list, int marker_size, Array< int > &marker, int mark_val=-1)
Convert an array of indices (list) to a Boolean marker array where all indices in the list are marked...
void BuildNURBSFaceToDofTable() const
Generates partial face_dof table for a NURBS space.
int DofToVDof(int dof, int vd, int ndofs=-1) const
int GetNV() const
Returns number of vertices in the mesh.
std::tuple< bool, ElementDofOrdering, FaceType, L2FaceValues > key_face
The face restriction operators, see GetFaceRestriction().
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
virtual void UpdatesFinished()
Free the GridFunction update operator (if any), to save memory.
void GetElementInteriorDofs(int i, Array< int > &dofs) const
SparseMatrix * cR_hp
A version of the conforming restriction matrix for variable-order spaces.
void SetUpdateOperatorType(Operator::Type tid)
Specify the Operator::Type to be used by the update operators.
static bool DofFinalizable(int dof, const Array< bool > &finalized, const SparseMatrix &deps)
Class representing the storage layout of a QuadratureFunction.
NURBSExtension * NURBSext
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
virtual const FaceRestriction * GetFaceRestriction(ElementDofOrdering e_ordering, FaceType, L2FaceValues mul=L2FaceValues::DoubleValued) const
Return an Operator that converts L-vectors to E-vectors on each face.
int GetNVariants(int entity, int index) const
Return number of possible DOF variants for edge/face (var. order spaces).
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Base class for operators that extracts Face degrees of freedom.
int GetNConformingDofs() const
virtual int GetFaceDofs(int face, Array< int > &dofs, int variant=0) const
Returns the indices of the degrees of freedom for the specified face, including the DOFs for the edge...
Rank 3 tensor (array of matrices)
void BuildDofToArrays()
Initialize internal data that enables the use of the methods GetElementForDof() and GetLocalDofForDof...
const Table & GetElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each mesh element...
virtual const SparseMatrix * GetHpRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
int GetNFDofs() const
Number of all scalar face-interior dofs.
void GetLocalRefinementMatrices(Geometry::Type geom, DenseTensor &localP) const
int GetLocalDofForDof(int i) const
Return the local dof index in the first element that contains dof i.
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
static void AdjustVDofs(Array< int > &vdofs)
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
const Table & GetFaceToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each face in the m...
int VDofToDof(int vdof) const
void GetTransferOperator(const FiniteElementSpace &coarse_fes, OperatorHandle &T) const
Construct and return an Operator that can be used to transfer GridFunction data from coarse_fes...
VDIM x NQPT x NE (values) / VDIM x DIM x NQPT x NE (grads)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Arbitrary order "L2-conforming" discontinuous finite elements.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
FiniteElementSpace(Mesh *mesh, NURBSExtension *ext, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
Construct a NURBS FE space based on the given NURBSExtension, ext.