POperators_ZOT.h 10.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/******************************************************************************
 *
 * Extension of AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: Simon Praetorius et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * See also license.opensource.txt in the distribution.
 * 
 ******************************************************************************/


#ifndef EXTENSIONS_P_OPERATORS_ZOT_H
#define EXTENSIONS_P_OPERATORS_ZOT_H
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#include "AMDiS.h"

using namespace std;
using namespace AMDiS;

/// < factor*phase*u , psi >
class Phase_ZOT : public ZeroOrderTerm 
{ 
public: 
Phase_ZOT(DOFVectorBase<double>* phaseDV, double fac=1.0);

/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, 
		SubAssembler* subAssembler,
		Quadrature *quad=NULL);
void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
		SubAssembler* subAssembler,
		Quadrature *quad=NULL);

Praetorius, Simon's avatar
Praetorius, Simon committed
41
void getC(const ElInfo *, int nPoints, ElementVector &C);
42

Praetorius, Simon's avatar
Praetorius, Simon committed
43
void eval(int nPoints,
44
45
46
47
48
49
		const mtl::dense_vector<double>&,
		const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		mtl::dense_vector<double>& result,
		double opFactor);

Praetorius, Simon's avatar
Praetorius, Simon committed
50
double f(const int iq) const;
51
52
53
54
55
56
57
58
void setFactor(const double fac_) { fac=fac_; }

protected:
DOFVectorBase<double> *phaseDV;
mtl::dense_vector<double> phase;
double fac;
}; 

Praetorius, Simon's avatar
Praetorius, Simon committed
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// struct DefaultOperation
// {
//   int degree;
//   int getDegree() const { return degree; }
//   
//   template<typename V1>
//   DefaultQuartOperation(V1* v1)
//     : degree(v1->getFeSpace()->getBasisFcts()->getDegree() ) {}
//   
//   DefaultQuartOperation(int d1)
//     : degree(d1) {}
//     
//   template<typename T>
//   double operator()(const T& v) const { return v; }
// };
// 
// struct DefaultBinaryOperation
// {
//   int degree;
//   int getDegree() const { return degree; }
//   
//   template<typename V1, typename V2>
//   DefaultQuartOperation(V1* v1, V2* v2)
//     : degree(v1->getFeSpace()->getBasisFcts()->getDegree() +
//              v2->getFeSpace()->getBasisFcts()->getDegree() ) {}
//   
//   DefaultQuartOperation(int d1, int d2)
//     : degree(d1 + d2) {}
//     
//   template<typename T1, typename T2>
//   double operator()(const T1& v1, const T2& v2) const { return v1 * v2; }
// };
// 
// struct DefaultTertiaryOperation
// {
//   int degree;
//   int getDegree() const { return degree; }
//   
//   template<typename V1, typename V2, typename V3>
//   DefaultQuartOperation(V1* v1, V2* v2, V3* v3)
//     : degree(v1->getFeSpace()->getBasisFcts()->getDegree() +
//              v2->getFeSpace()->getBasisFcts()->getDegree() +
//              v3->getFeSpace()->getBasisFcts()->getDegree() ) {}
//   
//   DefaultQuartOperation(int d1, int d2, int d3)
//     : degree(d1 + d2 + d3) {}
//     
//   template<typename T1, typename T2, typename T3>
//   double operator()(const T1& v1, const T2& v2, const T3& v3) const { return v1 * v2 * v3; }
// };
// 
// struct DefaultQuartOperation
// {
//   int degree;
//   int getDegree() const { return degree; }
//   
//   template<typename V1, typename V2, typename V3, typename V4>
//   DefaultQuartOperation(V1* v1, V2* v2, V3* v3, V4* v4)
//     : degree(v1->getFeSpace()->getBasisFcts()->getDegree() +
//              v2->getFeSpace()->getBasisFcts()->getDegree() +
//              v3->getFeSpace()->getBasisFcts()->getDegree() +
//              v4->getFeSpace()->getBasisFcts()->getDegree() ) {}
//   
//   DefaultQuartOperation(int d1, int d2, int d3, int d4)
//     : degree(d1 + d2 + d3 + d4) {}
//              
//   template<typename T1, typename T2, typename T3, typename T4>
//   double operator()(const T1& v1, const T2& v2, const T3& v3, const T4& v4) const { return v1 * v2 * v3 * v4; }
// };
// 
// /// < factor*op(vec)*u , psi >
// template<typename Op = DefaultOperation>
// class VecAtQP_Op_ZOT : public ZeroOrderTerm 
// { 
// public: 
// VecAtQP_Op_ZOT(DOFVectorBase<double>* vecDV, double fac=1.0);
// 
// /// Implementation of \ref OperatorTerm::initElement().
// void initElement(const ElInfo* elInfo, 
// 		SubAssembler* subAssembler,
// 		Quadrature *quad=NULL);
// void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
// 		SubAssembler* subAssembler,
// 		Quadrature *quad=NULL);
// 
// void getC(const ElInfo *, int nPoints, ElementVector &C);
// 
// void eval(int nPoints,
// 		const mtl::dense_vector<double>&,
// 		const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
// 		const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
// 		mtl::dense_vector<double>& result,
// 		double opFactor);
// 
// protected:
// Op op;
// DOFVectorBase<double> *vecDV;
// mtl::dense_vector<double> vec;
// double fac;
// }; 

