Operator.h 105 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
	degree(deg),
57
58
59
	dimOfWorld(Global::getGeo(WORLD)),
	auxFESpaces(0),
	bOne(-1)
60
    {}
61

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

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

73
74
    virtual void initElement(const ElInfo* largeElInfo, const ElInfo* smallElInfo,
			     SubAssembler*, 
Thomas Witkowski's avatar
Thomas Witkowski committed
75
76
77
78
			     Quadrature *quad = NULL)
    {}

    /// Returs \auxFESpaces, the list of all aux fe spaces the operator makes use off.
79
80
    std::vector<const FiniteElemSpace*>& getAuxFESpaces() 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
81
82
83
84
      return auxFESpaces;
    }

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

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

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

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

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

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

    /** \brief
Thomas Witkowski's avatar
Thomas Witkowski committed
117
118
     * Determines the value of a dof vector at the quadrature points of a given 
     * element. It is used by all VecAtQP like operator terms.
119
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
    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
137
    ///
Thomas Witkowski's avatar
Thomas Witkowski committed
138
139
140
141
142
    WorldVector<double>* getGradientsAtQPs(DOFVectorBase<double>* vec,
					   const ElInfo* elInfo,
					   SubAssembler* subAssembler,
					   Quadrature *quad);

Thomas Witkowski's avatar
Thomas Witkowski committed
143
    ///
Thomas Witkowski's avatar
Thomas Witkowski committed
144
145
146
147
148
149
150
151
    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$.
152
153
154
155
156
    void lalt(const DimVec<WorldVector<double> >& Lambda,
	      const WorldMatrix<double>& matrix,
	      DimMat<double>& LALt,
	      bool symm,
	      double factor) const;
157
158
159
160
161
162
163
164

    /** \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
165
166
			DimMat<double>& LALt,
			double factor);
167

168
    /// Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$ for A equal to the identity.
169
170
171
    void l1lt(const DimVec<WorldVector<double> >& Lambda, 
	      DimMat<double>& LALt,
	      double factor) const;
172

Thomas Witkowski's avatar
Thomas Witkowski committed
173
    /// Evaluation of \f$ \Lambda \cdot b\f$.
174
175
176
177
    inline void lb(const DimVec<WorldVector<double> >& Lambda,
		   const WorldVector<double>& b,
		   DimVec<double>& Lb,
		   double factor) const
178
    {
179
180
181
      const int dim = Lambda.size() - 1;

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

191
192
193
194
195
196
197
198
199
200
201
    /// Evaluation of \f$ \Lambda \cdot b\f$.
    inline void lb_one(const DimVec<WorldVector<double> >& Lambda,
		       DimVec<double>& Lb,
		       double factor) const
    {
      const int dim = Lambda.size();

      for (int i = 0; i < dim; i++)
	Lb[i] += Lambda[i][bOne] * factor;
    }

202
203
204
205
    /** \brief
     * Evaluation of \f$ \Lambda \cdot b\f$ if b contains the value 1.0 in 
     * each component.
     */
206
207
208
    inline void l1(const DimVec<WorldVector<double> >& Lambda,
		   DimVec<double>& Lb,
		   double factor) const
209
    {
210
      const int dim = Lambda.size() - 1;
211

212
      for (int i = 0; i <= dim; i++) {
213
214
	double val = 0.0;
      
215
	for (int j = 0; j < dimOfWorld; j++)
216
	  val += Lambda[i][j];
217

218
	Lb[i] += val * factor;
219
      }    
220
    }
221
222

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
223
    /// Stores the properties of this OperatorTerm
224
225
    Flag properties;

Thomas Witkowski's avatar
Thomas Witkowski committed
226
    /// Polynomial degree of the term. Used to detemine the degree of the quadrature.
227
228
    int degree;

229
230
231
    /// Stores the dimension of the world.
    int dimOfWorld;

Thomas Witkowski's avatar
Thomas Witkowski committed
232
233
234
235
    /// List off all fe spaces, the operator term makes use off.
    std::vector<const FiniteElemSpace*> auxFESpaces;

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

238
239
240
241
242
243
244
245
246
    /** \brief
     * 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.
     */
    int bOne;

Thomas Witkowski's avatar
Thomas Witkowski committed
247
    /// Flag for piecewise constant terms
248
249
    static const Flag PW_CONST;

Thomas Witkowski's avatar
Thomas Witkowski committed
250
    /// Flag for symmetric terms
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
    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
269
    /// Constructor.
270
271
272
    SecondOrderTerm(int deg) 
      : OperatorTerm(deg) 
    {}
