Operator.h 105 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file Operator.h */

#ifndef AMDIS_OPERATOR_H
#define AMDIS_OPERATOR_H

#include <vector>
#include "FixVec.h"
#include "Flag.h"
#include "MemoryManager.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

namespace AMDiS {

  class Assembler;
  class ElInfo;
  class FiniteElemSpace;
  class Operator;
  class SubAssembler;
  class ElementMatrix;
  class ElementVector;
  class Quadrature;
  template<typename T> class DOFVectorBase;

  // ============================================================================
  // ===== class OperatorTerm ===================================================
  // ============================================================================

  /** 
   * \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:
    MEMORY_MANAGED(OperatorTerm);

    /** \brief
     * Constructs an OperatorTerm with initially no properties.
     * degree_ is used to determine the degree of the needed quadrature
     * for the assemblage.  
     */
    OperatorTerm(int degree_) 
      : properties(0), 
	degree(degree_) 
73
    {}
74
75
76
77

    /** \brief
     * Destructor.
     */
78
79
    virtual ~OperatorTerm() 
    {}
80
81
82
83
84
85
86

    /** \brief
     * Virtual method. It's called by SubAssembler::initElement() for
     * each OperatorTerm belonging to this SubAssembler. Here e.g. vectors
     * and coordinates at quadrature points can be calculated.
     */
    virtual void initElement(const ElInfo*, 
Thomas Witkowski's avatar
Thomas Witkowski committed
87
88
			     SubAssembler*,
			     Quadrature *quad = NULL) 
89
    {}
90
91
92
93
94
95
96
97
98

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

    /** \brief
     * Returns true, if the term is piecewise constant, returns false otherwise
     */
99
100
    inline bool isPWConst() { 
      return (degree == 0);
101
    }
102
103
104
105
106
107
108
109
110
111

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

    /** \brief
     * Returns \ref degree.
     */
112
113
    inline int getDegree() { 
      return degree; 
114
    }
115
116
117
118

    /** \brief
     * Evaluation of the OperatorTerm at all quadrature points.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
119
120
    virtual void eval(int nPoints,
		      const double *uhAtQP,
121
122
		      const WorldVector<double> *grdUhAtQP,
		      const WorldMatrix<double> *D2UhAtQP,
Thomas Witkowski's avatar
Thomas Witkowski committed
123
		      double *result,
124
125
126
127
128
129
130
		      double factor) const = 0;

  protected:
    /** \brief
     * Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$.
     */
    static void lalt(const DimVec<WorldVector<double> >& Lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
131
132
133
134
		     const WorldMatrix<double>& matrix,
		     DimMat<double>& LALt,
		     bool symm,
		     double factor);
135
136
137
138
139
140
141
142

    /** \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
143
144
			DimMat<double>& LALt,
			double factor);
145
146
147
148
149
150

    /** \brief
     * Evaluation of \f$ \Lambda \cdot A \cdot \Lambda^t\f$ for A equal to the 
     * identity.
     */
    static void l1lt(const DimVec<WorldVector<double> >& Lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
151
152
		     DimMat<double>& LALt,
		     double factor);
153
154
155
156
157

    /** \brief
     * Evaluation of \f$ \Lambda \cdot b\f$.
     */
    static void lb(const DimVec<WorldVector<double> >& Lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
158
159
160
		   const WorldVector<double>& b,
		   DimVec<double>& Lb,
		   double factor);
161
162
163
164
165
166

    /** \brief
     * Evaluation of \f$ \Lambda \cdot b\f$ if b contains the value 1.0 in
     * each component.
     */
    static void l1(const DimVec<WorldVector<double> >& Lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
167
168
		   DimVec<double>& Lb,
		   double factor)
169
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
170
171
      int dim = Lb.getSize() - 1;
      static const int dimOfWorld = Global::getGeo(WORLD);
172
173
174
175
176
177
178
179
180
181

