POperators_FOT.h 12.9 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_FOT_H
#define EXTENSIONS_P_OPERATORS_FOT_H
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

#include "AMDiS.h"

using namespace std;
using namespace AMDiS;


/// < factor*phase*grad(u) , grad(psi) >
class Phase_FOT : public FirstOrderTerm 
{
public:
/// Constructor.
Phase_FOT(DOFVectorBase<double>* phaseDV, double fac=1.0);

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

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

void getLb(const ElInfo *elInfo,
    vector<mtl::dense_vector<double> >& result) const;

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);

Praetorius, Simon's avatar
Praetorius, Simon committed
54
WorldVector<double> f(const int iq) const;
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
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
194
195
196
197
198
void setFactor(const double fac_) { fac=fac_; }

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

/// < phase*(vecs*grad(u)) , psi > or < phase*vecs*u , grad(psi) > where vecs in R^n
class WorldVecAndVecFct_FOT : public FirstOrderTerm
{
public:
WorldVecAndVecFct_FOT(WorldVector<DOFVectorBase<double>*> vecs,
	DOFVectorBase<double>* phaseDV_, 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 getLb(const ElInfo *elInfo,
		vector<mtl::dense_vector<double> >& result) const;

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> *vec0DV, *vec1DV, *vec2DV, *phaseDV;
mtl::dense_vector<double> phase, vec0, vec1, vec2;
double fac;
int numVecs;
};



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

/// < vecs*grad(u) , psi > or < vecs*u , grad(psi) > where vecs in R^n
class WorldVec_FOT : public FirstOrderTerm
{
public:
WorldVec_FOT(WorldVector<DOFVector<double>*> vecs,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 getLb(const ElInfo *elInfo,
		vector<mtl::dense_vector<double> >& result) const;

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> *vec0DV, *vec1DV, *vec2DV;
mtl::dense_vector<double> vec0, vec1, vec2;
double fac;
int numVecs;
};

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

/// First order term: \f$ < \vec{v}(\vec{x}) \cdot \nabla u(\vec{x}) , \theta > or < \vec{v}(\vec{x}) \cdot u(\vec{x}) , \nabla \theta >\f$.
class WorldVector_FOT : public FirstOrderTerm
{
public:
  /// Constructor.
  WorldVector_FOT(DOFVector<WorldVector<double> > *dv, 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);

  /// Implements FirstOrderTerm::getLb().
  void getLb(const ElInfo *elInfo,
	     vector<mtl::dense_vector<double> >& Lb) const;

  /// Implements FirstOrderTerm::eval().
  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 factor);

protected:
  DOFVector<WorldVector<double> >* vec;

  /// Gradient of v at quadrature points.
  mtl::dense_vector<WorldVector<double> > vecAtQPs;

  double fac;
};

/// < phase*(vecs*grad(u)) , psi > or < phase*vecs*u , grad(psi) > where vecs in R^n
class WorldVecPhase_FOT : public FirstOrderTerm
{
public:
WorldVecPhase_FOT(DOFVectorBase<double>* phaseDV_, WorldVector<DOFVector<double>*> vecs,
    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 getLb(const ElInfo *elInfo,
        vector<mtl::dense_vector<double> >& result) const;

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> *vec0DV, *vec1DV, *vec2DV, *phaseDV;
mtl::dense_vector<double> phase, vec0, vec1, vec2;
double fac;
int numVecs;
};

Praetorius, Simon's avatar
Praetorius, Simon committed
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237


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

/// < f(vec0)*vecs*grad(u) , psi > or < f(vec0)*vecs*u , grad(psi) > where vecs in R^n
struct VecAndWorldVec_FOT : FirstOrderTerm
{
  VecAndWorldVec_FOT(DOFVector<double>* vec0, 
					 WorldVector<DOFVector<double>*> vecs, 
					 AbstractFunction<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 getLb(const ElInfo *elInfo,
			 vector<mtl::dense_vector<double> >& result) const;

  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:
  DOFVector<double> *vDV, *vec0DV, *vec1DV, *vec2DV;
  mtl::dense_vector<double> v, vec0, vec1, vec2;
  AbstractFunction<double, double>* fct;
  double fac;
  int numVecs;
};

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
267
268
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
299
/* -------------------------------------------------------------- */

/// < factor*d_i(u) , psi > or < factor*u , d_i(psi) >
class PartialDerivative_FOT : public FirstOrderTerm
{
public:
PartialDerivative_FOT(int component_, 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 getLb(const ElInfo *elInfo,
		vector<mtl::dense_vector<double> >& result) const;

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:
int component;
double fac;
};

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

/// < factor*v1*d_i(u) , psi > or < factor*v1*u , d_i(psi) >
class VecAndPartialDerivative_FOT : public FirstOrderTerm
{
public:

VecAndPartialDerivative_FOT(DOFVectorBase<double> *dv1, int component_, 
  double fac_=1.0);

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

void getLb(const ElInfo *elInfo, vector<mtl::dense_vector<double> >& result) const;

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>* vec1DV;
mtl::dense_vector<double> vec1;
double fac;
int component;
};
Praetorius, Simon's avatar
Praetorius, Simon committed
300
301
302
303
304
305
306
307
308
309
310
311
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388

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

/// < d_i(u) * factor*v1*d_j(v2) , psi > or < u * factor*v1*d_j(v2) , d_i(psi) >
struct VecAndPartialDerivativeIJ_FOT : FirstOrderTerm
{
  VecAndPartialDerivativeIJ_FOT(DOFVectorBase<double> *dv1, 
				DOFVectorBase<double> *dv2,
				int i_,
				int j_,
				double fac_ = 1.0);

