Newer
Older
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
69
70
71
72
73
74
#ifndef SRC_BOUNDARYCONDITION_HH
#define SRC_BOUNDARYCONDITION_HH
#include <dune/common/bitsetvector.hh>
#include <dune/common/function.hh>
#include <dune/fufem/boundarypatch.hh>
template <class GridView, int dims>
class BoundaryCondition {
public:
using BoundaryPatch = BoundaryPatch<GridView>;
private:
using Function = Dune::VirtualFunction<double, double>;
const std::string tag_; // store type of boundary condition, e.g. dirichlet, neumann, friction, etc
std::shared_ptr<BoundaryPatch> boundaryPatch_;
std::shared_ptr<Dune::BitSetVector<dims>> boundaryNodes_;
std::shared_ptr<Function> boundaryFunction_;
public:
BoundaryCondition(const std::string& tag = "") :
tag_(tag)
{}
BoundaryCondition(std::shared_ptr<BoundaryPatch> patch, std::shared_ptr<Function> function, const std::string& tag = "") :
tag_(tag),
boundaryPatch_(patch),
boundaryFunction_(function)
{}
void setBoundaryPatch(const GridView& gridView, std::shared_ptr<Dune::BitSetVector<dims>> nodes) {
boundaryNodes_ = nodes;
boundaryPatch_ = std::make_shared<BoundaryPatch>(gridView, *nodes);
}
void setBoundaryPatch(std::shared_ptr<BoundaryPatch> patch) {
boundaryPatch_ = patch;
}
void setBoundaryPatch(const BoundaryPatch& patch) {
boundaryPatch_ = std::make_shared<BoundaryPatch>(patch);
}
void setBoundaryFunction(std::shared_ptr<Function> function) {
boundaryFunction_ = function;
}
void set(std::shared_ptr<BoundaryPatch> patch, std::shared_ptr<Function> function) {
boundaryPatch_ = patch;
boundaryFunction_ = function;
}
const std::string& tag() const {
return tag_;
}
const std::shared_ptr<BoundaryPatch>& boundaryPatch() const {
return boundaryPatch_;
}
const std::shared_ptr<Dune::BitSetVector<dims>>& boundaryNodes() const {
return boundaryNodes_;
}
const std::shared_ptr<Function>& boundaryFunction() const {
return boundaryFunction_;
}
};
#endif