9#include "kernel/geometry/intern/adaptive_refinement_utils.hpp"
10#include <kernel/geometry/templates/two_refinement_data.hpp>
11#include <kernel/geometry/intern/congruency_mapping.hpp>
12#include <kernel/geometry/intern/congruency_sampler.hpp>
13#include <kernel/geometry/intern/face_index_mapping.hpp>
14#include <kernel/geometry/templates/schneiders_data.hpp>
15#include <kernel/geometry/templates/sun_zhao_ma_data.hpp>
16#include <kernel/geometry/templates/sun_zhao_ma_expansion_data.hpp>
17#include <kernel/shape.hpp>
19#include <kernel/geometry/conformal_mesh.hpp>
20#include <kernel/geometry/intern/adaptive_mesh_algorithms.hpp>
21#include <kernel/geometry/intern/adaptive_mesh_storage.hpp>
22#include <kernel/geometry/intern/refinement_field.hpp>
23#include <kernel/geometry/mesh_part.hpp>
24#include <kernel/geometry/subdivision_levels.hpp>
25#include <kernel/geometry/template_interface.hpp>
27#include <kernel/geometry/template_sets.hpp>
28#include <kernel/geometry/template_builder.hpp>
34#include <unordered_map>
55 std::unordered_map<Index, Intern::ElementKey<dim_>> roots;
57 template<
int query_dim_>
58 std::unordered_map<Index, Intern::ElementKey<query_dim_>>& by_dim()
60 static_assert(query_dim_ <= dim_);
64 template<
int query_dim_>
65 const std::unordered_map<Index, Intern::ElementKey<query_dim_>>& by_dim()
const
67 static_assert(query_dim_ <= dim_);
78 std::unordered_map<Index, Intern::ElementKey<0>> roots;
80 template<
int query_dim_>
81 std::unordered_map<Index, Intern::ElementKey<0>>& by_dim()
83 static_assert(query_dim_ == 0);
87 template<
int query_dim_>
88 const std::unordered_map<Index, Intern::ElementKey<0>>& by_dim()
const
90 static_assert(query_dim_ == 0);
143 added[dim_] += count;
165 for(
Index i = 0; i < 4; i++)
207 typename TemplateSet_,
209 int num_coords_ = Shape_::dimension,
210 typename Coord_ =
Real>
213 static_assert(TemplateSet_::template is_shape_compatible<Shape_>());
255 using VertexKey =
typename MeshStorage::template ElementRefByDim<0>;
256 using EdgeKey =
typename MeshStorage::template ElementRefByDim<1>;
257 using FaceKey =
typename MeshStorage::template ElementRefByDim<2>;
258 using CellKey =
typename MeshStorage::template ElementRefByDim<3>;
260 using OrientedEdge =
typename MeshStorage::template OrientedElementRefByDim<1>;
261 using OrientedFace =
typename MeshStorage::template OrientedElementRefByDim<2>;
268 typename TemplateSet::VertexMarkerType,
272 using ElementRef =
typename MeshStorage::template ElementRefByDim<dim_>;
275 using OrientedElementRef =
typename MeshStorage::template OrientedElementRefByDim<dim_>;
278 using ElementTopology =
typename MeshStorage::template ElementTopologyByDim<dim_>;
281 using ElementChildren =
typename MeshStorage::template ElementChildrenByDim<dim_>;
284 using AdaptiveElement =
typename MeshStorage::template AdaptiveElementByDim<dim_>;
288 using VertexMarkerType =
typename TemplateSet::VertexMarkerType;
294 template<
typename AdaptiveMeshType_,
typename TargetMeshType_,
typename AlgShape_>
297 template<
typename AdaptiveMeshType_,
int topology_dim_,
int collection_dim_>
401 template<
typename VertexMarker_>
408 for(
Index i(0); i < num_vertices; ++i)
410 sdls[i] = std::uint64_t(marker(i));
431 std::array<Index, 4> entities = {};
439 MeshWriter::write_to_mesh(result, *
this, layer);
466 template<
typename TargetMeshType_>
486 std::array<Index, 4> num_elements =
487 {visitor.vertices.size(), visitor.edges.size(), visitor.faces.size(), visitor.cells.size()};
491 Projector::write_meshpart(visitor, result,
_storage);
502 return _storage.template num_total_entities<dim_>();
530 template<
int dim_,
int codim_>
533 auto& entity =
_storage.template get_by_index<dim_>(layer, entity_idx);
535 return _storage.
get_index(entity.topology.template key_by_dim<codim_>(face_idx));
566 auto& element =
_storage.template get_by_index<dim_>(layer, parent_idx);
568 if(element.type.is_zero_refinement())
575 if(child < TemplateSet::template num_children<dim_, dim_>(element.type))
596 auto type =
_storage.template get_by_index<dim>(layer, elem).
type;
597 if(!type.is_zero_refinement())
599 return TemplateSet::template num_children<dim, dim>(type);
613 return vertex.layer <= layer && layer <=
vertex.last_changed;
621 std::vector<std::pair<Index, Index>> pairs;
623 for(
auto& iter :
_roots.vertices)
656 const std::unordered_map<Index, ElementRef<dim_>>& root_map =
_roots.template by_dim<dim_>();
658 auto iter = root_map.find(foundation_index);
659 if(iter != root_map.end())
677 for(
auto& entry :
_roots.vertices)
712 const std::unordered_map<Index, ElementRef<shape_dim>>& root_map =
_roots.template by_dim<ShapeType::dimension>();
716 const Index overlap_cells = root_map.size();
717 const Index part_cells = total_cells - overlap_cells;
718 std::array<Index, shape_dim + 1> part_size = {};
723 auto& target_set = result.template get_target_set<shape_dim>();
726 Index tset_index = 0;
727 for(
Index i(0); i < total_cells; ++i)
729 if(root_map.find(i) == root_map.end())
732 target_set[tset_index] = i;
756 const std::unordered_map<Index, ElementRef<shape_dim>>& root_map =
_roots.template by_dim<ShapeType::dimension>();
759 const Index overlap_cells = root_map.size();
760 std::array<Index, shape_dim + 1> part_size = {};
765 auto& target_set = result.template get_target_set<shape_dim>();
768 Index tset_index = 0;
769 for(
auto& entry : root_map)
771 target_set[tset_index] = entry.first;
800 for(
Index v_fine_idx = 0; v_fine_idx < num_fine_vertices; v_fine_idx++)
803 Real closest_distance = std::numeric_limits<Real>::max();
804 Index closest_vertex = 0;
805 for(
Index v_base_idx = 0; v_base_idx < num_base_vertices; v_base_idx++)
809 const Real distance = (v_fine.vertex - v_base.vertex).norm_euclid_sqr();
810 if(distance < closest_distance)
812 closest_distance = distance;
813 closest_vertex = v_base_idx;
818 result[closest_vertex] = std::max(result[closest_vertex], lvls_in[v_fine_idx]);
892 ASSERT(_dbg_check_topology_unique<dim_>(topology));
893 ASSERT(_dbg_check_topology_orientations<dim_>(topology));
894 ASSERT(_dbg_is_topology_consistent<dim_>(topology));
899 auto type =
typename TemplateSet::template RefinementTypeByDim<dim_>(levels);
903 auto self = AdaptiveElement<dim_>(type,
Layer{depth}, topology);
905 if(type.is_zero_refinement())
923 std::array<VertexType, num_vertices> vertex_coordinates;
925 for(
int i(0); i < num_vertices; i++)
927 vertex_coordinates[std::size_t(i)] =
_storage[topology.template key_by_dim<0>(i)].vertex;
931 auto& child_vertices = self.children.template by_dim<0>();
932 for(
Index i = 0; i < tmplt.template num_entities<0>(); i++)
934 const VertexType vertex(Intern::interpolate(vertex_coordinates, tmplt.get_vertex_coefficients()[i]));
941 if(tmplt.template num_entities<0>() > 0)
945 auto& topo_vertices = self.topology.template by_dim<0>();
946 for(
Index v = 0; v < topo_vertices.size(); v++)
949 if(depth + 1 >
vertex.last_changed.idx)
957 if constexpr(dim_ >= 1)
959 auto& children = self.children.template by_dim<1>();
960 const auto& topo_templates = tmplt.template get_topologies<1>();
961 for(
Index i = 0; i < tmplt.template num_entities<1>(); i++)
963 ElementTopology<1> child_topo;
964 _build_topology<dim_, 1>(topo_templates[i], child_topo, topology, self.children);
966 children[i] = _build<1>(depth + 1, _levels<dim_, 1>(topo_templates[i], levels), child_topo);
971 if constexpr(dim_ >= 2)
973 auto& children = self.children.template by_dim<2>();
974 const auto& topo_templates = tmplt.template get_topologies<2>();
975 for(
Index i = 0; i < tmplt.template num_entities<2>(); i++)
977 ElementTopology<2> child_topo;
978 _build_topology<dim_, 2>(topo_templates[i], child_topo, topology, self.children);
980 children[i] = _build<2>(depth + 1, _levels<dim_, 2>(topo_templates[i], levels), child_topo);
985 if constexpr(dim_ >= 3)
987 auto& children = self.children.template by_dim<3>();
988 const auto& topo_templates = tmplt.template get_topologies<3>();
989 for(
Index i = 0; i < tmplt.template num_entities<3>(); i++)
991 ElementTopology<3> child_topo;
992 _build_topology<dim_, 3>(topo_templates[i], child_topo, topology, self.children);
994 children[i] = _build<3>(depth + 1, _levels<dim_, 3>(topo_templates[i], levels), child_topo);
1024 auto& foundation_entities =
_foundation_mesh.template get_index_set<dim_, 0>();
1025 auto& roots =
_roots.template by_dim<dim_>();
1027 for(
Index idx : set.template by_dim<dim_>())
1030 auto markings = sdls.get_tuple(foundation_entities[idx]);
1031 auto type =
typename TemplateSet::template RefinementTypeByDim<dim_>(markings);
1034 auto iter = roots.find(idx);
1035 bool exists = iter != roots.end();
1041 _adapt_children<dim_>(iter->second, markings);
1047 for(
Index i(0); i < markings.size; i++)
1069 ElementTopology<dim_> topology;
1070 TopologyCollector::collect(topology, idx, *
this);
1076 iter->second = _build<dim_>(0, markings, topology);
1081 roots[idx] = _build<dim_>(0, markings, topology);
1105 auto& vertex_roots =
_roots.template by_dim<0>();
1106 for(
const auto& vert : set.vertices)
1108 if(vertex_roots.find(vert) == vertex_roots.end())
1110 _stats.template added_element<0>();
1115 _stats.template kept_element<0>();
1121 _adapt_roots_of_dim<1>(set, sdls);
1125 _adapt_roots_of_dim<2>(set, sdls);
1129 _adapt_roots_of_dim<3>(set, sdls);
1156 XASSERTM(type ==
typename TemplateSet::template RefinementTypeByDim<dim_>(levels),
"Called adapt_children on element with changed type.");
1161 if(type.is_zero_refinement())
1179 if constexpr(dim_ >= 1)
1181 _adapt_sub_entities<dim_, 1>(depth, self, tmplt, levels);
1184 if constexpr(dim_ >= 2)
1186 _adapt_sub_entities<dim_, 2>(depth, self, tmplt, levels);
1189 if constexpr(dim_ >= 3)
1191 _adapt_sub_entities<dim_, 3>(depth, self, tmplt, levels);
1224 template<
int parent_dim_,
int child_dim_>
1227 AdaptiveElement<parent_dim_>& self,
1232 auto& children = self.children.template by_dim<child_dim_>();
1233 auto& topo_templates = tmplt.template get_topologies<child_dim_>();
1235 for(
Index i = 0; i < tmplt.template num_entities<child_dim_>(); i++)
1239 auto child_type =
typename TemplateSet::template RefinementTypeByDim<child_dim_>(child_levels);
1244 _adapt_children<child_dim_>(children[i], child_levels);
1251 ElementTopology<child_dim_> child_topology;
1252 _build_topology<parent_dim_, child_dim_>(topo_templates[i], child_topology, self.topology, self.children);
1254 children[i] = _build<child_dim_>(depth + 1, child_levels, child_topology);
1271 template<
int parent_dim_,
int entity_dim_>
1282 const auto& vertex_refs = tmplt.template get_references<0>();
1286 for(
int i(0); i < result.
size; ++i)
1288 result[i] = TemplateSet::template spread_refinement_field<ParentShape>(vertex_refs[std::size_t(i)], lvls);
1308 template<
int parent_dim_,
int topo_dim_,
int dim_ = topo_dim_ - 1>
1311 ElementTopology<topo_dim_>& topo,
1312 const ElementTopology<parent_dim_>& parent_topo,
1313 const ElementChildren<parent_dim_>& siblings)
1315 if constexpr(dim_ >= 0)
1317 _build_topology<parent_dim_, topo_dim_, dim_ - 1>(tmplt, topo, parent_topo, siblings);
1322 auto& target = topo.template by_dim<dim_>();
1323 for(
int i(0); i < num_entities; i++)
1326 target[std::size_t(i)] = _resolve_entity_reference<parent_dim_, dim_>(parent_topo, siblings, ref);
1328 if constexpr(dim_ >= 1)
1334 using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
1335 using CongruencySampler = Intern::CongruencySampler<ResultShape>;
1338 std::array<ElementRef<0>, num_vertices> local_keys;
1339 std::array<ElementRef<0>, num_vertices> foreign_keys;
1341 const auto& entity =
_storage[target[std::size_t(i)]];
1344 int local_vertex = FaceMapping::map(i,
vertex);
1345 local_keys[std::size_t(
vertex)] = topo.template key_by_dim<0>(local_vertex).key;
1346 foreign_keys[std::size_t(
vertex)] = entity.topology.template key_by_dim<0>(
vertex).key;
1349 target[std::size_t(i)].orientation = CongruencySampler::compare(local_keys.data(), foreign_keys.data());
1366 template<
int entity_dim_,
int result_dim_>
1367 OrientedElementRef<result_dim_> _resolve_entity_reference(
1368 const ElementTopology<entity_dim_>& topo,
1369 const ElementChildren<entity_dim_>& siblings,
1375 return topo.template key_by_dim<result_dim_>(ref.
index);
1377 return OrientedElementRef<result_dim_>(ref.
orientation, siblings.template by_dim<result_dim_>()[std::size_t(ref.
index)]);
1380 if constexpr (entity_dim_ >= 2 && result_dim_ <= 1)
1382 return _resolve_boundary_entity_reference<entity_dim_, result_dim_, 1>(topo, ref);
1386 XABORTM(
"_resolve_entity_reference failed: EntitySource::BoundaryEdge: Either source or target has invalid dimension");
1391 if constexpr (entity_dim_ >= 3 && result_dim_ <= 2)
1393 return _resolve_boundary_entity_reference<entity_dim_, result_dim_, 2>(topo, ref);
1397 XABORTM(
"_resolve_entity_reference failed: EntitySource::BoundaryFace: Either source or target has invalid dimension");
1401 XABORTM(
"_resolve_entitiy_reference failed: Unkown EntitySource");
1406 template<
int entity_dim_,
int result_dim_,
int boundary_dim_>
1408 const ElementTopology<entity_dim_>& topo,
1415 OrientedElementRef<boundary_dim_> boundary_ref = topo.template key_by_dim<boundary_dim_>(ref.
entity);
1416 typename TemplateSet::template RefinementTypeByDim<boundary_dim_> type =
_storage.
type(boundary_ref.key);
1419 std::pair<Index, int> orientation_mapping =
1420 TemplateSet::template correct_for_orientation<BoundaryShape, result_dim_>(type, boundary_ref.orientation, ref.
index);
1423 AdaptiveElement<boundary_dim_>& boundary_element =
_storage[boundary_ref];
1424 ElementRef<result_dim_> result_ref =
1425 boundary_element.children.template by_dim<result_dim_>()[orientation_mapping.first];
1428 return OrientedElementRef<result_dim_>(orientation_mapping.second, result_ref);
1442 auto iter = roots.begin();
1443 while(iter != roots.end())
1445 if(elements.find(iter->first) == elements.end())
1448 iter = roots.erase(iter);
1465 template<
int dim_ = shape_dim>
1468 if constexpr(dim_ >= 0)
1471 _delete_unused<dim_>(roots.template by_dim<dim_>(), set.by_dim<dim_>());
1475 template<
int topo_dim_,
int dim_ = topo_dim_ - 1>
1476 bool _dbg_check_topology_unique(
const ElementTopology<topo_dim_>& topology)
1478 if constexpr(dim_ >= 0)
1482 bool all_unique =
true;
1486 const auto& entities = topology.template by_dim<dim_>();
1487 for(
int i(0); i < num_entities; i++)
1489 for(
int j(0); j < num_entities; j++)
1491 all_unique = all_unique && (i == j || (entities[std::size_t(i)] != entities[std::size_t(j)]));
1495 return all_unique && _dbg_check_topology_unique<topo_dim_, dim_ - 1>(topology);
1503 template<
int topo_dim_,
int dim_ = topo_dim_ - 1>
1504 bool _dbg_check_topology_orientations(
const ElementTopology<topo_dim_>& topology)
1506 if constexpr(dim_ == 0)
1512 bool is_oriented =
true;
1517 using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
1518 using CongruencySampler = Intern::CongruencySampler<EntityShape>;
1520 static constexpr int num_entities = Shape::FaceTraits<TopologyShape, dim_>::count;
1521 static constexpr int num_vertices = Shape::FaceTraits<EntityShape, 0>::count;
1523 const auto& entities = topology.template by_dim<dim_>();
1525 for(
int entity_idx(0); entity_idx < num_entities; entity_idx++)
1527 const Intern::OrientedElement<dim_> o_ref = entities[std::size_t(entity_idx)];
1528 const auto& entity =
_storage[o_ref];
1530 std::array<ElementRef<0>, num_vertices> local_keys;
1531 std::array<ElementRef<0>, num_vertices> foreign_keys;
1535 const int local_vertex = int(FaceMapping::map(entity_idx,
vertex));
1536 local_keys[std::size_t(
vertex)] = topology.template key_by_dim<0>(local_vertex).key;
1537 foreign_keys[std::size_t(
vertex)] = entity.topology.template key_by_dim<0>(
vertex).key;
1540 is_oriented = is_oriented && (CongruencySampler::compare(local_keys.data(), foreign_keys.data()) == o_ref.orientation);
1543 return is_oriented && _dbg_check_topology_orientations<topo_dim_, dim_ - 1>(topology);
1547 template<
int topo_dim_,
int dim_ = topo_dim_ - 1>
1548 bool _dbg_is_topology_consistent(
const ElementTopology<topo_dim_>& topology)
1550 if constexpr(dim_ == 0)
1556 bool is_consistent =
true;
1561 using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
1562 using CongruencyMapping = Intern::CongruencyMapping<EntityShape, 0>;
1564 static constexpr int num_entities = Shape::FaceTraits<TopologyShape, dim_>::count;
1565 static constexpr int num_vertices = Shape::FaceTraits<EntityShape, 0>::count;
1567 const auto& entities = topology.template by_dim<dim_>();
1568 for(
int entity_idx(0); entity_idx < num_entities; entity_idx++)
1570 const auto& entity =
_storage[entities[std::size_t(entity_idx)]];
1574 ElementRef<0> v_topo = topology.template by_dim<0>()[std::size_t(FaceMapping::map(entity_idx,
vertex))].key;
1575 const int orientation = entities[std::size_t(entity_idx)].orientation;
1577 ElementRef<0> v_entity = entity.topology.template by_dim<0>()[mapped].key;
1578 is_consistent = is_consistent && (v_topo == v_entity);
1580 if(v_topo != v_entity)
1582 std::cout <<
"Inconsistent topology. Vertex " <<
vertex <<
" of entity " << entity_idx <<
" of dimension << " << dim_ <<
" mismatches!\n";
1587 return is_consistent && _dbg_is_topology_consistent<topo_dim_, dim_ - 1>(topology);
1591 template<
int topo_dim_,
int dim_ = topo_dim_ - 1>
1592 bool _dbg_is_topology_layering_consistent(Intern::Layer layer,
const ElementTopology<topo_dim_>& topology)
1594 if constexpr(dim_ == 0)
1596 bool is_consistent =
true;
1602 for(
const auto& entity : topology.template by_dim<0>())
1604 is_consistent = is_consistent && entity.key.layer <= layer;
1607 return is_consistent;
1611 bool is_consistent = _dbg_is_topology_layering_consistent<topo_dim_, dim_ - 1>(layer, topology);
1613 for(
const auto& entity : topology.template by_dim<dim_>())
1615 is_consistent = is_consistent && (entity.key.layer == layer || (entity.key.layer < layer && entity.key.is_permanent));
1618 return is_consistent;
#define ASSERT(expr)
Debug-Assertion macro definition.
#define XABORTM(msg)
Abortion macro definition with custom message.
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Dynamic mesh data structure.
Intern::MeshRoots< shape_dim > _roots
Mesh roots.
const FoundationMeshType & foundation_mesh() const
Accessor for foundation mesh.
Index get_num_entities(Layer layer, int dim) const
Returns number of elements of dimension dim in layer layer.
Index get_face_index(Layer layer, Index entity_idx, int face_idx) const
Returns an index of a sub-entity, i.e. the index of a face of a cell.
SubdivisionLevels transfer_sdls(SubdivisionLevels &lvls_in) const
Transfer subdivision levels from the adaptive mesh to the foundation mesh.
AdaptionStats adapt(SubdivisionLevels &foundation_levels, ImportBehaviour import_behaviour=ImportBehaviour::RequiredOnly)
Adapt the mesh to new SubdivisionLevels.
std::vector< Index > overlap_mapping()
Computes mapping from AdaptiveMesh elements to foundation mesh elements.
typename FoundationMeshType::VertexType VertexType
Vertex type.
std::optional< Index > get_child(Layer layer, Index parent_idx, Index child) const
Retrieve index of a child element.
MeshPart< FoundationMeshType > exclusive_meshpart() const
Exclusive MeshPart factory.
LevelTuple< entity_dim_ > _levels(const TopologyTemplate< typename Shape::FaceTraits< ShapeType, entity_dim_ >::ShapeType > &tmplt, const LevelTuple< parent_dim_ > &lvls)
Spread refinement levels to a child entity.
Coord_ CoordType
Coordinate type.
OrientedElementRef< result_dim_ > _resolve_boundary_entity_reference(const ElementTopology< entity_dim_ > &topo, const EntityReference &ref)
Helper-function for _resolve_entity_reference. Handles boundary entities of any dimension.
void _adapt_sub_entities(Index depth, AdaptiveElement< parent_dim_ > &self, const RefinementTemplate< typename Shape::FaceTraits< ShapeType, parent_dim_ >::ShapeType > &tmplt, const LevelTuple< parent_dim_ > &levels)
Adapts children of dimension dim_.
MeshStorage _storage
Mesh storage.
const VertexType & vertex(Layer layer, Index vertex_index) const
Retrieve vertex at index v from layer layer.
bool has_vertex_changed(Layer layer, Index vertex_idx) const
Indicates whether any mesh element adjacent to the given vertex has changed on the given layer.
VertexType & vertex(Layer layer, Index vertex_index)
Retrieve vertex at index v from layer layer.
std::optional< Index > get_overlap_cell(Index foundation_index) const
Mapping of elements of the foundation mesh to elements of the AdaptiveMesh.
void transform(const VertexType &origin, const VertexType &angles, const VertexType &offset)
Applies a "proper rigid" transformation onto the mesh vertices.
const FoundationMeshType & _foundation_mesh
Reference to foundation mesh.
AdaptionStats _stats
Stats of latest adaption.
void _erase(Intern::ElementKey< dim_ > key)
Erases an element and all its children from the mesh.
void fill_neighbors()
Computes neighboring elements for all mesh elements.
std::vector< std::pair< Index, Index > > bridge_pairs()
Computes mapping from elements of the foundation mesh to elements of the AdaptiveMesh.
static constexpr int shape_dim
Shape dimension.
void _garbage_collect(Intern::MeshRoots< shape_dim > &roots, const Intern::MeshIndexSet &set)
Delete all elements from the storage and mesh roots that are not in the index set.
void _adapt_roots(const Intern::MeshIndexSet &set, Intern::RefinementField< typename TemplateSet::VertexMarkerType > &sdls)
Adapts roots of refinement trees.
static constexpr int world_dim
World dimension.
MeshPart< TargetMeshType_ > project_meshpart(Layer layer, const MeshPart< FoundationMeshType > &part) const
Index get_neighbor(Layer layer, Index element_idx, Index neighbor_idx) const
Returns the index of the n-th neighbor of the given element.
Shape_ ShapeType
Shape of this mesh.
void _adapt_children(ElementRef< dim_ > key, const LevelTuple< dim_ > &levels)
Adjusts the children of the given element to match new subdivision levels.
AdaptiveMesh(const FoundationMeshType &mesh)
Constructor.
MeshPart< FoundationMeshType > overlap_meshpart() const
Overlap MeshPart factory.
FoundationMeshType & foundation_mesh()
Accessor for foundation mesh.
Index num_total_entities() const
Returns the total number of entities of dimension dim_ across all mesh layers.
Index get_num_children(Layer layer, Index elem)
Returns the number of children of an element in the mesh.
Intern::ElementKey< dim_ > _build(Index depth, const LevelTuple< dim_ > &levels, const ElementTopology< dim_ > &topology)
Construct a new subtree.
FoundationMeshType to_conformal_mesh(Layer layer) const
Create a ConformalMesh from a layer.
static FoundationMeshType create_refined_mesh(const FoundationMeshType &foundation_mesh, const VertexMarker_ &marker)
Use the AdaptiveMesh as a generator for other meshes.
void _delete_unused(std::unordered_map< Index, ElementRef< dim_ > > &roots, const std::set< Index > &elements)
Helper for garbage_collect. Deletes all entities of dimension dim that are not in the given set.
void _adapt_roots_of_dim(const Intern::MeshIndexSet &set, Intern::RefinementField< typename TemplateSet::VertexMarkerType > &sdls)
Adapts roots of refinement trees.
void _build_topology(const TopologyTemplate< typename Shape::FaceTraits< ShapeType, topo_dim_ >::ShapeType > &tmplt, ElementTopology< topo_dim_ > &topo, const ElementTopology< parent_dim_ > &parent_topo, const ElementChildren< parent_dim_ > &siblings)
Construct a topology for a new child element.
TemplateSet_ TemplateSet
Template set used by this mesh.
ImportBehaviour
ImportBehaviour for this mesh.
@ RequiredOnly
Import only entites required for the current subdivision levels.
@ All
Import all entities. Useful for exporting the complete mesh later.
Index num_layers() const
Returns number of layers of the AdaptiveMesh.
VertexKey insert(const AdaptiveVertexType &vertex)
Insert a vertex into the storage.
void fill_neighbors()
Determines neighboring elements for all mesh elements.
void transform(const VertexType &origin, const VertexType &angles, const VertexType &offset)
Applies a "proper rigid" transformation onto the mesh vertices.
const AdaptiveVertexType & get_vertex_by_index(Layer layer, Index idx) const
Retrieves a vertex of the mesh by its layer and index.
Index num_entities(Layer layer, int dim) const
Returns the number of mesh elements of the given dimension on the given layer.
Index get_neighbor(Layer layer, Index element_idx, Index neighbor_idx) const
Returns the index of the n-th neighbor of the given element.
void reindex()
Re-indexes the storage.
Index num_layers() const
Return the number of layers in this mesh.
AdaptiveVertex< VertexType > AdaptiveVertexType
Adaptive vertex type.
TemplateSet::template RefinementTypeByDim< dim > type(ElementKey< dim > key)
Get refinement type of element.
std::array< Index, 4 > erase(ElementKey< dim_ > key)
Erases an element and all its children from the storage.
Index get_index(ElementKey< dim_ > key) const
Get the numeric mesh index of the element pointed to by key.
static constexpr int size
Tuple size.
Schneiders template set for adaptive mesh refinement.
Class template for partial meshes.
Schneiders template set for adaptive mesh refinement.
Subdivision level markings for meshes.
@ other
generic/other permutation strategy
@ BoundaryEdge
Entity is part of a boundary edge, i.e. a child of one of the parents edges.
@ ParentTopology
Entity is part of the parents topology.
@ BoundaryFace
Entity is part of a boundary face, i.e. a child of one of the parents faces.
@ Sibling
Entity is a sibling in the refinement tree.
double Real
Real data type.
std::uint64_t Index
Index data type.
Statistics about entities added, removed, and kept during a mesh adaption.
std::array< Index, 4 > removed
Statistics about removed entities.
void removed_element(Index count=1)
Indicate a entity was removed.
void reset()
Reset statistics to zero.
void removed_elements(const std::array< Index, 4 > &counts)
Indicate entities were removed.
void kept_element(Index count=1)
Indicate a entity was kept.
void added_element(Index count=1)
Indicate a entity was added.
std::array< Index, 4 > added
Statistics about added entities.
std::array< Index, 4 > kept
Statistics about kept entities.
Reference to another local mesh entity.
EntitySource source
Where to retrieve the entity from.
int entity
Index of boundary entity to retrieve entity from. Only set for boundary entities.
int orientation
Orientation of the retrieved entity relative to the retrieving entity. Only set for sibling entities.
VertexType vertex
Vertex coordinates.
SlotMap key for use by the AdaptiveMeshStorage class.
Alorithm for collecting mesh entities that must be adaptively refined.
Algorithm for collecting topologies from the foundation mesh.
Newtype wrapper for mesh layers.
Algorithm for projecting MeshParts of an underlying mesh onto its adaptive mesh.
Visitor class for mesh part projection.
Mapping from ConformalMesh Indices to MeshStorage keys.
Template for refining a mesh entity.
Construction rule for a single entities topology.
Face traits tag struct template.
typedef ShapeType
Shape type of the face.