Operator.hpp 3.59 KB
Newer Older
1
2
3
4
5
6
7
8
#pragma once

#include <list>

#include "OperatorTerm.hpp"

namespace AMDiS
{
9
10
11
12
13
14
15
  enum FirstOrderType
  {
      GRD_PSI,
      GRD_PHI
  };
    
    
16
17
18
19
20
21
22
  template <class MeshView>
  class Operator
  {
    using Self = Operator;
    using OperatorTermType = OperatorTerm<MeshView>;
    
  public:
23
24
25
26
    template <class RowFeSpace, class ColFeSpace>
    void init(RowFeSpace const& rowFeSpace,
	      ColFeSpace const& colFeSpace);
      
27
28
29
30
31
32
33
34
35
    template <class RowView, class ColView, class ElementMatrix>
    void getElementMatrix(RowView const& rowView,
			  ColView const& colView,
			  ElementMatrix& elementMatrix);
    
    template <class RowView, class ElementVector>
    void getElementVector(RowView const& rowView,
			  ElementVector& elementVector);
    
36
37
    template <class Term>
    Self& addZOT(Term const& term)
38
    {
39
40
	zeroOrder.push_back(new GenericOperatorTerm<MeshView, Term>(term));
	return *this;
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
    template <class Term>
    Self& addFOT(Term const& term, FirstOrderType firstOrderType)
    {
	using OpTerm = GenericOperatorTerm<MeshView, Term>;
	if (firstOrderType == GRD_PHI)
	    firstOrderGrdPhi.push_back(new OpTerm(term));
	else
	    firstOrderGrdPsi.push_back(new OpTerm(term));
	return *this;
    }
    
    template <class Term, size_t I>
    Self& addFOT(Term const& term, const index_<I>, FirstOrderType firstOrderType)
    {
	using OpTerm = GenericOperatorTerm<MeshView, Term, VectorComponent<I>>;
	
	if (firstOrderType == GRD_PHI)
	    firstOrderGrdPhi.push_back(new OpTerm(term));
	else
	    firstOrderGrdPsi.push_back(new OpTerm(term));
	return *this;
    }
    
66
67
    template <class Term>
    Self& addSOT(Term const& term)
68
    {
69
70
	secondOrder.push_back(new GenericOperatorTerm<MeshView, Term>(term));
	return *this;
71
72
    }
    
73
74
75
76
77
78
79
80
    template <class Term, size_t I, size_t J>
    Self& addSOT(Term const& term, const index_<I>, const index_<J>)
    {
	using OpTerm = GenericOperatorTerm<MeshView, Term, MatrixComponent<I,J>>;
	secondOrder.push_back(new OpTerm(term));
	return *this;
    }
    
81
82

    /// Calculates the needed quadrature degree for the given order.
83
    int getQuadratureDegree(int order, FirstOrderType firstOrderType = GRD_PHI);
84
85
86
87
88
89
90
91
    
    
  protected:
    template <class RowView, class ColView, class ElementMatrix>
    void assembleZeroOrderTerms(RowView const& rowView,
				ColView const& colView,
				ElementMatrix& elementMatrix);
    
92
93
94
95
    template <class RowView, class ElementVector>
    void assembleZeroOrderTerms(RowView const& rowView,
				ElementVector& elementVector);
    
96
97
98
99
100
101
102
103
104
105
    template <class RowView, class ColView, class ElementMatrix>
    void assembleFirstOrderTermsGrdPhi(RowView const& rowView,
				       ColView const& colView,
				       ElementMatrix& elementMatrix);
    
    template <class RowView, class ColView, class ElementMatrix>
    void assembleFirstOrderTermsGrdPsi(RowView const& rowView,
				       ColView const& colView,
				       ElementMatrix& elementMatrix);
    
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
    template <class RowView, class ColView, class ElementMatrix>
    void assembleSecondOrderTerms(RowView const& rowView,
				  ColView const& colView,
				  ElementMatrix& elementMatrix);
    
  private:
      /// List of all second order terms
      std::list<OperatorTermType*> secondOrder;

      /// List of all first order terms derived to psi
      std::list<OperatorTermType*> firstOrderGrdPsi;

      /// List of all first order terms derived to phi
      std::list<OperatorTermType*> firstOrderGrdPhi;

      /// List of all zero order terms
      std::list<OperatorTermType*> zeroOrder;
123
124
125
      
      int psiDegree = 1;
      int phiDegree = 1;
126
127
128
129
130
  };
  
} // end namespace AMDiS

#include "Operator.inc.hpp"