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)
 
  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)
 
  647      std::unordered_map<Index, ElementRef<shape_dim>>& root_map = 
_roots.template by_dim<ShapeType::dimension>();
 
  649      auto iter = root_map.find(foundation_index);
 
  650      if(iter != root_map.end())
 
  668      for(
auto& entry : 
_roots.vertices)
 
  703      const std::unordered_map<Index, ElementRef<shape_dim>>& root_map = 
_roots.template by_dim<ShapeType::dimension>();
 
  707      const Index overlap_cells = root_map.size();
 
  708      const Index part_cells = total_cells - overlap_cells;
 
  709      std::array<Index, shape_dim + 1> part_size = {};
 
  714      auto& target_set = result.template get_target_set<shape_dim>();
 
  717      Index tset_index = 0;
 
  718      for(
Index i(0); i < total_cells; ++i)
 
  720        if(root_map.find(i) == root_map.end())
 
  723          target_set[tset_index] = i;
 
  747      const std::unordered_map<Index, ElementRef<shape_dim>>& root_map = 
_roots.template by_dim<ShapeType::dimension>();
 
  750      const Index overlap_cells = root_map.size();
 
  751      std::array<Index, shape_dim + 1> part_size = {};
 
  756      auto& target_set = result.template get_target_set<shape_dim>();
 
  759      Index tset_index = 0;
 
  760      for(
auto& entry : root_map)
 
  762        target_set[tset_index] = entry.first;
 
  791      for(
Index v_fine_idx = 0; v_fine_idx < num_fine_vertices; v_fine_idx++)
 
  794        Real closest_distance = std::numeric_limits<Real>::max();
 
  795        Index closest_vertex = 0;
 
  796        for(
Index v_base_idx = 0; v_base_idx < num_base_vertices; v_base_idx++)
 
  800          const Real distance = (v_fine.vertex - v_base.vertex).norm_euclid_sqr();
 
  801          if(distance < closest_distance)
 
  803            closest_distance = distance;
 
  804            closest_vertex = v_base_idx;
 
  809        result[closest_vertex] = std::max(result[closest_vertex], lvls_in[v_fine_idx]);
 
  883      ASSERT(_dbg_check_topology_unique<dim_>(topology));
 
  884      ASSERT(_dbg_check_topology_orientations<dim_>(topology));
 
  885      ASSERT(_dbg_is_topology_consistent<dim_>(topology));
 
  890      auto type = 
typename TemplateSet::template RefinementTypeByDim<dim_>(levels);
 
  894      auto self = AdaptiveElement<dim_>(type, 
Layer{depth}, topology);
 
  896      if(type.is_zero_refinement())
 
  914      std::array<VertexType, num_vertices> vertex_coordinates;
 
  916      for(
int i{0}; i < num_vertices; i++)
 
  918        vertex_coordinates[i] = 
_storage[topology.template key_by_dim<0>(i)].vertex;
 
  922      auto& child_vertices = self.children.template by_dim<0>();
 
  923      for(
Index i = 0; i < tmplt.template num_entities<0>(); i++)
 
  925        const VertexType vertex(Intern::interpolate(vertex_coordinates, tmplt.get_vertex_coefficients()[i]));
 
  932      if(tmplt.template num_entities<0>() > 0)
 
  936        auto& topo_vertices = self.topology.template by_dim<0>();
 
  937        for(
Index v = 0; v < topo_vertices.size(); v++)
 
  940          if(depth + 1 > 
vertex.last_changed.idx)
 
  948      if constexpr(dim_ >= 1)
 
  950        auto& children = self.children.template by_dim<1>();
 
  951        const auto& topo_templates = tmplt.template get_topologies<1>();
 
  952        for(
Index i = 0; i < tmplt.template num_entities<1>(); i++)
 
  954          ElementTopology<1> child_topo;
 
  955          _build_topology<dim_, 1>(topo_templates[i], child_topo, topology, self.children);
 
  957          children[i] = _build<1>(depth + 1, _levels<dim_, 1>(topo_templates[i], levels), child_topo);
 
  962      if constexpr(dim_ >= 2)
 
  964        auto& children = self.children.template by_dim<2>();
 
  965        const auto& topo_templates = tmplt.template get_topologies<2>();
 
  966        for(
Index i = 0; i < tmplt.template num_entities<2>(); i++)
 
  968          ElementTopology<2> child_topo;
 
  969          _build_topology<dim_, 2>(topo_templates[i], child_topo, topology, self.children);
 
  971          children[i] = _build<2>(depth + 1, _levels<dim_, 2>(topo_templates[i], levels), child_topo);
 
  976      if constexpr(dim_ >= 3)
 
  978        auto& children = self.children.template by_dim<3>();
 
  979        const auto& topo_templates = tmplt.template get_topologies<3>();
 
  980        for(
Index i = 0; i < tmplt.template num_entities<3>(); i++)
 
  982          ElementTopology<3> child_topo;
 
  983          _build_topology<dim_, 3>(topo_templates[i], child_topo, topology, self.children);
 
  985          children[i] = _build<3>(depth + 1, _levels<dim_, 3>(topo_templates[i], levels), child_topo);
 
 1015      auto& foundation_entities = 