      for (int i = 0; i <= dim; i++) {
	double val = 0.0;
      
	for (int j = 0; j < dimOfWorld; j++) {
	  val += Lambda[i][j];
	}
	val *= factor;
	Lb[i] += val;
      }    
182
    }
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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

  protected:
    /** \brief
     * Stores the properties of this OperatorTerm
     */
    Flag properties;

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

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

    /** \brief
     * Constant Flag for piecewise constant terms
     */
    static const Flag PW_CONST;

    /** \brief
     * Constant Flag for symmetric terms
     */
    static const Flag SYMMETRIC;

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

  // ============================================================================
  // =====  class SecondOrderTerm ===============================================
  // ============================================================================

  /**
   * \ingroup Assembler
   * 
   * \brief
   * Describes the second order terms: \f$ \nabla \cdot A \nabla u(\vec{x}) \f$
   */
  class SecondOrderTerm : public OperatorTerm
  {
  public:
    /** \brief
     * Constructor.
     */
234
235
236
    SecondOrderTerm(int deg) 
      : OperatorTerm(deg) 
    {}
237
238
239
240

    /** \brief
     * Destructor.
     */
241
242
    virtual ~SecondOrderTerm() 
    {}
243
244
245
246
247

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

    /** \brief
     * Evaluation of \f$ A \nabla u(\vec{x}) \f$ at all quadrature points.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
254
    virtual void weakEval(int nPoints,
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
			  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:
    /** \brief
     * Constructor.
     */
    Laplace_SOT() 
      : SecondOrderTerm(0) 
    {
      setSymmetric(true);
278
    }
279
280
281
282
283
284
285
286
287
288
289

    /** \brief
     * Implenetation of SecondOrderTerm::getLALt().
     */
    inline void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const
    {
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();

      for (int iq = 0; iq < numPoints; iq++) {
	l1lt(Lambda, *(LALt[iq]), 1.0);
      }
290
    }
291
292
293
294

    /** \brief
     * Implementation of SecondOrderTerm::eval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
295
296
297
298
299
300
    inline void eval(int nPoints,
		     const double * ,    // uhAtQP
		     const WorldVector<double> * ,  // grdUhAtQP
		     const WorldMatrix<double> *D2UhAtQP,
		     double *result,
		     double factor) const
301
302
303
304
    {
      int dow = Global::getGeo(WORLD);
    
      if (D2UhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
305
	for (int iq = 0; iq < nPoints; iq++) {
306
307
308
309
310
311
312
	  double resultQP = 0.0;
	  for (int i = 0; i < dow; i++) {
	    resultQP += D2UhAtQP[iq][i][i];
	  }
	  result[iq] += factor * resultQP;
	}
      }
313
    }
314
315
316
317

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
318
    void weakEval(int nPoints,
319
320
321
322
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
      if (grdUhAtQP) {
Thomas Witkowski's avatar
Thomas Witkowski committed
323
	for (int iq = 0; iq < nPoints; iq++) { 
324
325
326
	  result[iq] += grdUhAtQP[iq];
	}
      }
327
328
    }
  };
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

  // ============================================================================

  /**
   * \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:
    /** \brief
     * Constructor.
     */
    FactorLaplace_SOT(double f) 
346
347
      : SecondOrderTerm(0)  
    {
348
349
350
351
      factor = new double;
      *factor = f;

      setSymmetric(true);
352
    }
353
354
355
356
357

    /** \brief
     * Constructor.
     */
    FactorLaplace_SOT(double *fptr) 
358
359
      : SecondOrderTerm(0), 
	factor(fptr)
360
361
    {
      setSymmetric(true);
362
    }
363
364
365
366
367
368

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    inline void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const
    {
369
370
      const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
      for (int iq = 0; iq < numPoints; iq++) 
371
	l1lt(Lambda, *(LALt[iq]), (*factor));
372
    }
373
374
375
376
377
378


    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
379
	      const double *,
380
381
382
383
384
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double f) const
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
385
      int dow = Global::getGeo(WORLD);
386

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

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
405
406
      if (grdUhAtQP) {
	for (int iq = 0; iq < numPoints; iq++) {
407
408
409
	  axpy(*factor, grdUhAtQP[iq], result[iq]);
	}
      }
410
    }
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445

  private:
    /** \brief
     * Pointer to the factor.
     */
    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:
    /** \brief
     * Constructor.
     */
    MatrixFct_SOT(DOFVectorBase<double> *dv, 
		  AbstractFunction<WorldMatrix<double>, double> *fct,
		  AbstractFunction<WorldVector<double>, WorldMatrix<double> > *div,
		  bool sym = false)
      : SecondOrderTerm(fct->getDegree()), 
	vec(dv), 
	matrixFct(fct), 
	divFct(div),
	symmetric(sym)
    {
      setSymmetric(symmetric);
446
    }
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;
  
    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    /** \brief
     * DOFVector to be evaluated at quadrature points.
     */
    DOFVectorBase<double>* vec;

    /** \brief
     * Pointer to the values of the DOFVector at quadrature points.
     */
    double* vecAtQPs;

    /** \brief
     * Function for A.
     */
    AbstractFunction<WorldMatrix<double>, double>* matrixFct;

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

    /** \brief
     * True, if \ref matrixFct produces always symmetric matrices.
     */
    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:
    /** \brief
     * Constructor
     */
    Matrix_SOT(WorldMatrix<double> mat) 
515
516
      : SecondOrderTerm(0),
	matrix(mat)
517
518
519
    {
      symmetric = matrix.isSymmetric();
      setSymmetric(symmetric);
520
    }
521
522
523
524
525
526
527
528
529
530

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    inline void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const{
      const DimVec<WorldVector<double> >& Lambda     = elInfo->getGrdLambda();
      //double det = elInfo->getDet();
      int iq;
      for(iq = 0; iq < numPoints; iq++) 
	lalt(Lambda, matrix, *(LALt[iq]), symmetric, 1.0);
531
    }
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
  
    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    /** \brief
     * Matrix stroring A.
     */
    WorldMatrix<double> matrix;

    /** \brief
     * True, if \ref matrix is symmetric.
     */
    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:
    /** \brief
     * Constructor.
     */
    FactorIJ_SOT(int x_i, int x_j, double f) 
