Operator.h 104 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
// ==                                                                        ==
// ============================================================================

/** \file Operator.h */

#ifndef AMDIS_OPERATOR_H
#define AMDIS_OPERATOR_H

#include <vector>
26
#include "AMDiS_fwd.h"
27
28
29
30
31
#include "FixVec.h"
#include "Flag.h"
#include "MatrixVector.h"
#include "ElInfo.h"
#include "AbstractFunction.h"
32
#include "OpenMP.h"
33
#include "SubAssembler.h"
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

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.  
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
54
    OperatorTerm(int deg) 
55
      : properties(0), 
Thomas Witkowski's avatar
Thomas Witkowski committed
56
57
	degree(deg),
	auxFESpaces(0)
58
    {}
59

Thomas Witkowski's avatar
Thomas Witkowski committed
60
61
    /// Destructor.
    virtual ~OperatorTerm() {}
62
63
64

    /** \brief
     * Virtual method. It's called by SubAssembler::initElement() for
Thomas Witkowski's avatar
Thomas Witkowski committed
65
66
     * each OperatorTerm belonging to this SubAssembler. E.g., vectors
     * and coordinates at quadrature points can be calculated here.
67
68
     */
    virtual void initElement(const ElInfo*, 
Thomas Witkowski's avatar
Thomas Witkowski committed
69
70
			     SubAssembler*,
			     Quadrature *quad = NULL) 
71
    {}
72

Thomas Witkowski's avatar
Thomas Witkowski committed
73
74
75
76
77
78
79
    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.
80
81
    std::vector<const FiniteElemSpace*>& getAuxFESpaces() 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
82
83
84
85
      return auxFESpaces;
    }

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

Thomas Witkowski's avatar
Thomas Witkowski committed
88
    /// Returns true, if the term is piecewise constant, returns false otherwise
89
90
    inline bool isPWConst() 
    { 
91
      return (degree == 0);
92
    }
93

Thomas Witkowski's avatar
Thomas Witkowski committed
94
    /// Returns true, if the term has a symmetric matrix, returns false otherwise.
95
96
    bool isSymmetric();

Thomas Witkowski's avatar
Thomas Witkowski committed
97
    /// Returns \ref degree.
98
99
    inline int getDegree() 
    { 
100
      return degree; 
101
    }
102

Thomas Witkowski's avatar
Thomas Witkowski committed
103
    /// Evaluation of the OperatorTerm at all quadrature points.
Thomas Witkowski's avatar
Thomas Witkowski committed
104
105
    virtual void eval(int nPoints,
		      const double *uhAtQP,
106
107
		      const WorldVector<double> *grdUhAtQP,
		      const WorldMatrix<double> *D2UhAtQP,
Thomas Witkowski's avatar
Thomas Witkowski committed
108
		      double *result,
109
110
111
		      double factor) const = 0;

    /** \brief
Thomas Witkowski's avatar
Thomas Witkowski committed
112
113
     * Determines the value of a dof vector at the quadrature points of a given 
     * element. It is used by all VecAtQP like operator terms.
114
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    double *getVectorAtQPs(DOFVectorBase<double>* vec,
			   const ElInfo* elInfo, 
			   SubAssembler* subAssembler,
			   Quadrature *quad);		   

    /** \brief
     * 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.
     */
    double *getVectorAtQPs(DOFVectorBase<double>* vec,
			   const ElInfo* smallElInfo, 
			   const ElInfo* largeElInfo, 
			   SubAssembler* subAssembler,
			   Quadrature *quad);	

Thomas Witkowski's avatar
Thomas Witkowski committed
132
    ///
Thomas Witkowski's avatar
Thomas Witkowski committed
133
134
135
136
137
    WorldVector<double>* getGradientsAtQPs(DOFVectorBase<double>* vec,
					   const ElInfo* elInfo,
					   SubAssembler* subAssembler,
					   Quadrature *quad);

Thomas Witkowski's avatar
Thomas Witkowski committed
138
    ///