  VecAndPartialDerivativeIJ_FOT(DOFVectorBase<double> *dv1, 
				DOFVectorBase<double> *dv2,
				int i_,
				int j_,
				BinaryAbstractFunction<double, double, double>* fct, // = f(v1, d_j(v2))
				double fac_ = 1.0);

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

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

  void getLb(const ElInfo *elInfo, vector<mtl::dense_vector<double> >& result) const;

  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;
  DOFVectorBase<double>* vec2DV;
  mtl::dense_vector<double> vec1;
  mtl::dense_vector<WorldVector<double> > grad;
  BinaryAbstractFunction<double, double, double>* fct;
  double fac;
  int xi, xj;
};


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

/// < factor*v1*v2*d_i(u) , psi > or < factor*v1*v2*u , d_i(psi) >
struct Vec2AndPartialDerivative_FOT : public FirstOrderTerm
{
  Vec2AndPartialDerivative_FOT(DOFVectorBase<double> *dv1, 
			       DOFVectorBase<double> *dv2,
			       int component_, 
			       double fac_=1.0);
  
  Vec2AndPartialDerivative_FOT(DOFVectorBase<double> *dv1, 
			       DOFVectorBase<double> *dv2,
			       int component_,
			       BinaryAbstractFunction<double, double, double>* fct, // = f(v1, v2)
			       double fac_=1.0);

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

  void getLb(const ElInfo *elInfo, vector<mtl::dense_vector<double> >& result) const;

  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;
  DOFVectorBase<double>* vec2DV;
  mtl::dense_vector<double> vec1,vec2;
  BinaryAbstractFunction<double, double, double>* fct;
  double fac;
  int component;
};

389
390
/* -------------------------------------------------------------- */

391
392
393
394
395
396
397
/**
  * \ingroup Assembler
  *
  * \brief
  * First order term: \f$ b(v(\vec{x}), \nabla w_1(\vec{x}), \nabla w_2(\vec{x})) \cdot \nabla u(\vec{x})\f$.
  */
class VecGrad2_FOT : public FirstOrderTerm
398
399
{
public:
400
401
  /// Constructor
  VecGrad2_FOT(DOFVectorBase<double> *dv, DOFVectorBase<double> *dw1, DOFVectorBase<double> *dw2,
402
	      TertiaryAbstractFunction<WorldVector<double>, double, WorldVector<double>, WorldVector<double> > *vecFct_);
403

404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
  /// Implementation of \ref OperatorTerm::initElement().
  void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
		    Quadrature *quad = NULL);
  
  /// Implements FirstOrderTerm::getLb().
  void getLb(const ElInfo *elInfo,
	      vector<mtl::dense_vector<double> >& Lb) const; 
  
  /// Implements FirstOrderTerm::eval().
  void eval(int nPoints,
	    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,
	    double factor);
  
420
protected:
421
422
423
424
425
  /// DOFVector to be evaluated at quadrature points.
  DOFVectorBase<double>* vec0;
  
  /// DOFVector to be evaluated at quadrature points.
  DOFVectorBase<double>* vec1;
426

427
428
429
430
431
432
433
  /// DOFVector to be evaluated at quadrature points.
  DOFVectorBase<double>* vec2;
  
  mtl::dense_vector<double> vec0AtQPs;
  
  /// Gradient v at quadrature points.
  mtl::dense_vector<WorldVector<double> > grad1AtQPs;
434

435
436
  /// Gradient v at quadrature points.
  mtl::dense_vector<WorldVector<double> > grad2AtQPs;
Praetorius, Simon's avatar
Praetorius, Simon committed
437

438
439
  /// Function for b.
  TertiaryAbstractFunction<WorldVector<double>, double, WorldVector<double>, WorldVector<double> > *vecFct;
440
441
};

Praetorius, Simon's avatar
Praetorius, Simon committed
442

443
#endif // EXTENSIONS_P_OPERATORS_FOT_H