_foundation_mesh.template get_index_set<dim_, 0>();
 
 1016      auto& roots = 
_roots.template by_dim<dim_>();
 
 1018      for(
Index idx : set.template by_dim<dim_>())
 
 1021        auto markings = sdls.get_tuple(foundation_entities[idx]);
 
 1022        auto type = 
typename TemplateSet::template RefinementTypeByDim<dim_>(markings);
 
 1025        auto iter = roots.find(idx);
 
 1026        bool exists = iter != roots.end();
 
 1032          _adapt_children<dim_>(iter->second, markings);
 
 1038          for(
Index i(0); i < markings.size; i++)
 
 1060          ElementTopology<dim_> topology;
 
 1061          TopologyCollector::collect(topology, idx, *
this);
 
 1067            iter->second = _build<dim_>(0, markings, topology);
 
 1072            roots[idx] = _build<dim_>(0, markings, topology);
 
 1096        auto& vertex_roots = 
_roots.template by_dim<0>();
 
 1097        for(
const auto& vert : set.vertices)
 
 1099          if(vertex_roots.find(vert) == vertex_roots.end())
 
 1101            _stats.template added_element<0>();
 
 1106            _stats.template kept_element<0>();
 
 1112        _adapt_roots_of_dim<1>(set, sdls);
 
 1116        _adapt_roots_of_dim<2>(set, sdls);
 
 1120        _adapt_roots_of_dim<3>(set, sdls);
 
 1147      XASSERTM(type == 
typename TemplateSet::template RefinementTypeByDim<dim_>(levels), 
"Called adapt_children on element with changed type.");
 
 1152      if(type.is_zero_refinement())
 
 1170      if constexpr(dim_ >= 1)
 
 1172        _adapt_sub_entities<dim_, 1>(depth, self, tmplt, levels);
 
 1175        if constexpr(dim_ >= 2)
 
 1177          _adapt_sub_entities<dim_, 2>(depth, self, tmplt, levels);
 
 1180          if constexpr(dim_ >= 3)
 
 1182            _adapt_sub_entities<dim_, 3>(depth, self, tmplt, levels);
 
 1215    template<
int parent_dim_, 
int child_dim_>
 
 1218        AdaptiveElement<parent_dim_>& self,
 
 1223      auto& children = self.children.template by_dim<child_dim_>();
 
 1224      auto& topo_templates = tmplt.template get_topologies<child_dim_>();
 
 1226      for(
Index i = 0; i < tmplt.template num_entities<child_dim_>(); i++)
 
 1230        auto child_type = 
typename TemplateSet::template RefinementTypeByDim<child_dim_>(child_levels);
 
 1235          _adapt_children<child_dim_>(children[i], child_levels);
 
 1242          ElementTopology<child_dim_> child_topology;
 
 1243          _build_topology<parent_dim_, child_dim_>(topo_templates[i], child_topology, self.topology, self.children);
 
 1245          children[i] = _build<child_dim_>(depth + 1, child_levels, child_topology);
 
 1262    template<
int parent_dim_, 
int entity_dim_>
 
 1273      const auto& vertex_refs = tmplt.template get_references<0>();
 
 1279        result[i] = TemplateSet::template spread_refinement_field<ParentShape>(vertex_refs[i], lvls);
 
 1299    template<