Thomas Witkowski's avatar
Thomas Witkowski committed
139
140
141
142
143
144
145
146
    WorldVector<double>* getGradientsAtQPs(DOFVectorBase<double>* vec,
					   const ElInfo* smallElInfo, 
					   const ElInfo* largeElInfo,
					   SubAssembler* subAssembler,
					   Quadrature *quad);

  protected:
    /// Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$.
147
148
149
150
151
    void lalt(const DimVec<WorldVector<double> >& Lambda,
	      const WorldMatrix<double>& matrix,
	      DimMat<double>& LALt,
	      bool symm,
	      double factor) const;
152
153
154
155
156
157
158
159

    /** \brief
     * Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$ for \f$ A \f$
     * the matrix having a ONE in the position \f$ (K,L) \f$
     * and ZEROS in all other positions.
     */
    static void lalt_kl(const DimVec<WorldVector<double> >& Lambda,
			int k, int l,
Thomas Witkowski's avatar
Thomas Witkowski committed
160
161
			DimMat<double>& LALt,
			double factor);
162

163
    /// Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$ for A equal to the identity.
164
165
166
    void l1lt(const DimVec<WorldVector<double> >& Lambda, 
	      DimMat<double>& LALt,
	      double factor) const;
167

Thomas Witkowski's avatar
Thomas Witkowski committed
168
    /// Evaluation of \f$ \Lambda \cdot b\f$.
169
170
171
172
173
174
    static inline void lb(const DimVec<WorldVector<double> >& Lambda,
			  const WorldVector<double>& b,
			  DimVec<double>& Lb,
			  double factor)
    {
      const int dimOfWorld = Global::getGeo(WORLD);
175
176
177
      const int dim = Lambda.size() - 1;

      for (int i = 0; i <= dim; i++) {
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
	double val = 0.0;
	
	for (int j = 0; j < dimOfWorld; j++)
	  val += Lambda[i][j] * b[j];
	
	Lb[i] += val * factor;
      }    
    }

    /** \brief
     * Evaluation of \f$ \Lambda \cdot b\f$ if b contains the value 1.0 in 
     * each component.
     */
    static inline void l1(const DimVec<WorldVector<double> >& Lambda,
			  DimVec<double>& Lb,
			  double factor)
194
    {
195
      const int dimOfWorld = Global::getGeo(WORLD);
196
      const int dim = Lambda.size() - 1;
197

198
      for (int i = 0; i <= dim; i++) {
199
200
	double val = 0.0;
      
201
	for (int j = 0; j < dimOfWorld; j++)
202
	  val += Lambda[i][j];
203

204
	Lb[i] += val * factor;
205
      }    
206
    }
207
208

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
209
    /// Stores the properties of this OperatorTerm
210
211
    Flag properties;

Thomas Witkowski's avatar
Thomas Witkowski committed
212
    /// Polynomial degree of the term. Used to detemine the degree of the quadrature.
213
214
    int degree;

Thomas Witkowski's avatar
Thomas Witkowski committed
215
216
217
218
    /// List off all fe spaces, the operator term makes use off.
    std::vector<const FiniteElemSpace*> auxFESpaces;

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

Thomas Witkowski's avatar
Thomas Witkowski committed
221
    /// Flag for piecewise constant terms
222
223
    static const Flag PW_CONST;

Thomas Witkowski's avatar
Thomas Witkowski committed
224
    /// Flag for symmetric terms
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
    static const Flag SYMMETRIC;

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

  /**
   * \ingroup Assembler
   * 
   * \brief
   * Describes the second order terms: \f$ \nabla \cdot A \nabla u(\vec{x}) \f$
   */
  class SecondOrderTerm : public OperatorTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
243
    /// Constructor.
244
245
246
    SecondOrderTerm(int deg) 
      : OperatorTerm(deg) 
    {}
247

248
    /// Destructor.
249
250
    virtual ~SecondOrderTerm() 
    {}
251

252
    /// Evaluation of \f$ \Lambda A \Lambda^t \f$ at all quadrature points.
