OperatorTerm.h 5.78 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

/** \file OperatorTerm.h */

#ifndef AMDIS_OPERATORTERM_H
#define AMDIS_OPERATORTERM_H

#include <set>
#include "AMDiS_fwd.h"
#include "SubAssembler.h"

namespace AMDiS {

  /** 
   * \ingroup Assembler
   * 
   * \brief
   * Base class for ZeroOrderTerm, FirstOrderTerm and SecondOrderTerm. 
   * OperatorTerms are the building blocks of an Operator. Each OperatorTerm
   * has its properties which are regarded, when constructing 
   * an Assembler for the corresponding Operator.
   */
  class OperatorTerm
  {
  public:
    /** \brief
     * Constructs an OperatorTerm with initially no properties.
     * degree_ is used to determine the degree of the needed quadrature
     * for the assemblage.  
     */
    OperatorTerm(int deg) 
      : properties(0), 
	degree(deg),
	dimOfWorld(Global::getGeo(WORLD)),
	bOne(-1)
    {}

    /// Destructor.
    virtual ~OperatorTerm() {}

    /** \brief
     * Virtual method. It's called by SubAssembler::initElement() for
     * each OperatorTerm belonging to this SubAssembler. E.g., vectors
     * and coordinates at quadrature points can be calculated here.
     */
    virtual void initElement(const ElInfo*, SubAssembler*, Quadrature *quad = NULL) 
    {}

    virtual void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
			     SubAssembler*, Quadrature *quad = NULL)
    {}


    /// Returs \auxFeSpaces, the list of all aux fe spaces the operator makes use off.
    inline std::set<const FiniteElemSpace*>& getAuxFeSpaces() 
    {
      return auxFeSpaces;
    }

    /// Specifies whether the matrix of the term is symmetric
    void setSymmetric(bool symm);

    /// Returns true, if the term is piecewise constant, returns false otherwise
    inline bool isPWConst() 
    { 
      return (degree == 0);
    }

    /// Returns true, if the term has a symmetric matrix, returns false otherwise.
    bool isSymmetric();

    /// Returns \ref degree.
    inline int getDegree() 
    { 
      return degree; 
    }

    /// Sets one component of the b vector to be one. See \ref bOne.
    void setB(int b)
    {
      bOne = b;
    }

    /// Evaluation of the OperatorTerm at all quadrature points.
    virtual void eval(int nPoints,
104
105
106
107
		      const mtl::dense_vector<double>& uhAtQP,
		      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		      mtl::dense_vector<double>& result,
108
109
		      double factor) = 0;

110
111
    /// Determines the value of a dof vector at the quadrature points of a given 
    /// element. It is used by all VecAtQP like operator terms.
112
    template<typename T>
113
114
115
116
117
    void getVectorAtQPs(DOFVectorBase<T>* vec,
			const ElInfo* elInfo, 
			SubAssembler* subAssembler,
			Quadrature *quad,
			mtl::dense_vector<T>& vecAtQPs);
118

119
120
121
122
123
    /// Determines the value of a dof vector at the quadrature points of a given 
    /// element. This function is used, if an operator is assembled on two
    /// different meshes using the dual traverse. The element, i.e. the small or
    /// the large one, is choosen, which corresponds to the mesh the dof vector 
    /// is defined on.
124
    template<typename T>
125
126
127
128
129
130
    void getVectorAtQPs(DOFVectorBase<T>* vec,
			const ElInfo* smallElInfo, 
			const ElInfo* largeElInfo, 
			SubAssembler* subAssembler,
			Quadrature *quad,
			mtl::dense_vector<T>& vecAtQPs);
131
132

    ///
133
134
135
136
137
138
    template<typename T>
    void getGradientsAtQPs( DOFVectorBase<T>* vec,
			    const ElInfo* elInfo,
			    SubAssembler* subAssembler,
			    Quadrature *quad,
			    mtl::dense_vector<typename GradientType<T>::type>& grdAtQPs);
139
140

    ///
141
142
143
144
145
146
147
    template<typename T>
    void getGradientsAtQPs( DOFVectorBase<T>* vec,
			    const ElInfo* smallElInfo,
			    const ElInfo* largeElInfo,
			    SubAssembler* subAssembler,
			    Quadrature *quad,
			    mtl::dense_vector<typename GradientType<T>::type>& grdAtQPs);
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

  protected:
    /// Stores the properties of this OperatorTerm
    Flag properties;

    /// Polynomial degree of the term. Used to detemine the degree of the quadrature.
    int degree;

    /// Stores the dimension of the world.
    int dimOfWorld;

    /// List off all fe spaces, the operator term makes use off.
    std::set<const FiniteElemSpace*> auxFeSpaces;

    /// Pointer to the Operator this OperatorTerm belongs to.
    Operator* operat;

165
166
167
168
169
    /// In many cases, the vector b in the evaluation \f$ \Lambda \cdot b\f$ has
    /// zeros in all components expect one that is set to one. Using the function
    /// \ref lb is then unnecessary time consuming. Instead, this variable
    /// defines the component of the vector b to be one. The function \ref lb_one
    /// is used if this variable is not -1.
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
    int bOne;

    /// Flag for piecewise constant terms
    static const Flag PW_CONST;

    /// Flag for symmetric terms
    static const Flag SYMMETRIC;

    friend class SubAssembler;
    friend class ZeroOrderAssembler;
    friend class FirstOrderAssembler;
    friend class SecondOrderAssembler;
    friend class Operator;
  };

}

187
188
189
#include "OperatorTerm.hh"

#endif // AMDIS_OPERATORTERM_H