int parent_dim_, 
int topo_dim_, 
int dim_ = topo_dim_ - 1>
 
 1302        ElementTopology<topo_dim_>& topo,
 
 1303        const ElementTopology<parent_dim_>& parent_topo,
 
 1304        const ElementChildren<parent_dim_>& siblings)
 
 1306      if constexpr(dim_ >= 0)
 
 1308        _build_topology<parent_dim_, topo_dim_, dim_ - 1>(tmplt, topo, parent_topo, siblings);
 
 1313        auto& target = topo.template by_dim<dim_>();
 
 1314        for(
int i(0); i < num_entities; i++)
 
 1317          target[i] = _resolve_entity_reference<parent_dim_, dim_>(parent_topo, siblings, ref);
 
 1319          if constexpr(dim_ >= 1)
 
 1325              using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
 
 1326              using CongruencySampler = Intern::CongruencySampler<ResultShape>;
 
 1329              std::array<ElementRef<0>, num_vertices> local_keys;
 
 1330              std::array<ElementRef<0>, num_vertices> foreign_keys;
 
 1332              const auto& entity = 
_storage[target[i]];
 
 1336                local_keys[
vertex] = topo.template key_by_dim<0>(local_vertex).key;
 
 1337                foreign_keys[
vertex] = entity.topology.template key_by_dim<0>(
vertex).key;
 
 1340              target[i].orientation = CongruencySampler::compare(local_keys.data(), foreign_keys.data());
 
 1357    template<