253
    virtual void getLALt(const ElInfo *elInfo, 
Thomas Witkowski's avatar
Thomas Witkowski committed
254
			 int nPoints, 
255
256
			 DimMat<double> **result) const = 0;

257
    /// Evaluation of \f$ A \nabla u(\vec{x}) \f$ at all quadrature points.
Thomas Witkowski's avatar
Thomas Witkowski committed
258
    virtual void weakEval(int nPoints,
259
260
261
262
263
264
265
266
267
268
269
270
271
272
			  const WorldVector<double> *grdUhAtQP,
			  WorldVector<double> *result) const = 0;

  };

  /**
   * \ingroup Assembler
   * 
   * \brief
   * Implements the laplace operator: \f$ \Delta u(\vec{x}) \f$
   */
  class Laplace_SOT : public SecondOrderTerm 
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
273
    /// Constructor.
274
275
276
277
    Laplace_SOT() 
      : SecondOrderTerm(0) 
    {
      setSymmetric(true);
278
    }
279

280
    /// Implenetation of SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
281
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
282
283
284
    {
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();

285
      for (int iq = 0; iq < nPoints; iq++)
286
	l1lt(Lambda, *(LALt[iq]), 1.0);
287
    }
288

289
    /// Implementation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
290
    inline void eval(int nPoints,
291
292
		     const double *,
		     const WorldVector<double> *,
Thomas Witkowski's avatar
Thomas Witkowski committed
293
294
295
		     const WorldMatrix<double> *D2UhAtQP,
		     double *result,
		     double factor) const
296
297
298
299
    {
      int dow = Global::getGeo(WORLD);
    
      if (D2UhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
300
	for (int iq = 0; iq < nPoints; iq++) {
301
	  double resultQP = 0.0;
302
	  for (int i = 0; i < dow; i++) 
303
304
305
306
	    resultQP += D2UhAtQP[iq][i][i];
	  result[iq] += factor * resultQP;
	}
      }
307
    }
308

309
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
310
    void weakEval(int nPoints,
311
312
313
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
314
      if (grdUhAtQP)
315
	for (int iq = 0; iq < nPoints; iq++)
316
	  result[iq] += grdUhAtQP[iq];
317
318
    }
  };
319
320
321
322
323
324
325
326
327
328
329

  /**
   * \ingroup Assembler
   * 
   * \brief
   * Implements the laplace operator multiplied with a scalar factor:
   * \f$ f \cdot \Delta u(\vec{x}) \f$
   */
  class FactorLaplace_SOT : public SecondOrderTerm 
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
330
    /// Constructor.
331
    FactorLaplace_SOT(double f) 
332
333
      : SecondOrderTerm(0)  
    {
334
335
336
337
      factor = new double;
      *factor = f;

      setSymmetric(true);
338
    }
339

Thomas Witkowski's avatar
Thomas Witkowski committed
340
    /// Constructor.
341
    FactorLaplace_SOT(double *fptr) 
342
343
      : SecondOrderTerm(0), 
	factor(fptr)
344
345
    {
      setSymmetric(true);
346
    }
347

348
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
349
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
350
    {
351
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
Thomas Witkowski's avatar
Thomas Witkowski committed
352
      for (int iq = 0; iq < nPoints; iq++) 
353
	l1lt(Lambda, *(LALt[iq]), (*factor));
354
    }
355

356
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
357
    void eval(int nPoints,
358
	      const double *,
359
360
361
362
363
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double f) const
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
364
      int dow = Global::getGeo(WORLD);
365

Thomas Witkowski's avatar
Thomas Witkowski committed
366
      if (D2UhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
367
	for (int iq = 0; iq < nPoints; iq++) {
368
	  double resultQP = 0.0;
Thomas Witkowski's avatar
Thomas Witkowski committed
369
	  for (int i = 0; i < dow; i++) {
370
371
372
373
374
	    resultQP += D2UhAtQP[iq][i][i];
	  }
	  result[iq] += resultQP * f * (*factor);
	}
      }
375
    }
376