579
580
581
      : SecondOrderTerm(0), 
	xi(x_i), 
	xj(x_j)
582
583
584
585
586
    {
      factor = new double;
      *factor = f;

      setSymmetric(xi == xj);
587
    }
588
589
590
591
592

    /** \brief
     * Constructor.
     */
    FactorIJ_SOT(int x_i, int x_j, double *fptr) 
593
594
595
596
      : SecondOrderTerm(0), 
	xi(x_i), 
	xj(x_j), 
	factor(fptr)
597
598
    {
      setSymmetric(xi == xj);
599
    }
600
601
602
603
604
605
606
607
608
609

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    inline void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const
    {
      const DimVec<WorldVector<double> > &Lambda     = elInfo->getGrdLambda();
      int iq;
      for(iq = 0; iq < numPoints; iq++)
	lalt_kl(Lambda, xi, xj, *(LALt[iq]), (*factor));
610
    }
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *,
	      const WorldVector<double> *,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double fac) const
    {
      int iq;
      if(D2UhAtQP) {
	for(iq = 0; iq < numPoints; iq++) {
	  result[iq] += (*factor) * D2UhAtQP[iq][xi][xj] * fac;
	}
      }
628
    }
629
630
631
632
633
634
635
636
637
638
639
640
641
642

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const
    {
      if(grdUhAtQP) {
	int iq;
	for(iq = 0; iq < numPoints; iq++) {
	  result[iq][xi] += (*factor) * grdUhAtQP[iq][xj];
	}
      }
643
    }
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724

  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:
    /** \brief
     * Constructor.
     */
    VecAtQP_SOT(DOFVectorBase<double> *dv, 
		AbstractFunction<double, double> *f_)
      : SecondOrderTerm(f_->getDegree()), vec(dv), f(f_)
    {
      setSymmetric(true);
    };

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;    

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;

  protected:
    /** \brief
     * DOFVector to be evaluated at quadrature points.
     */
    DOFVectorBase<double>* vec;

    /** \brief
     * Pointer to an array containing the DOFVector evaluated at quadrature
     * points.
     */
    double* vecAtQPs;

    /** \brief
     * Function evaluated at \ref vecAtQPs.
     */
    AbstractFunction<double, double> *f;
  };

725
726
727
728
729
730
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
758
759
760
761
762
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
  /**
   * \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:
    /** \brief
     * Constructor.
     */
    Vec2AtQP_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, 
		 BinaryAbstractFunction<double, double, double> *f_)
      : SecondOrderTerm(f_->getDegree()), 
	vec1(dv1), 
	vec2(dv2), 
	f(f_)
    {
      setSymmetric(true);
    };

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;    
    
    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;
    
    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  const WorldVector<double> *grdUhAtQP,
		  WorldVector<double> *result) const;
    
  protected:
    /** \brief
     * DOFVector to be evaluated at quadrature points.
     */
    DOFVectorBase<double>* vec1;
    DOFVectorBase<double>* vec2;
    
    /** \brief
     * Pointer to an array containing the DOFVector evaluated at quadrature
     * points.
     */
    double* vecAtQPs1;
    double* vecAtQPs2;
    
    /** \brief
     * Function evaluated at \ref vecAtQPs.
     */
    BinaryAbstractFunction<double, double, double> *f;
  };

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
825
826
827
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
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
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
  // ============================================================================

  /**
   * \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:
    /** \brief
     * Constructor.
     */
    CoordsAtQP_SOT(AbstractFunction<double, WorldVector<double> > *g_)
      : SecondOrderTerm(g_->getDegree()), g(g_)
    {
      setSymmetric(true);
    };

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;    

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  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:
    /** \brief
     * Constructor.
     */
    MatrixGradient_SOT(DOFVectorBase<double> *dv,
		       AbstractFunction<WorldMatrix<double>, WorldVector<double> > *f_,
		       AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divFct_,
		       bool symm = false) 
      : SecondOrderTerm(f_->getDegree()), vec(dv), f(f_), divFct(divFct_), symmetric(symm)
    {
      setSymmetric(symmetric);
    };

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  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:
    /** \brief
     * Constructor.
     */
    FctGradient_SOT(DOFVectorBase<double> *dv,
		    AbstractFunction<double, WorldVector<double> > *f_)
      : SecondOrderTerm(f_->getDegree()), vec(dv), f(f_)
    {
    };

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

    /** \brief
     * Implements SecondOrderTerm::getLALt().
     */
    void getLALt(const ElInfo *elInfo, int numPoints, DimMat<double> **LALt) const;

    /** \brief
     * Implenetation of SecondOrderTerm::eval().
     */
    void eval(int numPoints,
	      const double              *uhAtQP,
	      const WorldVector<double> *grdUhAtQP,
	      const WorldMatrix<double> *D2UhAtQP,
	      double *result,
	      double factor) const;

    /** \brief
     * Implenetation of SecondOrderTerm::weakEval().
     */
    void weakEval(int numPoints,
		  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;
  };


  // Ergaenzung Andreas

  // ============================================================================
For faster browsing, not all history is shown. View entire blame