16 namespace SubMeshUtils
36 for (
int a = 0;
a < attributes.
Size();
a++)
52 Array<int> parent_vertex_ids, parent_element_ids;
54 const int ne = from_boundary ? parent.
GetNBE() : parent.
GetNE();
55 for (
int i = 0; i < ne; i++)
57 const Element *pel = from_boundary ?
65 for (
int iv = 0; iv < v.
Size(); iv++)
68 int mesh_vertex_id = v[iv];
69 int submesh_vertex_id = vertex_ids.
Get(mesh_vertex_id, new_vertex);
73 parent_vertex_ids.
Append(mesh_vertex_id);
75 submesh_v[iv] = submesh_vertex_id;
83 parent_element_ids.
Append(i);
85 return std::tuple<Array<int>,
Array<int>>(parent_vertex_ids,
98 const int vdim = parentfes.
GetVDim();
103 for (
int i = 0; i < m->GetNE(); i++)
106 if (from == SubMesh::From::Domain)
110 else if (from == SubMesh::From::Boundary)
114 MFEM_ASSERT(static_cast<const L2_FECollection*>
116 "Only BasisType::GaussLobatto is supported for L2 spaces");
120 int face_info, parent_volel_id;
124 pm->GetLocalFaceTransformation(
125 pm->GetBdrElementType(parent_element_ids[i]),
126 pm->GetElementType(parent_volel_id),
131 pm->GetBdrElementBaseGeometry(parent_element_ids[i]);
134 MFEM_VERIFY(dynamic_cast<const NodalFiniteElement*>(face_el),
135 "Nodal Finite Element is required");
143 parent_vdofs.
SetSize(vdim * T.Height());
144 for (
int j = 0; j < T.Height(); j++)
146 for (
int k = 0; k < T.Width(); k++)
150 for (
int vd=0; vd<vdim; vd++)
152 int sub_vdof = j + T.Height() * vd;
153 int parent_vdof = k + T.Width() * vd;
154 parent_vdofs[sub_vdof] =
155 z1[
static_cast<int>(parent_vdof)];
168 MFEM_ABORT(
"SubMesh::From type unknown");
174 MFEM_ASSERT(parent_vdofs.
Size() == sub_vdofs.
Size(),
"internal error");
175 for (
int j = 0; j < parent_vdofs.
Size(); j++)
177 double sub_sign = 1.0;
178 int sub_vdof = subfes.
DecodeDof(sub_vdofs[j], sub_sign);
180 double parent_sign = 1.0;
181 int parent_vdof = parentfes.
DecodeDof(parent_vdofs[j], parent_sign);
183 vdof_to_vdof_map[sub_vdof] =
184 (sub_sign * parent_sign > 0.0) ? parent_vdof : (-1-parent_vdof);
196 for (
int i = 0; i < sm.
GetNE(); i++)
198 int peid = parent_element_ids[i];
212 MFEM_ASSERT(sel_faces.
Size() == pel_faces.
Size(),
"internal error");
214 for (
int j = 0; j < sel_faces.
Size(); j++)
216 if (pfids[sel_faces[j]] != -1)
218 MFEM_ASSERT(pfids[sel_faces[j]] == pel_faces[j],
"internal error");
220 pfids[sel_faces[j]] = pel_faces[j];
std::unordered_map< int, int > idx
Abstract class for all finite elements.
Convenience object to create unique indices.
void BuildVdofToVdofMap(const FiniteElementSpace &subfes, const FiniteElementSpace &parentfes, const SubMesh::From &from, const Array< int > &parent_element_ids, Array< int > &vdof_to_vdof_map)
Build the vdof to vdof mapping between two FiniteElementSpace objects.
void GetElementEdges(int i, Array< int > &edges, Array< int > &cor) const
Return the indices and the orientations of all edges of element i.
virtual void GetVertices(Array< int > &v) const =0
Returns element's vertices.
int Dimension() const
Dimension of the reference space used within the elements.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
static int DecodeDof(int dof)
Helper to return the DOF associated with a sign encoded DOF.
Element::Type GetBdrElementType(int i) const
Returns the type of boundary element i.
int GetAttribute() const
Return element's attribute.
Data type dense matrix using column-major storage.
const FiniteElement * GetTraceElement(int i, Geometry::Type geom_type) const
Return the trace element from element 'i' to the given 'geom_type'.
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
const Element * GetElement(int i) const
Return pointer to the i'th element object.
int GetNBE() const
Returns number of boundary elements.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Element * NewElement(int geom)
std::function< double(const Vector &)> f(double mass_coeff)
int Get(int i, bool &new_index)
Returns the unique index from an index set.
void GetBdrElementAdjacentElement2(int bdr_el, int &el, int &info) const
For the given boundary element, bdr_el, return its adjacent element and its info, i...
int AddVertex(double x, double y=0.0, double z=0.0)
void GetElementFaces(int i, Array< int > &faces, Array< int > &ori) const
Return the indices and the orientations of all faces of element i.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
const FiniteElementCollection * FEColl() const
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
int AddElement(Element *elem)
virtual void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
int GetVDim() const
Returns vector dimension.
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 ...
Mesh * GetMesh() const
Returns the mesh.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
std::tuple< Array< int >, Array< int > > AddElementsToMesh(const Mesh &parent, Mesh &mesh, const Array< int > &attributes, bool from_boundary)
Given a Mesh parent and another Mesh mesh using the list of attributes in attributes, this function adds matching elements with those attributes from parent to mesh.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Array< int > BuildFaceMap(const Mesh &pm, const Mesh &sm, const Array< int > &parent_element_ids)
Given two meshes that have a parent to SubMesh relationship create a face map, using a SubMesh to par...
From
Indicator from which part of the parent Mesh the SubMesh is created.
int GetNE() const
Returns number of elements.
Element::Type GetElementType(int i) const
Returns the type of element i.
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...
bool ElementHasAttribute(const Element &el, const Array< int > &attributes)
Given an element el and a list of attributes, determine if that element is in at least one attribute ...
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
void SetAttribute(const int attr)
Set element's attribute.
int Size() const
Return the logical size of the array.
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Abstract data type element.