DirichletBC.hpp 1.35 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#pragma once

#include <functional>
#include <type_traits>
#include <vector>

#include <dune/functions/common/functionconcepts.hh>

namespace AMDiS
{
  template <class WorldVector>
  class DirichletBC
  {
  public:
    template <class Predicate, class Values,
16
17
      class = std::enable_if_t< Dune::Functions::Concept::isFunction<Predicate, bool(WorldVector)>() &&
				Dune::Functions::Concept::isFunction<Values,  double(WorldVector)>() > >
18
19
    DirichletBC(Predicate&& predicate, Values&& values)
      : predicate(std::forward<Predicate>(predicate))
20
      , values(std::forward<Values>(values))
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
    {}
    
    
    template <class RowFeSpace, class ColFeSpace, class DOFMatrix, class DOFVector>
    void init(bool apply, 
	      RowFeSpace const& rowFeSpace, 
	      ColFeSpace const& colFeSpace, 
	      DOFMatrix* matrix, 
	      DOFVector* rhs, 
	      DOFVector* solution);
    
    
    template <class RowFeSpace, class ColFeSpace, class DOFMatrix, class DOFVector>
    void finish(bool apply, 
		RowFeSpace const& rowFeSpace, 
		ColFeSpace const& colFeSpace, 
		DOFMatrix* matrix, 
		DOFVector* rhs, 
		DOFVector* solution);
    
  private:
    std::function<bool(WorldVector)> predicate;
    std::function<double(WorldVector)> values;
    
    bool initialized = false;
    std::vector<char> dirichletNodes;
  };

} // end namespace AMDiS

#include "DirichletBC.inc.hpp"