ExaDG
Loading...
Searching...
No Matches
marked_vertices.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_GRID_MARKED_VERTICES_H_
23#define INCLUDE_EXADG_GRID_MARKED_VERTICES_H_
24
25// deal.II
26#include <deal.II/grid/tria.h>
27
32template<int dim>
33std::vector<bool>
34get_marked_vertices_via_boundary_ids(dealii::Triangulation<dim> const & triangulation,
35 std::set<dealii::types::boundary_id> const & boundary_ids)
36{
37 // mark vertices at interface in order to make search of active cells around point more
38 // efficient
39 std::vector<bool> marked_vertices(triangulation.n_vertices(), false);
40
41 for(auto const & cell : triangulation.active_cell_iterators())
42 {
43 if(not(cell->is_artificial()) and cell->at_boundary())
44 {
45 for(auto const & f : cell->face_indices())
46 {
47 if(cell->face(f)->at_boundary())
48 {
49 if(boundary_ids.find(cell->face(f)->boundary_id()) != boundary_ids.end())
50 {
51 for(auto const & v : cell->face(f)->vertex_indices())
52 {
53 marked_vertices[cell->face(f)->vertex_index(v)] = true;
54 }
55 }
56 }
57 }
58 }
59 }
60
61 // To improve robustness, make sure that not all entries of marked_vertices are false.
62 // If no useful information about marked vertices can be provided, an empty vector should
63 // be used.
64 if(std::all_of(marked_vertices.begin(), marked_vertices.end(), [](bool vertex_is_marked) {
65 return vertex_is_marked == false;
66 }))
67 {
68 marked_vertices.clear();
69 }
70
71 return marked_vertices;
72}
73
74
75
76#endif /* INCLUDE_EXADG_GRID_MARKED_VERTICES_H_ */