273

274
    /// Destructor.
275
276
    virtual ~SecondOrderTerm() 
    {}
277

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

283
    /// Evaluation of \f$ A \nabla u(\vec{x}) \f$ at all quadrature points.
Thomas Witkowski's avatar
Thomas Witkowski committed
284
    virtual void weakEval(int nPoints,
285
286
287
288
289
290
291
292
293
294
295
296
297
298
			  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
299
    /// Constructor.
300
301
302
303
    Laplace_SOT() 
      : SecondOrderTerm(0) 
    {
      setSymmetric(true);
304
    }
305

306
    /// Implenetation of SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
307
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
308
309
310
    {
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();

311
      for (int iq = 0; iq < nPoints; iq++)
312
	l1lt(Lambda, *(LALt[iq]), 1.0);
313
    }
314

315
    /// Implementation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
316
    inline void eval(int nPoints,
317
318
		     const double *,
		     const WorldVector<double> *,
Thomas Witkowski's avatar
Thomas Witkowski committed
319
320
321
		     const WorldMatrix<double> *D2UhAtQP,
		     double *result,
		     double factor) const
322
323
324
325
    {
      int dow = Global::getGeo(WORLD);
    
      if (D2UhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
326
	for (int iq = 0; iq < nPoints; iq++) {
327
	  double resultQP = 0.0;
328
	  for (int i = 0; i < dow; i++) 
329
330
331
332
	    resultQP += D2UhAtQP[iq][i][i];
	  result[iq] += factor * resultQP;
	}
      }
333
    }
334

335
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
336
    void weakEval(int nPoints,
337
338
339
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
340
      if (grdUhAtQP)
341
	for (int iq = 0; iq < nPoints; iq++)
342
	  result[iq] += grdUhAtQP[iq];
343
344
    }
  };
