MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
fespace.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_FESPACE
13#define MFEM_FESPACE
14
15#include "../config/config.hpp"
19#include "../mesh/mesh.hpp"
20#include "fe_coll.hpp"
21#include "doftrans.hpp"
22#include "restriction.hpp"
23#include <iostream>
24#include <unordered_map>
25#include <vector>
26
27namespace mfem
28{
29
30/// @brief Type describing possible layouts for Q-vectors.
31/// @sa QuadratureInterpolator and FaceQuadratureInterpolator.
32enum class QVectorLayout
33{
34 /** Layout depending on the input space and the computed quantity:
35 - scalar H1/L2 spaces, values: NQPT x VDIM x NE,
36 - scalar H1/L2 spaces, gradients: NQPT x VDIM x DIM x NE,
37 - vector RT/ND spaces, values: NQPT x SDIM x NE (vdim = 1). */
38 byNODES,
39
40 /** Layout depending on the input space and the computed quantity:
41 - scalar H1/L2 spaces, values: VDIM x NQPT x NE,
42 - scalar H1/L2 spaces, gradients: VDIM x DIM x NQPT x NE,
43 - vector RT/ND spaces, values: SDIM x NQPT x NE (vdim = 1). */
44 byVDIM
45};
46
47/// Constants describing the possible orderings of the DOFs in one element.
49{
50 /// Native ordering as defined by the FiniteElement.
51 /** This ordering can be used by tensor-product elements when the
52 interpolation from the DOFs to quadrature points does not use the
53 tensor-product structure. */
54 NATIVE,
55 /// Lexicographic: DOFs are listed in order of increasing x-coordinate,
56 /// followed by increasing y-coordinate, and z-coordinate.
57 /** This ordering is usually used with tensor-product elements, but it is
58 also supported by some non-tensor elements. */
60};
61
62/** Represents the index of an element to p-refine, plus a change to the order
63 of that element. */
65{
66 int index; ///< Mesh element number
67 int delta; ///< Change to element order
68
69 pRefinement() = default;
70
71 pRefinement(int element, int change)
72 : index(element), delta(change) {}
73};
74
75// Forward declarations
76class NURBSExtension;
77class BilinearFormIntegrator;
78class QuadratureSpace;
79class QuadratureInterpolator;
80class FaceQuadratureInterpolator;
81class PRefinementTransferOperator;
82struct DerefineMatrixOp;
83
84/** @brief Class FiniteElementSpace - responsible for providing FEM view of the
85 mesh, mainly managing the set of degrees of freedom.
86
87 @details The term "degree of freedom", or "dof" for short, can mean
88 different things in different contexts. In MFEM we use "dof" to refer to
89 four closely related types of data; @ref edof "edofs", @ref ldof "ldofs",
90 @ref tdof "tdofs", and @ref vdof "vdofs".
91
92 @anchor edof @par Element DoF:
93 %Element dofs, sometimes referred to as @b edofs, are the expansion
94 coefficients used to build the linear combination of basis functions which
95 approximate a field within one element of the computational mesh. The
96 arrangement of the element dofs is determined by the basis function and
97 element types.
98 @par
99 %Element dofs are usually accessed one element at a time but they can be
100 concatenated together into a global vector when minimizing access time is
101 crucial. The global number of element dofs is not directly available from
102 the FiniteElementSpace. It can be determined by repeatedly calling
103 FiniteElementSpace::GetElementDofs and summing the lengths of the resulting
104 @a dofs arrays.
105
106 @anchor ldof @par Local DoF:
107 Most basis function types share many of their element dofs with neighboring
108 elements. Consequently, the global @ref edof "edof" vector suggested above
109 would contain many redundant entries. One of the primary roles of the
110 FiniteElementSpace is to collapse out these redundancies and
111 define a unique ordering of the remaining degrees of freedom. The
112 collapsed set of dofs are called @b "local dofs" or @b ldofs in
113 the MFEM parlance.
114 @par
115 The term @b local in this context refers to the local rank in a parallel
116 processing environment. MFEM can, of course, be used in sequential
117 computing environments but it is designed with parallel processing in mind
118 and this terminology reflects that design focus.
119 @par
120 When running in parallel the set of local dofs contains all of the degrees
121 of freedom associated with locally owned elements. When running in serial
122 all elements are locally owned so all element dofs are represented in the
123 set of local dofs.
124 @par
125 There are two important caveats regarding local dofs. First, some basis
126 function types, Nedelec and Raviart-Thomas are the prime examples, have an
127 orientation associated with each basis function. The relative orientations
128 of such basis functions in neighboring elements can lead to shared degrees
129 of freedom with opposite signs from the point of view of these neighboring
130 elements. MFEM typically chooses the orientation of the first such shared
131 degree of freedom that it encounters as the default orientation for the
132 corresponding local dof. When this local dof is referenced by a neighboring
133 element which happens to require the opposite orientation the local dof
134 index will be returned (by calls to functions such as
135 FiniteElementSpace::GetElementDofs) as a negative integer. In such cases
136 the actual offset into the vector of local dofs is @b -index-1 and the
137 value expected by this element should have the opposite sign to the value
138 stored in the local dof vector.
139 @par
140 The second important caveat only pertains to high order Nedelec basis
141 functions when shared triangular faces are present in the mesh. In this
142 very particular case the relative orientation of the face with respect to
143 its two neighboring elements can lead to different definitions of the
144 degrees of freedom associated with the interior of the face which cannot
145 be handled by simply flipping the signs of the corresponding values. The
146 DofTransformation class is designed to manage the necessary @b edof to
147 @b ldof transformations in this case. In the majority of cases the
148 DofTransformation is unnecessary and a NULL pointer will be returned in
149 place of a pointer to this object. See DofTransformation for more
150 information.
151
152 @anchor tdof @par True DoF:
153 As the name suggests "true dofs" or @b tdofs form the minimal set of data
154 values needed (along with mesh and basis function definitions) to uniquely
155 define a finite element discretization of a field. The number of true dofs
156 determines the size of the linear systems which typically need to be solved
157 in FEM simulations.
158 @par
159 Often the true dofs and the local dofs are identical, however, there are
160 important cases where they differ significantly. The first such case is
161 related to non-conforming meshes. On non-conforming meshes it is common
162 for degrees of freedom associated with "hanging" nodes, edges, or faces to
163 be constrained by degrees of freedom associated with another mesh entity.
164 In such cases the "hanging" degrees of freedom should not be considered
165 "true" degrees of freedom since their values cannot be independently
166 assigned. For this reason the FiniteElementSpace must process these
167 constraints and define a reduced set of "true" degrees of freedom which are
168 distinct from the local degrees of freedom.
169 @par
170 The second important distinction arises in parallel processing. When
171 distributing a linear system in parallel each degree of freedom must be
172 assigned to a particular processor, its owner. From the finite element
173 point of view it is convenient to distribute a computational mesh and
174 define an owning processor for each element. Since degrees of freedom may
175 be shared between neighboring elements they may also be shared between
176 neighboring processors. Another role of the FiniteElementSpace is to
177 identify the ownership of degrees of freedom which must be shared between
178 processors. Therefore the set of "true" degrees of freedom must also remove
179 redundant degrees of freedom which are owned by other processors.
180 @par
181 To summarize the set of true degrees of freedom are those degrees of
182 freedom needed to solve a linear system representing the partial
183 differential equation being modeled. True dofs differ from "local" dofs by
184 eliminating redundancies across processor boundaries and applying
185 the constraints needed to properly define fields on non-conforming meshes.
186
187 @anchor vdof @par Vector DoF:
188 %Vector dofs or @b vdofs are related to fields which are constructed using
189 multiple copies of the same set of basis functions. A typical example would
190 be the use of three instances of the scalar H1 basis functions to
191 approximate the x, y, and z components of a displacement vector field in
192 three dimensional space as often seen in elasticity simulations.
193 @par
194 %Vector dofs do not represent a specific index space the way the three
195 previous types of dofs do. Rather they are related to modifications of
196 these other index spaces to accommodate multiple copies of the underlying
197 function spaces.
198 @par
199 When using @b vdofs, i.e. when @b vdim != 1, the FiniteElementSpace only
200 manages a single set of degrees of freedom and then uses simple rules to
201 determine the appropriate offsets into the full index spaces. Two ordering
202 rules are supported; @b byNODES and @b byVDIM. See Ordering::Type for
203 details.
204 @par
205 Clearly the notion of a @b vdof is relevant in each of the three contexts
206 mentioned above so extra care must be taken whenever @b vdim != 1 to ensure
207 that the @b edof, @b ldof, or @b tdof is being interpreted correctly.
208 */
210{
213 friend void Mesh::Swap(Mesh &, bool);
214 friend class LORBase;
215 friend struct DerefineMatrixOp;
216
217protected:
218 /// The mesh that FE space lives on (not owned).
220
221 /// Associated FE collection (not owned).
223
224 /// %Vector dimension (number of unknowns per degree of freedom).
225 int vdim;
226
227 /** Type of ordering of the vector dofs when #vdim > 1.
228 - Ordering::byNODES - first nodes, then vector dimension,
229 - Ordering::byVDIM - first vector dimension, then nodes */
231
232 /// Number of degrees of freedom. Number of unknowns is #ndofs * #vdim.
233 int ndofs;
234
235 bool variableOrder = false;
236
237 /** Polynomial order for each element. If empty, all elements are assumed
238 to be of the default order (fec->GetOrder()). */
240
242 int uni_fdof; ///< # of single face DOFs if all faces uniform; -1 otherwise
243 int *bdofs; ///< internal DOFs of elements if mixed/var-order; NULL otherwise
244
245 /** Variable-order spaces only: DOF assignments for edges and faces, see
246 docs in MakeDofTable. For constant order spaces the tables are empty. */
248 Table var_face_dofs; ///< NOTE: also used for spaces with mixed faces
249
250 // Temporary data for condensing all DOFs to local DOFs.
252
253 /** Map from all DOFs of all orders on each entity to local DOFs of orders
254 occurring on a local element containing the entity. */
256
257 /// Bit-mask representing a set of orders needed by an edge/face.
258 typedef std::uint64_t VarOrderBits;
259 static constexpr int MaxVarOrder = 8*sizeof(VarOrderBits) - 1;
260
261 /** Additional data for the var_*_dofs tables: individual variant orders
262 (these are basically alternate J arrays for var_edge/face_dofs). */
266
267 /// Minimum order among neighboring elements.
269
270 /// Marker arrays for ghost master entities to be skipped in conforming
271 /// interpolation constraints.
273
274 // precalculated DOFs for each element, boundary element, and face
275 mutable Table *elem_dof; // owned (except in NURBS FE space)
276 mutable Table *elem_fos; // face orientations by element index
277 mutable Table *bdr_elem_dof; // owned (except in NURBS FE space)
278 mutable Table *bdr_elem_fos; // bdr face orientations by bdr element index
279 mutable Table *face_dof; // owned; in var-order space contains variant 0 DOFs
280
285
287 /** array of NURBS extension for H(div) and H(curl) vector elements.
288 For each direction an extension is created from the base NURBSext,
289 with an increase in order in the appropriate direction. */
292 mutable Array<int> face_to_be; // NURBS FE space only
293
296
297 /** Matrix representing the prolongation from the global conforming dofs to
298 a set of intermediate partially conforming dofs, e.g. the dofs associated
299 with a "cut" space on a non-conforming mesh. */
300 mutable std::unique_ptr<SparseMatrix> cP;
301 /// Conforming restriction matrix such that cR.cP=I.
302 mutable std::unique_ptr<SparseMatrix> cR;
303 /// A version of the conforming restriction matrix for variable-order spaces.
304 mutable std::unique_ptr<SparseMatrix> cR_hp;
305 mutable bool cP_is_set;
306 /// Operator computing the action of the transpose of the restriction.
307 mutable std::unique_ptr<Operator> R_transpose;
308
309 /** Stores the previous FiniteElementSpace, before p-refinement, in the case
310 that @a PTh is constructed by PRefineAndUpdate(). */
311 std::unique_ptr<FiniteElementSpace> fesPrev;
312
313 /// Transformation to apply to GridFunctions after space Update().
315
316 std::shared_ptr<PRefinementTransferOperator> PTh;
317
318 /// Flag to indicate whether the last update was for p-refinement.
319 bool lastUpdatePRef = false;
320
321 /// The element restriction operators, see GetElementRestriction().
323 /// The face restriction operators, see GetFaceRestriction().
324 using key_face = std::tuple<bool, ElementDofOrdering, FaceType, L2FaceValues>;
325 mutable std::unordered_map<key_face,std::unique_ptr<FaceRestriction>,
327
328 mutable std::unordered_map<std::tuple<ElementDofOrdering,FaceType>,
329 std::unique_ptr<InterpolationManager>, TupleHasher> interpolations;
330
334
335 /** Update counter, incremented every time the space is constructed/updated.
336 Used by GridFunctions to check if they are up to date with the space. */
338
339 /** Mesh sequence number last seen when constructing the space. The space
340 needs updating if Mesh::GetSequence() is larger than this. */
342
343 /// True if at least one element order changed (variable-order space only).
345
346 bool relaxed_hp; // see SetRelaxedHpConformity()
347
348 void UpdateNURBS();
349
350 /** Helper function for constructing the data in this class, for initial
351 construction or updates (e.g. h- or p-refinement). */
352 void Construct();
353
354 void Destroy();
355
358
359 void BuildElementToDofTable() const;
360 void BuildBdrElementToDofTable() const;
361 void BuildFaceToDofTable() const;
362
363 /** Get all @a edges and @a faces (in 3D) on boundary elements with attribute
364 marked as essential in @a bdr_attr_is_ess. */
365 void GetEssentialBdrEdgesFaces(const Array<int> &bdr_attr_is_ess,
366 std::set<int> & edges,
367 std::set<int> & faces) const;
368
369 /** @brief Initialize internal data that enables the use of the methods
370 GetElementForDof() and GetLocalDofForDof(). */
371 void BuildDofToArrays_() const;
372
373 /** @brief Initialize internal data that enables the use of the methods
374 GetBdrElementForDof() and GetBdrLocalDofForDof(). */
375 void BuildDofToBdrArrays() const;
376
377 /** @brief Generates partial face_dof table for a NURBS space.
378
379 The table is only defined for exterior faces that coincide with a
380 boundary. */
381 void BuildNURBSFaceToDofTable() const;
382
383 /// Sets @a all2local. See documentation of @a all2local for details.
385
386 /// Return the minimum order (least significant bit set) in the bit mask.
387 static int MinOrder(VarOrderBits bits);
388
389 /// Return element order: internal version of GetElementOrder without checks.
390 int GetElementOrderImpl(int i) const;
391
392 /// Returns true if the space is H1 and has variable-order elements.
393 bool IsVariableOrderH1() const
394 {
395 return variableOrder &&
396 dynamic_cast<const H1_FECollection*>(fec);
397 }
398
399 /** In a variable-order space, calculate a bitmask of polynomial orders that
400 need to be represented on each edge and face. */
402 Array<VarOrderBits> &edge_orders, Array<VarOrderBits> &face_orders,
403 Array<VarOrderBits> &edge_elem_orders,
404 Array<VarOrderBits> &face_elem_orders,
405 Array<bool> &skip_edges, Array<bool> &skip_faces) const;
406
407 /// Helper function for ParFiniteElementSpace.
409 Array<VarOrderBits> &edge_orders, Array<VarOrderBits> &face_orders) const;
410
411 /// Helper function for ParFiniteElementSpace.
413 const Array<VarOrderBits> &face_orders,
414 Array<VarOrderBits> &edge_orders) const { }
415
416 /// Returns true if order propagation is done, for variable-order spaces.
417 virtual bool OrderPropagation(const std::set<int> &edges,
418 const std::set<int> &faces,
419 Array<VarOrderBits> &edge_orders,
420 Array<VarOrderBits> &face_orders) const
421 { return edges.size() == 0 && faces.size() == 0; };
422
423 /// Returns the number of ghost edges (nonzero in ParFiniteElementSpace).
424 virtual int NumGhostEdges() const { return 0; }
425
426 /// Returns the number of ghost faces (nonzero in ParFiniteElementSpace).
427 virtual int NumGhostFaces() const { return 0; }
428
429 /** Build the table var_edge_dofs (or var_face_dofs) in a variable-order
430 space; return total edge/face DOFs. */
431 int MakeDofTable(int ent_dim, const Array<VarOrderBits> &entity_orders,
432 Table &entity_dofs, Array<char> *var_ent_order);
433
434 /// Search row of a DOF table for a DOF set of size 'ndof', return first DOF.
435 int FindDofs(const Table &var_dof_table, int row, int ndof) const;
436
437 /** In a variable-order space, return edge DOFs associated with a polynomial
438 order that has 'ndof' degrees of freedom. */
439 int FindEdgeDof(int edge, int ndof) const
440 { return FindDofs(var_edge_dofs, edge, ndof); }
441
442 /// Similar to FindEdgeDof, but used for mixed meshes too.
443 int FindFaceDof(int face, int ndof) const
444 { return FindDofs(var_face_dofs, face, ndof); }
445
446 int FirstFaceDof(int face, int variant = 0) const
447 { return uni_fdof >= 0 ? face*uni_fdof : var_face_dofs.GetRow(face)[variant];}
448
449 /// Return number of possible DOF variants for edge/face (var. order spaces).
450 int GetNVariants(int entity, int index) const;
451
452 /// Helper to get vertex, edge or face DOFs (entity=0,1,2 resp.).
453 int GetEntityDofs(int entity, int index, Array<int> &dofs,
454 Geometry::Type master_geom = Geometry::INVALID,
455 int variant = 0) const;
456 /// Helper to get vertex, edge or face VDOFs (entity=0,1,2 resp.).
457 int GetEntityVDofs(int entity, int index, Array<int> &dofs,
458 Geometry::Type master_geom = Geometry::INVALID,
459 int variant = 0) const;
460
461 // Get degenerate face DOFs: see explanation in method implementation.
463 Geometry::Type master_geom, int variant) const;
464
465 int GetNumBorderDofs(Geometry::Type geom, int order) const;
466
467 /// Calculate the cP and cR matrices for a nonconforming mesh.
468 void BuildConformingInterpolation() const;
469
470 /** In variable-order spaces, enforce the minimum order rule on edges and
471 faces, by adding constraints to @a deps for high-order DOFs to
472 interpolate the lowest-order DOFs per mesh entity. */
473 void VariableOrderMinimumRule(SparseMatrix & deps) const;
474
475 static void AddDependencies(SparseMatrix& deps, Array<int>& master_dofs,
476 Array<int>& slave_dofs, DenseMatrix& I,
477 int skipfirst = 0);
478
479 static bool DofFinalizable(int dof, const Array<bool>& finalized,
480 const SparseMatrix& deps);
481
482 void AddEdgeFaceDependencies(SparseMatrix &deps, Array<int>& master_dofs,
483 const FiniteElement *master_fe,
484 Array<int> &slave_dofs, int slave_face,
485 const DenseMatrix *pm) const;
486
487 /// Replicate 'mat' in the vector dimension, according to vdim ordering mode.
488 void MakeVDimMatrix(SparseMatrix &mat) const;
489
490 /// GridFunction interpolation operator applicable after mesh refinement.
492 {
493 const FiniteElementSpace* fespace;
495 Table* old_elem_dof; // Owned.
496 Table* old_elem_fos; // Owned.
497
498 Array<StatelessDofTransformation*> old_DoFTransArray;
499 mutable DofTransformation old_DoFTrans;
500
501 void ConstructDoFTransArray();
502
503 public:
504 /** Construct the operator based on the elem_dof table of the original
505 (coarse) space. The class takes ownership of the table. */
507 Table *old_elem_dof/*takes ownership*/,
508 Table *old_elem_fos/*takes ownership*/, int old_ndofs);
510 const FiniteElementSpace *coarse_fes);
511 virtual void Mult(const Vector &x, Vector &y) const;
512 virtual void MultTranspose(const Vector &x, Vector &y) const;
513 virtual ~RefinementOperator();
514 };
515
516 /// Derefinement operator, used by the friend class InterpolationGridTransfer.
518 {
519 const FiniteElementSpace *fine_fes; // Not owned.
521 Table *coarse_elem_dof; // Owned.
522 // Table *coarse_elem_fos; // Owned.
523 Table coarse_to_fine;
524 Array<int> coarse_to_ref_type;
525 Array<Geometry::Type> ref_type_to_geom;
526 Array<int> ref_type_to_fine_elem_offset;
527
528 public:
530 const FiniteElementSpace *c_fes,
531 BilinearFormIntegrator *mass_integ);
532 void Mult(const Vector &x, Vector &y) const override;
533 virtual ~DerefinementOperator();
534 };
535
536 /** This method makes the same assumptions as the method:
537 void GetLocalRefinementMatrices(
538 const FiniteElementSpace &coarse_fes, Geometry::Type geom,
539 DenseTensor &localP) const
540 which is defined below. It also assumes that the coarse fes and this have
541 the same vector dimension, vdim. */
542 SparseMatrix *RefinementMatrix_main(const int coarse_ndofs,
543 const Table &coarse_elem_dof,
544 const Table *coarse_elem_fos,
545 const DenseTensor localP[]) const;
546
547 /* This method returns the Refinement matrix (i.e., the embedding)
548 from a coarse variable-order fes to a fine fes (after a geometric refinement) */
549 SparseMatrix *VariableOrderRefinementMatrix(const int coarse_ndofs,
550 const Table &coarse_elem_dof) const;
551
553 DenseTensor &localP) const;
555 DenseTensor &localR) const;
556
557 /** Calculate explicit GridFunction interpolation matrix (after mesh
558 refinement). NOTE: consider using the RefinementOperator class instead
559 of the fully assembled matrix, which can take a lot of memory. */
560 SparseMatrix* RefinementMatrix(int old_ndofs, const Table* old_elem_dof,
561 const Table* old_elem_fos);
562
563 /// Calculate GridFunction restriction matrix after mesh derefinement.
564 SparseMatrix* DerefinementMatrix(int old_ndofs, const Table* old_elem_dof,
565 const Table* old_elem_fos);
566
567 /** @brief Return in @a localP the local refinement matrices that map
568 between fespaces after mesh refinement. */
569 /** This method assumes that this->mesh is a refinement of coarse_fes->mesh
570 and that the CoarseFineTransformations of this->mesh are set accordingly.
571 Another assumption is that the FEs of this use the same MapType as the FEs
572 of coarse_fes. Finally, it assumes that the spaces this and coarse_fes are
573 NOT variable-order spaces. */
574 void GetLocalRefinementMatrices(const FiniteElementSpace &coarse_fes,
575 Geometry::Type geom,
576 DenseTensor &localP) const;
577
578 /// Help function for constructors + Load().
581 int vdim = 1, int ordering = Ordering::byNODES);
582
583 /// Updates the internal mesh pointer. @warning @a new_mesh must be
584 /// <b>topologically identical</b> to the existing mesh. Used if the address
585 /// of the Mesh object has changed, e.g. in @a Mesh::Swap.
586 virtual void UpdateMeshPointer(Mesh *new_mesh);
587
588 /// Resize the elem_order array on mesh change.
589 void UpdateElementOrders();
590
591 /// @brief Copies the prolongation and restriction matrices from @a fes.
592 ///
593 /// Used for low order preconditioning on non-conforming meshes. If the DOFs
594 /// require a permutation, it will be supplied by non-NULL @a perm. NULL @a
595 /// perm indicates that no permutation is required.
597 const Array<int> *perm);
598
599public:
600
601
602 /** @brief Default constructor: the object is invalid until initialized using
603 the method Load(). */
605
606 /** @brief Copy constructor: deep copy all data from @a orig except the Mesh,
607 the FiniteElementCollection, and some derived data. */
608 /** If the @a mesh or @a fec pointers are NULL (default), then the new
609 FiniteElementSpace will reuse the respective pointers from @a orig. If
610 any of these pointers is not NULL, the given pointer will be used instead
611 of the one used by @a orig.
612
613 @note The objects pointed to by the @a mesh and @a fec parameters must be
614 either the same objects as the ones used by @a orig, or copies of them.
615 Otherwise, the behavior is undefined.
616
617 @note Derived data objects, such as the conforming prolongation and
618 restriction matrices, and the update operator, will not be copied, even
619 if they are created in the @a orig object. */
620 FiniteElementSpace(const FiniteElementSpace &orig, Mesh *mesh = NULL,
621 const FiniteElementCollection *fec = NULL);
622
625 int vdim = 1, int ordering = Ordering::byNODES);
626
627 /// Construct a NURBS FE space based on the given NURBSExtension, @a ext.
628 /** @note If the pointer @a ext is NULL, this constructor is equivalent to
629 the standard constructor with the same arguments minus the
630 NURBSExtension, @a ext. */
633 int vdim = 1, int ordering = Ordering::byNODES);
634
635 /// Copy assignment not supported
637
638 /// Returns the mesh
639 inline Mesh *GetMesh() const { return mesh; }
640
641 const NURBSExtension *GetNURBSext() const { return NURBSext; }
644
645 bool Conforming() const
646 {
647 return NURBSext != NULL ||
648 (mesh->Conforming() && cP == NULL);
649 }
650 bool Nonconforming() const { return !Conforming(); }
651
652 /** Set the prolongation operator of the space to an arbitrary sparse matrix,
653 creating a copy of the argument. */
654 void SetProlongation(const SparseMatrix& p);
655
656 /** Set the restriction operator of the space to an arbitrary sparse matrix,
657 creating a copy of the argument. */
658 void SetRestriction(const SparseMatrix& r);
659
660 /// Sets the order of the i'th finite element.
661 /** By default, all elements are assumed to be of fec->GetOrder(). Once
662 SetElementOrder is called, the space becomes a variable-order space. */
663 void SetElementOrder(int i, int p);
664
665 /// Returns the order of the i'th finite element.
666 int GetElementOrder(int i) const;
667
668 /// Return the maximum polynomial order over all elements.
669 virtual int GetMaxElementOrder() const
670 { return IsVariableOrder() ? elem_order.Max() : fec->GetOrder(); }
671
672 /// Returns true if the space contains elements of varying polynomial orders.
673 bool IsVariableOrder() const { return variableOrder; }
674
675 /// The returned SparseMatrix is owned by the FiniteElementSpace. The method
676 /// returns nullptr if the matrix is identity.
678
679 /// The returned SparseMatrix is owned by the FiniteElementSpace.
681
682 /** Return a version of the conforming restriction matrix for variable-order
683 spaces with complex hp interfaces, where some true DOFs are not owned by
684 any elements and need to be interpolated from higher order edge/face
685 variants (see also @a SetRelaxedHpConformity()). */
686 /// The returned SparseMatrix is owned by the FiniteElementSpace.
688
689 /// The returned Operator is owned by the FiniteElementSpace. The method
690 /// returns nullptr if the prolongation matrix is identity.
691 virtual const Operator *GetProlongationMatrix() const
692 { return GetConformingProlongation(); }
693
694 /// Return an operator that performs the transpose of GetRestrictionOperator
695 /** The returned operator is owned by the FiniteElementSpace.
696
697 For a serial conforming space, this returns NULL, indicating the identity
698 operator.
699
700 For a parallel conforming space, this will return a matrix-free
701 (Device)ConformingProlongationOperator.
702
703 For a non-conforming mesh this will return a TransposeOperator wrapping
704 the restriction matrix. */
706
707 /// An abstract operator that performs the same action as GetRestrictionMatrix
708 /** In some cases this is an optimized matrix-free implementation. The
709 returned operator is owned by the FiniteElementSpace. */
710 virtual const Operator *GetRestrictionOperator() const
711 { return GetConformingRestriction(); }
712
713 /// The returned SparseMatrix is owned by the FiniteElementSpace.
714 virtual const SparseMatrix *GetRestrictionMatrix() const
715 { return GetConformingRestriction(); }
716
717 /// The returned SparseMatrix is owned by the FiniteElementSpace.
719 { return GetHpConformingRestriction(); }
720
721 /// Return an Operator that converts L-vectors to E-vectors.
722 /** An L-vector is a vector of size GetVSize() which is the same size as a
723 GridFunction. An E-vector represents the element-wise discontinuous
724 version of the FE space.
725
726 The layout of the E-vector is: ND x VDIM x NE, where ND is the number of
727 degrees of freedom, VDIM is the vector dimension of the FE space, and NE
728 is the number of the mesh elements.
729
730 The parameter @a e_ordering describes how the local DOFs in each element
731 should be ordered in the E-vector, see ElementDofOrdering.
732
733 For discontinuous spaces, the element restriction corresponds to a
734 permutation of the degrees of freedom, implemented by the
735 L2ElementRestriction class.
736
737 The returned Operator is owned by the FiniteElementSpace. */
739 ElementDofOrdering e_ordering) const;
740
741 /** @brief Return an Operator that converts L-vectors to E-vectors on each
742 face. */
743 /** @warning only meshes with tensor-product elements are currently
744 supported. */
745 virtual const FaceRestriction *GetFaceRestriction(
746 ElementDofOrdering f_ordering, FaceType,
748
750 ElementDofOrdering f_ordering, FaceType type) const;
751
752 /** @brief Return a QuadratureInterpolator that interpolates E-vectors to
753 quadrature point values and/or derivatives (Q-vectors). */
754 /** An E-vector represents the element-wise discontinuous version of the FE
755 space and can be obtained, for example, from a GridFunction using the
756 Operator returned by GetElementRestriction().
757
758 All elements will use the same IntegrationRule, @a ir as the target
759 quadrature points.
760
761 @note The returned pointer is shared. A good practice, before using it,
762 is to set all its properties to their expected values, as other parts of
763 the code may also change them. That is, it's good to call
764 SetOutputLayout() and DisableTensorProducts() before interpolating.
765
766 @note If the space is not supported by QuadratureInterpolator, nullptr is
767 returned. */
769 const IntegrationRule &ir) const;
770
771 /** @brief Return a QuadratureInterpolator that interpolates E-vectors to
772 quadrature point values and/or derivatives (Q-vectors). */
773 /** An E-vector represents the element-wise discontinuous version of the FE
774 space and can be obtained, for example, from a GridFunction using the
775 Operator returned by GetElementRestriction().
776
777 The target quadrature points in the elements are described by the given
778 QuadratureSpace, @a qs.
779
780 @note The returned pointer is shared. A good practice, before using it,
781 is to set all its properties to their expected values, as other parts of
782 the code may also change them. That is, it's good to call
783 SetOutputLayout() and DisableTensorProducts() before interpolating.
784
785 @note If the space is not supported by QuadratureInterpolator, nullptr is
786 returned. */
788 const QuadratureSpace &qs) const;
789
790 /** @brief Return a FaceQuadratureInterpolator that interpolates E-vectors to
791 quadrature point values and/or derivatives (Q-vectors).
792
793 @note The returned pointer is shared. A good practice, before using it,
794 is to set all its properties to their expected values, as other parts of
795 the code may also change them. That is, it's good to call
796 SetOutputLayout() and DisableTensorProducts() before interpolating.
797
798 @note If the space is not supported by FaceQuadratureInterpolator,
799 nullptr is returned. */
801 const IntegrationRule &ir, FaceType type) const;
802
803 /// Returns the polynomial degree of the i'th finite element.
804 /** NOTE: it is recommended to use GetElementOrder in new code. */
805 int GetOrder(int i) const { return GetElementOrder(i); }
806
807 /** Return the order of an edge. In a variable-order space, return the order
808 of a specific variant, or -1 if there are no more variants. */
809 int GetEdgeOrder(int edge, int variant = 0) const;
810
811 /// Returns the polynomial degree of the i'th face finite element
812 int GetFaceOrder(int face, int variant = 0) const;
813
814 /// Returns the vector dimension of the finite element space.
815 /** Since the finite elements could be vector-valued, this may not be the
816 dimension of an actual vector in the space; see GetVectorDim(). */
817 inline int GetVDim() const { return vdim; }
818
819 /// @brief Returns number of degrees of freedom.
820 /// This is the number of @ref ldof "Local Degrees of Freedom"
821 inline int GetNDofs() const { return ndofs; }
822
823 /// @brief Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
824 inline int GetVSize() const { return vdim * ndofs; }
825
826 /// @brief Return the number of vector true (conforming) dofs.
827 virtual int GetTrueVSize() const { return GetConformingVSize(); }
828
829 /// Returns the number of conforming ("true") degrees of freedom
830 /// (if the space is on a nonconforming mesh with hanging nodes).
831 int GetNConformingDofs() const;
832
833 int GetConformingVSize() const { return vdim * GetNConformingDofs(); }
834
835 /// Return the total dimension of a vector in the space
836 /** This accounts for the vectorization of elements and cases where the
837 elements themselves are vector-valued; see FiniteElement:GetRangeDim().
838 If the finite elements are FiniteElement::SCALAR, this equals GetVDim().
839
840 Note: For vector-valued elements, the results pads up the range dimension
841 to the spatial dimension. E.g., consider a stack of 5 vector-valued
842 elements each representing 2D vectors, living in a 3 dimensional space.
843 Then this function would give 15, not 10.
844 */
845 int GetVectorDim() const;
846
847 /// Return the dimension of the curl of a GridFunction defined on this space.
848 /** Note: This assumes a space dimension of 2 or 3 only. */
849 int GetCurlDim() const;
850
851 /// Return the ordering method.
852 inline Ordering::Type GetOrdering() const { return ordering; }
853
854 const FiniteElementCollection *FEColl() const { return fec; }
855
856 /// Number of all scalar vertex dofs
857 int GetNVDofs() const { return nvdofs; }
858 /// Number of all scalar edge-interior dofs
859 int GetNEDofs() const { return nedofs; }
860 /// Number of all scalar face-interior dofs
861 int GetNFDofs() const { return nfdofs; }
862
863 /// Returns number of vertices in the mesh.
864 inline int GetNV() const { return mesh->GetNV(); }
865
866 /// Returns number of elements in the mesh.
867 inline int GetNE() const { return mesh->GetNE(); }
868
869 /// Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
870 /** The co-dimension 1 entities are those that have dimension 1 less than the
871 mesh dimension, e.g. for a 2D mesh, the faces are the 1D entities, i.e.
872 the edges. */
873 inline int GetNF() const { return mesh->GetNumFaces(); }
874
875 /// Returns number of boundary elements in the mesh.
876 inline int GetNBE() const { return mesh->GetNBE(); }
877
878 /// Returns the number of faces according to the requested type.
879 /** If type==Boundary returns only the "true" number of boundary faces
880 contrary to GetNBE() that returns "fake" boundary faces associated to
881 visualization for GLVis.
882 Similarly, if type==Interior, the "fake" boundary faces associated to
883 visualization are counted as interior faces. */
884 inline int GetNFbyType(FaceType type) const
885 { return mesh->GetNFbyType(type); }
886
887 /// Returns the type of element i.
888 inline int GetElementType(int i) const
889 { return mesh->GetElementType(i); }
890
891 /// Returns the vertices of element i.
892 inline void GetElementVertices(int i, Array<int> &vertices) const
893 { mesh->GetElementVertices(i, vertices); }
894
895 /// Returns the type of boundary element i.
896 inline int GetBdrElementType(int i) const
897 { return mesh->GetBdrElementType(i); }
898
899 /// Returns ElementTransformation for the @a i-th element.
900 /// @note The returned pointer references an object owned by the associated
901 /// @a Mesh that will be modified by other calls to `GetElementTransformation`.
902 /// As such, this pointer should @b not be deleted by the caller.
905
906 /** @brief Returns the transformation defining the @a i-th element in the
907 user-defined variable @a ElTr. */
910
911 /// Returns ElementTransformation for the @a i-th boundary element.
914
915 int GetAttribute(int i) const { return mesh->GetAttribute(i); }
916
917 int GetBdrAttribute(int i) const { return mesh->GetBdrAttribute(i); }
918
919 /// @anchor getdof @name Local DoF Access Members
920 /// These member functions produce arrays of local degree of freedom
921 /// indices, see @ref ldof. If @b vdim == 1 these indices can be used to
922 /// access entries in GridFunction, LinearForm, and BilinearForm objects.
923 /// If @b vdim != 1 the corresponding @ref getvdof "Get*VDofs" methods
924 /// should be used instead or one of the @ref dof2vdof "DofToVDof" methods
925 /// could be used to produce the appropriate offsets from these local dofs.
926 ///@{
927
928 /// @brief Returns indices of degrees of freedom of element 'elem'. The
929 /// returned indices are offsets into an @ref ldof vector. See also
930 /// GetElementVDofs().
931 ///
932 /// @note In many cases the returned DofTransformation object will be NULL.
933 /// In other cases see the documentation of the DofTransformation class for
934 /// guidance on its role in performing @ref edof to @ref ldof transformations
935 /// on local vectors and matrices. At present the DofTransformation is only
936 /// needed for Nedelec basis functions of order 2 and above on 3D elements
937 /// with triangular faces.
938 ///
939 /// @deprecated Use of the returned object is deprecated. The returned object
940 /// should @b not be deleted by the caller. If the DofTransformation is
941 /// needed, use GetElementDofs(int, Array<int> &, DofTransformation &)
942 /// instead.
943 DofTransformation *GetElementDofs(int elem, Array<int> &dofs) const;
944
945 /// @brief The same as GetElementDofs(), but with a user-provided
946 /// DofTransformation object.
947 ///
948 /// The user can use DofTransformation::IsIdentity on the returned @a
949 /// doftrans object to determine if the DofTransformation needs to actually
950 /// be used.
951 virtual void GetElementDofs(int elem, Array<int> &dofs,
952 DofTransformation &doftrans) const;
953
954 /// @brief Returns indices of degrees of freedom for boundary element 'bel'.
955 /// The returned indices are offsets into an @ref ldof vector. See also
956 /// GetBdrElementVDofs().
957 ///
958 /// @note In many cases the returned DofTransformation object will be NULL.
959 /// In other cases see the documentation of the DofTransformation class for
960 /// guidance on its role in performing @ref edof to @ref ldof transformations
961 /// on local vectors and matrices. At present the DofTransformation is only
962 /// needed for Nedelec basis functions of order 2 and above on 3D elements
963 /// with triangular faces.
964 ///
965 /// @deprecated Use of the returned object is deprecated. The returned object
966 /// should @b not be deleted by the caller. If the DofTransformation is
967 /// needed, use GetBdrElementDofs(int, Array<int> &, DofTransformation &)
968 /// instead.
969 DofTransformation *GetBdrElementDofs(int bel, Array<int> &dofs) const;
970
971 /// @brief The same as GetBdrElementDofs(), but with a user-provided
972 /// DofTransformation object.
973 ///
974 /// The user can use DofTransformation::IsIdentity on the returned @a
975 /// doftrans object to determine if the DofTransformation needs to actually
976 /// be used.
977 virtual void GetBdrElementDofs(int bel, Array<int> &dofs,
978 DofTransformation &doftrans) const;
979
980 /// @brief Returns the indices of the degrees of freedom for the specified
981 /// face, including the DOFs for the edges and the vertices of the face.
982 ///
983 /// In variable-order spaces, multiple variants of DOFs can be returned.
984 /// See GetEdgeDofs() for more details.
985 /// @return Order of the selected variant, or -1 if there are no more
986 /// variants.
987 ///
988 /// The returned indices are offsets into an @ref ldof vector. See also
989 /// GetFaceVDofs().
990 virtual int GetFaceDofs(int face, Array<int> &dofs, int variant = 0) const;
991
992 /// @brief Returns the indices of the degrees of freedom for the specified
993 /// edge, including the DOFs for the vertices of the edge.
994 ///
995 /// In variable-order spaces, multiple sets of DOFs may exist on an edge,
996 /// corresponding to the different polynomial orders of incident elements.
997 /// The 'variant' parameter is the zero-based index of the desired DOF set.
998 /// The variants are ordered from lowest polynomial degree to the highest.
999 /// @return Order of the selected variant, or -1 if there are no more
1000 /// variants.
1001 ///
1002 /// The returned indices are offsets into an @ref ldof vector. See also
1003 /// GetEdgeVDofs().
1004 int GetEdgeDofs(int edge, Array<int> &dofs, int variant = 0) const;
1005
1006 /// @brief Returns the indices of the degrees of freedom for the specified
1007 /// vertices.
1008 ///
1009 /// The returned indices are offsets into an @ref ldof vector. See also
1010 /// GetVertexVDofs().
1011 void GetVertexDofs(int i, Array<int> &dofs) const;
1012
1013 /// @brief Returns the indices of the degrees of freedom for the interior
1014 /// of the specified element.
1015 ///
1016 /// Specifically this refers to degrees of freedom which are not associated
1017 /// with the vertices, edges, or faces of the mesh. This method may be
1018 /// useful in conjunction with schemes which process shared and non-shared
1019 /// degrees of freedom differently such as static condensation.
1020 ///
1021 /// The returned indices are offsets into an @ref ldof vector. See also
1022 /// GetElementInteriorVDofs().
1023 void GetElementInteriorDofs(int i, Array<int> &dofs) const;
1024
1025 /// @brief Returns the number of degrees of freedom associated with the
1026 /// interior of the specified element.
1027 ///
1028 /// See GetElementInteriorDofs() for more information or to obtain the
1029 /// relevant indices.
1030 int GetNumElementInteriorDofs(int i) const;
1031
1032 /// @brief Returns the indices of the degrees of freedom for the interior
1033 /// of the specified face.
1034 ///
1035 /// Specifically this refers to degrees of freedom which are not associated
1036 /// with the vertices, edges, or cell interiors of the mesh. This method may
1037 /// be useful in conjunction with schemes which process shared and non-shared
1038 /// degrees of freedom differently such as static condensation.
1039 ///
1040 /// The returned indices are offsets into an @ref ldof vector. See also
1041 /// GetFaceInteriorVDofs().
1042 void GetFaceInteriorDofs(int i, Array<int> &dofs) const;
1043
1044 /// @brief Returns the indices of the degrees of freedom for the interior
1045 /// of the specified edge.
1046 ///
1047 /// The returned indices are offsets into an @ref ldof vector. See also
1048 /// GetEdgeInteriorVDofs().
1049 void GetEdgeInteriorDofs(int i, Array<int> &dofs) const;
1050 ///@}
1051
1052 /** @brief Returns indices of degrees of freedom for NURBS patch index
1053 @a patch. Cartesian ordering is used, for the tensor-product degrees of
1054 freedom. */
1055 void GetPatchDofs(int patch, Array<int> &dofs) const;
1056
1057 /// @anchor dof2vdof @name DoF To VDoF Conversion methods
1058 /// These methods convert between local dof and local vector dof using the
1059 /// appropriate relationship based on the Ordering::Type defined in this
1060 /// FiniteElementSpace object.
1061 ///
1062 /// These methods assume the index set has a range [0, GetNDofs()) which
1063 /// will be mapped to the range [0, GetVSize()). This assumption can be
1064 /// changed in the forward mappings by passing a value for @a ndofs which
1065 /// differs from that returned by GetNDofs().
1066 ///
1067 /// @note These methods, with the exception of VDofToDof(), are designed to
1068 /// produce the correctly encoded values when dof entries are negative,
1069 /// see @ref ldof for more on negative dof indices.
1070 ///
1071 /// @warning When MFEM_DEBUG is enabled at build time the forward mappings
1072 /// will verify that each @a dof lies in the proper range. If MFEM_DEBUG is
1073 /// disabled no range checking is performed.
1074 ///@{
1075
1076 /// @brief Returns the indices of all of the VDofs for the specified
1077 /// dimension 'vd'.
1078 ///
1079 /// The @a ndofs parameter can be used to indicate the total number of Dofs
1080 /// associated with each component of @b vdim. If @a ndofs is -1 (the
1081 /// default value), then the number of Dofs is determined by the
1082 /// FiniteElementSpace::GetNDofs().
1083 ///
1084 /// @note This method does not resize the @a dofs array. It takes the range
1085 /// of dofs [0, dofs.Size()) and converts these to @ref vdof "vdofs" and
1086 /// stores the results in the @a dofs array.
1087 void GetVDofs(int vd, Array<int> &dofs, int ndofs = -1) const;
1088
1089 /// @brief Compute the full set of @ref vdof "vdofs" corresponding to each
1090 /// entry in @a dofs.
1091 ///
1092 /// @details Produces a set of @ref vdof "vdofs" of
1093 /// length @b vdim * dofs.Size() corresponding to the entries contained in
1094 /// the @a dofs array.
1095 ///
1096 /// The @a ndofs parameter can be used to indicate the total number of Dofs
1097 /// associated with each component of @b vdim. If @a ndofs is -1 (the
1098 /// default value), then the number of Dofs is <determined by the
1099 /// FiniteElementSpace::GetNDofs().
1100 ///
1101 /// @note The @a dofs array is overwritten and resized to accommodate the
1102 /// new values.
1103 void DofsToVDofs(Array<int> &dofs, int ndofs = -1) const;
1104
1105 /// @brief Compute the set of @ref vdof "vdofs" corresponding to each entry
1106 /// in @a dofs for the given vector index @a vd.
1107 ///
1108 /// The @a ndofs parameter can be used to indicate the total number of Dofs
1109 /// associated with each component of @b vdim. If @a ndofs is -1 (the
1110 /// default value), then the number of Dofs is <determined by the
1111 /// FiniteElementSpace::GetNDofs().
1112 ///
1113 /// @note The @a dofs array is overwritten with the new values but its size
1114 /// will not be altered.
1115 void DofsToVDofs(int vd, Array<int> &dofs, int ndofs = -1) const;
1116
1117 /// @brief Compute a single @ref vdof corresponding to the index @a dof and
1118 /// the vector index @a vd.
1119 ///
1120 /// The @a ndofs parameter can be used to indicate the total number of Dofs
1121 /// associated with each component of @b vdim. If @a ndofs is -1 (the
1122 /// default value), then the number of Dofs is <determined by the
1123 /// FiniteElementSpace::GetNDofs().
1124 int DofToVDof(int dof, int vd, int ndofs = -1) const;
1125
1126 /// @brief Compute the inverse of the Dof to VDof mapping for a single
1127 /// index @a vdof.
1128 ///
1129 /// @warning This method is only intended for use with positive indices.
1130 /// Passing a negative value for @a vdof will produce an invalid result.
1131 int VDofToDof(int vdof) const
1132 { return (ordering == Ordering::byNODES) ? (vdof%ndofs) : (vdof/vdim); }
1133
1134 ///@}
1135
1136 /// @brief Remove the orientation information encoded into an array of dofs
1137 /// Some basis function types have a relative orientation associated with
1138 /// degrees of freedom shared between neighboring elements, see @ref ldof
1139 /// for more information. An orientation mismatch is indicated in the dof
1140 /// indices by a negative index value. This method replaces such negative
1141 /// indices with the corresponding positive offsets.
1142 ///
1143 /// @note The name of this method reflects the fact that it is most often
1144 /// applied to sets of @ref vdof "Vector Dofs" but it would work equally
1145 /// well on sets of @ref ldof "Local Dofs".
1146 static void AdjustVDofs(Array<int> &vdofs);
1147
1148 /// Helper to encode a sign flip into a DOF index (for Hcurl/Hdiv shapes).
1149 static inline int EncodeDof(int entity_base, int idx)
1150 { return (idx >= 0) ? (entity_base + idx) : (-1-(entity_base + (-1-idx))); }
1151
1152 /// Helper to return the DOF associated with a sign encoded DOF
1153 static inline int DecodeDof(int dof)
1154 { return UnsignIndex(dof); }
1155
1156 /// Helper to determine the DOF and sign of a sign encoded DOF
1157 static inline int DecodeDof(int dof, real_t& sign)
1158 { return (dof >= 0) ? (sign = 1, dof) : (sign = -1, (-1 - dof)); }
1159
1160 /// @anchor getvdof @name Local Vector DoF Access Members
1161 /// These member functions produce arrays of local vector degree of freedom
1162 /// indices, see @ref ldof and @ref vdof. These indices can be used to
1163 /// access entries in GridFunction, LinearForm, and BilinearForm objects
1164 /// regardless of the value of @b vdim.
1165 /// @{
1166
1167 /// @brief Returns indices of degrees of freedom for the @a i'th element.
1168 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1169 /// not necessarily equal to 1. The returned indices are always ordered
1170 /// byNODES, irrespective of whether the space is byNODES or byVDIM.
1171 /// See also GetElementDofs().
1172 ///
1173 /// @note In many cases the returned DofTransformation object will be NULL.
1174 /// In other cases see the documentation of the DofTransformation class for
1175 /// guidance on its role in performing @ref edof to @ref ldof transformations
1176 /// on local vectors and matrices. At present the DofTransformation is only
1177 /// needed for Nedelec basis functions of order 2 and above on 3D elements
1178 /// with triangular faces.
1179 ///
1180 /// @deprecated Use of the returned object is deprecated. The returned object
1181 /// should @b not be deleted by the caller. If the DofTransformation is
1182 /// needed, use GetElementVDofs(int, Array<int> &, DofTransformation &)
1183 /// instead.
1184 DofTransformation *GetElementVDofs(int i, Array<int> &vdofs) const;
1185
1186 /// @brief The same as GetElementVDofs(), but with a user-provided
1187 /// DofTransformation object.
1188 ///
1189 /// The user can use DofTransformation::IsIdentity on the returned @a
1190 /// doftrans object to determine if the DofTransformation needs to actually
1191 /// be used.
1192 void GetElementVDofs(int i, Array<int> &vdofs,
1193 DofTransformation &doftrans) const;
1194
1195 /// @brief Returns indices of degrees of freedom for @a i'th boundary
1196 /// element.
1197 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1198 /// not necessarily equal to 1. See also GetBdrElementDofs().
1199 ///
1200 /// @note In many cases the returned DofTransformation object will be NULL.
1201 /// In other cases see the documentation of the DofTransformation class for
1202 /// guidance on its role in performing @ref edof to @ref ldof transformations
1203 /// on local vectors and matrices. At present the DofTransformation is only
1204 /// needed for Nedelec basis functions of order 2 and above on 3D elements
1205 /// with triangular faces.
1206 ///
1207 /// @deprecated Use of the returned object is deprecated. The returned object
1208 /// should @b not be deleted by the caller. If the DofTransformation is
1209 /// needed, use GetBdrElementVDofs(int, Array<int> &, DofTransformation &)
1210 /// instead.
1211 DofTransformation *GetBdrElementVDofs(int i, Array<int> &vdofs) const;
1212
1213 /// @brief The same as GetBdrElementVDofs(), but with a user-provided
1214 /// DofTransformation object.
1215 ///
1216 /// The user can use DofTransformation::IsIdentity on the returned @a
1217 /// doftrans object to determine if the DofTransformation needs to actually
1218 /// be used.
1219 void GetBdrElementVDofs(int i, Array<int> &vdofs,
1220 DofTransformation &doftrans) const;
1221
1222 /// Returns indices of degrees of freedom in @a vdofs for NURBS patch @a i.
1223 void GetPatchVDofs(int i, Array<int> &vdofs) const;
1224
1225 /// @brief Returns the indices of the degrees of freedom for the specified
1226 /// face, including the DOFs for the edges and the vertices of the face.
1227 ///
1228 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1229 /// not necessarily equal to 1. See GetFaceDofs() for more information.
1230 void GetFaceVDofs(int i, Array<int> &vdofs) const;
1231
1232 /// @brief Returns the indices of the degrees of freedom for the specified
1233 /// edge, including the DOFs for the vertices of the edge.
1234 ///
1235 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1236 /// not necessarily equal to 1. See GetEdgeDofs() for more information.
1237 void GetEdgeVDofs(int i, Array<int> &vdofs) const;
1238
1239 /// @brief Returns the indices of the degrees of freedom for the specified
1240 /// vertices.
1241 ///
1242 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1243 /// not necessarily equal to 1. See also GetVertexDofs().
1244 void GetVertexVDofs(int i, Array<int> &vdofs) const;
1245
1246 /// @brief Returns the indices of the degrees of freedom for the interior
1247 /// of the specified element.
1248 ///
1249 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1250 /// not necessarily equal to 1. See GetElementInteriorDofs() for more
1251 /// information.
1252 void GetElementInteriorVDofs(int i, Array<int> &vdofs) const;
1253
1254 /// @brief Returns the indices of the degrees of freedom for the interior
1255 /// of the specified edge.
1256 ///
1257 /// The returned indices are offsets into an @ref ldof vector with @b vdim
1258 /// not necessarily equal to 1. See also GetEdgeInteriorDofs().
1259 void GetEdgeInteriorVDofs(int i, Array<int> &vdofs) const;
1260 /// @}
1261
1262 /// (@deprecated) Use the Update() method if the space or mesh changed.
1263 MFEM_DEPRECATED void RebuildElementToDofTable();
1264
1265 /** @brief Reorder the scalar DOFs based on the element ordering.
1266
1267 The new ordering is constructed as follows: 1) loop over all elements as
1268 ordered in the Mesh; 2) for each element, assign new indices to all of
1269 its current DOFs that are still unassigned; the new indices we assign are
1270 simply the sequence `0,1,2,...`; if there are any signed DOFs their sign
1271 is preserved. */
1273
1275
1276 /** @brief Return a reference to the internal Table that stores the lists of
1277 scalar dofs, for each mesh element, as returned by GetElementDofs(). */
1278 const Table &GetElementToDofTable() const { return *elem_dof; }
1279
1280 /** @brief Return a reference to the internal Table that stores the lists of
1281 scalar dofs, for each boundary mesh element, as returned by
1282 GetBdrElementDofs(). */
1285
1286 /** @brief Return a reference to the internal Table that stores the lists of
1287 scalar dofs, for each face in the mesh, as returned by GetFaceDofs(). In
1288 this context, "face" refers to a (dim-1)-dimensional mesh entity. */
1289 /** @note In the case of a NURBS space, the rows corresponding to interior
1290 faces will be empty. */
1292 { if (!face_dof) { BuildFaceToDofTable(); } return *face_dof; }
1293
1294 /// Deprecated. This function is not required to be called by the user.
1295 MFEM_DEPRECATED void BuildDofToArrays() const { BuildDofToArrays_(); }
1296
1297 /// Return the index of the first element that contains ldof index @a i.
1298 int GetElementForDof(int i) const { BuildDofToArrays_(); return dof_elem_array[i]; }
1299
1300 /// Return the dof index within the element from GetElementForDof() for ldof index @a i.
1301 int GetLocalDofForDof(int i) const { BuildDofToArrays_(); return dof_ldof_array[i]; }
1302
1303 /// Return the index of the first boundary element that contains ldof index @a i.
1305
1306 /// Return the dof index within the boundary element from GetBdrElementForDof() for ldof index @a i.
1308
1309
1310 /** @brief Returns pointer to the FiniteElement in the FiniteElementCollection
1311 associated with i'th element in the mesh object.
1312 Note: The method has been updated to abort instead of returning NULL for
1313 an empty partition. */
1314 virtual const FiniteElement *GetFE(int i) const;
1315
1316 /** @brief Return GetFE(0) if the local mesh is not empty; otherwise return a
1317 typical FE based on the Geometry types in the global mesh.
1318
1319 This method can be used as a replacement for GetFE(0) that will be valid
1320 even if the local mesh is empty. */
1321 const FiniteElement *GetTypicalFE() const;
1322
1323 /** @brief Returns pointer to the FiniteElement in the FiniteElementCollection
1324 associated with i'th boundary face in the mesh object. */
1325 const FiniteElement *GetBE(int i) const;
1326
1327 /// @brief Return a "typical" boundary element.
1328 ///
1329 /// This can be used in situations where the local mesh partition may be
1330 /// empty.
1331 const FiniteElement *GetTypicalBE() const;
1332
1333 /** @brief Returns pointer to the FiniteElement in the FiniteElementCollection
1334 associated with i'th face in the mesh object. Faces in this case refer
1335 to the MESHDIM-1 primitive so in 2D they are segments and in 1D they are
1336 points.*/
1337 const FiniteElement *GetFaceElement(int i) const;
1338
1339 /// @brief Return a "typical" face element.
1340 ///
1341 /// This can be used in situations where the local mesh partition may be
1342 /// empty.
1343 const FiniteElement *GetTypicalFaceElement() const;
1344
1345 /** @brief Returns pointer to the FiniteElement in the FiniteElementCollection
1346 associated with i'th edge in the mesh object. */
1347 const FiniteElement *GetEdgeElement(int i, int variant = 0) const;
1348
1349 /// Return the trace element from element 'i' to the given 'geom_type'
1350 const FiniteElement *GetTraceElement(int i, Geometry::Type geom_type) const;
1351
1352 /// @brief Return a "typical" trace element.
1353 ///
1354 /// This can be used in situations where the local mesh partition may be
1355 /// empty.
1357
1358 /** @brief Mark degrees of freedom associated with boundary elements with
1359 the specified boundary attributes (marked in 'bdr_attr_is_ess').
1360 For spaces with 'vdim' > 1, the 'component' parameter can be used
1361 to restricts the marked vDOFs to the specified component. */
1362 virtual void GetEssentialVDofs(const Array<int> &bdr_attr_is_ess,
1363 Array<int> &ess_vdofs,
1364 int component = -1) const;
1365
1366 /** @brief Get a list of essential true dofs, ess_tdof_list, corresponding to the
1367 boundary attributes marked in the array bdr_attr_is_ess.
1368 For spaces with 'vdim' > 1, the 'component' parameter can be used
1369 to restricts the marked tDOFs to the specified component. */
1370 virtual void GetEssentialTrueDofs(const Array<int> &bdr_attr_is_ess,
1372 int component = -1) const;
1373
1374 /** @brief Get a list of all boundary true dofs, @a boundary_dofs. For spaces
1375 with 'vdim' > 1, the 'component' parameter can be used to restricts the
1376 marked tDOFs to the specified component. Equivalent to
1377 FiniteElementSpace::GetEssentialTrueDofs with all boundary attributes
1378 marked as essential. */
1379 void GetBoundaryTrueDofs(Array<int> &boundary_dofs, int component = -1);
1380
1381 /** @brief Mark degrees of freedom associated with exterior faces of the
1382 mesh. For spaces with 'vdim' > 1, the 'component' parameter can be used
1383 to restricts the marked vDOFs to the specified component. */
1384 virtual void GetExteriorVDofs(Array<int> &exterior_vdofs,
1385 int component = -1) const;
1386
1387 /** @brief Get a list of all true dofs on the exterior of the mesh,
1388 @a exterior_dofs. For spaces with 'vdim' > 1, the 'component' parameter
1389 can be used to restricts the marked tDOFs to the specified component. */
1390 virtual void GetExteriorTrueDofs(Array<int> &exterior_dofs,
1391 int component = -1) const;
1392
1393 /** @brief Extract the edge degrees of freedom of a boundary "loop".
1394
1395 Here a "loop" is the set of boundary edges bounding the region covered by
1396 @a boundary_element_indices: in 3D the outer edges of a patch of boundary
1397 faces, in 2D the boundary segments themselves. An edge that is shared by
1398 two (or more) of the selected boundary elements is interior to that region
1399 rather than on its bounding loop, so its DOFs are excluded from the result.
1400 This exclusion of interior DOFs is the defining feature of the method.
1401
1402 The three output arrays share a single indexing: for each valid index @a i,
1403 @a dof_edges[i] and @a dof_boundary_elements[i] describe the DOF
1404 @a boundary_edge_dofs[i].
1405
1406 @param[in] boundary_element_indices Boundary element indices spanning a
1407 boundary surface (3D) or curve (2D).
1408 @param[out] boundary_edge_dofs Local DOF indices on the boundary loop.
1409 @param[out] dof_edges Optional; local edge index carrying each DOF.
1410 @param[out] dof_boundary_elements Optional; a boundary element containing
1411 each DOF.
1412
1413 @note In 3D the edge DOFs are extracted from the 1D edges of the 2D
1414 boundary faces; in 2D they come directly from the 1D boundary segments, so
1415 @a dof_edges then holds the boundary element (segment) edge indices.
1416 @note This method uses GetEdgeDofs internally, which returns both vertex and
1417 edge DOFs. Standard Nédélec elements (ND_FECollection) have no vertex DOFs,
1418 so only genuine edge DOFs appear. Collections that carry vertex DOFs (e.g.
1419 ND_R2D_FECollection) additionally contribute the vertex DOFs at loop
1420 endpoints.
1421 @note This is the serial version. For parallel meshes, use the parallel
1422 version in ParFiniteElementSpace which handles processor boundaries
1423 correctly.
1424 @note Requires a 2D or 3D mesh to identify edge objects. The method will
1425 assert if called on 1D meshes.
1426 @note Only supports conforming meshes; non-conforming meshes are not
1427 supported. */
1428 void GetBoundaryLoopEdgeDofs(const Array<int> &boundary_element_indices,
1429 Array<int> &boundary_edge_dofs,
1430 Array<int> *dof_edges = nullptr,
1431 Array<int> *dof_boundary_elements = nullptr) const;
1432
1433 /** @brief Get boundary elements grouped by attribute.
1434
1435 For each attribute in @a bdr_attrs, collect the indices of all boundary
1436 elements carrying that attribute. The result is indexed to match
1437 @a bdr_attrs: @a attr_to_elements[i] holds the boundary elements with
1438 attribute @a bdr_attrs[i]. */
1440 const Array<int> &bdr_attrs,
1441 std::vector<Array<int>> &attr_to_elements) const;
1442
1443 /** @brief Get all boundary elements with a specific attribute. */
1444 void GetBoundaryElementsByAttribute(int bdr_attr,
1445 Array<int> &boundary_elements) const;
1446
1447 /** @brief Compute edge orientations relative to a boundary loop direction.
1448
1449 For each boundary-loop DOF described by @a dof_edges and
1450 @a dof_boundary_elements (see GetBoundaryLoopEdgeDofs), determine whether
1451 the carrying edge is
1452 traversed in the direction consistent with @a loop_normal, following the
1453 right-hand rule. Intended for 3D meshes.
1454
1455 @param[in] dof_edges Local edge index of each DOF (parallel-indexed with
1456 the boundary_edge_dofs output of GetBoundaryLoopEdgeDofs).
1457 @param[in] dof_boundary_elements A boundary element containing each DOF,
1458 using the same indexing as @a dof_edges.
1459 @param[in] loop_normal Normal vector defining the loop orientation.
1460 @param[out] dof_orientations Orientation (+1 or -1) for each DOF, using the
1461 same indexing as @a dof_edges. */
1462 void ComputeLoopEdgeOrientations(const Array<int> &dof_edges,
1463 const Array<int> &dof_boundary_elements,
1464 const Vector &loop_normal,
1465 Array<int> &dof_orientations) const;
1466
1467 /// Convert a Boolean marker array to a list containing all marked indices.
1468 static void MarkerToList(const Array<int> &marker, Array<int> &list);
1469
1470 /** @brief Convert an array of indices (list) to a Boolean marker array where all
1471 indices in the list are marked with the given value and the rest are set
1472 to zero. */
1473 static void ListToMarker(const Array<int> &list, int marker_size,
1474 Array<int> &marker, int mark_val = -1);
1475
1476 /** @brief For a partially conforming FE space, convert a marker array (nonzero
1477 entries are true) on the partially conforming dofs to a marker array on
1478 the conforming dofs. A conforming dofs is marked iff at least one of its
1479 dependent dofs is marked. */
1480 void ConvertToConformingVDofs(const Array<int> &dofs, Array<int> &cdofs);
1481
1482 /** @brief For a partially conforming FE space, convert a marker array (nonzero
1483 entries are true) on the conforming dofs to a marker array on the
1484 (partially conforming) dofs. A dof is marked iff it depends on a marked
1485 conforming dofs, where dependency is defined by the ConformingRestriction
1486 matrix; in other words, a dof is marked iff it corresponds to a marked
1487 conforming dof. */
1488 void ConvertFromConformingVDofs(const Array<int> &cdofs, Array<int> &dofs);
1489
1490 /** @brief Generate the global restriction matrix from a discontinuous
1491 FE space to the continuous FE space of the same polynomial degree. */
1493
1494 /** @brief Generate the global restriction matrix from a discontinuous
1495 FE space to the piecewise constant FE space. */
1497
1498 /** @brief Construct the restriction matrix from the FE space given by
1499 (*this) to the lower degree FE space given by (*lfes) which
1500 is defined on the same mesh. */
1502
1503 /** @brief Construct and return an Operator that can be used to transfer
1504 GridFunction data from @a coarse_fes, defined on a coarse mesh, to @a
1505 this FE space, defined on a refined mesh. */
1506 /** It is assumed that the mesh of this FE space is a refinement of the mesh
1507 of @a coarse_fes and the CoarseFineTransformations returned by the method
1508 Mesh::GetRefinementTransforms() of the refined mesh are set accordingly.
1509 The Operator::Type of @a T can be set to request an Operator of the set
1510 type. Currently, only Operator::MFEM_SPARSEMAT and Operator::ANY_TYPE
1511 (matrix-free) are supported. When Operator::ANY_TYPE is requested, the
1512 choice of the particular Operator sub-class is left to the method. This
1513 method also works in parallel because the transfer operator is local to
1514 the MPI task when the input is a synchronized ParGridFunction. */
1515 void GetTransferOperator(const FiniteElementSpace &coarse_fes,
1516 OperatorHandle &T) const;
1517
1518 /** @brief Construct and return an Operator that can be used to transfer
1519 true-dof data from @a coarse_fes, defined on a coarse mesh, to @a this FE
1520 space, defined on a refined mesh.
1521
1522 This method calls GetTransferOperator() and multiplies the result by the
1523 prolongation operator of @a coarse_fes on the right, and by the
1524 restriction operator of this FE space on the left.
1525
1526 The Operator::Type of @a T can be set to request an Operator of the set
1527 type. In serial, the supported types are: Operator::MFEM_SPARSEMAT and
1528 Operator::ANY_TYPE (matrix-free). In parallel, the supported types are:
1529 Operator::Hypre_ParCSR and Operator::ANY_TYPE. Any other type is treated
1530 as Operator::ANY_TYPE: the operator representation choice is made by this
1531 method. */
1532 virtual void GetTrueTransferOperator(const FiniteElementSpace &coarse_fes,
1533 OperatorHandle &T) const;
1534
1535 /** @brief Reflect changes in the mesh: update number of DOFs, etc. Also,
1536 calculate GridFunction transformation operator (unless want_transform is
1537 false). Safe to call multiple times, does nothing if space already up to
1538 date. */
1539 virtual void Update(bool want_transform = true);
1540
1541 /** P-refine and update the space. If @a want_transfer, also maintain the old
1542 space and a transfer operator accessible by GetPrefUpdateOperator(). */
1543 virtual void PRefineAndUpdate(const Array<pRefinement> & refs,
1544 bool want_transfer = true);
1545
1546 /** Return true iff p-refinement is supported in this space. Current support
1547 is only for L2 or H1 spaces on purely quadrilateral or hexahedral
1548 meshes. */
1549 bool PRefinementSupported();
1550
1551 /// Get the GridFunction update operator.
1552 const Operator* GetUpdateOperator() { Update(); return Th.Ptr(); }
1553
1554 /// Return the update operator in the given OperatorHandle, @a T.
1556
1557 /** Returns @a PTh, the transfer operator from the previous space to the
1558 current space, after p-refinement. */
1559 std::shared_ptr<const PRefinementTransferOperator> GetPrefUpdateOperator();
1560
1561 /** @brief Set the ownership of the update operator: if set to false, the
1562 Operator returned by GetUpdateOperator() must be deleted outside the
1563 FiniteElementSpace. */
1564 /** The update operator ownership is automatically reset to true when a new
1565 update operator is created by the Update() method. */
1567
1568 /// Specify the Operator::Type to be used by the update operators.
1569 /** The default type is Operator::ANY_TYPE which leaves the choice to this
1570 class. The other currently supported option is Operator::MFEM_SPARSEMAT
1571 which is only guaranteed to be honored for a refinement update operator.
1572 Any other type will be treated as Operator::ANY_TYPE.
1573 @note This operation destroys the current update operator (if owned). */
1575
1576 /// Free the GridFunction update operator (if any), to save memory.
1577 virtual void UpdatesFinished() { Th.Clear(); }
1578
1579 /** Return update counter, similar to Mesh::GetSequence(). Used by
1580 GridFunction to check if it is up to date with the space. */
1581 long GetSequence() const { return sequence; }
1582
1583 /// Return a flag indicating whether the last update was for p-refinement.
1584 bool LastUpdatePRef() const { return lastUpdatePRef; }
1585
1586 /// Return whether or not the space is discontinuous (L2)
1587 bool IsDGSpace() const
1588 {
1589 return dynamic_cast<const L2_FECollection*>(fec) != NULL;
1590 }
1591
1592 /// @brief Return true if the mesh contains only one topology, the elements are
1593 /// all triangles or tetrahedrons, and the elements are ragged tensor elements
1594 /// i.e. Bernstein/positive basis.
1596 {
1597 bool simplex = this->GetMesh()->IsSimplexMesh();
1598 bool positive =
1599 dynamic_cast<const mfem::H1Pos_TriangleElement *>(this->GetTypicalFE()) ||
1600 dynamic_cast<const mfem::H1Pos_TetrahedronElement *>(this->GetTypicalFE());
1601 return simplex && positive;
1602 }
1603
1604 /** In variable-order spaces on nonconforming (NC) meshes, this function
1605 controls whether strict conformity is enforced in cases where coarse
1606 edges/faces have higher polynomial order than their fine NC neighbors.
1607 In the default (strict) case, the coarse side polynomial order is
1608 reduced to that of the lowest order fine edge/face, so all fine
1609 neighbors can interpolate the coarse side exactly. If relaxed == true,
1610 some discontinuities in the solution in such cases are allowed and the
1611 coarse side is not restricted. For an example, see
1612 https://github.com/mfem/mfem/pull/1423#issuecomment-621340392 */
1613 void SetRelaxedHpConformity(bool relaxed = true)
1614 {
1615 relaxed_hp = relaxed;
1616 orders_changed = true; // force update
1617 Update(false);
1618 }
1619
1620 /** @brief Compute the space's node positions w.r.t. given mesh positions.
1621 The function uses FiniteElement::GetNodes() to obtain the reference DOF
1622 positions of each finite element.
1623
1624 @param[in] mesh_nodes Mesh positions. Assumes that it has the same
1625 topology & ordering as the mesh of the FE space,
1626 i.e, same size as this->GetMesh()->GetNodes().
1627 @param[out] fes_node_pos Positions of the FE space's nodes.
1628 @param[in] fes_nodes_ordering Ordering of fes_node_pos. */
1629 void GetNodePositions(const Vector &mesh_nodes, Vector &fes_node_pos,
1630 int fes_nodes_ordering = Ordering::byNODES) const;
1631
1632 /// Save finite element space to output stream @a out.
1633 void Save(std::ostream &out) const;
1634
1635 /** @brief Read a FiniteElementSpace from a stream. The returned
1636 FiniteElementCollection is owned by the caller. */
1637 FiniteElementCollection *Load(Mesh *m, std::istream &input);
1638
1639 virtual ~FiniteElementSpace();
1640};
1641
1642/// @brief Return true if the mesh contains only one topology and the elements
1643/// are tensor elements.
1645{
1646 Mesh & mesh = *fes.GetMesh();
1647 const bool mixed = mesh.GetNumGeometries(mesh.Dimension()) > 1;
1648 return !mixed &&
1649 dynamic_cast<const mfem::TensorBasisElement *>(
1650 fes.GetTypicalFE()) != nullptr;
1651}
1652
1653/// @brief Return LEXICOGRAPHIC if mesh contains only one topology and the
1654/// elements are tensor elements, otherwise, return NATIVE.
1655ElementDofOrdering GetEVectorOrdering(const FiniteElementSpace& fes);
1656
1657}
1658
1659#endif
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:69
Abstract base class BilinearFormIntegrator.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Rank 3 tensor (array of matrices)
Abstract base class that defines an interface for element restrictions.
A class that performs interpolation from a face E-vector to quadrature point values and/or derivative...
Base class for operators that extracts Face degrees of freedom.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
Definition fe_coll.hpp:248
Derefinement operator, used by the friend class InterpolationGridTransfer.
Definition fespace.hpp:518
void Mult(const Vector &x, Vector &y) const override
Operator application: y=A(x).
Definition fespace.cpp:2349
DerefinementOperator(const FiniteElementSpace *f_fes, const FiniteElementSpace *c_fes, BilinearFormIntegrator *mass_integ)
TODO: Implement DofTransformation support.
Definition fespace.cpp:2248
GridFunction interpolation operator applicable after mesh refinement.
Definition fespace.hpp:492
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 ...
Definition fespace.cpp:2023
RefinementOperator(const FiniteElementSpace *fespace, Table *old_elem_dof, Table *old_elem_fos, int old_ndofs)
Definition fespace.cpp:1835
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Definition fespace.cpp:1944
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
std::unique_ptr< FiniteElementSpace > fesPrev
Definition fespace.hpp:311
void Save(std::ostream &out) const
Save finite element space to output stream out.
Definition fespace.cpp:4409
virtual void ApplyGhostElementOrdersToEdgesAndFaces(Array< VarOrderBits > &edge_orders, Array< VarOrderBits > &face_orders) const
Helper function for ParFiniteElementSpace.
Definition fespace.cpp:3032
int GetEntityVDofs(int entity, int index, Array< int > &dofs, Geometry::Type master_geom=Geometry::INVALID, int variant=0) const
Helper to get vertex, edge or face VDOFs (entity=0,1,2 resp.).
Definition fespace.cpp:1084
void GetVDofs(int vd, Array< int > &dofs, int ndofs=-1) const
Returns the indices of all of the VDofs for the specified dimension 'vd'.
Definition fespace.cpp:212
DofTransformation DoFTrans
Definition fespace.hpp:295
int GetNVDofs() const
Number of all scalar vertex dofs.
Definition fespace.hpp:857
static int EncodeDof(int entity_base, int idx)
Helper to encode a sign flip into a DOF index (for Hcurl/Hdiv shapes).
Definition fespace.hpp:1149
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.cpp:1429
void ReorderElementToDofTable()
Reorder the scalar DOFs based on the element ordering.
Definition fespace.cpp:471
Array< char > var_face_orders
Definition fespace.hpp:263
int GetVectorDim() const
Return the total dimension of a vector in the space.
Definition fespace.cpp:1456
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
Definition fespace.hpp:673
void SetRestriction(const SparseMatrix &r)
Definition fespace.cpp:152
void BuildNURBSFaceToDofTable() const
Generates partial face_dof table for a NURBS space.
Definition fespace.cpp:2720
void BuildDofToBdrArrays() const
Initialize internal data that enables the use of the methods GetBdrElementForDof() and GetBdrLocalDof...
Definition fespace.cpp:517
static void AddDependencies(SparseMatrix &deps, Array< int > &master_dofs, Array< int > &slave_dofs, DenseMatrix &I, int skipfirst=0)
Definition fespace.cpp:915
const Table & GetElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each mesh element,...
Definition fespace.hpp:1278
Array< int > dof_ldof_array
Definition fespace.hpp:282
int GetElementType(int i) const
Returns the type of element i.
Definition fespace.hpp:888
Array< StatelessDofTransformation * > DoFTransArray
Definition fespace.hpp:294
int GetBdrElementForDof(int i) const
Return the index of the first boundary element that contains ldof index i.
Definition fespace.hpp:1304
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const
Compute the full set of vdofs corresponding to each entry in dofs.
Definition fespace.cpp:232
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
Returns the indices of the degrees of freedom for the interior of the specified edge.
Definition fespace.cpp:3841
Array< FaceQuadratureInterpolator * > E2BFQ_array
Definition fespace.hpp:333
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
Definition fespace.cpp:3906
Array< bool > skip_face
Definition fespace.hpp:272
Array< FaceQuadratureInterpolator * > E2IFQ_array
Definition fespace.hpp:332
NURBSExtension * GetNURBSext()
Definition fespace.hpp:642
friend struct DerefineMatrixOp
Definition fespace.hpp:215
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Definition fespace.hpp:827
bool IsVariableOrderH1() const
Returns true if the space is H1 and has variable-order elements.
Definition fespace.hpp:393
Array< int > face_min_nghb_order
Definition fespace.hpp:268
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
Definition fespace.cpp:3538
int GetNumElementInteriorDofs(int i) const
Returns the number of degrees of freedom associated with the interior of the specified element.
Definition fespace.cpp:3811
std::shared_ptr< PRefinementTransferOperator > PTh
Definition fespace.hpp:316
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition fespace.hpp:896
ElementTransformation * GetElementTransformation(int i) const
Definition fespace.hpp:903
virtual void GetExteriorTrueDofs(Array< int > &exterior_dofs, int component=-1) const
Get a list of all true dofs on the exterior of the mesh, exterior_dofs. For spaces with 'vdim' > 1,...
Definition fespace.cpp:712
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified edge, including the DOFs for the vert...
Definition fespace.cpp:332
NURBSExtension * NURBSext
Definition fespace.hpp:286
void GetUpdateOperator(OperatorHandle &T)
Return the update operator in the given OperatorHandle, T.
Definition fespace.hpp:1555
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.hpp:714
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...
Definition fespace.cpp:3650
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,...
Definition fespace.cpp:4115
static void AdjustVDofs(Array< int > &vdofs)
Remove the orientation information encoded into an array of dofs Some basis function types have a rel...
Definition fespace.cpp:284
virtual void GetExteriorVDofs(Array< int > &exterior_vdofs, int component=-1) const
Mark degrees of freedom associated with exterior faces of the mesh. For spaces with 'vdim' > 1,...
Definition fespace.cpp:683
SparseMatrix * VariableOrderRefinementMatrix(const int coarse_ndofs, const Table &coarse_elem_dof) const
Definition fespace.cpp:1727
const Table & GetFaceToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each face in the m...
Definition fespace.hpp:1291
int GetEdgeOrder(int edge, int variant=0) const
Definition fespace.cpp:3379
Array< char > loc_var_face_orders
Definition fespace.hpp:264
bool Nonconforming() const
Definition fespace.hpp:650
void GetVertexVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified vertices.
Definition fespace.cpp:338
MFEM_DEPRECATED void BuildDofToArrays() const
Deprecated. This function is not required to be called by the user.
Definition fespace.hpp:1295
void GetVertexDofs(int i, Array< int > &dofs) const
Returns the indices of the degrees of freedom for the specified vertices.
Definition fespace.cpp:3786
OperatorHandle L2E_lex
Definition fespace.hpp:322
void BuildFaceToDofTable() const
Definition fespace.cpp:436
int GetFaceOrder(int face, int variant=0) const
Returns the polynomial degree of the i'th face finite element.
Definition fespace.cpp:3395
int GetNEDofs() const
Number of all scalar edge-interior dofs.
Definition fespace.hpp:859
int GetNumBorderDofs(Geometry::Type geom, int order) const
Definition fespace.cpp:1050
FiniteElementSpace()
Default constructor: the object is invalid until initialized using the method Load().
Definition fespace.cpp:33
Array< int > dof_elem_array
Definition fespace.hpp:281
int FindFaceDof(int face, int ndof) const
Similar to FindEdgeDof, but used for mixed meshes too.
Definition fespace.hpp:443
static int MinOrder(VarOrderBits bits)
Return the minimum order (least significant bit set) in the bit mask.
Definition fespace.cpp:3019
int GetAttribute(int i) const
Definition fespace.hpp:915
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...
Definition fespace.cpp:775
MFEM_DEPRECATED void RebuildElementToDofTable()
(
Definition fespace.cpp:462
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
Definition fespace.hpp:821
bool orders_changed
True if at least one element order changed (variable-order space only).
Definition fespace.hpp:344
SparseMatrix * DerefinementMatrix(int old_ndofs, const Table *old_elem_dof, const Table *old_elem_fos)
Calculate GridFunction restriction matrix after mesh derefinement.
Definition fespace.cpp:2407
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Returns the transformation defining the i-th element in the user-defined variable ElTr.
Definition fespace.hpp:908
void GetLocalRefinementMatrices(Geometry::Type geom, DenseTensor &localP) const
Definition fespace.cpp:1788
void GetEdgeInteriorVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the interior of the specified edge.
Definition fespace.cpp:350
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,...
Definition fespace.cpp:4080
SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Generate the global restriction matrix from a discontinuous FE space to the continuous FE space of th...
Definition fespace.cpp:805
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
Definition fespace.cpp:624
int GetNBE() const
Returns number of boundary elements in the mesh.
Definition fespace.hpp:876
virtual void UpdateMeshPointer(Mesh *new_mesh)
Definition fespace.cpp:4363
const NURBSExtension * GetNURBSext() const
Definition fespace.hpp:641
int GetDegenerateFaceDofs(int index, Array< int > &dofs, Geometry::Type master_geom, int variant) const
Definition fespace.cpp:1008
virtual const Operator * GetProlongationMatrix() const
Definition fespace.hpp:691
const QuadratureInterpolator * GetQuadratureInterpolator(const IntegrationRule &ir) const
Return a QuadratureInterpolator that interpolates E-vectors to quadrature point values and/or derivat...
Definition fespace.cpp:1588
Array< char > ghost_edge_orders
Definition fespace.hpp:265
int GetBdrAttribute(int i) const
Definition fespace.hpp:917
Array< int > dof_bdr_elem_array
Definition fespace.hpp:283
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.).
Definition fespace.cpp:1059
const InterpolationManager & GetInterpolationManager(ElementDofOrdering f_ordering, FaceType type) const
Definition fespace.cpp:1547
virtual const Operator * GetRestrictionOperator() const
An abstract operator that performs the same action as GetRestrictionMatrix.
Definition fespace.hpp:710
int GetLocalDofForDof(int i) const
Return the dof index within the element from GetElementForDof() for ldof index i.
Definition fespace.hpp:1301
static constexpr int MaxVarOrder
Definition fespace.hpp:259
int GetElementForDof(int i) const
Return the index of the first element that contains ldof index i.
Definition fespace.hpp:1298
virtual void CopyProlongationAndRestriction(const FiniteElementSpace &fes, const Array< int > *perm)
Copies the prolongation and restriction matrices from fes.
Definition fespace.cpp:82
Array< char > var_edge_orders
Definition fespace.hpp:263
const FiniteElement * GetTypicalBE() const
Return a "typical" boundary element.
Definition fespace.cpp:3939
std::unique_ptr< Operator > R_transpose
Operator computing the action of the transpose of the restriction.
Definition fespace.hpp:307
bool Conforming() const
Definition fespace.hpp:645
int MakeDofTable(int ent_dim, const Array< VarOrderBits > &entity_orders, Table &entity_dofs, Array< char > *var_ent_order)
Definition fespace.cpp:3289
void UpdateElementOrders()
Resize the elem_order array on mesh change.
Definition fespace.cpp:4156
void MakeVDimMatrix(SparseMatrix &mat) const
Replicate 'mat' in the vector dimension, according to vdim ordering mode.
Definition fespace.cpp:1394
int GetNF() const
Returns number of faces (i.e. co-dimension 1 entities) in the mesh.
Definition fespace.hpp:873
SparseMatrix * H2L_GlobalRestrictionMatrix(FiniteElementSpace *lfes)
Construct the restriction matrix from the FE space given by (*this) to the lower degree FE space give...
Definition fespace.cpp:868
SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Generate the global restriction matrix from a discontinuous FE space to the piecewise constant FE spa...
Definition fespace.cpp:837
const FiniteElementCollection * fec
Associated FE collection (not owned).
Definition fespace.hpp:222
void GetNodePositions(const Vector &mesh_nodes, Vector &fes_node_pos, int fes_nodes_ordering=Ordering::byNODES) const
Compute the space's node positions w.r.t. given mesh positions. The function uses FiniteElement::GetN...
Definition fespace.cpp:4368
FiniteElementCollection * Load(Mesh *m, std::istream &input)
Read a FiniteElementSpace from a stream. The returned FiniteElementCollection is owned by the caller.
Definition fespace.cpp:4734
int VDofToDof(int vdof) const
Compute the inverse of the Dof to VDof mapping for a single index vdof.
Definition fespace.hpp:1131
void BuildBdrElementToDofTable() const
Definition fespace.cpp:397
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
Definition fespace.cpp:299
Array< QuadratureInterpolator * > E2Q_array
Definition fespace.hpp:331
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Definition fespace.cpp:3860
Ordering::Type GetOrdering() const
Return the ordering method.
Definition fespace.hpp:852
NURBSExtension * StealNURBSext()
Definition fespace.cpp:2634
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i-th boundary element.
Definition fespace.hpp:912
bool LastUpdatePRef() const
Return a flag indicating whether the last update was for p-refinement.
Definition fespace.hpp:1584
void GetPatchDofs(int patch, Array< int > &dofs) const
Returns indices of degrees of freedom for NURBS patch index patch. Cartesian ordering is used,...
Definition fespace.cpp:3853
void BuildDofToArrays_() const
Initialize internal data that enables the use of the methods GetElementForDof() and GetLocalDofForDof...
Definition fespace.cpp:492
FiniteElementSpace & operator=(const FiniteElementSpace &)=delete
Copy assignment not supported.
const Operator * GetRestrictionTransposeOperator() const
Return an operator that performs the transpose of GetRestrictionOperator.
Definition fespace.cpp:1444
Array< char > elem_order
Definition fespace.hpp:239
int FirstFaceDof(int face, int variant=0) const
Definition fespace.hpp:446
static bool DofFinalizable(int dof, const Array< bool > &finalized, const SparseMatrix &deps)
Definition fespace.cpp:994
Array< int > face_to_be
Definition fespace.hpp:292
void GetLocalDerefinementMatrices(Geometry::Type geom, DenseTensor &localR) const
Definition fespace.cpp:2383
void BuildConformingInterpolation() const
Calculate the cP and cR matrices for a nonconforming mesh.
Definition fespace.cpp:1144
int GetNE() const
Returns number of elements in the mesh.
Definition fespace.hpp:867
int vdim
Vector dimension (number of unknowns per degree of freedom).
Definition fespace.hpp:225
Table var_face_dofs
NOTE: also used for spaces with mixed faces.
Definition fespace.hpp:248
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
Definition fespace.hpp:805
OperatorHandle L2E_nat
The element restriction operators, see GetElementRestriction().
Definition fespace.hpp:322
bool lastUpdatePRef
Flag to indicate whether the last update was for p-refinement.
Definition fespace.hpp:319
int GetConformingVSize() const
Definition fespace.hpp:833
virtual void UpdatesFinished()
Free the GridFunction update operator (if any), to save memory.
Definition fespace.hpp:1577
std::unordered_map< std::tuple< ElementDofOrdering, FaceType >, std::unique_ptr< InterpolationManager >, TupleHasher > interpolations
Definition fespace.hpp:329
int GetBdrLocalDofForDof(int i) const
Return the dof index within the boundary element from GetBdrElementForDof() for ldof index i.
Definition fespace.hpp:1307
int * bdofs
internal DOFs of elements if mixed/var-order; NULL otherwise
Definition fespace.hpp:243
std::unordered_map< key_face, std::unique_ptr< FaceRestriction >, TupleHasher > L2F
Definition fespace.hpp:326
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
Definition fespace.cpp:1476
const FiniteElement * GetEdgeElement(int i, int variant=0) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th edge in the ...
Definition fespace.cpp:3984
Array< bool > skip_edge
Definition fespace.hpp:272
void SetUpdateOperatorOwner(bool own)
Set the ownership of the update operator: if set to false, the Operator returned by GetUpdateOperator...
Definition fespace.hpp:1566
Array< char > ghost_face_orders
Definition fespace.hpp:265
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...
Definition fespace.cpp:3738
std::tuple< bool, ElementDofOrdering, FaceType, L2FaceValues > key_face
The face restriction operators, see GetFaceRestriction().
Definition fespace.hpp:324
std::unique_ptr< SparseMatrix > cR
Conforming restriction matrix such that cR.cP=I.
Definition fespace.hpp:302
void GetElementInteriorVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the interior of the specified element.
Definition fespace.cpp:344
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns the indices of the degrees of freedom for the specified face, including the DOFs for the edge...
Definition fespace.cpp:326
void GetEssentialBdrEdgesFaces(const Array< int > &bdr_attr_is_ess, std::set< int > &edges, std::set< int > &faces) const
Definition fespace.cpp:4482
Array< char > loc_var_edge_orders
Definition fespace.hpp:264
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
Definition fespace.cpp:4192
OperatorHandle Th
Transformation to apply to GridFunctions after space Update().
Definition fespace.hpp:314
SparseMatrix * RefinementMatrix(int old_ndofs, const Table *old_elem_dof, const Table *old_elem_fos)
Definition fespace.cpp:1811
std::uint64_t VarOrderBits
Bit-mask representing a set of orders needed by an edge/face.
Definition fespace.hpp:258
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
Definition fespace.hpp:892
void GetBoundaryElementsByAttribute(const Array< int > &bdr_attrs, std::vector< Array< int > > &attr_to_elements) const
Get boundary elements grouped by attribute.
Definition fespace.cpp:4626
SparseMatrix * RefinementMatrix_main(const int coarse_ndofs, const Table &coarse_elem_dof, const Table *coarse_elem_fos, const DenseTensor localP[]) const
Definition fespace.cpp:1663
int ndofs
Number of degrees of freedom. Number of unknowns is ndofs * vdim.
Definition fespace.hpp:233
std::unique_ptr< SparseMatrix > cP
Definition fespace.hpp:300
void SetUpdateOperatorType(Operator::Type tid)
Specify the Operator::Type to be used by the update operators.
Definition fespace.hpp:1574
void AddEdgeFaceDependencies(SparseMatrix &deps, Array< int > &master_dofs, const FiniteElement *master_fe, Array< int > &slave_dofs, int slave_face, const DenseMatrix *pm) const
Definition fespace.cpp:940
const FiniteElement * GetTraceElement(int i, Geometry::Type geom_type) const
Return the trace element from element 'i' to the given 'geom_type'.
Definition fespace.cpp:3993
void SetRelaxedHpConformity(bool relaxed=true)
Definition fespace.hpp:1613
bool UsesRaggedTensorBasis() const
Return true if the mesh contains only one topology, the elements are all triangles or tetrahedrons,...
Definition fespace.hpp:1595
void ComputeLoopEdgeOrientations(const Array< int > &dof_edges, const Array< int > &dof_boundary_elements, const Vector &loop_normal, Array< int > &dof_orientations) const
Compute edge orientations relative to a boundary loop direction.
Definition fespace.cpp:4667
const FiniteElement * GetTypicalTraceElement() const
Return a "typical" trace element.
Definition fespace.cpp:3999
void GetBoundaryLoopEdgeDofs(const Array< int > &boundary_element_indices, Array< int > &boundary_edge_dofs, Array< int > *dof_edges=nullptr, Array< int > *dof_boundary_elements=nullptr) const
Extract the edge degrees of freedom of a boundary "loop".
Definition fespace.cpp:4530
static void MarkerToList(const Array< int > &marker, Array< int > &list)
Convert a Boolean marker array to a list containing all marked indices.
Definition fespace.cpp:756
Array< NURBSExtension * > VNURBSext
Definition fespace.hpp:290
int GetNFDofs() const
Number of all scalar face-interior dofs.
Definition fespace.hpp:861
int GetElementOrder(int i) const
Returns the order of the i'th finite element.
Definition fespace.cpp:195
void SetVarOrderLocalDofs()
Sets all2local. See documentation of all2local for details.
Definition fespace.cpp:2968
Mesh * mesh
The mesh that FE space lives on (not owned).
Definition fespace.hpp:219
const FiniteElement * GetFaceElement(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th face in the ...
Definition fespace.cpp:3949
Ordering::Type ordering
Definition fespace.hpp:230
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...
Definition fespace.cpp:788
void CalcEdgeFaceVarOrders(Array< VarOrderBits > &edge_orders, Array< VarOrderBits > &face_orders, Array< VarOrderBits > &edge_elem_orders, Array< VarOrderBits > &face_elem_orders, Array< bool > &skip_edges, Array< bool > &skip_faces) const
Definition fespace.cpp:3043
virtual bool OrderPropagation(const std::set< int > &edges, const std::set< int > &faces, Array< VarOrderBits > &edge_orders, Array< VarOrderBits > &face_orders) const
Returns true if order propagation is done, for variable-order spaces.
Definition fespace.hpp:417
std::shared_ptr< const PRefinementTransferOperator > GetPrefUpdateOperator()
Definition fespace.cpp:4479
void SetElementOrder(int i, int p)
Sets the order of the i'th finite element.
Definition fespace.cpp:170
const SparseMatrix * GetHpConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.cpp:1437
int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type.
Definition fespace.hpp:884
const SparseMatrix * GetConformingProlongation() const
Definition fespace.cpp:1422
const FiniteElementCollection * FEColl() const
Definition fespace.hpp:854
Mesh * GetMesh() const
Returns the mesh.
Definition fespace.hpp:639
int GetNV() const
Returns number of vertices in the mesh.
Definition fespace.hpp:864
int GetElementOrderImpl(int i) const
Return element order: internal version of GetElementOrder without checks.
Definition fespace.cpp:206
int GetNVariants(int entity, int index) const
Return number of possible DOF variants for edge/face (var. order spaces).
Definition fespace.cpp:3416
Array< int > dof_bdr_ldof_array
Definition fespace.hpp:284
const Table & GetBdrElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each boundary mesh...
Definition fespace.hpp:1283
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:824
const Table * GetElementToFaceOrientationTable() const
Definition fespace.hpp:1274
DofTransformation * GetBdrElementDofs(int bel, Array< int > &dofs) const
Returns indices of degrees of freedom for boundary element 'bel'. The returned indices are offsets in...
Definition fespace.cpp:3643
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...
Definition fespace.cpp:668
int GetVDim() const
Returns the vector dimension of the finite element space.
Definition fespace.hpp:817
const FaceQuadratureInterpolator * GetFaceQuadratureInterpolator(const IntegrationRule &ir, FaceType type) const
Return a FaceQuadratureInterpolator that interpolates E-vectors to quadrature point values and/or der...
Definition fespace.cpp:1627
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
Definition fespace.hpp:1587
void GetFaceInteriorDofs(int i, Array< int > &dofs) const
Returns the indices of the degrees of freedom for the interior of the specified face.
Definition fespace.cpp:3817
virtual void PRefineAndUpdate(const Array< pRefinement > &refs, bool want_transfer=true)
Definition fespace.cpp:4315
virtual const SparseMatrix * GetHpRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.hpp:718
int GetNConformingDofs() const
Definition fespace.cpp:1450
void SetProlongation(const SparseMatrix &p)
Definition fespace.cpp:133
Array< int > edge_min_nghb_order
Minimum order among neighboring elements.
Definition fespace.hpp:268
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
Definition fespace.cpp:3896
static int DecodeDof(int dof)
Helper to return the DOF associated with a sign encoded DOF.
Definition fespace.hpp:1153
static int DecodeDof(int dof, real_t &sign)
Helper to determine the DOF and sign of a sign encoded DOF.
Definition fespace.hpp:1157
virtual int GetMaxElementOrder() const
Return the maximum polynomial order over all elements.
Definition fespace.hpp:669
void GetElementInteriorDofs(int i, Array< int > &dofs) const
Returns the indices of the degrees of freedom for the interior of the specified element.
Definition fespace.cpp:3796
virtual int NumGhostEdges() const
Returns the number of ghost edges (nonzero in ParFiniteElementSpace).
Definition fespace.hpp:424
void Constructor(Mesh *mesh, NURBSExtension *ext, const FiniteElementCollection *fec, int vdim=1, int ordering=Ordering::byNODES)
Help function for constructors + Load().
Definition fespace.cpp:2533
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for i'th boundary element. The returned indices are offsets int...
Definition fespace.cpp:314
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...
Definition fespace.cpp:796
const FiniteElement * GetTypicalFaceElement() const
Return a "typical" face element.
Definition fespace.cpp:3979
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...
Definition fespace.cpp:550
virtual int NumGhostFaces() const
Returns the number of ghost faces (nonzero in ParFiniteElementSpace).
Definition fespace.hpp:427
int DofToVDof(int dof, int vd, int ndofs=-1) const
Compute a single vdof corresponding to the index dof and the vector index vd.
Definition fespace.cpp:268
virtual const FaceRestriction * GetFaceRestriction(ElementDofOrdering f_ordering, FaceType, L2FaceValues mul=L2FaceValues::DoubleValued) const
Return an Operator that converts L-vectors to E-vectors on each face.
Definition fespace.cpp:1509
int GetCurlDim() const
Return the dimension of the curl of a GridFunction defined on this space.
Definition fespace.cpp:1466
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
Definition fespace.hpp:1552
virtual void GhostFaceOrderToEdges(const Array< VarOrderBits > &face_orders, Array< VarOrderBits > &edge_orders) const
Helper function for ParFiniteElementSpace.
Definition fespace.hpp:412
int FindEdgeDof(int edge, int ndof) const
Definition fespace.hpp:439
void GetPatchVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom in vdofs for NURBS patch i.
Definition fespace.cpp:320
void BuildElementToDofTable() const
Definition fespace.cpp:356
std::unique_ptr< SparseMatrix > cR_hp
A version of the conforming restriction matrix for variable-order spaces.
Definition fespace.hpp:304
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.
Definition fespace.cpp:3362
void VariableOrderMinimumRule(SparseMatrix &deps) const
Definition fespace.cpp:1094
Abstract class for all finite elements.
Definition fe_base.hpp:294
static const int NumGeom
Definition geom.hpp:46
Arbitrary order H1 elements in 2D utilizing the Bernstein basis on a triangle.
Definition fe_pos.hpp:182
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:291
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:96
Transfer data between a coarse mesh and an embedded refined mesh using interpolation.
Definition transfer.hpp:139
This class manages the storage and computation of the interpolations from master (coarse) face to sla...
A standard isoparametric element transformation.
Definition eltrans.hpp:629
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:369
Abstract base class for LORDiscretization and ParLORDiscretization classes, which construct low-order...
Definition lor.hpp:23
Mesh data type.
Definition mesh.hpp:67
Element::Type GetElementType(int i) const
Returns the type of element i.
Definition mesh.cpp:8445
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition mesh.cpp:8450
bool Conforming() const
Definition mesh.cpp:16102
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
Definition mesh.cpp:7302
int GetAttribute(int i) const
Return the attribute of element i.
Definition mesh.hpp:1497
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
Definition mesh.hpp:1622
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition mesh.hpp:1503
virtual int GetNFbyType(FaceType type) const
Returns the number of faces according to the requested type, does not count master nonconforming face...
Definition mesh.cpp:7318
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1390
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
Definition mesh.cpp:361
ElementTransformation * GetBdrElementTransformation(int i)
Returns a pointer to the transformation defining the i-th boundary element.
Definition mesh.cpp:533
bool IsSimplexMesh() const
Returns true if the mesh is a simplex mesh, false otherwise.
Definition mesh.hpp:1370
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
Definition mesh.hpp:1387
void Swap(Mesh &other, bool non_geometry)
Definition mesh.cpp:11521
int GetNBE() const
Returns number of boundary elements.
Definition mesh.hpp:1393
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Definition mesh.cpp:8014
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
Definition nurbs.hpp:575
Pointer to an Operator of a specified type.
Definition handle.hpp:34
void SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
Definition handle.hpp:120
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.
Definition handle.hpp:132
Operator * Ptr() const
Access the underlying Operator pointer.
Definition handle.hpp:87
void Clear()
Clear the OperatorHandle, deleting the held Operator (if owned), while leaving the type id unchanged.
Definition handle.hpp:124
Abstract operator.
Definition operator.hpp:27
Type
Enumeration defining IDs for some classes derived from Operator.
Definition operator.hpp:319
Type
Ordering methods:
Definition ordering.hpp:17
Matrix-free transfer operator between finite element spaces on the same mesh.
Definition transfer.hpp:636
A class that performs interpolation from an E-vector to quadrature point values and/or derivatives (Q...
Class representing the storage layout of a QuadratureFunction.
Definition qspace.hpp:164
Data type sparse matrix.
Definition sparsemat.hpp:51
Table stores the connectivity of elements of TYPE I to elements of TYPE II. For example,...
Definition table.hpp:43
void GetRow(int i, Array< int > &row) const
Return row i in array row (the Table must be finalized)
Definition table.cpp:233
Vector data type.
Definition vector.hpp:82
const int * ess_tdof_list
int index(int i, int j, int nx, int ny)
Definition life.cpp:236
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
MFEM_HOST_DEVICE int UnsignIndex(int i)
Definition globals.hpp:118
bool UsesTensorBasis(const FiniteElementSpace &fes)
Return true if the mesh contains only one topology and the elements are tensor elements.
Definition fespace.hpp:1644
QVectorLayout
Type describing possible layouts for Q-vectors.
Definition fespace.hpp:33
float real_t
Definition config.hpp:46
ElementDofOrdering GetEVectorOrdering(const FiniteElementSpace &fes)
Return LEXICOGRAPHIC if mesh contains only one topology and the elements are tensor elements,...
Definition fespace.cpp:4836
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Definition fespace.hpp:49
@ NATIVE
Native ordering as defined by the FiniteElement.
FaceType
Definition mesh.hpp:49
real_t p(const Vector &x, real_t t)
Helper class for hashing std::tuple of hashable types.
int index
Mesh element number.
Definition fespace.hpp:66
int delta
Change to element order.
Definition fespace.hpp:67
pRefinement(int element, int change)
Definition fespace.hpp:71
pRefinement()=default