-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometrybase.hpp
68 lines (56 loc) · 1.8 KB
/
geometrybase.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef PARAMSIM_GEOMETRYBASE_HPP_
#define PARAMSIM_GEOMETRYBASE_HPP_
#include <deal.II/base/tensor_function.h>
#include <deal.II/base/types.h>
#include <deal.II/grid/tria.h>
namespace paramsim {
using bc_id_t = dealii::types::boundary_id;
/** Abstraction for generating a Deal II Triangulation from some kind of geometry description.
*
* Also provides a routine for setting boundary face IDs for boundary conditions.
*/
template <int dim>
class DomainGeometry
{
public:
/// Type describing a boundary marker and the condition for a point to be on that boundary
using bc_mark_desc = std::pair<bc_id_t, std::function<bool(const dealii::Point<dim>&)>>;
DomainGeometry() { }
DomainGeometry(const std::vector<bc_mark_desc>& bc_marks)
: bciddesc(bc_marks)
{ }
virtual void generate_grid(dealii::Triangulation<dim>& tria,
const unsigned int initial_resolution) const = 0;
void set_bc_mark_desc(const std::vector<bc_mark_desc>& bc_marks) {
bciddesc = bc_marks;
}
void set_boundary_ids(dealii::Triangulation<dim>& tria) const
{
if(bciddesc.empty()) {
return;
}
for (const auto &cell : tria.cell_iterators()) {
for (const auto &face : cell->face_iterators()) {
if (face->at_boundary()) {
for (auto bcid : bciddesc) {
if (bcid.second(face->center())) {
face->set_boundary_id(bcid.first);
}
}
}
}
}
}
protected:
std::vector<bc_mark_desc> bciddesc;
};
/// Abstract type for a function on a facet
template <int dim>
class FaceFunction
{
public:
virtual double value_normal(const dealii::Point<dim>& p, const dealii::Tensor<1,dim>& normal,
const unsigned int = 0) const = 0;
};
}
#endif