18 void LORBase::AddIntegrators(BilinearForm &a_from,
20 GetIntegratorsFn get_integrators,
21 AddIntegratorFn add_integrator,
22 const IntegrationRule *ir)
24 Array<BilinearFormIntegrator*> *integrators = (a_from.*get_integrators)();
25 for (
int i=0; i<integrators->Size(); ++i)
27 (a_to.*add_integrator)((*integrators)[i]);
28 ir_map[(*integrators)[i]] = ((*integrators)[i])->GetIntegrationRule();
29 if (ir) { ((*integrators)[i])->SetIntegrationRule(*ir); }
33 void LORBase::AddIntegratorsAndMarkers(BilinearForm &a_from,
35 GetIntegratorsFn get_integrators,
36 GetMarkersFn get_markers,
37 AddIntegratorMarkersFn add_integrator_marker,
38 AddIntegratorFn add_integrator,
39 const IntegrationRule *ir)
41 Array<BilinearFormIntegrator*> *integrators = (a_from.*get_integrators)();
42 Array<Array<int>*> *markers = (a_from.*get_markers)();
44 for (
int i=0; i<integrators->Size(); ++i)
48 (a_to.*add_integrator_marker)((*integrators)[i], *(*markers[i]));
52 (a_to.*add_integrator)((*integrators)[i]);
54 ir_map[(*integrators)[i]] = ((*integrators)[i])->GetIntegrationRule();
55 if (ir) { ((*integrators)[i])->SetIntegrationRule(*ir); }
59 void LORBase::ResetIntegrationRules(GetIntegratorsFn get_integrators)
61 Array<BilinearFormIntegrator*> *integrators = (
a->*get_integrators)();
62 for (
int i=0; i<integrators->Size(); ++i)
64 ((*integrators)[i])->SetIntegrationRule(*ir_map[(*integrators)[i]]);
71 if (dynamic_cast<const H1_FECollection*>(fec_ho)) {
return H1; }
72 else if (dynamic_cast<const ND_FECollection*>(fec_ho)) {
return ND; }
73 else if (dynamic_cast<const RT_FECollection*>(fec_ho)) {
return RT; }
74 else if (dynamic_cast<const L2_FECollection*>(fec_ho)) {
return L2; }
75 else { MFEM_ABORT(
"Bad LOR space type."); }
82 return (type ==
L2 || type ==
RT) ? 0 : 1;
88 MFEM_VERIFY(type !=
H1 && type !=
L2,
"");
94 MFEM_ASSERT(tfe != NULL,
"");
95 return tfe->GetDofMap();
103 using GeomRef = std::pair<Geometry::Type, int>;
104 std::map<GeomRef, int> point_matrices_offsets;
108 for (
int ilor=0; ilor<mesh_lor.
GetNE(); ++ilor)
112 int lor_index = cf_tr.
embeddings[ilor].matrix;
121 if (point_matrices_offsets.find(
id) == point_matrices_offsets.end())
123 point_matrices_offsets[id] = lor_index;
125 lor_index -= point_matrices_offsets[id];
132 perm_[vdof_lor[0]] = vdof_ho[lor_index];
137 int ndof_per_dim = (dim == 2) ? p*p1 : type ==
ND ? p*p1*p1 : p*p*p1;
140 const Array<int> &dofmap_lor = get_dof_map(fes_lor, ilor);
142 int off_x = lor_index %
p;
143 int off_y = (lor_index /
p) % p;
144 int off_z = (lor_index /
p) / p;
146 auto set_perm = [&](
int off_lor,
int off_ho,
int n1,
int n2)
148 for (
int i1=0; i1<2; ++i1)
150 int m = (dim == 2 || type ==
RT) ? 1 : 2;
151 for (
int i2=0; i2<m; ++i2)
154 i = dofmap_lor[off_lor + i1 + i2*2];
155 int s1 = i < 0 ? -1 : 1;
156 int idof_lor = vdof_lor[absdof(i)];
157 i = dofmap_ho[off_ho + i1*n1 + i2*n2];
158 int s2 = i < 0 ? -1 : 1;
159 int idof_ho = vdof_ho[absdof(i)];
160 int s3 = idof_lor < 0 ? -1 : 1;
161 int s4 = idof_ho < 0 ? -1 : 1;
164 perm_[absdof(idof_lor)] = s < 0 ? -1-absdof(i) : absdof(i);
174 offset = off_x + off_y*p + off_z*p*p1;
175 set_perm(0, offset, p, p*p1);
177 offset = ndof_per_dim + off_x + off_y*(p1) + off_z*p1*p;
178 set_perm(dim == 2 ? 2 : 4, offset, 1, p*p1);
182 offset = 2*ndof_per_dim + off_x + off_y*p1 + off_z*p1*p1;
183 set_perm(8, offset, 1, p+1);
189 offset = off_x + off_y*p1 + off_z*p*p1;
190 set_perm(0, offset, 1, 0);
192 offset = ndof_per_dim + off_x + off_y*p + off_z*p1*
p;
193 set_perm(2, offset, p, 0);
197 offset = 2*ndof_per_dim + off_x + off_y*p + off_z*p*
p;
198 set_perm(4, offset, p*p, 0);
207 if (type ==
H1 || type ==
L2)
219 if (pfes_ho && pfes_lor)
224 for (
int i=0; i<l_perm.
Size(); ++i)
227 int s = j < 0 ? -1 : 1;
231 if ((t_i < 0 && t_j >=0) || (t_j < 0 && t_i >= 0))
233 MFEM_ABORT(
"Inconsistent DOF numbering");
235 if (t_i < 0) {
continue; }
236 perm[t_i] = s < 0 ? -1 - t_j : t_j;
255 return type ==
H1 || type ==
L2;
260 MFEM_VERIFY(
a != NULL &&
A.
Ptr() != NULL,
"No LOR system assembled");
301 template <
typename FEC>
304 const FEC *fec =
dynamic_cast<const FEC*
>(fes.
FEColl());
307 int btype = fec->GetBasisType();
310 mfem::err <<
"\nWARNING: Constructing low-order refined "
311 <<
"discretization with basis type\n"
313 <<
"The LOR discretization is only spectrally equivalent\n"
314 <<
"with Gauss-Lobatto basis.\n" << std::endl;
319 template <
typename FEC>
322 const FEC *fec =
dynamic_cast<const FEC*
>(fes.
FEColl());
325 int cbtype = fec->GetClosedBasisType();
326 int obtype = fec->GetOpenBasisType();
329 mfem::err <<
"\nWARNING: Constructing vector low-order refined "
330 <<
"discretization with basis type \npair ("
333 <<
"The LOR discretization is only spectrally\nequivalent "
334 <<
"with basis types (Gauss-Lobatto, IntegratedGLL).\n"
342 CheckScalarBasisType<H1_FECollection>(fes);
343 CheckVectorBasisType<ND_FECollection>(fes);
344 CheckVectorBasisType<RT_FECollection>(fes);
357 ir_el = &irs.
Get(geoms[0], 1);
385 int ref_type) :
LORBase(fes_ho)
394 for (
int i=0; i<refinements.Size(); ++i)
396 refinements[i] = fes_ho.
GetOrder(i) + increment;
417 MFEM_VERIFY(
a != NULL &&
A.
Ptr() != NULL,
"No LOR system assembled");
432 int ref_type) :
LORBase(fes_ho)
437 "Cannot construct LOR operators on variable-order spaces");
464 MFEM_VERIFY(
a != NULL &&
A.
Ptr() != NULL,
"No LOR system assembled");
Abstract class for all finite elements.
Integrated GLL indicator functions.
int Size() const
Return the logical size of the array.
Abstract base class for LORDiscretization and ParLORDiscretization classes, which construct low-order...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
LORDiscretization(BilinearForm &a_ho, const Array< int > &ess_tdof_list, int ref_type=BasisType::GaussLobatto)
Construct the low-order refined version of a_ho using the given list of essential DOFs...
const OperatorHandle & GetAssembledSystem() const
Returns the assembled LOR system.
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get()...
Create and assemble a low-order refined version of a ParBilinearForm.
static Type TensorProductGeometry(int dim)
FESpaceType GetFESpaceType() const
Returns the type of finite element space: H1, ND, RT or L2.
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
ParMesh * GetParMesh() const
static ParMesh MakeRefined(ParMesh &orig_mesh, int ref_factor, int ref_type)
Create a uniformly refined (by any factor) version of orig_mesh.
int GetLOROrder() const
Returns the order of the LOR space. 1 for H1 or ND, 0 for L2 or RT.
Pointer to an Operator of a specified type.
FiniteElementSpace & fes_ho
static Mesh MakeRefined(Mesh &orig_mesh, int ref_factor, int ref_type)
Create a refined (by any factor) version of orig_mesh.
void GetGeometries(int dim, Array< Geometry::Type > &el_geoms) const
Return all element geometries of the given dimension present in the mesh.
const Array< int > & GetDofPermutation() const
Returns the permutation that maps LOR DOFs to high-order DOFs.
int GetNE() const
Returns number of elements.
Abstract parallel finite element space.
A class container for 1D quadrature type constants.
int GetLocalTDofNumber(int ldof) const
static const char * Name(int b_type)
Check and convert a BasisType constant to a string identifier.
virtual void CopyProlongationAndRestriction(const FiniteElementSpace &fes, const Array< int > *perm)
Copies the prolongation and restriction matrices from fes.
HypreParMatrix & GetAssembledMatrix() const
Return the assembled LOR operator as a HypreParMatrix.
Geometry::Type GetElementBaseGeometry(int i) const
void CheckScalarBasisType(const FiniteElementSpace &fes)
Create and assemble a low-order refined version of a BilinearForm.
virtual int GetTrueVSize() const
Return the number of local vector true dofs.
bool HasSameDofNumbering() const
void AssembleSystem(BilinearForm &a_ho, const Array< int > &ess_dofs)
Assembles the LOR system corresponding to a_ho.
ID for class SparseMatrix.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
Mesh * GetMesh() const
Returns the mesh.
FiniteElementSpace & GetFESpace() const
Returns the low-order refined finite element space.
void SetupProlongationAndRestriction()
void CheckBasisType(const FiniteElementSpace &fes)
int GetMaxElementOrder() const
Return the maximum polynomial order.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Operator * Ptr() const
Access the underlying Operator pointer.
double p(const Vector &x, double t)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
void AssembleSystem(ParBilinearForm &a_ho, const Array< int > &ess_dofs)
Assembles the LOR system corresponding to a_ho.
void ConstructDofPermutation() const
const CoarseFineTransformations & GetRefinementTransforms()
virtual FiniteElementCollection * Clone(int p) const
Instantiate a new collection of the same type with a different order.
static bool IsTensorProduct(Type geom)
ParFiniteElementSpace & GetParFESpace() const
Return the LOR ParFiniteElementSpace.
FiniteElementCollection * fec
ParLORDiscretization(ParBilinearForm &a_ho, const Array< int > &ess_tdof_list, int ref_type=BasisType::GaussLobatto)
Construct the low-order refined version of a_ho using the given list of essential DOFs...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
void ConstructLocalDofPermutation(Array< int > &perm_) const
LORBase(FiniteElementSpace &fes_ho_)
void CheckVectorBasisType(const FiniteElementSpace &fes)
SparseMatrix & GetAssembledMatrix() const
Return the assembled LOR operator as a SparseMatrix.
const FiniteElementCollection * FEColl() const
ID for class HypreParMatrix.
void AssembleSystem_(BilinearForm &a_ho, const Array< int > &ess_dofs)
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
void SetType(Operator::Type tid)
Invoke Clear() and set a new type id.