ExaDG
Loading...
Searching...
No Matches
perform_local_refinements.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_PERFORM_LOCAL_REFINEMENTS_H_
23#define INCLUDE_EXADG_GRID_PERFORM_LOCAL_REFINEMENTS_H_
24
25// C/C++
26#include <vector>
27
28// deal.II
29#include <deal.II/grid/tria.h>
30
31namespace ExaDG
32{
41template<int dim>
42void
43refine_local(dealii::Triangulation<dim> & tria,
44 std::vector<unsigned int> const & vector_local_refinements)
45{
46 std::vector<unsigned int> refine_local = vector_local_refinements;
47
48 // execute refinement until every refinement counter has been decreased to 0
49 while(*max_element(refine_local.begin(), refine_local.end()) > 0)
50 {
51 // loop over all material IDs in refinement vector
52 for(size_t material_id = 0; material_id < refine_local.size(); material_id++)
53 {
54 // only if cells with current material_id have to be refined
55 if(refine_local[material_id] > 0)
56 {
57 for(auto & cell : tria.active_cell_iterators())
58 {
59 if(cell->material_id() == material_id)
60 {
61 cell->set_refine_flag();
62 }
63 }
64
65 // decrease refinement counter
66 refine_local[material_id]--;
67 }
68 }
69
70 // execute local refinement
71 tria.execute_coarsening_and_refinement();
72 }
73}
74
75} // namespace ExaDG
76
77
78#endif /* INCLUDE_EXADG_GRID_PERFORM_LOCAL_REFINEMENTS_H_ */
Definition driver.cpp:33
void refine_local(dealii::Triangulation< dim > &tria, std::vector< unsigned int > const &vector_local_refinements)
Definition perform_local_refinements.h:43