9#include <kernel/geometry/factory.hpp>
10#include <kernel/geometry/mesh_permutation.hpp>
11#include <kernel/geometry/intern/facet_neighbors.hpp>
12#include <kernel/geometry/intern/standard_index_refiner.hpp>
13#include <kernel/geometry/intern/standard_vertex_refiner.hpp>
14#include <kernel/geometry/index_calculator.hpp>
15#include <kernel/geometry/facet_flipper.hpp>
16#include <kernel/util/math.hpp>
40 int num_coords_ = Shape_::dimension,
41 typename Coord_ =
Real>
44 static_assert(num_coords_ >= Shape_::dimension,
"invalid number of coordinates");
63 static constexpr int shape_dim = ShapeType::dimension;
87 static_assert(cell_dim_ <=
shape_dim,
"invalid cell dimension");
88 static_assert(face_dim_ < cell_dim_,
"invalid face/cell dimension");
89 static_assert(face_dim_ >= 0,
"invalid face dimension");
156 Intern::NumEntitiesWrapper<shape_dim>::apply(factory,
_num_entities);
166 Intern::NumEntitiesWrapper<shape_dim>::apply(factory,
_num_entities);
226 this->_num_entities[i] =
other._num_entities[i];
227 this->_vertex_set =
other._vertex_set.clone();
228 this->_index_set_holder.clone(
other._index_set_holder);
229 this->_neighbors =
other._neighbors.clone();
291 return !this->_permutation.
empty();
322 XASSERTM(this->_permutation.
empty(),
"mesh is already permuted!");
325 this->_permutation.
create(strategy, this->_index_set_holder, this->_vertex_set);
331 this->_index_set_holder.permute(this->_permutation.
get_perms(), this->_permutation.get_inv_perms());
356 XASSERTM(this->_permutation.
empty(),
"mesh is already permuted!");
359 XASSERTM(mesh_perm.validate_sizes(this->_num_entities) == 0,
"mesh permutation has invalid size!");
362 this->_permutation = std::forward<MeshPermutationType>(mesh_perm);
368 this->_index_set_holder.permute(this->_permutation.
get_perms(), this->_permutation.get_inv_perms());
390 const auto& verts_at_elem = this->
template get_index_set<shape_dim, 0>();
396 for(std::size_t icol(0); icol+1u < coloring.size(); ++icol)
399 const Index iel_beg = coloring[icol];
400 const Index iel_end = coloring[icol+1u];
403 for(
Index iel(iel_beg); iel < iel_end; ++iel)
406 for(
int ivt(0); ivt < verts_at_elem.num_indices; ++ivt)
409 const Index ivtx = verts_at_elem(iel, ivt);
413 if((iel_beg <= *it) && (*it < iel_end) && (*it != iel))
440 const auto& verts_at_elem = this->
template get_index_set<shape_dim, 0>();
446 for(std::size_t ilay(0); ilay+1u < layering.size(); ++ilay)
449 const Index iel_beg = layering[ilay];
450 const Index iel_end = layering[ilay+1u];
453 const Index iel_lower = layering[
Math::max(ilay, std::size_t(1)) - 1u];
456 const Index iel_upper = layering[
Math::min(ilay+2u, layering.size()-1u)];
459 for(
Index iel(iel_beg); iel < iel_end; ++iel)
462 for(
int ivt(0); ivt < verts_at_elem.num_indices; ++ivt)
465 const Index ivtx = verts_at_elem(iel, ivt);
469 if(!((iel_lower <= *it) && (*it < iel_upper)))
491 Intern::FacetNeighbors::compute(
_neighbors, facet_idx);
535 return _index_set_holder.template get_index_set_wrapper<cell_dim_>().template get_index_set<face_dim_>();
544 return _index_set_holder.template get_index_set_wrapper<cell_dim_>().template get_index_set<face_dim_>();
632 return "ConformalMesh<"+Shape_::name()+
","+
stringify(num_coords_)+
">";
708 return std::unique_ptr<MeshType>(
new MeshType(*
this));
724 public Factory< ConformalMesh<Shape_, num_coords_, CoordType_> >
737 static constexpr int shape_dim = ShapeType::dimension;
743 Index _num_entities_coarse[shape_dim + 1];
745 Index _num_entities_fine[shape_dim + 1];
755 _coarse_mesh(coarse_mesh)
758 for(
int i(0); i <= shape_dim; ++i)
765 Intern::EntityCountWrapper<Intern::StandardRefinementTraits, ShapeType>::query(_num_entities_fine);
784 return _num_entities_fine[dim];
796 Intern::StandardVertexRefineWrapper<ShapeType, VertexSetType>
797 ::refine(vertex_set, _coarse_mesh.
get_vertex_set(), _coarse_mesh.get_index_set_holder());
809 Intern::IndexRefineWrapper<ShapeType>
810 ::refine(index_set_holder, _num_entities_coarse, _coarse_mesh.get_index_set_holder());
815 extern template class ConformalMesh<Shape::Simplex<2>, 2,
Real>;
816 extern template class ConformalMesh<Shape::Simplex<3>, 3,
Real>;
817 extern template class ConformalMesh<Shape::Hypercube<2>, 2,
Real>;
818 extern template class ConformalMesh<Shape::Hypercube<3>, 3,
Real>;
820 extern template class StandardRefinery<ConformalMesh<Shape::Simplex<2>, 2,
Real>>;
821 extern template class StandardRefinery<ConformalMesh<Shape::Simplex<3>, 3,
Real>>;
822 extern template class StandardRefinery<ConformalMesh<Shape::Hypercube<2>, 2,
Real>>;
823 extern template class StandardRefinery<ConformalMesh<Shape::Hypercube<3>, 3,
Real>>;
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Adjacency Graph implementation.
ImageIterator image_begin(Index domain_node) const
Returns an iterator for the first adjacent image node.
ImageIterator image_end(Index domain_node) const
Returns an iterator for the first position past the last adjacent image node.
static void reorient(IndexSetHolder< Shape_ > &ish)
Reorients the boundary facets in the index set holder to be positive.
Mesh Factory class template.
Conformal Index-Set class template.
Mesh permutation class template.
void clone(const MeshPermutation &other)
Clones another mesh permutation object into this object.
std::size_t bytes() const
const std::vector< Index > & get_element_layering() const
Returns a const reference to the element layering vector.
const PermArray & get_perms() const
bool empty() const
Checks whether this permutation is empty.
const std::vector< Index > & get_element_coloring() const
Returns a const reference to the element coloring vector.
void create(PermutationStrategy strategy, const IndexSetHolder< Shape_ > &ish, const VertexSet< num_coords_, Coord_ > &vtx)
Creates a mesh permutation for a conformal mesh.
const Adjacency::Permutation & get_perm(int dim=shape_dim) const
Returns a const reference to a (forward) permutation.
static void compute(IndexSetHolder< Shape_ > &index_set_holder)
Routine that does the actual work.
Standard Refinery class template.
String class implementation.
Tiny Vector class template.
@ transpose
Render-Transpose mode.
PermutationStrategy
Mesh permutation strategy enumeration.
@ other
generic/other permutation strategy
T_ min(T_ a, T_ b)
Returns the minimum of two values.
T_ max(T_ a, T_ b)
Returns the maximum of two values.
double Real
Real data type.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
Fixed-Sized Vertex Set class template.
static constexpr int num_coords
number of coordinates per vertex
void permute(const Adjacency::Permutation &perm, bool invert=false)
Applies a permutation onto this vertex set.
std::size_t bytes() const
void transform(const VertexType &origin, const VertexType &angles, const VertexType &offset)
Applies a "proper rigid" transformation onto the vertex set.
Face traits tag struct template.