AMDiS  2.10
The Adaptive Multi-Dimensional Simulation Toolbox
DirichletBC.hpp
1 #pragma once
2 
3 #include <functional>
4 #include <utility>
5 #include <vector>
6 
7 #include <amdis/Boundary.hpp>
8 #include <amdis/BoundaryCondition.hpp>
9 #include <amdis/BoundarySubset.hpp>
10 #include <amdis/common/Concepts.hpp>
11 #include <amdis/common/TypeTraits.hpp>
12 #include <amdis/typetree/RangeType.hpp>
13 #include <amdis/typetree/TreePath.hpp>
14 
15 namespace AMDiS
16 {
18 
36  template <class Basis, class RowPath, class ColPath, class ValueGridFct>
38  {
39  using GridView = typename Basis::GridView;
40  using Intersection = typename GridView::Intersection;
41 
42  using Domain = typename GridView::template Codim<0>::Geometry::GlobalCoordinate;
43  using Range = TYPEOF(std::declval<ValueGridFct>()(std::declval<Domain>()));
44 
45  public:
47  template <class B>
48  DirichletBC(B&& basis, RowPath const& row, ColPath const& col,
49  BoundarySubset<Intersection> boundarySubset, ValueGridFct values)
50  : basis_{wrap_or_share(FWD(basis))}
51  , row_{row}
52  , col_{col}
53  , boundarySubset_(std::move(boundarySubset))
54  , valueGridFct_(std::move(values))
55  {}
56 
58  template <class B>
59  DirichletBC(B&& basis, BoundarySubset<Intersection> boundarySubset, ValueGridFct values)
60  : DirichletBC(FWD(basis), makeTreePath(), makeTreePath(),
61  std::move(boundarySubset), std::move(values))
62  {}
63 
64 
67 
70  void init();
71 
73 
78  template <class Mat, class Sol, class Rhs>
79  void apply(Mat& matrix, Sol& solution, Rhs& rhs, bool symmetric = false);
80 
81  private:
82  std::shared_ptr<Basis const> basis_;
83  RowPath row_;
84  ColPath col_;
85  BoundarySubset<Intersection> boundarySubset_;
86  ValueGridFct valueGridFct_;
87 
88  std::vector<typename Basis::MultiIndex> rowIndices_;
89  std::vector<typename Basis::MultiIndex> colIndices_;
90  };
91 
92  // deduction guides
93 
94  // Make a DirichletBC from a basis with treepath arguments
95  template <class B, class Row, class Col, class Values, class Basis = Underlying_t<B>,
96  REQUIRES(Concepts::GlobalBasis<Basis>)>
97  DirichletBC(B const&, Row const&, Col const&, BoundarySubset<typename Basis::GridView::Intersection>, Values const&)
99 
100  // Make a DirichletBC from a global basis
101  template <class B, class Values, class Basis = Underlying_t<B>,
102  REQUIRES(Concepts::GlobalBasis<Basis>)>
105 
106 } // end namespace AMDiS
107 
108 #include "DirichletBC.inc.hpp"
DirichletBC(B &&basis, BoundarySubset< Intersection > boundarySubset, ValueGridFct values)
Make a DirichletBC from a global basis.
Definition: DirichletBC.hpp:59
Definition: FieldMatVec.hpp:12
Implements a boundary condition of Dirichlet-type.
Definition: DirichletBC.hpp:37
Definition: AdaptBase.hpp:6
DirichletBC(B &&basis, RowPath const &row, ColPath const &col, BoundarySubset< Intersection > boundarySubset, ValueGridFct values)
Make a DirichletBC from a basis with treepath arguments.
Definition: DirichletBC.hpp:48
void init()
Definition: DirichletBC.inc.hpp:18
void apply(Mat &matrix, Sol &solution, Rhs &rhs, bool symmetric=false)
Apply dirichlet BC to matrix and vector.
Definition: DirichletBC.inc.hpp:81