8#include <kernel/adjacency/base.hpp>
9#include <kernel/adjacency/graph.hpp>
10#include <kernel/assembly/common_operators.hpp>
11#include <kernel/assembly/fe_interpolator.hpp>
12#include <kernel/assembly/interpolator.hpp>
13#include <kernel/assembly/slip_filter_assembler.hpp>
14#include <kernel/assembly/unit_filter_assembler.hpp>
16#include <kernel/geometry/export_vtk.hpp>
17#include <kernel/geometry/mesh_part.hpp>
19#include <kernel/global/gate.hpp>
20#include <kernel/lafem/dense_vector.hpp>
21#include <kernel/lafem/dense_vector_blocked.hpp>
22#include <kernel/lafem/projection_filter.hpp>
23#include <kernel/lafem/vector_mirror.hpp>
24#include <kernel/shape.hpp>
25#include <kernel/space/lagrange1/element.hpp>
26#include <kernel/trafo/standard/mapping.hpp>
28#include <kernel/util/dist.hpp>
29#include <kernel/util/memory_arbiter.hpp>
30#include <kernel/util/tiny_algebra.hpp>
53 template<
typename Mesh_>
77 static MeshPart make(Mesh_& mesh,
const MeshPart& boundary,
typename Mesh_::CoordType critial_angle = 0.34)
80 static constexpr int dim = Mesh_::ShapeType::dimension;
83 static constexpr int feature_dim = dim - 2;
86 static constexpr int facet_dim = dim - 1;
95 using DataType =
typename Mesh_::CoordType;
98 std::array<std::set<Index>, dim + 1> entities;
101 std::vector<DataType> orientations(mesh.get_num_entities(facet_dim), DataType(0));
102 std::vector<Index> facet_mask(mesh.get_num_entities(facet_dim), ~
Index(0));
104 const auto& facet_tgs = boundary.template get_target_set<facet_dim>();
108 facet_mask[facet_tgs[i]] = idx;
112 NormalComputer::compute_orientations(orientations.data(), facet_mask.data(), mesh);
114 const TrafoType trafo(mesh);
115 const auto& feature_tgs = boundary.template get_target_set<feature_dim>();
117 const auto& feature_at_facet = mesh.template get_index_set<facet_dim, feature_dim>();
122 const Index candidate = feature_tgs[i];
127 std::array<Index, 2> boundary_facets;
129 for(
auto it = facet_at_feature.
image_begin(candidate); it != facet_at_feature.
image_end(candidate); ++it)
131 if(facet_mask[*it] != ~
Index(0))
133 boundary_facets[idx++] = *it;
138 XASSERTM(idx == 2,
"FeatureMeshPartFactory: Too many adjacent facets at feature entity " +
stringify(candidate));
142 Index facet_a = boundary_facets[0];
143 Index facet_b = boundary_facets[1];
145 auto normals_a = NormalComputer::compute_oriented_normals(trafo, facet_a);
146 auto normals_b = NormalComputer::compute_oriented_normals(trafo, facet_b);
153 if(angle > critial_angle)
155 add_sub_entities<dim, feature_dim>(entities, mesh, candidate);
160 std::array<Index, 4> result_size{0, 0, 0, 0};
163 result_size[i] =
Index(entities[i].size());
165 MeshPart result(result_size.data());
167 fill_target_sets<dim, dim>(entities, result);
174 template<
int mesh_dim,
int dim>
177 if constexpr(dim >= 0)
179 auto& target_set = mesh_part.template get_target_set<dim>();
181 for(
Index entity : entities[dim])
183 target_set[i++] = entity;
191 template<
int mesh_dim,
int entity_dim>
194 entities[entity_dim].insert(entity);
196 if constexpr(entity_dim > 0)
198 const auto& idx_set = mesh.template get_index_set<entity_dim, entity_dim - 1>();
200 for(
int i(0); i < idx_set.num_indices; i++)
202 add_sub_entities<mesh_dim, entity_dim - 1>(entities, mesh, idx_set(entity, i));
217 template<
typename Mesh_>
236 static constexpr std::array<Index, 4> empty_mesh_part_size = {{0, 0, 0, 0}};
258 Intern::UnitAsmWrapper<shape_dim>::merge(
_entities.data(), mesh_part);
262 [](
auto a,
auto ) {
return a; });
276 [](
auto a,
auto ) {
return a; });
288 template<
typename DataType_,
typename IndexType_,
typename Space_,
typename Gate_>
300 _dof_positions<DataType_, IndexType_>(space);
310 gate->sync_0(feature_valences);
319 _assemble(filter, feature_valences, dof_positions);
324 template<
typename DataType_,
typename IndexType_>
335 for(
Index i(0); i < target_set.get_num_entities(); i++)
338 Index vertex = target_set[i];
339 if(
Index(valences(vertex)) == 0)
343 filter.add_boundary_dof(vertex, dof_view(vertex));
345 else if(
Index(valences(vertex)) == 2)
349 filter.add_feature_dof(vertex, dof_view(vertex));
357 filter.add_fixed_dof(vertex, dof_view(vertex));
363 template<
typename DataType_>
369 if constexpr(Mesh_::world_dim == 3)
373 const auto& index_set = mesh.template get_index_set<1, 0>();
376 view[index_set(target_set[i], 0)]++;
377 view[index_set(target_set[i], 1)]++;
383 if constexpr(Mesh_::world_dim == 2)
389 view[target_set[i]]++;
397 template<
typename DataType_,
typename IndexType_,
typename Space_>
400 using TrafoType =
typename Space_::TrafoType;
409 const auto& vtx = mesh.get_vertex_set();
411 for(
Index i(0); i < mesh.get_num_vertices(); i++)
413 vertex_view[i] = vtx[i];
426 return dof_positions;
#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.
Factory for MeshParts describing features of the mesh boundary.
static void add_sub_entities(std::array< std::set< Index >, mesh_dim+1 > &entities, const Mesh_ &mesh, Index entity)
Add entity and all contained lower-dimensional entities into entity arrays.
static MeshPart make(Mesh_ &mesh, const MeshPart &boundary, typename Mesh_::CoordType critial_angle=0.34)
Creates a MeshPart whose target sets contain all feature entities of the given boundary.
static void fill_target_sets(std::array< std::set< Index >, mesh_dim+1 > &entities, MeshPart &mesh_part)
Write collected entities into proper target sets.
Helper class that computes a weighted outer unit normal field.
ProjectionFilter assembler class template.
static constexpr int world_dim
World dimension.
static constexpr int shape_dim
Shape dimension.
void assemble(LAFEM::ProjectionFilter< MeshType, DataType_, IndexType_ > &filter, Space_ &space, const Gate_ *gate=nullptr) const
Assemble a ProjectionFilter.
void add_mesh_part(const Geometry::MeshPart< MeshType > &mesh_part)
Adds the given MeshPart to the Neumann boundary.
Geometry::MeshPart< Mesh_ > _neuman_zero_boundary
MeshPart describing Neumann boundary.
LAFEM::DenseVectorBlocked< DataType_, Index, MeshType::world_dim > _dof_positions(Space_ &space) const
Determine position of DoFs by interpolating vertex positions from P1 to the given space.
void add_feature_mesh_part(const Geometry::MeshPart< MeshType > &mesh_part)
Adds the given MeshPart to the boundary features.
std::array< IndexSet, shape_dim+1 > _entities
dof-index sets for entities that must be filtered
Geometry::MeshPart< Mesh_ > _feature_network
MeshPart describing boundary features.
std::set< Index > IndexSet
IndexSet type.
Mesh_ MeshType
Type of mesh to assemble filter on.
void _assemble(LAFEM::ProjectionFilter< MeshType, DataType_, IndexType_ > &filter, const LAFEM::DenseVector< DataType_, IndexType_ > &feature_valences, const LAFEM::DenseVectorBlocked< DataType_, IndexType_, MeshType::world_dim > &dof_positions) const
Inner assembly helper. Classifies DoFs based on feature network valences and adds DoFs to ProjectionF...
std::array< IndexSet, shape_dim+1 > _feature_entities
dof-index sets for feature entities
Index get_num_entities(int dim) const
Returns the number of entities.
void clone(const MeshPart &other)
Clones another mesh part object into this object.
static MeshPartType meshpart_union(const MeshPartType &left, const MeshPartType &right, const AttributeFn_ &attribute_merge)
Compute the union of two meshparts.
void format()
Reset all elements of the container to a given value or zero if missing.
Blocked Dense data vector class template.
Dense data vector class template.
Enforces homogenous Neumann boundary conditions in normal direction by projecting onto the boundary.
Standard Lagrange-1 Finite-Element space class template.
Tiny Vector class template.
Standard transformation mapping class template.
Contains boolean operations on meshparts (intersection, union, difference, symmetric difference)
@ transpose
Render-Transpose mode.
T_ acos(T_ x)
Returns the arccosine of a value.
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
Interpolation operator between two finite element spaces.