int entity_dim_, 
int result_dim_>
 
 1358    OrientedElementRef<result_dim_> _resolve_entity_reference(
 
 1359        const ElementTopology<entity_dim_>& topo,
 
 1360        const ElementChildren<entity_dim_>& siblings,
 
 1366          return topo.template key_by_dim<result_dim_>(ref.
index);
 
 1368          return OrientedElementRef<result_dim_>(ref.
orientation, siblings.template by_dim<result_dim_>()[ref.
index]);
 
 1371          if constexpr (entity_dim_ >= 2 && result_dim_ <= 1)
 
 1373            return _resolve_boundary_entity_reference<entity_dim_, result_dim_, 1>(topo, ref);
 
 1378          if constexpr (entity_dim_ >= 3 && result_dim_ <= 2)
 
 1380            return _resolve_boundary_entity_reference<entity_dim_, result_dim_, 2>(topo, ref);
 
 1389    template<
int entity_dim_, 
int result_dim_, 
int boundary_dim_>
 
 1391        const ElementTopology<entity_dim_>& topo,
 
 1398      OrientedElementRef<boundary_dim_> boundary_ref = topo.template key_by_dim<boundary_dim_>(ref.
entity);
 
 1399      typename TemplateSet::template RefinementTypeByDim<boundary_dim_> type = 
_storage.
type(boundary_ref.key);
 
 1402      std::pair<Index, int> orientation_mapping =
 
 1403        TemplateSet::template correct_for_orientation<BoundaryShape, result_dim_>(type, boundary_ref.orientation, ref.
index);
 
 1406      AdaptiveElement<boundary_dim_>& boundary_element = 
_storage[boundary_ref];
 
 1407      ElementRef<result_dim_> result_ref =
 
 1408        boundary_element.children.template by_dim<result_dim_>()[orientation_mapping.first];
 
 1411      return OrientedElementRef<result_dim_>(orientation_mapping.second, result_ref);
 
 1425      auto iter = roots.begin();
 
 1426      while(iter != roots.end())
 
 1428        if(elements.find(iter->first) == elements.end())
 
 1431          iter = roots.erase(iter);
 
 1448    template<
int dim_ = shape_dim>
 
 1451      if constexpr(dim_ >= 0)
 
 1454        _delete_unused<dim_>(roots.template by_dim<dim_>(), set.by_dim<dim_>());
 
 1458    template<
int topo_dim_, 
int dim_ = topo_dim_ - 1>
 
 1459    bool _dbg_check_topology_unique(
const ElementTopology<topo_dim_>& topology)
 
 1461      if constexpr(dim_ >= 0)
 
 1465        bool all_unique = 
true;
 
 1469        const auto& entities = topology.template by_dim<dim_>();
 
 1470        for(
int i(0); i < num_entities; i++)
 
 1472          for(
int j(0); j < num_entities; j++)
 
 1474            all_unique = all_unique && (i == j || (entities[i] != entities[j]));
 
 1478        return all_unique && _dbg_check_topology_unique<topo_dim_, dim_ - 1>(topology);
 
 1486    template<
int topo_dim_, 
int dim_ = topo_dim_ - 1>
 
 1487    bool _dbg_check_topology_orientations(
const ElementTopology<topo_dim_>& topology)
 
 1489      if constexpr(dim_ == 0)
 
 1495        bool is_oriented = 
true;
 
 1500        using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
 
 1501        using CongruencySampler = Intern::CongruencySampler<EntityShape>;
 
 1503        static constexpr int num_entities = Shape::FaceTraits<TopologyShape, dim_>::count;
 
 1504        static constexpr int num_vertices = Shape::FaceTraits<EntityShape, 0>::count;
 
 1506        const auto& entities = topology.template by_dim<dim_>();
 
 1508        for(
int entity_idx(0); entity_idx < num_entities; entity_idx++)
 
 1510          const Intern::OrientedElement<dim_> o_ref = entities[entity_idx];
 
 1511          const auto& entity = 
_storage[o_ref];
 
 1513          std::array<ElementRef<0>, num_vertices> local_keys;
 
 1514          std::array<ElementRef<0>, num_vertices> foreign_keys;
 
 1518            Index local_vertex = FaceMapping::map(entity_idx, 
vertex);
 
 1519            local_keys[
vertex] = topology.template key_by_dim<0>(local_vertex).key;
 
 1520            foreign_keys[
vertex] = entity.topology.template key_by_dim<0>(
vertex).key;
 
 1523          is_oriented = is_oriented && (CongruencySampler::compare(local_keys.data(), foreign_keys.data()) == o_ref.orientation);
 
 1526        return is_oriented && _dbg_check_topology_orientations<topo_dim_, dim_ - 1>(topology);
 
 1530    template<
int topo_dim_, 
int dim_ = topo_dim_ - 1>
 
 1531    bool _dbg_is_topology_consistent(
const ElementTopology<topo_dim_>& topology)
 
 1533      if constexpr(dim_ == 0)
 
 1539        bool is_consistent = 
true;
 
 1544        using FaceMapping = Intern::FaceIndexMapping<TopologyShape, dim_, 0>;
 
 1545        using CongruencyMapping = Intern::CongruencyMapping<EntityShape, 0>;
 
 1547        static constexpr int num_entities = Shape::FaceTraits<TopologyShape, dim_>::count;
 
 1548        static constexpr int num_vertices = Shape::FaceTraits<EntityShape, 0>::count;
 
 1550        const auto& entities = topology.template by_dim<dim_>();
 
 1551        for(
int entity_idx(0); entity_idx < num_entities; entity_idx++)
 
 1553          const auto& entity = 
_storage[entities[entity_idx]];
 
 1557            ElementRef<0> v_topo = topology.template by_dim<0>()[FaceMapping::map(entity_idx, 
vertex)].key;
 
 1558            int orientation = entities[entity_idx].orientation;
 
 1559            Index mapped = CongruencyMapping::map(orientation, 
vertex);
 
 1560            ElementRef<0> v_entity = entity.topology.template by_dim<0>()[mapped].key;
 
 1561            is_consistent = is_consistent && (v_topo == v_entity);
 
 1563            if(v_topo != v_entity)
 
 1565              std::cout << 
"Inconsistent topology. Vertex " << 
vertex << 
" of entity " << entity_idx << 
" of dimension << " << dim_ << 
" mismatches!\n";
 
 1570        return is_consistent && _dbg_is_topology_consistent<topo_dim_, dim_ - 1>(topology);
 
 1574    template<
int topo_dim_, 
int dim_ = topo_dim_ - 1>
 
 1575    bool _dbg_is_topology_layering_consistent(Intern::Layer layer, 
const ElementTopology<topo_dim_>& topology)
 
 1577      if constexpr(dim_ == 0)
 
 1579        bool is_consistent = 
true;
 
 1585        for(
const auto& entity : topology.template by_dim<0>())
 
 1587          is_consistent = is_consistent && entity.key.layer <= layer;
 
 1590        return is_consistent;
 
 1594        bool is_consistent = _dbg_is_topology_layering_consistent<topo_dim_, dim_ - 1>(layer, topology);
 
 1596        for(
const auto& entity : topology.template by_dim<dim_>())
 
 1598          is_consistent = is_consistent && (entity.key.layer == layer || (entity.key.layer < layer && entity.key.is_permanent));
 
 1601        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.
Index get_num_entities(Layer layer, int dim) const
Returns number of elements of dimension dim in layer layer.
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.
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.
std::optional< Index > get_overlap_cell(Index foundation_index)
Mapping of elements of the foundation mesh to elements of the AdaptiveMesh.
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.
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.
Index get_face_index(Layer layer, Index entity_idx, Index face_idx) const
Returns an index of a sub-entity, i.e. the index of a face of a cell.
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.
std::optional< Index > get_child(Layer layer, Index parent_idx, Index child)
Retrieve index of a 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 std::size_t 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.