// _____________________________________________________________________________

/// < factor*op2(vec1,vec2)*u , psi >
// template<typename BinaryOp = DefaultBinaryOperation>
// class Vec2AtQP_Op_ZOT : public ZeroOrderTerm 
// { 
// public: 
// Vec2AtQP_Op_ZOT(DOFVectorBase<double>* vec1DV, DOFVectorBase<double>* vec2DV, double fac=1.0);
// 
// /// Implementation of \ref OperatorTerm::initElement().
// void initElement(const ElInfo* elInfo, 
// 		SubAssembler* subAssembler,
// 		Quadrature *quad=NULL);
// void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
// 		SubAssembler* subAssembler,
// 		Quadrature *quad=NULL);
// 
// void getC(const ElInfo *, int nPoints, ElementVector &C);
// 
// void eval(int nPoints,
// 		const mtl::dense_vector<double>&,
// 		const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
// 		const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
// 		mtl::dense_vector<double>& result,
// 		double opFactor);
// 
// protected:
// binaryOp op2;
// DOFVectorBase<double> *vec1DV, *vec2DV;
// mtl::dense_vector<double> vec, vec2;
// double fac;
// }; 


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/* -------------------------------------------------------------- */

/// < factor*(1-phase)*u , psi > or < factor*v[i]*(1-phase)*u , psi > where v in R^n
class PhaseInverse_ZOT : public ZeroOrderTerm 
{ 
public: 
PhaseInverse_ZOT(DOFVectorBase<double>* phaseDV, double fac=1.0);
PhaseInverse_ZOT(DOFVectorBase<double>* phaseDV, double fac, WorldVector<double>* facVec, int component);

/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, 
		SubAssembler* subAssembler,
		Quadrature *quad=NULL);
void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
		SubAssembler* subAssembler,
		Quadrature *quad=NULL);

Praetorius, Simon's avatar
Praetorius, Simon committed
211
void getC(const ElInfo *, int nPoints, ElementVector &C);
212

Praetorius, Simon's avatar
Praetorius, Simon committed
213
void eval(int nPoints,
214
215
216
217
218
219
		const mtl::dense_vector<double>&,
		const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		mtl::dense_vector<double>& result,
		double opFactor);

Praetorius, Simon's avatar
Praetorius, Simon committed
220
double f(const int iq) const;
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
void setFactor(const double fac_) { fac=fac_; }

protected:
DOFVectorBase<double> *phaseDV;
mtl::dense_vector<double> phase;
double fac;
int component;
WorldVector<double>* facVec;
}; 

/* -------------------------------------------------------------- */