377
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
378
    void weakEval(int nPoints,
379
380
381
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
382
383
      if (grdUhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
384
	  axpy(*factor, grdUhAtQP[iq], result[iq]);
385
    }
386
387

  private:
388
    /// Pointer to the factor.
389
390
391
392
393
394
395
396
397
398
399
400
401
402
    double *factor;
  };

  /**
   * \ingroup Assembler
   * 
   * \brief
   * SecondOrderTerm where A is a function which maps a DOFVector evaluated at
   * a given quadrature point to a WolrdMatrix:
   * \f$ \nabla \cdot A(v(\vec{x})) \nabla u(\vec{x}) \f$
   */
  class MatrixFct_SOT : public SecondOrderTerm 
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
403
    /// Constructor.
404
405
406
    MatrixFct_SOT(DOFVectorBase<double> *dv, 
		  AbstractFunction<WorldMatrix<double>, double> *fct,
		  AbstractFunction<WorldVector<double>, WorldMatrix<double> > *div,
Thomas Witkowski's avatar
Thomas Witkowski committed
407
		  bool sym = false);
408

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

413
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
414
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
415
  
416
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
417
418
    void eval(int nPoints,
	      const double *uhAtQP,
419
420
421
422
423
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

424
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
425
    void weakEval(int nPoints,
426
427
428
429
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
430
    /// DOFVector to be evaluated at quadrature points.
431
432
    DOFVectorBase<double>* vec;

433
    /// Pointer to the values of the DOFVector at quadrature points.
434
435
    double* vecAtQPs;

436
    /// Function for A.
437
438
    AbstractFunction<WorldMatrix<double>, double>* matrixFct;

439
    ///
440
441
    AbstractFunction<WorldVector<double>, WorldMatrix<double> >* divFct;

442
    /// True, if \ref matrixFct produces always symmetric matrices.
443
444
445
446
447
448
449
450
451
452
453
454
    bool symmetric;
  };

  /** 
   * \ingroup Assembler
   *
   * \brief
   * SecondOrderTerm where A is a given fixed WorldMatrix<double>:
   * \f$ \nabla \cdot A \nabla u(\vec{x}) \f$
   */
  class Matrix_SOT : public SecondOrderTerm {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
455
    /// Constructor
456
    Matrix_SOT(WorldMatrix<double> mat) 
Thomas Witkowski's avatar
Thomas Witkowski committed
457
      : SecondOrderTerm(0), matrix(mat)
458
459
460
    {
      symmetric = matrix.isSymmetric();
      setSymmetric(symmetric);
461
    }
462

463
    /// Implements SecondOrderTerm::getLALt().
464
465
466
467
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
    {
      const DimVec<WorldVector<double> >& Lambda = elInfo->getGrdLambda();
      for (int iq = 0; iq < nPoints; iq++) 
468
	lalt(Lambda, matrix, *(LALt[iq]), symmetric, 1.0);
469
    }
470
  
471
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
472
473
    void eval(int nPoints,
	      const double *uhAtQP,
474
475
476
477
478
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

479
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
480
    void weakEval(int nPoints,
481
482
483
484
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
485
    /// Matrix stroring A.
486
487
    WorldMatrix<double> matrix;

488
    /// True, if \ref matrix is symmetric.
489
490
491
492
493
494
495
496
497
498
499
500
501
502
    bool symmetric;
  };

  /** 
   * \ingroup Assembler
   *
   * \brief
   * SecondOrderTerm where A is a WorldMatrix<double> having a ONE in position IJ
   * and ZERO in all other positions
   * \f$ \nabla \cdot A \nabla u(\vec{x}) \f$
   */
  class FactorIJ_SOT : public SecondOrderTerm 
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
503
    /// Constructor.
504
    FactorIJ_SOT(int x_i, int x_j, double f) 
Thomas Witkowski's avatar
Thomas Witkowski committed
505
      : SecondOrderTerm(0), xi(x_i), xj(x_j)
506
507
508
509
510
    {
      factor = new double;
      *factor = f;

      setSymmetric(xi == xj);
511
    }
512

Thomas Witkowski's avatar
Thomas Witkowski committed
513
    /// Constructor.
514
    FactorIJ_SOT(int x_i, int x_j, double *fptr) 
Thomas Witkowski's avatar
Thomas Witkowski committed
515
      : SecondOrderTerm(0), xi(x_i), xj(x_j), factor(fptr)
516
517
    {
      setSymmetric(xi == xj);
518
    }
519

520
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
521
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
522
    {
523
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
524
      for (int iq = 0; iq < nPoints; iq++)
525
	lalt_kl(Lambda, xi, xj, *(LALt[iq]), (*factor));
526
    }
527
528
529
530

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
531
    void eval(int nPoints,
532
533
534
535
536
537
	      const double              *,
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double fac) const
    {
538
539
      if (D2UhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
540
	  result[iq] += (*factor) * D2UhAtQP[iq][xi][xj] * fac;
541
    }
542
543
544
545

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
546
    void weakEval(int nPoints,
547
548
549
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
550
551
      if (grdUhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
552
	  result[iq][xi] += (*factor) * grdUhAtQP[iq][xj];
553
    }
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576

  private:
    /** \brief
     * Directions for the derivatives.
     */
    int xi, xj;

    /** \brief
     * Pointer to the factor.
     */
    double *factor;
  };

  /**
   * \ingroup Assembler
   *  
   * \brief
   * Laplace operator multiplied with a function evaluated at the quadrature
   * points of a given DOFVector:
   * \f$ f(v(\vec{x})) \Delta u(\vec{x}) \f$
   */
  class VecAtQP_SOT : public SecondOrderTerm {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
577
578
    /// Constructor.
    VecAtQP_SOT(DOFVectorBase<double> *dv, AbstractFunction<double, double> *af);
579

Thomas Witkowski's avatar
Thomas Witkowski committed
580
    /// Implementation of \ref OperatorTerm::initElement().
581
582
583
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
		     Quadrature *quad = NULL);

Thomas Witkowski's avatar
Thomas Witkowski committed
584
585
586
587
588
    /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes.
    void initElement(const ElInfo* smallElInfo,
		     const ElInfo* largeElInfo,
		     SubAssembler* subAssembler,
		     Quadrature *quad = NULL);
589

Thomas Witkowski's avatar
Thomas Witkowski committed
590
591
592
593
594
595
    /// Implements SecondOrderTerm::getLALt().
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;    

    /// Implenetation of SecondOrderTerm::eval().
    void eval(int nPoints,
	      const double *uhAtQP,
596
597
598
599
600
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

Thomas Witkowski's avatar
Thomas Witkowski committed
601
602
    /// Implenetation of SecondOrderTerm::weakEval().
    void weakEval(int nPoints,
603
604
605
606
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
607
    /// DOFVector to be evaluated at quadrature points.
608
609
    DOFVectorBase<double>* vec;

Thomas Witkowski's avatar
Thomas Witkowski committed
610
    /// Pointer to an array containing the DOFVector evaluated at quadrature points.
611
612
    double* vecAtQPs;

Thomas Witkowski's avatar
Thomas Witkowski committed
613
    /// Function evaluated at \ref vecAtQPs.
614
615
616
    AbstractFunction<double, double> *f;
  };

617
618
619
620
621
622
623
624
625
626
  /**
   * \ingroup Assembler
   *  
   * \brief
   * Laplace operator multiplied with a function evaluated at the quadrature
   * points of a given DOFVector:
   * \f$ f(v(\vec{x}), w(\vec{x})) \Delta u(\vec{x}) \f$
   */
  class Vec2AtQP_SOT : public SecondOrderTerm {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
627
    /// Constructor.
628
    Vec2AtQP_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, 
Thomas Witkowski's avatar
Thomas Witkowski committed
629
		 BinaryAbstractFunction<double, double, double> *af);
630

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

635
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
636
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;    
637
    
638
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
639
    void eval(int nPoints,
640
641
642
643
644
645
	      const double *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;
    
646
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
647
    void weakEval(int nPoints,
648
649
650
651
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;
    
  protected:
652
    /// DOFVector to be evaluated at quadrature points.
653
654
655
    DOFVectorBase<double>* vec1;
    DOFVectorBase<double>* vec2;
    
656
    /// Pointer to an array containing the DOFVector evaluated at quadrature points.
657
658
659
    double* vecAtQPs1;
    double* vecAtQPs2;
    
660
    /// Function evaluated at \ref vecAtQPs.
661
662
663
    BinaryAbstractFunction<double, double, double> *f;
  };

664
665
666
667
668
669
670
671
672
  /**
   * \ingroup Assembler
   * 
   * \brief
   * Laplace multiplied with a function evaluated at each quadrature point:
   * \f$ f(\vec{x}) \Delta u(\vec{x}) \f$
   */
  class CoordsAtQP_SOT : public SecondOrderTerm {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
673
674
675
    /// Constructor.
    CoordsAtQP_SOT(AbstractFunction<double, WorldVector<double> > *af)
      : SecondOrderTerm(af->getDegree()), g(af)
676
677
    {
      setSymmetric(true);
Thomas Witkowski's avatar
Thomas Witkowski committed
678
    }
679
680
681
682
683
684
685
686
687
688

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
689
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;    
690
691
692
693

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
694
695
    void eval(int nPoints,
	      const double *uhAtQP,
696
697
698
699
700
701
702
703
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
704
    void weakEval(int nPoints,
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;


  protected:
    /** \brief
     * Stores coordinates at quadrature points. Set in \ref initElement().
     */
    WorldVector<double>* coordsAtQPs;

    /** \brief
     * Function evaluated at quadrature points.
     */
    AbstractFunction<double, WorldVector<double> > *g;
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * SecondOrderTerm where A is a function which maps the gradient of a 
   * DOFVector at each quadrature point to WorldMatrix<double>:
   * \f$ \nabla \cdot A(\nabla v(\vec{x})) \nabla u(\vec{x})\f$
   */
  class MatrixGradient_SOT : public SecondOrderTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
732
    /// Constructor.
733
    MatrixGradient_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
734
735
736
		       AbstractFunction<WorldMatrix<double>, WorldVector<double> > *af,
		       AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
		       bool symm = false);
737
738
739
740
741
742
743
744
745
746

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
747
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
748
749
750
751

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
752
753
    void eval(int nPoints,
	      const double *uhAtQP,
754
755
756
757
758
759
760
761
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
762
    void weakEval(int nPoints,
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    DOFVectorBase<double>* vec;

    /** \brief
     * Function which maps each entry in \ref gradAtQPs to a WorldMatrix<double>.
     */
    AbstractFunction<WorldMatrix<double>, WorldVector<double> > *f;

    AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divFct;

    /** \brief
     * Pointer to a WorldVector<double> array containing the gradients of the DOFVector
     * at each quadrature point.
     */
    WorldVector<double>* gradAtQPs;

    /** \brief
     * True, if \ref f provides always a symmetric WorldMatrix<double>.
     */
    bool symmetric;
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * Laplace multiplied with a function which maps the gradient of a DOFVector
   * at each quadrature point to a double:
   * \f$ f(\nabla v(\vec{x})) \Delta u(\vec{x}) \f$
   */
  class FctGradient_SOT : public SecondOrderTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
799
800
801
    /// Constructor.
    FctGradient_SOT(DOFVectorBase<double> *dv,  
		    AbstractFunction<double, WorldVector<double> > *af);
802
803
804
805
806
807
808
809
810
811

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
812
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
813
814
815
816

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
817
818
    void eval(int nPoints,
	      const double *uhAtQP,
819
820
821
822
823
824
825
826
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
827
    void weakEval(int nPoints,
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    DOFVectorBase<double>* vec;

    /** \brief
     * Function wich maps \ref gradAtQPs to a double.
     */
    AbstractFunction<double, WorldVector<double> > *f;

    /** \brief
     * Pointer to a WorldVector<double> array containing the gradients of the DOFVector
     * at each quadrature point.
     */
    WorldVector<double>* gradAtQPs;
  };


  /**
   * \ingroup Assembler
   *
   * \brief
   * Laplace multiplied with a function which maps the gradient of a DOFVector
   * at each quadrature point to a double:
   * \f$ f(\nabla v(\vec{x})) \Delta u(\vec{x}) \f$
   */
  class VecAndGradientAtQP_SOT : public SecondOrderTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
858
    /// Constructor.
859
    VecAndGradientAtQP_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
860
			   BinaryAbstractFunction<double, double, WorldVector<double> > *af);
861
862
863
864
865
866
867
868
869
870

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
871
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
872
873
874
875

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
876
877
    void eval(int nPoints,
	      const double *uhAtQP,
878
879
880
881
882
883
884
885
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
886
    void weakEval(int nPoints,
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    DOFVectorBase<double>* vec;

    /** \brief
     * Function wich maps \ref gradAtQPs to a double.
     */
    BinaryAbstractFunction<double, double, WorldVector<double> > *f;

    /** \brief
     * Pointer to a WorldVector<double> array containing the gradients of the DOFVector
     * at each quadrature point.
     */
    double* vecAtQPs;
    WorldVector<double>* gradAtQPs;
  };

906
907
908
909
910
911
912
913
914
915
916
  /**
   * \ingroup Assembler
   *
   * \brief
   * Laplace multiplied with a function which maps the gradient of a DOFVector
   * at each quadrature point to a double:
   * \f$ \nabla \cdot A(v(\vec{x}), \nabla v(\vec{x})) \nabla u(\vec{x}) \f$
   */
  class VecMatrixGradientAtQP_SOT : public SecondOrderTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
917
    /// Constructor.
918
    VecMatrixGradientAtQP_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
919
920
921
			      BinaryAbstractFunction<WorldMatrix<double>, double, WorldVector<double> > *af,
			      AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
			      bool symm = false);
922
923
924
925
926
927
928
929
930
931

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
932
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
933
934
935
936

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
937
938
    void eval(int nPoints,
	      const double *uhAtQP,
939
940
941
942
943
944
945
946
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
947
    void weakEval(int nPoints,
948
949
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;
Thomas Witkowski's avatar
Thomas Witkowski committed
950
    
951
952
  protected:
    DOFVectorBase<double>* vec;
Thomas Witkowski's avatar
Thomas Witkowski committed
953
    
954
955
956
957
958
    /** \brief
     * Function wich maps \ref gradAtQPs to a double.
     */
    BinaryAbstractFunction<WorldMatrix<double>, 
			   double, WorldVector<double> > *f;
Thomas Witkowski's avatar
Thomas Witkowski committed
959
960
961
962
963
964
965
966
967
968
969
970
    
    AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divFct;
    
    /** \brief
     * Pointer to a WorldVector<double> array containing the gradients of the DOFVector
     * at each quadrature point.
     */
    double* vecAtQPs;
    WorldVector<double>* gradAtQPs;
    
    bool symmetric;
  };
971
972
973
974
975
976
977
978
979
980
981
982

  /**
   * \ingroup Assembler
   *
   * \brief
   * Laplace multiplied with a function which maps the gradient of a DOFVector
   * at each quadrature point to a double:
   * \f$ f(\nabla v(\vec{x})) \Delta u(\vec{x}) \f$
   */
  class VecGradCoordsAtQP_SOT : public SecondOrderTerm
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
983
    /// Constructor.
984
985
    VecGradCoordsAtQP_SOT(DOFVectorBase<double> *dv,
			  TertiaryAbstractFunction<double, double,
Thomas Witkowski's avatar
Thomas Witkowski committed
986
			  WorldVector<double>, WorldVector<double> > *af);
987
988
989
990
991
992
993
994
995
996

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
997
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
998
999
1000

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
For faster browsing, not all history is shown. View entire blame