15 #include "../config/config.hpp"
16 #include "../linalg/sparsemat.hpp"
17 #include "../mesh/mesh.hpp"
22 #include <unordered_map>
44 static inline int Map(
int ndofs,
int vdim,
int dof,
int vd);
50 template <>
inline int
51 Ordering::Map<Ordering::byNODES>(
int ndofs,
int vdim,
int dof,
int vd)
53 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
54 return (dof >= 0) ? dof+ndofs*vd : dof-ndofs*vd;
57 template <>
inline int
58 Ordering::Map<Ordering::byVDIM>(
int ndofs,
int vdim,
int dof,
int vd)
60 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
61 return (dof >= 0) ? vd+vdim*dof : -1-(vd+vdim*(-1-dof));
80 class BilinearFormIntegrator;
81 class QuadratureSpace;
82 class QuadratureInterpolator;
83 class FaceQuadratureInterpolator;
162 using key_face = std::tuple<bool, ElementDofOrdering, FaceType, L2FaceValues>;
167 return std::get<0>(k)
168 + 2 * (
int)std::get<1>(k)
169 + 4 * (
int)std::get<2>(k)
170 + 8 * (
int)std::get<3>(k);
173 using map_L2F = std::unordered_map<const key_face,FaceRestriction*,key_hash>;
232 int FindDofs(
const Table &var_dof_table,
int row,
int ndof)
const;
251 {
return (idx >= 0) ? (entity_base + idx) : (-1-(entity_base + (-1-idx))); }
255 {
return (dof >= 0) ? dof : (-1 - dof); }
258 {
return (dof >= 0) ? (sign = 1, dof) : (sign = -1, (-1 - dof)); }
263 int variant = 0)
const;
300 void ConstructDoFTrans();
307 Table *old_elem_fos,
int old_ndofs);
320 Table *coarse_elem_dof;
322 Table coarse_to_fine;
342 const Table &coarse_elem_dof,
343 const Table *coarse_elem_fos,
355 const Table* old_elem_fos);
359 const Table* old_elem_fos);
782 int component = -1)
const;
870 virtual void Update(
bool want_transform =
true);
923 void Save(std::ostream &
out)
const;
980 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 GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type.
Ordering::Type GetOrdering() const
Return the ordering method.
int Size() const
Return the logical size of the array.
Abstract base class for LORDiscretization and ParLORDiscretization classes, which construct low-order...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
void GetVertexVDofs(int i, Array< int > &vdofs) const
int GetAttribute(int i) const
SparseMatrix * RefinementMatrix_main(const int coarse_ndofs, const Table &coarse_elem_dof, const Table *coarse_elem_fos, const DenseTensor localP[]) const
int GetNDofs() const
Returns number of degrees of freedom.
int ndofs
Number of degrees of freedom. Number of unknowns is ndofs * vdim.
Class for an integration rule - an Array of IntegrationPoint.
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
int * bdofs
internal DOFs of elements if mixed/var-order; NULL otherwise
const Table & GetBdrElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each boundary mesh...
void GetElementInteriorVDofs(int i, Array< int > &vdofs) const
int DofToVDof(int dof, int vd, int ndofs=-1) const
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
static void AddDependencies(SparseMatrix &deps, Array< int > &master_dofs, Array< int > &slave_dofs, DenseMatrix &I, int skipfirst=0)
virtual const Operator * GetRestrictionTransposeOperator() const
Return an operator that performs the transpose of GetRestrictionOperator.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
static int Map(int ndofs, int vdim, int dof, int vd)
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
virtual const SparseMatrix * GetHpRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
SparseMatrix * DerefinementMatrix(int old_ndofs, const Table *old_elem_dof, const Table *old_elem_fos)
Calculate GridFunction restriction matrix after mesh derefinement.
void BuildElementToDofTable() const
const IntegrationRule & GetElementIntRule(int idx) const
Get the IntegrationRule associated with mesh element idx.
int MakeDofTable(int ent_dim, const Array< int > &entity_orders, Table &entity_dofs, Array< char > *var_ent_order)
void BuildNURBSFaceToDofTable() const
Generates partial face_dof table for a NURBS space.
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
DerefinementOperator(const FiniteElementSpace *f_fes, const FiniteElementSpace *c_fes, BilinearFormIntegrator *mass_integ)
TODO: Implement DofTransformation support.
const FiniteElement * GetTraceElement(int i, Geometry::Type geom_type) const
Return the trace element from element 'i' to the given 'geom_type'.
Matrix-free transfer operator between finite element spaces on the same mesh.
int GetNBE() const
Returns number of boundary elements.
static int DecodeDof(int dof, double &sign)
virtual DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'.
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.
int GetSize() const
Return the total number of quadrature points.
static int MinOrder(VarOrderBits bits)
Return the minimum order (least significant bit set) in the bit mask.
Element::Type GetElementType(int i) const
Returns the type of element i.
Pointer to an Operator of a specified type.
int VDofToDof(int vdof) const
static constexpr int MaxVarOrder
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
virtual ~DerefinementOperator()
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...
Data type dense matrix using column-major storage.
int vdim
Vector dimension (number of unknowns per degree of freedom).
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
Mesh * GetMesh() const
Returns the mesh.
int GetNumElementInteriorDofs(int i) const
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
int GetBdrAttribute(int i) const
const SparseMatrix * GetHpConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
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 ...
int GetNE() const
Returns number of elements.
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...
int GetBdrElementType(int i) const
Returns the type of boundary element i.
MFEM_DEPRECATED void RebuildElementToDofTable()
(
int GetNV() const
Returns number of vertices in the mesh.
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 ...
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
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.
void AddEdgeFaceDependencies(SparseMatrix &deps, Array< int > &master_dofs, const FiniteElement *master_fe, Array< int > &slave_dofs, int slave_face, const DenseMatrix *pm) const
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller...
bool UsesTensorBasis(const FiniteElementSpace &fes)
const IntegrationRule * int_rule[Geometry::NumGeom]
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().
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...
NURBSExtension * GetNURBSext()
Geometry::Type GetElementBaseGeometry(int i) const
void GetLocalDerefinementMatrices(Geometry::Type geom, DenseTensor &localR) const
int GetConformingVSize() const
std::unordered_map< const key_face, FaceRestriction *, key_hash > map_L2F
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
std::uint64_t VarOrderBits
Bit-mask representing a set of orders needed by an edge/face.
const Table & GetFaceToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each face in the m...
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.
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
void GetFaceInteriorDofs(int i, Array< int > &dofs) const
Derefinement operator, used by the friend class InterpolationGridTransfer.
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
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...
const Operator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
int uni_fdof
of single face DOFs if all faces uniform; -1 otherwise
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
int GetNE() const
Returns number of elements in the mesh.
int GetNE() const
Returns number of elements in the mesh.
void GetVertexDofs(int i, Array< int > &dofs) const
bool Nonconforming() const
void BuildBdrElementToDofTable() const
int FindFaceDof(int face, int ndof) const
Similar to FindEdgeDof, but used for mixed meshes too.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
int GetFaceOrder(int face, int variant=0) const
Returns the polynomial degree of the i'th face finite element.
Array< DofTransformation * > DoFTrans
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
int GetNBE() const
Returns number of boundary elements in the mesh.
bool orders_changed
True if at least one element order changed (variable-order space only).
Native ordering as defined by the FiniteElement.
int FindEdgeDof(int edge, int ndof) const
Mesh * GetMesh() const
Returns the mesh.
void GetVDofs(int vd, Array< int > &dofs, int ndofs=-1) const
Returns the indices of all of the VDofs for the specified dimension 'vd'.
A class that performs interpolation from an E-vector to quadrature point values and/or derivatives (Q...
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...
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' param...
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
void BuildConformingInterpolation() const
Calculate the cP and cR matrices for a nonconforming mesh.
NURBSExtension * StealNURBSext()
int GetElementForDof(int i) const
Return the index of the first element that contains dof i.
virtual ~RefinementOperator()
int GetMaxElementOrder() const
Return the maximum polynomial order.
FiniteElementSpace & operator=(const FiniteElementSpace &)=delete
Copy assignment not supported.
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Returns the transformation defining the i-th element in the user-defined variable ElTr...
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
Array< int > dof_ldof_array
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
int GetVDim() const
Returns vector dimension.
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
static int EncodeDof(int entity_base, int idx)
Helper to encode a sign flip into a DOF index (for Hcurl/Hdiv shapes).
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.
Array< QuadratureInterpolator * > E2Q_array
A class that performs interpolation from a face E-vector to quadrature point values and/or derivative...
int GetNumBorderDofs(Geometry::Type geom, int order) const
Operator * Ptr() const
Access the underlying Operator pointer.
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.).
int FirstFaceDof(int face, int variant=0) const
OperatorHandle L2E_nat
The element restriction operators, see GetElementRestriction().
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
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...
void GetElementInteriorDofs(int i, Array< int > &dofs) const
void GetLocalRefinementMatrices(Geometry::Type geom, DenseTensor &localP) const
static void DofsToVDofs(int ndofs, int vdim, Array< int > &dofs)
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
Type
Enumeration defining IDs for some classes derived from Operator.
double p(const Vector &x, double t)
const NURBSExtension * GetNURBSext() const
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Transfer data between a coarse mesh and an embedded refined mesh using interpolation.
int GetLocalDofForDof(int i) const
Return the local dof index in the first element that contains dof i.
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...
virtual ~QuadratureSpace()
void GetUpdateOperator(OperatorHandle &T)
Return the update operator in the given OperatorHandle, T.
RefinementOperator(const FiniteElementSpace *fespace, Table *old_elem_dof, Table *old_elem_fos, int old_ndofs)
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
void Save(std::ostream &out) const
Write the QuadratureSpace to the stream out.
Array< char > var_face_orders
void Clear()
Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged...
void MakeVDimMatrix(SparseMatrix &mat) const
Replicate 'mat' in the vector dimension, according to vdim ordering mode.
The ordering method used when the number of unknowns per mesh node (vector dimension) is bigger than ...
void GetEdgeInteriorVDofs(int i, Array< int > &vdofs) const
void SetRelaxedHpConformity(bool relaxed=true)
int GetNVariants(int entity, int index) const
Return number of possible DOF variants for edge/face (var. order spaces).
int GetOrder() const
Return the order of the quadrature rule(s) used by all elements.
int GetElementType(int i) const
Returns the type of element i.
FiniteElementSpace(Mesh *mesh, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
bool Nonconforming() const
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int GetNVDofs() const
Number of all scalar vertex dofs.
int GetDegenerateFaceDofs(int index, Array< int > &dofs, Geometry::Type master_geom, int variant) const
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.
void Swap(Mesh &other, bool non_geometry)
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.
void CalcEdgeFaceVarOrders(Array< VarOrderBits > &edge_orders, Array< VarOrderBits > &face_orders) const
Array< FaceQuadratureInterpolator * > E2BFQ_array
const Table * GetElementToFaceOrientationTable() const
int GetNConformingDofs() const
Table var_face_dofs
NOTE: also used for spaces with mixed faces.
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
const QuadratureInterpolator * GetQuadratureInterpolator(const IntegrationRule &ir) const
Return a QuadratureInterpolator that interpolates E-vectors to quadrature point values and/or derivat...
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Array< FaceQuadratureInterpolator * > E2IFQ_array
void BuildFaceToDofTable() const
void UpdateElementOrders()
Resize the elem_order array on mesh change.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int index(int i, int j, int nx, int ny)
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
Array< char > var_edge_orders
int GetEdgeOrder(int edge, int variant=0) const
Lexicographic ordering for tensor-product FiniteElements.
FiniteElementSpace()
Default constructor: the object is invalid until initialized using the method Load().
QuadratureSpace(Mesh *mesh_, int order_)
Create a QuadratureSpace based on the global rules from IntRules.
void Constructor(Mesh *mesh, NURBSExtension *ext, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
Help function for constructors + Load().
void SetUpdateOperatorOwner(bool own)
Set the ownership of the update operator: if set to false, the Operator returned by GetUpdateOperator...
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th face element (2D and 3D).
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th edge.
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...
std::size_t operator()(const key_face &k) const
const FiniteElementCollection * FEColl() const
std::tuple< bool, ElementDofOrdering, FaceType, L2FaceValues > key_face
The face restriction operators, see GetFaceRestriction().
virtual int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type, does not count master nonconforming face...
virtual void UpdatesFinished()
Free the GridFunction update operator (if any), to save memory.
const Table & GetElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each mesh element...
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.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
NURBSExtension * NURBSext
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Base class for operators that extracts Face degrees of freedom.
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
int GetElementOrderImpl(int i) const
Return element order: internal version of GetElementOrder without checks.
Rank 3 tensor (array of matrices)
virtual const Operator * GetRestrictionOperator() const
An abstract operator that performs the same action as GetRestrictionMatrix.
void Save(std::ostream &out) const
Save finite element space to output stream out.
int GetAttribute(int i) const
Return the attribute of element i.
void BuildDofToArrays()
Initialize internal data that enables the use of the methods GetElementForDof() and GetLocalDofForDof...
Class representing a function through its values (scalar or vector) at quadrature points...
int GetNFDofs() const
Number of all scalar face-interior dofs.
int GetNEDofs() const
Number of all scalar edge-interior dofs.
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
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.
static void AdjustVDofs(Array< int > &vdofs)
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
Arbitrary order "L2-conforming" discontinuous finite elements.
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
const FaceQuadratureInterpolator * GetFaceQuadratureInterpolator(const IntegrationRule &ir, FaceType type) const
Return a FaceQuadratureInterpolator that interpolates E-vectors to quadrature point values and/or der...
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.