15 #include "../config/config.hpp"
16 #include "../linalg/sparsemat.hpp"
17 #include "../mesh/mesh.hpp"
41 static inline int Map(
int ndofs,
int vdim,
int dof,
int vd);
47 template <>
inline int
48 Ordering::Map<Ordering::byNODES>(
int ndofs,
int vdim,
int dof,
int vd)
50 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
51 return (dof >= 0) ? dof+ndofs*vd : dof-ndofs*vd;
54 template <>
inline int
55 Ordering::Map<Ordering::byVDIM>(
int ndofs,
int vdim,
int dof,
int vd)
57 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim,
"");
58 return (dof >= 0) ? vd+vdim*dof : -1-(vd+vdim*(-1-dof));
78 class BilinearFormIntegrator;
79 class QuadratureSpace;
80 class QuadratureInterpolator;
145 {
return (dof >= 0) ? (sign = 1, dof) : (sign = -1, (-1 - dof)); }
172 Table *old_elem_dof,
int old_ndofs);
184 Table *coarse_elem_dof;
185 Table coarse_to_fine;
205 const Table &coarse_elem_dof,
506 int component = -1)
const;
587 virtual void Update(
bool want_transform =
true);
616 void Save(std::ostream &
out)
const;
664 void Save(std::ostream &
out)
const;
785 bool own_mass_integ_ =
true);
829 int ndof_lor, ndof_ho, nref;
961 void Mult(
const Vector &e_vec,
unsigned eval_flags,
971 template<const
int T_VDIM = 0, const
int T_ND = 0, const
int T_NQ = 0>
972 static void Eval2D(
const int NE,
979 const int eval_flags);
982 template<const
int T_VDIM = 0, const
int T_ND = 0, const
int T_NQ = 0>
983 static void Eval3D(
const int NE,
990 const int eval_flags);
Abstract class for Finite Elements.
virtual ~InterpolationGridTransfer()
const Operator & MakeTrueOperator(FiniteElementSpace &fes_in, FiniteElementSpace &fes_out, const Operator &oper, OperatorHandle &t_oper)
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Ordering::Type GetOrdering() const
Return the ordering method.
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
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.
const Table & GetBdrElementToDofTable() const
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.
virtual void Update(bool want_transform=true)
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.
BilinearFormIntegrator * mass_integ
Ownership depends on own_mass_integ.
void BuildElementToDofTable() const
const IntegrationRule & GetElementIntRule(int idx) const
Get the IntegrationRule associated with mesh element idx.
DerefinementOperator(const FiniteElementSpace *f_fes, const FiniteElementSpace *c_fes, BilinearFormIntegrator *mass_integ)
void Prolongate(const Vector &x, Vector &y) const
L2Prolongation(const L2Projection &l2proj_)
static const int MAX_ND2D
FiniteElementSpace & dom_fes
Domain FE space.
const FiniteElement * GetTraceElement(int i, Geometry::Type geom_type) const
Return the trace element from element 'i' to the given 'geom_type'.
SparseMatrix * RefinementMatrix(int old_ndofs, const Table *old_elem_dof)
int GetNBE() const
Returns number of boundary elements.
SparseMatrix * DerefinementMatrix(int old_ndofs, const Table *old_elem_dof)
Calculate GridFunction restriction matrix after mesh derefinement.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
const FiniteElementSpace * fespace
Not owned.
static int DecodeDof(int dof, double &sign)
Helper to remove encoded sign from a DOF.
SparseMatrix * RefinementMatrix_main(const int coarse_ndofs, const Table &coarse_elem_dof, const DenseTensor localP[]) const
int GetSize() const
Return the total number of quadrature points.
Element::Type GetElementType(int i) const
Returns the type of element i.
Pointer to an Operator of a specified type.
static const int MAX_NQ3D
int VDofToDof(int vdof) const
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
virtual ~DerefinementOperator()
int GetFaceOrder(int i) const
Returns the order of the i'th face finite element.
virtual const Operator & BackwardOperator()=0
Return an Operator that transfers GridFunctions from the range FE space back to GridFunctions in the ...
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_vdofs, int component=-1) const
virtual ~L2Prolongation()
Data type dense matrix using column-major storage.
int vdim
Vector dimension (number of unknowns per degree of freedom).
void GetEntityDofs(int entity, int index, Array< int > &dofs) const
Helper to get vertex, edge or face DOFs (entity=0,1,2 resp.).
Operator::Type oper_type
Desired Operator::Type for the construction of all operators defined by the underlying transfer algor...
int GetNumElementInteriorDofs(int i) const
int GetBdrAttribute(int i) const
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
int GetNE() const
Returns number of elements.
int GetBdrElementType(int i) const
Returns the type of boundary element i.
void RebuildElementToDofTable()
int GetNV() const
Returns number of vertices in the mesh.
Evaluate the derivatives at quadrature points.
const FiniteElement * GetFaceElement(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.
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller...
virtual const Operator & ForwardOperator()
Return an Operator that transfers GridFunctions from the domain FE space to GridFunctions in the rang...
const IntegrationRule * int_rule[Geometry::NumGeom]
L2ProjectionGridTransfer(FiniteElementSpace &coarse_fes, FiniteElementSpace &fine_fes)
const FiniteElementCollection * fec
Associated FE collection (not owned).
OperatorHandle Th
Transformation to apply to GridFunctions after space Update().
NURBSExtension * GetNURBSext()
Geometry::Type GetElementBaseGeometry(int i) const
void GetLocalDerefinementMatrices(Geometry::Type geom, DenseTensor &localR) const
int GetConformingVSize() const
static const int MAX_ND3D
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.
virtual const Operator & TrueBackwardOperator()
Return an Operator that transfers true-dof Vectors from the range FE space back to true-dof Vectors i...
void GetFaceInteriorDofs(int i, Array< int > &dofs) const
virtual int DofForGeometry(Geometry::Type GeomType) const =0
virtual void GetFaceDofs(int i, Array< int > &dofs) const
virtual ~GridTransfer()
Virtual destructor.
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
FiniteElementSpace & ran_fes
Range FE space.
void ConvertFromConformingVDofs(const Array< int > &cdofs, Array< int > &dofs)
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).
void DisableTensorProducts(bool disable=true) const
Disable the use of tensor product evaluations, for tensor-product elements, e.g. quads and hexes...
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.
void GetVertexDofs(int i, Array< int > &dofs) const
virtual const Operator & BackwardOperator()
Return an Operator that transfers GridFunctions from the range FE space back to GridFunctions in the ...
bool Nonconforming() const
const FiniteElement * GetEdgeElement(int i) const
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.
Native ordering as defined by the FiniteElement.
Mesh * GetMesh() const
Returns the mesh.
OperatorHandle F
Forward, coarse-to-fine, operator.
virtual const Operator & ForwardOperator()=0
Return an Operator that transfers GridFunctions from the domain FE space to GridFunctions in the rang...
A class that performs interpolation from an E-vector to quadrature point values and/or derivatives (Q...
GridTransfer(FiniteElementSpace &dom_fes_, FiniteElementSpace &ran_fes_)
SparseMatrix * cR
Conforming restriction matrix such that cR.cP=I.
const IntegrationRule * IntRule
Not owned.
SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
void BuildConformingInterpolation() const
Calculate the cP and cR matrices for a nonconforming mesh.
NURBSExtension * StealNURBSext()
int GetElementForDof(int i) const
virtual ~RefinementOperator()
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
L2Projection(const FiniteElementSpace &fes_ho_, const FiniteElementSpace &fes_lor_)
static void AddDependencies(SparseMatrix &deps, Array< int > &master_dofs, Array< int > &slave_dofs, DenseMatrix &I)
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
InterpolationGridTransfer(FiniteElementSpace &coarse_fes, FiniteElementSpace &fine_fes)
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
OperatorHandle bw_t_oper
Backward true-dof operator.
ElementRestriction(const FiniteElementSpace &, ElementDofOrdering)
int GetVDim() const
Returns vector dimension.
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
static const int MAX_VDIM2D
void SetOperatorType(Operator::Type type)
Set the desired Operator::Type for the construction of all operators defined by the underlying transf...
Array< QuadratureInterpolator * > E2Q_array
void GetEdgeDofs(int i, Array< int > &dofs) const
Operator * Ptr() const
Access the underlying Operator pointer.
OperatorHandle L2E_nat
The element restriction operators, see GetElementRestriction().
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...
OperatorHandle B
Backward, fine-to-coarse, operator.
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)
virtual const Operator & BackwardOperator()
Return an Operator that transfers GridFunctions from the range FE space back to GridFunctions in the ...
Base class for transfer algorithms that construct transfer Operators between two finite element (FE) ...
OperatorHandle fw_t_oper
Forward true-dof operator.
const FiniteElementSpace & fes
void SetMassIntegrator(BilinearFormIntegrator *mass_integ_, bool own_mass_integ_=true)
Assign a mass integrator to be used in the construction of the backward, fine-to-coarse, transfer operator.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
QuadratureInterpolator(const FiniteElementSpace &fes, const IntegrationRule &ir)
Type
Enumeration defining IDs for some classes derived from Operator.
RefinementOperator(const FiniteElementSpace *fespace, Table *old_elem_dof, int old_ndofs)
const NURBSExtension * GetNURBSext() const
Operator that converts FiniteElementSpace L-vectors to E-vectors.
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
virtual ~FiniteElementSpace()
SparseMatrix * H2L_GlobalRestrictionMatrix(FiniteElementSpace *lfes)
static void Eval2D(const int NE, const int vdim, const DofToQuad &maps, const Vector &e_vec, Vector &q_val, Vector &q_der, Vector &q_det, const int eval_flags)
Template compute kernel for 2D.
virtual ~QuadratureSpace()
void GetUpdateOperator(OperatorHandle &T)
Return the update operator in the given OperatorHandle, T.
L2Prolongation * B
Backward, fine-to-coarse, operator.
int GetOrder(int i) const
Returns the order of the i'th finite element.
void Save(std::ostream &out) const
Write the QuadratureSpace to the stream out.
void Clear()
Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged...
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
void MakeVDimMatrix(SparseMatrix &mat) const
bool own_mass_integ
Ownership flag for mass_integ.
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
L2Projection * F
Forward, coarse-to-fine, operator.
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
virtual void GetBdrElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i'th boundary element.
Assuming the derivative at quadrature points form a matrix, this flag can be used to compute and stor...
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.
virtual const Operator & ForwardOperator()
Return an Operator that transfers GridFunctions from the domain FE space to GridFunctions in the rang...
void ConvertToConformingVDofs(const Array< int > &dofs, Array< int > &cdofs)
static void Eval3D(const int NE, const int vdim, const DofToQuad &maps, const Vector &e_vec, Vector &q_val, Vector &q_der, Vector &q_det, const int eval_flags)
Template compute kernel for 3D.
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
virtual const Operator & TrueForwardOperator()
Return an Operator that transfers true-dof Vectors from the domain FE space to true-dof Vectors in th...
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.
int GetNConformingDofs() const
static const int MAX_VDIM3D
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
void Mult(const Vector &e_vec, unsigned eval_flags, Vector &q_val, Vector &q_der, Vector &q_det) const
Interpolate the E-vector e_vec to quadrature points.
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.
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i'th element.
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
Transfer data between a coarse mesh and an embedded refined mesh using L2 projection.
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)
virtual void Mult(const Vector &x, Vector &y) const
Perform the L2 projection onto the LOR space.
const FiniteElementCollection * FEColl() const
virtual void UpdatesFinished()
Free the GridFunction update operator (if any), to save memory.
const Table & GetElementToDofTable() const
static const int MAX_NQ2D
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 for the i'th boundary element.
NURBSExtension * NURBSext
void GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
long GetSequence() const
Return update counter (see Mesh::sequence)
Rank 3 tensor (array of matrices)
void Save(std::ostream &out) const
int GetAttribute(int i) const
Return the attribute of element i.
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.
static void AdjustVDofs(Array< int > &vdofs)
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
void MultTranspose(unsigned eval_flags, const Vector &q_val, const Vector &q_der, Vector &e_vec) const
Perform the transpose operation of Mult(). (TODO)
Evaluate the values at quadrature points.
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 QuadratureSpace * qspace
Not owned.
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
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.