LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
special_entity_sets.cc
1/***************************************************************************
2 * LehrFEM++ - A simple C++ finite element libray for teaching
3 * Developed from 2018 at the Seminar of Applied Mathematics of ETH Zurich,
4 * lead developers Dr. R. Casagrande and Prof. R. Hiptmair
5 ***************************************************************************/
6
15#include "special_entity_sets.h"
16
17namespace lf::mesh::utils {
19 const std::shared_ptr<const Mesh>& mesh_p, lf::base::dim_t codim_sub,
20 lf::base::dim_t codim_super) {
21 LF_VERIFY_MSG((mesh_p->DimMesh() >= codim_sub),
22 "Illegal codim_sub = " << codim_sub);
23 LF_VERIFY_MSG(codim_super <= codim_sub, "Codim_super to large");
24
25 // Declare and initialize the data set
26 CodimMeshDataSet<lf::base::size_type> sup_ent_cnt{mesh_p, codim_sub, 0};
27
28 const lf::base::dim_t super_codim = codim_sub - codim_super;
29 // Run through all super entities
30 for (const lf::mesh::Entity* e : mesh_p->Entities(super_codim)) {
31 // Traverse all sub-entities of a specific relative co-dimension
32 for (const lf::mesh::Entity* subent : e->SubEntities(codim_super)) {
33 // Write access to an entry in the data set
34 sup_ent_cnt(*subent) += 1;
35 }
36 }
37 return sup_ent_cnt;
38}
39
41 const std::shared_ptr<const Mesh>& mesh_p, lf::base::dim_t codim) {
42 LF_ASSERT_MSG((codim > 0) && (codim <= mesh_p->DimMesh()),
43 "Illegal codim = " << codim);
44 // count cells adjacent to entities of co-dimension 1
46 CountNumSuperEntities(mesh_p, 1, 1)};
47 // flag array
48 CodimMeshDataSet<bool> bd_flags{mesh_p, codim, false};
49 // relative codimension with respect to faces (entities of co-dimension 1)
50 const lf::base::dim_t rel_codim = codim - 1;
51 // Run through faces and flag sub-entities
52 for (const lf::mesh::Entity* edge : mesh_p->Entities(1)) {
53 if (no_adjacent_cells(*edge) == 1) {
54 // Boundary face detected!
55 // Traverse all sub-entities of a specific relative co-dimension
56 for (const lf::mesh::Entity* subent : edge->SubEntities(rel_codim)) {
57 bd_flags(*subent) = true;
58 }
59 }
60 }
61 return bd_flags;
62}
63
65 const std::shared_ptr<const Mesh>& mesh_p) {
66 // count cells adjacent to entities of co-dimension 1
68 CountNumSuperEntities(mesh_p, 1, 1)};
69 // flag array
70 AllCodimMeshDataSet<bool> bd_flags{mesh_p, false};
71
72 // Run through faces (entities of co-dimension 1) and flag sub-entities
73 for (const lf::mesh::Entity* edge : mesh_p->Entities(1)) {
74 if (no_adjacent_cells(*edge) == 1) {
75 // Boundary face detected!
76 // Traverse all sub-entities of all co-dimensions
77 const lf::base::dim_t dim_mesh = mesh_p->DimMesh();
78 for (lf::base::dim_t rel_codim = 0; rel_codim < dim_mesh; rel_codim++) {
79 for (const lf::mesh::Entity* subent : edge->SubEntities(rel_codim)) {
80 bd_flags(*subent) = true;
81 }
82 }
83 }
84 }
85 return bd_flags;
86}
87
88} // namespace lf::mesh::utils
Interface class representing a topological entity in a cellular complex
Definition entity.h:42
Assigns to every entity(all codims) in a mesh a value of type T
A MeshDataSet that attaches data of type T to every entity of a mesh that has a specified codimension...
unsigned int dim_t
type for dimensions and co-dimensions and numbers derived from them
Definition types.h:32
Contains helper functions and classes that all operate on the interface classes defined in lf::mesh.
CodimMeshDataSet< lf::base::size_type > CountNumSuperEntities(const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim_sub, lf::base::dim_t codim_super)
store number of adjacent super-entities
CodimMeshDataSet< bool > flagEntitiesOnBoundary(const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim)
flag entities of a specific co-dimension located on the boundary