/// < factor*d_i(v)*u , psi > or < factor*b[j]*d_i(v)*u , psi >
class PartialDerivative_ZOT : public ZeroOrderTerm
{
public:
PartialDerivative_ZOT(DOFVectorBase<double>* vecDV_, int component_, double fac_=1.0);
PartialDerivative_ZOT(DOFVectorBase<double>* vecDV_, int component_, double fac_, WorldVector<double>* vec, int component2_);

void initElement(const ElInfo*, 
	SubAssembler*,
	Quadrature *quad= NULL);
void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
	SubAssembler*,
	Quadrature *quad = NULL);

void getC(const ElInfo *, int nPoints, ElementVector &C);

void eval(int nPoints,
		const mtl::dense_vector<double>&,
		const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		mtl::dense_vector<double>& result,
		double opFactor);

protected:
DOFVectorBase<double> *vecDV;
mtl::dense_vector<WorldVector<double> > grad;
double fac;
WorldVector<double>* facVec;
int component, component2;
};

/* -------------------------------------------------------------- */

/// < factor*v*d_i(w)*u , psi >
Praetorius, Simon's avatar
Praetorius, Simon committed
267
struct VecAndPartialDerivative_ZOT : ZeroOrderTerm
268
{
Praetorius, Simon's avatar
Praetorius, Simon committed
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  VecAndPartialDerivative_ZOT(DOFVectorBase<double>* vecDV_, 
			      DOFVectorBase<double>* gradDV_, 
			      int component_, 
			      double fac_ = 1.0);
  
  VecAndPartialDerivative_ZOT(DOFVectorBase<double>* vecDV_, 
			      DOFVectorBase<double>* gradDV_, 
			      int component_, 
			      AbstractFunction<double, double>* fct, // f(v)
			      double fac_ = 1.0);

  void initElement(const ElInfo*, 
	  SubAssembler*,
	  Quadrature *quad= NULL);
  
  void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
	  SubAssembler*,
	  Quadrature *quad = NULL);

  void getC(const ElInfo *, int nPoints, ElementVector &C);

  void eval(int nPoints,
		  const mtl::dense_vector<double>&,
		  const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		  const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		  mtl::dense_vector<double>& result,
		  double opFactor);

private:
  DOFVectorBase<double> *vecDV, *gradDV;
299
  int component;
Praetorius, Simon's avatar
Praetorius, Simon committed
300
301
  AbstractFunction<double, double>* fct;
  double fac;
302
303
  
  mtl::dense_vector<double> vec;
Praetorius, Simon's avatar
Praetorius, Simon committed
304
  mtl::dense_vector<WorldVector<double> > grad;
305
306
307
308
309
};

/* -------------------------------------------------------------- */

/// < factor*v1*v2*d_i(w)*u , psi >
Praetorius, Simon's avatar
Praetorius, Simon committed
310
struct Vec2AndPartialDerivative_ZOT : ZeroOrderTerm
311
{
Praetorius, Simon's avatar
Praetorius, Simon committed
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
  Vec2AndPartialDerivative_ZOT(DOFVectorBase<double>* vec1DV_, 
							  DOFVectorBase<double>* vec2DV_, 
							  DOFVectorBase<double>* gradDV_, 
							  int component_, 
							  double fac_ = 1.0);
  
  Vec2AndPartialDerivative_ZOT(DOFVectorBase<double>* vec1DV_, 
							  DOFVectorBase<double>* vec2DV_, 
							  DOFVectorBase<double>* gradDV_, 
							  int component_, 
							  BinaryAbstractFunction<double, double, double>* fct,
							  double fac_ = 1.0);

  void initElement(const ElInfo*,
	  SubAssembler*,
	  Quadrature *quad= NULL);

  void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
	  SubAssembler*,
	  Quadrature *quad = NULL);

  void getC(const ElInfo *, int nPoints, ElementVector &C);

  void eval(int nPoints,
		  const mtl::dense_vector<double>&,
		  const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
		  const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
		  mtl::dense_vector<double>& result,
		  double opFactor);

private:
  DOFVectorBase<double> *vec1DV, *vec2DV, *gradDV;
  mtl::dense_vector<double> vec1, vec2;
  BinaryAbstractFunction<double, double, double>* fct;
  double fac;
  mtl::dense_vector<WorldVector<double> > grad;
  int component;
349
350
};

351
#endif // EXTENSIONS_P_OPERATORS_ZOT_H