345
346
347
348
349
350
351
352
353
354
355

  /**
   * \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
356
    /// Constructor.
357
    FactorLaplace_SOT(double f) 
358
359
      : SecondOrderTerm(0)  
    {
360
361
362
363
      factor = new double;
      *factor = f;

      setSymmetric(true);
364
    }
365

Thomas Witkowski's avatar
Thomas Witkowski committed
366
    /// Constructor.
367
    FactorLaplace_SOT(double *fptr) 
368
369
      : SecondOrderTerm(0), 
	factor(fptr)
370
371
    {
      setSymmetric(true);
372
    }
373

374
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
375
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
376
    {
377
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
Thomas Witkowski's avatar
Thomas Witkowski committed
378
      for (int iq = 0; iq < nPoints; iq++) 
379
	l1lt(Lambda, *(LALt[iq]), (*factor));
380
    }
381

382
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
383
    void eval(int nPoints,
384
	      const double *,
385
386
387
388
389
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double f) const
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
390
      int dow = Global::getGeo(WORLD);
391

Thomas Witkowski's avatar
Thomas Witkowski committed
392
      if (D2UhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
393
	for (int iq = 0; iq < nPoints; iq++) {
394
	  double resultQP = 0.0;
Thomas Witkowski's avatar
Thomas Witkowski committed
395
	  for (int i = 0; i < dow; i++) {
396
397
398
399
400
	    resultQP += D2UhAtQP[iq][i][i];
	  }
	  result[iq] += resultQP * f * (*factor);
	}
      }
401
    }
402

403
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
404
    void weakEval(int nPoints,
405
406
407
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
408
409
      if (grdUhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
410
	  axpy(*factor, grdUhAtQP[iq], result[iq]);
411
    }
412
413

  private:
414
    /// Pointer to the factor.
415
416
417
418
419
420
421
422
423
424
425
426
427
428
    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
429
    /// Constructor.
430
431
432
    MatrixFct_SOT(DOFVectorBase<double> *dv, 
		  AbstractFunction<WorldMatrix<double>, double> *fct,
		  AbstractFunction<WorldVector<double>, WorldMatrix<double> > *div,
Thomas Witkowski's avatar
Thomas Witkowski committed
433
		  bool sym = false);
434

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

439
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
440
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
441
  
442
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
443
444
    void eval(int nPoints,
	      const double *uhAtQP,
445
446
447
448
449
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

450
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
451
    void weakEval(int nPoints,
452
453
454
455
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
456
    /// DOFVector to be evaluated at quadrature points.
457
458
    DOFVectorBase<double>* vec;

459
    /// Pointer to the values of the DOFVector at quadrature points.
460
461
    double* vecAtQPs;

462
    /// Function for A.
463
464
    AbstractFunction<WorldMatrix<double>, double>* matrixFct;

465
    ///
466
467
    AbstractFunction<WorldVector<double>, WorldMatrix<double> >* divFct;

468
    /// True, if \ref matrixFct produces always symmetric matrices.
469
470
471
472
473
474
475
476
477
478
479
480
    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
481
    /// Constructor
482
    Matrix_SOT(WorldMatrix<double> mat) 
Thomas Witkowski's avatar
Thomas Witkowski committed
483
      : SecondOrderTerm(0), matrix(mat)
484
485
486
    {
      symmetric = matrix.isSymmetric();
      setSymmetric(symmetric);
487
    }
488

489
    /// Implements SecondOrderTerm::getLALt().
490
491
492
493
    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++) 
494
	lalt(Lambda, matrix, *(LALt[iq]), symmetric, 1.0);
495
    }
496
  
497
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
498
499
    void eval(int nPoints,
	      const double *uhAtQP,
500
501
502
503
504
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

505
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
506
    void weakEval(int nPoints,
507
508
509
510
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
511
    /// Matrix stroring A.
512
513
    WorldMatrix<double> matrix;

514
    /// True, if \ref matrix is symmetric.
515
516
517
518
519
520
521
522
523
524
525
526
527
528
    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
529
    /// Constructor.
530
    FactorIJ_SOT(int x_i, int x_j, double f) 
Thomas Witkowski's avatar
Thomas Witkowski committed
531
      : SecondOrderTerm(0), xi(x_i), xj(x_j)
532
533
534
535
536
    {
      factor = new double;
      *factor = f;

      setSymmetric(xi == xj);
537
    }
538

Thomas Witkowski's avatar
Thomas Witkowski committed
539
    /// Constructor.
540
    FactorIJ_SOT(int x_i, int x_j, double *fptr) 
Thomas Witkowski's avatar
Thomas Witkowski committed
541
      : SecondOrderTerm(0), xi(x_i), xj(x_j), factor(fptr)
542
543
    {
      setSymmetric(xi == xj);
544
    }
545

546
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
547
    inline void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const
548
    {
549
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
550
      for (int iq = 0; iq < nPoints; iq++)
551
	lalt_kl(Lambda, xi, xj, *(LALt[iq]), (*factor));
552
    }
553
554
555
556

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
557
    void eval(int nPoints,
558
559
560
561
562
563
	      const double              *,
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double fac) const
    {
564
565
      if (D2UhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
566
	  result[iq] += (*factor) * D2UhAtQP[iq][xi][xj] * fac;
567
    }
568
569
570
571

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
572
    void weakEval(int nPoints,
573
574
575
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
576
577
      if (grdUhAtQP)
	for (int iq = 0; iq < nPoints; iq++)
578
	  result[iq][xi] += (*factor) * grdUhAtQP[iq][xj];
579
    }
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602

  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
603
604
    /// Constructor.
    VecAtQP_SOT(DOFVectorBase<double> *dv, AbstractFunction<double, double> *af);
605

Thomas Witkowski's avatar
Thomas Witkowski committed
606
    /// Implementation of \ref OperatorTerm::initElement().
607
608
609
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
		     Quadrature *quad = NULL);

Thomas Witkowski's avatar
Thomas Witkowski committed
610
611
612
613
614
    /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes.
    void initElement(const ElInfo* smallElInfo,
		     const ElInfo* largeElInfo,
		     SubAssembler* subAssembler,
		     Quadrature *quad = NULL);
615

Thomas Witkowski's avatar
Thomas Witkowski committed
616
617
618
619
620
621
    /// 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,
622
623
624
625
626
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

Thomas Witkowski's avatar
Thomas Witkowski committed
627
628
    /// Implenetation of SecondOrderTerm::weakEval().
    void weakEval(int nPoints,
629
630
631
632
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

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

Thomas Witkowski's avatar
Thomas Witkowski committed
636
    /// Pointer to an array containing the DOFVector evaluated at quadrature points.
637
638
    double* vecAtQPs;

Thomas Witkowski's avatar
Thomas Witkowski committed
639
    /// Function evaluated at \ref vecAtQPs.
640
641
642
    AbstractFunction<double, double> *f;
  };

643
644
645
646
647
648
649
650
651
652
  /**
   * \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
653
    /// Constructor.
654
    Vec2AtQP_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, 
Thomas Witkowski's avatar
Thomas Witkowski committed
655
		 BinaryAbstractFunction<double, double, double> *af);
656

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

661
    /// Implements SecondOrderTerm::getLALt().
Thomas Witkowski's avatar
Thomas Witkowski committed
662
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;    
663
    
664
    /// Implenetation of SecondOrderTerm::eval().
Thomas Witkowski's avatar
Thomas Witkowski committed
665
    void eval(int nPoints,
666
667
668
669
670
671
	      const double *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;
    
672
    /// Implenetation of SecondOrderTerm::weakEval().
Thomas Witkowski's avatar
Thomas Witkowski committed
673
    void weakEval(int nPoints,
674
675
676
677
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;
    
  protected:
678
    /// DOFVector to be evaluated at quadrature points.
679
680
681
    DOFVectorBase<double>* vec1;
    DOFVectorBase<double>* vec2;
    
682
    /// Pointer to an array containing the DOFVector evaluated at quadrature points.
683
684
685
    double* vecAtQPs1;
    double* vecAtQPs2;
    
686
    /// Function evaluated at \ref vecAtQPs.
687
688
689
    BinaryAbstractFunction<double, double, double> *f;
  };

690
691
692
693
694
695
696
697
698
  /**
   * \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
699
700
701
    /// Constructor.
    CoordsAtQP_SOT(AbstractFunction<double, WorldVector<double> > *af)
      : SecondOrderTerm(af->getDegree()), g(af)
702
703
    {
      setSymmetric(true);
Thomas Witkowski's avatar
Thomas Witkowski committed
704
    }
705
706
707
708
709
710
711
712
713
714

    /** \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
715
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;    
716
717
718
719

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
720
721
    void eval(int nPoints,
	      const double *uhAtQP,
722
723
724
725
726
727
728
729
	      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
730
    void weakEval(int nPoints,
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
		  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
758
    /// Constructor.
759
    MatrixGradient_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
760
761
762
		       AbstractFunction<WorldMatrix<double>, WorldVector<double> > *af,
		       AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
		       bool symm = false);
763
764
765
766
767
768
769
770
771
772

    /** \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
773
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
774
775
776
777

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
778
779
    void eval(int nPoints,
	      const double *uhAtQP,
780
781
782
783
784
785
786
787
	      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
788
    void weakEval(int nPoints,
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
		  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
825
826
827
    /// Constructor.
    FctGradient_SOT(DOFVectorBase<double> *dv,  
		    AbstractFunction<double, WorldVector<double> > *af);
828
829
830
831
832
833
834
835
836
837

    /** \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
838
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
839
840
841
842

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
843
844
    void eval(int nPoints,
	      const double *uhAtQP,
845
846
847
848
849
850
851
852
	      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
853
    void weakEval(int nPoints,
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
		  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
884
    /// Constructor.
885
    VecAndGradientAtQP_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
886
			   BinaryAbstractFunction<double, double, WorldVector<double> > *af);
887
888
889
890
891
892
893
894
895
896

    /** \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
897
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
898
899
900
901

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
902
903
    void eval(int nPoints,
	      const double *uhAtQP,
904
905
906
907
908
909
910
911
	      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
912
    void weakEval(int nPoints,
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
		  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;
  };

932
933
934
935
936
937
938
939
940
941
942
  /**
   * \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
943
    /// Constructor.
944
    VecMatrixGradientAtQP_SOT(DOFVectorBase<double> *dv,
Thomas Witkowski's avatar
Thomas Witkowski committed
945
946
947
			      BinaryAbstractFunction<WorldMatrix<double>, double, WorldVector<double> > *af,
			      AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
			      bool symm = false);
948
949
950
951
952
953
954
955
956
957

    /** \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
958
    void getLALt(const ElInfo *elInfo, int nPoints, DimMat<double> **LALt) const;
959
960
961
962

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
963
964
    void eval(int nPoints,
	      const double *uhAtQP,
965
966
967
968
969
970
971
972
	      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
973
    void weakEval(int nPoints,
974
975
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;
Thomas Witkowski's avatar
Thomas Witkowski committed
976
    
977
978
  protected:
    DOFVectorBase<double>* vec;
Thomas Witkowski's avatar
Thomas Witkowski committed
979
    
980
981
982
983
984
    /** \brief
     * Function wich maps \ref gradAtQPs to a double.
     */
    BinaryAbstractFunction<WorldMatrix<double>, 
			   double, WorldVector<double> > *f;
Thomas Witkowski's avatar
Thomas Witkowski committed
985
986
987
988
989
990
991
992
993
994
995
996
    
    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;
  };
997
998
999
1000

  /**
   * \ingroup Assembler
   *
For faster browsing, not all history is shown. View entire blame