21 #include "smith/numerics/functional/element_restriction.hpp"
22 #include "smith/numerics/functional/typedefs.hpp"
26 struct BlockElementRestriction;
39 InteriorBoundaryElements
85 std::vector<int> edge_ids_;
86 std::vector<int> tri_ids_;
87 std::vector<int> quad_ids_;
88 std::vector<int> tet_ids_;
89 std::vector<int> hex_ids_;
91 std::vector<int> mfem_edge_ids_;
92 std::vector<int> mfem_tri_ids_;
93 std::vector<int> mfem_quad_ids_;
94 std::vector<int> mfem_tet_ids_;
95 std::vector<int> mfem_hex_ids_;
131 static Domain ofEdges(
const mesh_t& mesh, std::function<
bool(std::vector<vec2>,
int)> func);
134 static Domain ofEdges(
const mesh_t& mesh, std::function<
bool(std::vector<vec3>)> func);
143 static Domain ofFaces(
const mesh_t& mesh, std::function<
bool(std::vector<vec2>,
int)> func);
146 static Domain ofFaces(
const mesh_t& mesh, std::function<
bool(std::vector<vec3>,
int)> func);
155 static Domain ofElements(
const mesh_t& mesh, std::function<
bool(std::vector<vec2>,
int)> func);
158 static Domain ofElements(
const mesh_t& mesh, std::function<
bool(std::vector<vec3>,
int)> func);
183 const std::vector<int>&
get(mfem::Geometry::Type geom)
const
185 if (geom == mfem::Geometry::SEGMENT)
return edge_ids_;
186 if (geom == mfem::Geometry::TRIANGLE)
return tri_ids_;
187 if (geom == mfem::Geometry::SQUARE)
return quad_ids_;
188 if (geom == mfem::Geometry::TETRAHEDRON)
return tet_ids_;
189 if (geom == mfem::Geometry::CUBE)
return hex_ids_;
197 if (geom == mfem::Geometry::SEGMENT)
return mfem_edge_ids_;
198 if (geom == mfem::Geometry::TRIANGLE)
return mfem_tri_ids_;
199 if (geom == mfem::Geometry::SQUARE)
return mfem_quad_ids_;
200 if (geom == mfem::Geometry::TETRAHEDRON)
return mfem_tet_ids_;
201 if (geom == mfem::Geometry::CUBE)
return mfem_hex_ids_;
211 return int(edge_ids_.size() + tri_ids_.size() + quad_ids_.size() + tet_ids_.size() + hex_ids_.size());
220 mfem::Array<int> offsets(mfem::Geometry::NUM_GEOMETRIES + 1);
223 offsets[mfem::Geometry::POINT] = total;
225 offsets[mfem::Geometry::SEGMENT] = total;
226 total += int(edge_ids_.size());
227 offsets[mfem::Geometry::TRIANGLE] = total;
228 total += int(tri_ids_.size());
229 offsets[mfem::Geometry::SQUARE] = total;
230 total += int(quad_ids_.size());
231 offsets[mfem::Geometry::TETRAHEDRON] = total;
232 total += int(tet_ids_.size());
233 offsets[mfem::Geometry::CUBE] = total;
234 total += int(hex_ids_.size());
235 offsets[mfem::Geometry::PRISM] = total;
236 offsets[mfem::Geometry::PYRAMID] = total;
237 offsets[mfem::Geometry::NUM_GEOMETRIES] = total;
243 mfem::Array<int>
dof_list(
const fes_t* fes)
const;
259 void addElement(
int geom_id,
int elem_id, mfem::Geometry::Type element_geometry);
266 void addElements(
const std::vector<int>& geom_id,
const std::vector<int>& elem_id,
267 mfem::Geometry::Type element_geometry);
286 Domain
operator|(
const Domain& a,
const Domain& b);
289 Domain
operator&(
const Domain& a,
const Domain& b);
292 Domain
operator-(
const Domain& a,
const Domain& b);
298 return [value](std::vector<tensor<double, dim>>,
int attr) {
return value == attr; };
305 return [values](std::vector<tensor<double, dim>>,
int attr) {
return values.find(attr) != values.end(); };
314 std::array<uint32_t, mfem::Geometry::NUM_GEOMETRIES> counts{};
316 constexpr std::array<mfem::Geometry::Type, 5> geometries = {mfem::Geometry::SEGMENT, mfem::Geometry::TRIANGLE,
317 mfem::Geometry::SQUARE, mfem::Geometry::TETRAHEDRON,
318 mfem::Geometry::CUBE};
319 for (
auto geom : geometries) {
320 counts[uint32_t(geom)] = uint32_t(domain.
get(geom).size());
332 for (
auto x : positions) {
335 return total / double(positions.size());
This file contains helper traits and enumerations for classifying finite elements.
Accelerator functionality.
Domain EntireInteriorBoundary(const mesh_t &mesh)
constructs a domain from all the interior boundary elements in a mesh
tensor< double, dim > average(std::vector< tensor< double, dim >> &positions)
convenience function for computing the arithmetic mean of some list of vectors
std::array< uint32_t, mfem::Geometry::NUM_GEOMETRIES > geometry_counts(const Domain &domain)
count the number of elements of each geometry in a domain
Domain operator&(const Domain &a, const Domain &b)
create a new domain that is the intersection of a and b
Domain operator|(const Domain &a, const Domain &b)
create a new domain that is the union of a and b
constexpr SMITH_HOST_DEVICE auto type(const tuple< T... > &values)
a function intended to be used for extracting the ith type from a tuple.
Domain EntireBoundary(const mesh_t &mesh)
constructs a domain from all the boundary elements in a mesh
auto by_attr(int value)
convenience predicate for creating domains by attribute
Domain EntireDomain(const mesh_t &mesh)
constructs a domain from all the elements in a mesh
mfem::ParFiniteElementSpace & space(FieldState field)
Get the space from the primal field of a field states.
FieldStateWeightedSum operator-(const FieldState &x, const FieldState &y)
subtract two FieldState
a generalization of mfem::ElementRestriction that works with multiple kinds of element geometries....
a class for representing a geometric region that can be used for integration
int dim_
the geometric dimension of the domain
std::vector< int > shared_interior_face_ids_
Ids of interior faces that lie on the boundary shared by two processors.
const BlockElementRestriction & get_restriction(FunctionSpace space)
getter for accessing a restriction operator by its function space
void insert_restriction(const fes_t *fes, FunctionSpace space)
create a restriction operator over this domain, using its FunctionSpace as a key
static Domain ofElements(const mesh_t &mesh, std::function< bool(std::vector< vec2 >, int)> func)
create a domain from some subset of the elements (spatial dim == geometry dim) in an mfem::Mesh
void addElement(int geom_id, int elem_id, mfem::Geometry::Type element_geometry)
Add an element to the domain.
mfem::Array< int > dof_list(const fes_t *fes) const
get mfem degree of freedom list for a given FiniteElementSpace
const std::vector< int > & get(mfem::Geometry::Type geom) const
get elements by geometry type
std::map< FunctionSpace, BlockElementRestriction > restriction_operators
a collection of restriction operators for the different test/trial spaces appearing in integrals eval...
int total_elements() const
returns how many elements of any type belong to this domain
Type
enum describing what kind of elements are included in a Domain
static Domain ofBoundaryElements(const mesh_t &mesh, std::function< bool(std::vector< vec2 >, int)> func)
create a domain from some subset of the boundary elements (spatial dim == geometry dim + 1) in an mfe...
Type type_
whether the elements in this domain are on the boundary or not
void addElements(const std::vector< int > &geom_id, const std::vector< int > &elem_id, mfem::Geometry::Type element_geometry)
Add a batch of elements to the domain.
static Domain ofFaces(const mesh_t &mesh, std::function< bool(std::vector< vec2 >, int)> func)
create a domain from some subset of the faces in an mfem::Mesh
static Domain ofVertices(const mesh_t &mesh, std::function< bool(vec3)> func)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static Domain ofInteriorBoundaryElements(const mesh_t &mesh, std::function< bool(std::vector< vec2 >, int)> func)
create a domain from some subset of the interior boundary elements in an a mesh
void insert_shared_interior_face_list()
Find the list of interior faces shared by two processors to make sure these faces are only integrated...
Domain(const mesh_t &m, int d, Type type)
empty Domain constructor, with connectivity info to be populated later
static Domain ofEdges(const mesh_t &mesh, std::function< bool(std::vector< vec2 >, int)> func)
create a domain from some subset of the edges in an mfem::Mesh
const std::vector< int > & get_mfem_ids(mfem::Geometry::Type geom) const
get elements by geometry type
static constexpr int num_types
the number of entries in the Type enum
mfem::Array< int > bOffsets() const
returns an array of the prefix sum of element counts belonging to this domain. Primarily intended to ...
static Domain ofVertices(const mesh_t &mesh, std::function< bool(vec2)> func)
create a domain from some subset of the vertices in an mfem::Mesh
const mesh_t & mesh_
the underyling mesh for this domain
a small POD class for tracking function space metadata
Arbitrary-rank tensor class.
Implementation of the tensor class used by Functional.