Operator.cc 98 KB
Newer Older
1
2
3
4
5
6
#include "Operator.h"
#include "ElInfo.h"
#include "Assembler.h"
#include "FixVec.h"
#include "DOFVector.h"
#include "Quadrature.h"
7
#include "OpenMP.h"
8
9
10
11
12
13
14
15
16
17
18
19

namespace AMDiS {

  const Flag OperatorTerm::PW_CONST = 1;
  const Flag OperatorTerm::SYMMETRIC = 2;

  const Flag Operator::MATRIX_OPERATOR = 1;
  const Flag Operator::VECTOR_OPERATOR = 2;


  int Operator::getQuadratureDegree(int order, FirstOrderType firstOrderType) 
  {
20
    std::vector<OperatorTerm*>* terms = NULL;
21
    int myRank = omp_get_thread_num();
22
23
24

    switch(order) {
    case 0:
25
      terms = &zeroOrder[myRank];
26
27
28
      break;
    case 1:
      if (firstOrderType == GRD_PHI)
29
	terms = &firstOrderGrdPhi[myRank];
30
      else 
31
	terms = &firstOrderGrdPsi[myRank];
32
33
      break;
    case 2:
34
      terms = &secondOrder[myRank];
35
36
37
38
39
40
41
42
43
44
      break;
    }

    const BasisFunction *psi = rowFESpace->getBasisFcts();
    const BasisFunction *phi = colFESpace->getBasisFcts();

    int psiDegree = psi->getDegree();
    int phiDegree = phi->getDegree();
    int maxTermDegree = 0;

Thomas Witkowski's avatar
Thomas Witkowski committed
45
    for (int i = 0; i < static_cast<int>(terms->size()); i++) {
46
47
48
      OperatorTerm *term = (*terms)[i];
      maxTermDegree = max(maxTermDegree, term->degree);
    }
49
50
   
    return psiDegree + phiDegree - order + maxTermDegree;
51
52
53
54
55
  }


  void OperatorTerm::setSymmetric(bool symm)
  {
56
    if (symm)
57
      properties.setFlag(SYMMETRIC);
58
59
    else
      properties.unsetFlag(SYMMETRIC);       
60
61
62
63
64
65
66
  }

  bool OperatorTerm::isSymmetric()
  {
    return properties.isSet(SYMMETRIC);
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
67
68
69
70
71
72
73
  double *OperatorTerm::getVectorAtQPs(DOFVectorBase<double>* vec,
				       const ElInfo* elInfo, 
				       SubAssembler* subAssembler,
				       Quadrature *quad)
  {
    FUNCNAME("OperatorTerm::getVectorAtQPs()");

74
    TEST_EXIT_DBG(elInfo->getMesh() == vec->getFESpace()->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
      ("There is something wrong!\n");
      
    return subAssembler->getVectorAtQPs(vec, elInfo, quad);
  }

  double *OperatorTerm::getVectorAtQPs(DOFVectorBase<double>* vec,
				       const ElInfo* smallElInfo, 
				       const ElInfo* largeElInfo, 
				       SubAssembler* subAssembler,
				       Quadrature *quad)
  {
    FUNCNAME("OperatorTerm::getVectorAtQPs()");

    TEST_EXIT(smallElInfo->getMesh() == vec->getFESpace()->getMesh() ||
	      largeElInfo->getMesh() == vec->getFESpace()->getMesh())
      ("There is something wrong!\n");

    if (smallElInfo->getLevel() == largeElInfo->getLevel()) {

      // Both elements have the same size, so we can use the simple procedure
      // to determine the vecAtQPs.
      
97
      if (vec->getFESpace()->getMesh() == smallElInfo->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
98
	return subAssembler->getVectorAtQPs(vec, smallElInfo, quad);
99
100
      else
	return subAssembler->getVectorAtQPs(vec, largeElInfo, quad);      
Thomas Witkowski's avatar
Thomas Witkowski committed
101
102
103
104
105
106

    } else {

      // The two elements are different. If the vector is defined on the mesh of the
      // small element, we can still use the simple procedure to determine the vecAtQPs.

107
      if (vec->getFESpace()->getMesh() == largeElInfo->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
108
	return subAssembler->getVectorAtQPs(vec, smallElInfo, largeElInfo, quad);
109
      else
Thomas Witkowski's avatar
Thomas Witkowski committed
110
111
112
113
114
115
116
117
118
119
120
	return subAssembler->getVectorAtQPs(vec, smallElInfo, quad);
    }
  }

  WorldVector<double>* OperatorTerm::getGradientsAtQPs(DOFVectorBase<double>* vec,
						       const ElInfo* elInfo,
						       SubAssembler* subAssembler,
						       Quadrature *quad)
  {
    FUNCNAME("OperatorTerm::getGradientsAtQPs()");

Thomas Witkowski's avatar
Thomas Witkowski committed
121
    TEST_EXIT_DBG(elInfo->getMesh() == vec->getFESpace()->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
122
123
124
125
126
127
128
129
130
131
132
133
134
      ("There is something wrong!\n");

    return subAssembler->getGradientsAtQPs(vec, elInfo, quad);
  }

  WorldVector<double>* OperatorTerm::getGradientsAtQPs(DOFVectorBase<double>* vec,
						       const ElInfo* smallElInfo, 
						       const ElInfo* largeElInfo,
						       SubAssembler* subAssembler,
						       Quadrature *quad)
  {
    FUNCNAME("OperatorTerm::getGradientsAtQPs()");

135
136
    ERROR_EXIT("Not yet tested!\n");

Thomas Witkowski's avatar
Thomas Witkowski committed
137
138
139
140
141
142
143
144
145
    TEST_EXIT(smallElInfo->getMesh() == vec->getFESpace()->getMesh() ||
	      largeElInfo->getMesh() == vec->getFESpace()->getMesh())
      ("There is something wrong!\n");

    if (smallElInfo->getLevel() == largeElInfo->getLevel()) {

      // Both elements have the same size, so we can use the simple procedure
      // to determine the gradients.
      
146
      if (vec->getFESpace()->getMesh() == smallElInfo->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
147
	return subAssembler->getGradientsAtQPs(vec, smallElInfo, quad);
148
149
      else
	return subAssembler->getGradientsAtQPs(vec, largeElInfo, quad);      
Thomas Witkowski's avatar
Thomas Witkowski committed
150
151
152
153
154
155

    } else {

      // The two elements are different. If the vector is defined on the mesh of the
      // small element, we can still use the simple procedure to determine the gradients.

156
      if (vec->getFESpace()->getMesh() == largeElInfo->getMesh())
Thomas Witkowski's avatar
Thomas Witkowski committed
157
	return subAssembler->getGradientsAtQPs(vec, smallElInfo, largeElInfo, quad);
158
      else
Thomas Witkowski's avatar
Thomas Witkowski committed
159
160
161
162
	return subAssembler->getGradientsAtQPs(vec, smallElInfo, quad);
    }
  }

163
  void OperatorTerm::lalt(const DimVec<WorldVector<double> >& Lambda,
164
165
166
			  const WorldMatrix<double>& matrix,
			  DimMat<double>& LALt,
			  bool symm,
167
			  double factor) const
168
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
169
    int j, k, l;
170
    const int dimOfWorld = Global::getGeo(WORLD);
171
    int dim = LALt.getNumRows() - 1;
172
173
174
  
    double val = 0.0;

175
    if (symm) {
Thomas Witkowski's avatar
Thomas Witkowski committed
176
      for (int i = 0; i <= dim; i++) {
177
178
179
	val = 0.0;
	for (k = 0; k < dimOfWorld; k++)
	  for (l = 0; l < dimOfWorld; l++)
180
181
182
	    val += Lambda[i][k] * matrix[k][l] * Lambda[i][l];
	val *= factor;
	LALt[i][i] += val;
183
	for (j = i + 1; j <= dim; j++) {
184
185
186
	  val = 0.0;
	  for (k = 0; k < dimOfWorld; k++)
	    for (l = 0; l < dimOfWorld; l++)
187
188
189
190
191
192
193
	      val += Lambda[i][k] * matrix[k][l] * Lambda[j][l];
	  val *= factor;
	  LALt[i][j] += val;
	  LALt[j][i] += val;
	}
      }    
    } else {	
Thomas Witkowski's avatar
Thomas Witkowski committed
194
      for (int i = 0; i <= dim; i++) {
195
	for (j = 0; j <= dim; j++) {
196
197
198
	  val = 0.0;
	  for (k = 0; k < dimOfWorld; k++)
	    for (l = 0; l < dimOfWorld; l++) 
199
200
201
202
203
204
205
206
207
208
	      val += Lambda[i][k] * matrix[k][l] * Lambda[j][l];
	  val *= factor;
	  LALt[i][j] += val;
	}
      }    
    }      
  }

  void OperatorTerm::lalt_kl(const DimVec<WorldVector<double> >& Lambda,
			     int k, int l,
Thomas Witkowski's avatar
Thomas Witkowski committed
209
210
			     DimMat<double>& LALt,
			     double factor)
211
212
213
  {
    int dim = LALt.getNumRows() - 1;

Thomas Witkowski's avatar
Thomas Witkowski committed
214
215
    for (int i = 0; i <= dim; i++)
      for (int j = 0; j <= dim; j++)
216
217
218
219
	LALt[i][j] += factor * Lambda[i][k] * Lambda[j][l];
  }

  Operator::Operator(Flag operatorType,
Thomas Witkowski's avatar
Thomas Witkowski committed
220
221
222
223
		     const FiniteElemSpace *row,
		     const FiniteElemSpace *col)
    : rowFESpace(row), 
      colFESpace(col ? col : row),
224
225
226
      type(operatorType), 
      fillFlag(Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | 
	       Mesh::FILL_DET | Mesh::FILL_GRD_LAMBDA),
Thomas Witkowski's avatar
Thomas Witkowski committed
227
      needDualTraverse(false),
228
229
230
      uhOld(NULL),
      optimized(true)
  {
231
    int maxThreads = omp_get_overall_max_threads();
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246

    assembler.resize(maxThreads);
    secondOrder.resize(maxThreads);
    firstOrderGrdPsi.resize(maxThreads);
    firstOrderGrdPhi.resize(maxThreads);
    zeroOrder.resize(maxThreads);

    for (int i = 0; i < maxThreads; i++) {
      assembler[i] = NULL;
      secondOrder[i].resize(0);
      firstOrderGrdPsi[i].resize(0);
      firstOrderGrdPhi[i].resize(0);
      zeroOrder[i].resize(0);
    }

247
248
    nRow = rowFESpace->getBasisFcts()->getNumber();
    nCol = colFESpace->getBasisFcts()->getNumber();
Thomas Witkowski's avatar
Thomas Witkowski committed
249
  }
250

251
252

  void Operator::setUhOld(const DOFVectorBase<double> *vec)
253
  {
254
255
    uhOld = vec;
    auxFeSpaces.insert(vec->getFESpace());
256
257
  }

258

259
  void Operator::getElementMatrix(const ElInfo *elInfo, 
260
				  ElementMatrix& userMat, 
261
262
				  double factor)
  {
263
264
    int myRank = omp_get_thread_num();

265
    if (!assembler[myRank])
266
      initAssembler(myRank, NULL, NULL, NULL, NULL);
267

268
    assembler[myRank]->calculateElementMatrix(elInfo, userMat, factor);
269
270
  }

271

Thomas Witkowski's avatar
Thomas Witkowski committed
272
273
  void Operator::getElementMatrix(const ElInfo *rowElInfo, const ElInfo *colElInfo,
				  const ElInfo *smallElInfo, const ElInfo *largeElInfo,
274
				  ElementMatrix& userMat, 
275
276
277
278
				  double factor)
  {
    int myRank = omp_get_thread_num();

279
    if (!assembler[myRank])
280
281
282
      initAssembler(myRank, NULL, NULL, NULL, NULL);

    assembler[myRank]->calculateElementMatrix(rowElInfo, colElInfo, 
283
					      smallElInfo, largeElInfo,
284
285
286
    					      userMat, factor);
  }

287

288
  void Operator::getElementVector(const ElInfo *elInfo, 
289
				  ElementVector& userVec, 
290
291
				  double factor)
  {
292
293
    int myRank = omp_get_thread_num();

294
    if (!assembler[myRank])
295
      initAssembler(myRank, NULL, NULL, NULL, NULL);
296

297
    assembler[myRank]->calculateElementVector(elInfo, userVec, factor);
298
299
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
300
301
  void Operator::getElementVector(const ElInfo *mainElInfo, const ElInfo *auxElInfo,
				  const ElInfo *smallElInfo, const ElInfo *largeElInfo,
302
				  ElementVector& userVec,
Thomas Witkowski's avatar
Thomas Witkowski committed
303
304
305
306
				  double factor)
  {
    int myRank = omp_get_thread_num();

307
    if (!assembler[myRank])
Thomas Witkowski's avatar
Thomas Witkowski committed
308
309
310
311
312
313
314
      initAssembler(myRank, NULL, NULL, NULL, NULL);

    assembler[myRank]->calculateElementVector(mainElInfo, auxElInfo, 
					      smallElInfo, largeElInfo,
					      userVec, factor);
  }

315
316
  void Operator::initAssembler(int rank,
			       Quadrature *quad2,
317
318
319
			       Quadrature *quad1GrdPsi,
			       Quadrature *quad1GrdPhi,
			       Quadrature *quad0) 
320
  {    
321
322
323
324
#ifdef _OPENMP
#pragma omp critical (initAssembler)
#endif
      {
325
326
327
328
329
330
331
332
	if (optimized)
	  assembler[rank] = 
	    new OptimizedAssembler(this, quad2, quad1GrdPsi, quad1GrdPhi, quad0,
				   rowFESpace, colFESpace);
	else
	  assembler[rank] = 
	    new StandardAssembler(this, quad2, quad1GrdPsi, quad1GrdPhi, quad0,
				  rowFESpace, colFESpace);	
333
334
335
      }
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
336
337
338
339
340
  void Operator::finishAssembling()
  {
    assembler[omp_get_thread_num()]->finishAssembling();
  }

341

Thomas Witkowski's avatar
Thomas Witkowski committed
342
343
344
345
346
347
348

  VecAtQP_ZOT::VecAtQP_ZOT(DOFVectorBase<double> *dv,
			   AbstractFunction<double, double> *af)
    : ZeroOrderTerm(af ? af->getDegree() : 0), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

349
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
350
351
352
353
354
355
356
357
358
359
360
361
  }

  MultVecAtQP_ZOT::MultVecAtQP_ZOT(DOFVectorBase<double> *dv1,
				   DOFVectorBase<double> *dv2,
				   AbstractFunction<double, double> *af1,
				   AbstractFunction<double, double> *af2)
    : ZeroOrderTerm(af1->getDegree() + af2->getDegree()), 
      vec1(dv1), vec2(dv2), f1(af1), f2(af2)
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");

362
363
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
364
365
366
367
368
369
370
371
372
373
  }

  Vec2AtQP_ZOT::Vec2AtQP_ZOT(DOFVectorBase<double> *dv1,
			     DOFVectorBase<double> *dv2,
			     BinaryAbstractFunction<double, double, double> *af)
    : ZeroOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), f(af)
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");

374
375
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
376
377
378
379
380
381
382
383
384
385
386
387
  }

  Vec3AtQP_ZOT::Vec3AtQP_ZOT(DOFVectorBase<double> *dv1,
			     DOFVectorBase<double> *dv2,
			     DOFVectorBase<double> *dv3,
			     TertiaryAbstractFunction<double, double, double, double> *af)
    : ZeroOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), vec3(dv3), f(af)
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");
    TEST_EXIT(dv3)("No thierd vector!\n");

388
389
390
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
    auxFeSpaces.insert(dv3->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
391
392
393
394
395
396
397
398
  }

  FctGradientCoords_ZOT::FctGradientCoords_ZOT(DOFVectorBase<double> *dv,
					       BinaryAbstractFunction<double, WorldVector<double>, WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

399
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
400
401
402
403
404
405
406
407
  }

  VecGradCoordsAtQP_ZOT::VecGradCoordsAtQP_ZOT(DOFVectorBase<double> *dv,
					       TertiaryAbstractFunction<double, double, WorldVector<double>, WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(dv), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");

408
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
409
410
411
412
413
414
415
416
  }

  VecAndCoordsAtQP_ZOT::VecAndCoordsAtQP_ZOT(DOFVectorBase<double> *dv,
					     BinaryAbstractFunction<double, double, WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(dv), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");

417
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
418
419
420
421
422
423
424
425
426
  }

  Vec2AndGradAtQP_ZOT::Vec2AndGradAtQP_ZOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
					   TertiaryAbstractFunction<double, double, WorldVector<double>, double > *af)
    : ZeroOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), f(af) 
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");

427
428
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
429
430
431
432
433
434
435
436
  }

  FctGradient_ZOT::FctGradient_ZOT(DOFVectorBase<double> *dv,
				   AbstractFunction<double, WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

437
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
438
439
440
441
442
443
444
445
  }

  VecAndGradAtQP_ZOT::VecAndGradAtQP_ZOT(DOFVectorBase<double> *dv,
					 BinaryAbstractFunction<double, double, WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(dv), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");

446
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
447
448
449
450
451
452
453
454
455
456
  }

  VecAndGradVecAtQP_ZOT::VecAndGradVecAtQP_ZOT(DOFVectorBase<double> *dv, 
					       DOFVectorBase<double> *dGrd,
					       BinaryAbstractFunction<double, double, WorldVector<double> > *af) 
    : ZeroOrderTerm(af->getDegree()), vec(dv), vecGrd(dGrd), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");
    TEST_EXIT(dGrd)("No gradient vector!\n");

457
458
    auxFeSpaces.insert(dv->getFESpace());
    auxFeSpaces.insert(dGrd->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
459
460
461
462
463
464
465
466
467
468
469
470
  }

  VecAndGradVec2AtQP_ZOT::VecAndGradVec2AtQP_ZOT(DOFVectorBase<double> *dv, 
						 DOFVectorBase<double> *dGrd1, 
						 DOFVectorBase<double> *dGrd2, 
						 TertiaryAbstractFunction<double, double, WorldVector<double>, WorldVector<double> > *af) 
    : ZeroOrderTerm(af->getDegree()), vec(dv), vecGrd1(dGrd1), vecGrd2(dGrd2), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");
    TEST_EXIT(dGrd1)("No first gradient vector!\n");
    TEST_EXIT(dGrd2)("No second gradient vector!\n");

471
472
473
    auxFeSpaces.insert(dv->getFESpace());
    auxFeSpaces.insert(dGrd1->getFESpace());
    auxFeSpaces.insert(dGrd2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
474
475
476
477
478
479
480
481
482
483
484
  }

  VecOfDOFVecsAtQP_ZOT::VecOfDOFVecsAtQP_ZOT(const std::vector<DOFVectorBase<double>*>& dv, 
					     AbstractFunction<double, std::vector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vecs(dv), f(af) 
  {
    vecsAtQPs.resize(vecs.size());

    for (int i = 0; i < static_cast<int>(dv.size()); i++) {
      TEST_EXIT(dv[i])("One vector is NULL!\n");

485
      auxFeSpaces.insert(dv[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
486
487
488
489
490
491
492
493
494
495
496
497
    }
  } 

  VecOfGradientsAtQP_ZOT::VecOfGradientsAtQP_ZOT(const std::vector<DOFVectorBase<double>*>& dv,
						 AbstractFunction<double, std::vector<WorldVector<double>*> > *af) 
    : ZeroOrderTerm(af->getDegree()), vecs(dv), f(af) 
  {
    gradsAtQPs.resize(vecs.size());

    for (int i = 0; i < static_cast<int>(dv.size()); i++) {
      TEST_EXIT(dv[i])("One vector is NULL!\n");

498
      auxFeSpaces.insert(dv[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
    }
  } 

  VecDivergence_ZOT::VecDivergence_ZOT(int nComponents,
				       DOFVectorBase<double> *vec0,
				       DOFVectorBase<double> *vec1,
				       DOFVectorBase<double> *vec2)
    : ZeroOrderTerm(0)
  {
    vecs.resize(nComponents);
    gradsAtQPs.resize(nComponents);
    vecs[0] = vec0;
    vecs[1] = vec1;
    vecs[2] = vec2;

514
    auxFeSpaces.insert(vec0->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
515
    if (vec1) 
516
      auxFeSpaces.insert(vec1->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
517
    if (vec2) 
518
      auxFeSpaces.insert(vec2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
519
520
521
522
523
524
525
526
527
528
529
530
  }


  VecAndVecOfGradientsAtQP_ZOT::VecAndVecOfGradientsAtQP_ZOT(DOFVector<double> *v,
							     const std::vector<DOFVector<double>*>& dv,
							     BinaryAbstractFunction<double, double, std::vector<WorldVector<double>*> > *af)
    : ZeroOrderTerm(af->getDegree()), vec(v), vecs(dv), f(af)
  {
    gradsAtQPs.resize(vecs.size());

    TEST_EXIT(v)("No vector!\n");

531
    auxFeSpaces.insert(v->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
532
533
534
    for (int i = 0; i < static_cast<int>(dv.size()); i++) {
      TEST_EXIT(dv[i])("One gradient vector is NULL!\n");

535
      auxFeSpaces.insert(dv[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
536
537
538
    }
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
539
540
541
542
543
544
545
546
547

  Vec2AndGrad2AtQP_ZOT::Vec2AndGrad2AtQP_ZOT(DOFVectorBase<double> *dv1, 
					     DOFVectorBase<double> *dv2,
					     QuartAbstractFunction<double, double, double, WorldVector<double>,WorldVector<double> > *af)
    : ZeroOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), f(af) 
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");
    
548
549
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
  }

  void Vec2AndGrad2AtQP_ZOT::initElement(const ElInfo* elInfo, 
					 SubAssembler* subAssembler,
					 Quadrature *quad) 
  {
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
    gradAtQPs1 = getGradientsAtQPs(vec1, elInfo, subAssembler, quad);
    gradAtQPs2 = getGradientsAtQPs(vec2, elInfo, subAssembler, quad);
  }
  
  
  void Vec2AndGrad2AtQP_ZOT::eval(int nPoints,
				  const double *uhAtQP,
				  const WorldVector<double> *grdUhAtQP,
				  const WorldMatrix<double> *D2UhAtQP,
				  double *result,
				  double fac) const
  {
    for (int iq = 0; iq < nPoints; iq++)
      result[iq] += 
	fac * 
	(*f)(vecAtQPs1[iq], vecAtQPs2[iq], gradAtQPs1[iq], gradAtQPs2[iq]) * 
	uhAtQP[iq];
  }

  void Vec2AndGrad2AtQP_ZOT::getC(const ElInfo *, int nPoints,
				 std::vector<double> &C) const 
  { 
    for (int iq = 0; iq < nPoints; iq++)
      C[iq] += (*f)(vecAtQPs1[iq], vecAtQPs2[iq], gradAtQPs1[iq], gradAtQPs2[iq]);
  }

  Vec2AndGradVecAtQP_ZOT::Vec2AndGradVecAtQP_ZOT(DOFVectorBase<double> *dv1, 
						 DOFVectorBase<double> *dv2, 
						 DOFVectorBase<double> *dGrd,
						 TertiaryAbstractFunction<double, double,double, WorldVector<double> > *af) 
    : ZeroOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), vecGrd(dGrd), f(af) 
  {
    TEST_EXIT(dv1)("No vector!\n");
    TEST_EXIT(dv2)("No vector!\n");
    TEST_EXIT(dGrd)("No gradient vector!\n");
    
594
595
596
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
    auxFeSpaces.insert(dGrd->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
  }
  
  void Vec2AndGradVecAtQP_ZOT::initElement(const ElInfo* elInfo, 
					   SubAssembler* subAssembler,
					   Quadrature *quad) 
  {
    vec1AtQPs = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vec2AtQPs = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vecGrd, elInfo, subAssembler, quad);
  }
  
  void Vec2AndGradVecAtQP_ZOT::getC(const ElInfo *, int nPoints,
				    std::vector<double> &C) const 
  { 
    for (int iq = 0; iq < nPoints; iq++)
      C[iq] += (*f)(vec1AtQPs[iq], vec2AtQPs[iq], gradAtQPs[iq]);
  }
  
  void Vec2AndGradVecAtQP_ZOT::eval(int nPoints,
				   const double *uhAtQP,
				   const WorldVector<double> *grdUhAtQP,
				   const WorldMatrix<double> *D2UhAtQP,
				   double *result,
				   double fac) const
  {
    for (int iq = 0; iq < nPoints; iq++)
      result[iq] += 
	fac * (*f)(vec1AtQPs[iq], vec2AtQPs[iq], gradAtQPs[iq]) * uhAtQP[iq];
  }
  
Thomas Witkowski's avatar
Thomas Witkowski committed
627
628
629
630
631
632
633
634
635
636
637
  General_ZOT::General_ZOT(std::vector<DOFVectorBase<double>*> vecs,
			   std::vector<DOFVectorBase<double>*> grads,
			   TertiaryAbstractFunction<double, WorldVector<double>, std::vector<double>, std::vector<WorldVector<double> > > *af)
    : ZeroOrderTerm(af->getDegree()), vecs_(vecs), grads_(grads), f_(af)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

638
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
639
640
641
642
643
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

644
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
    }   
  }

  GeneralParametric_ZOT::GeneralParametric_ZOT(std::vector<DOFVectorBase<double>*> vecs,
					       std::vector<DOFVectorBase<double>*> grads,
					       QuartAbstractFunction<double, 
					       WorldVector<double>,
					       WorldVector<double>,
					       std::vector<double>, 
					       std::vector<WorldVector<double> > > *af)
    : ZeroOrderTerm(af->getDegree()), vecs_(vecs), grads_(grads), f_(af)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

663
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
664
665
666
667
668
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

669
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
670
671
672
673
674
675
676
677
678
679
    }   
  }

  VecAtQP_FOT::VecAtQP_FOT(DOFVectorBase<double> *dv,
			   AbstractFunction<double, double> *af,
			   WorldVector<double> *wv)
    : FirstOrderTerm(af->getDegree()), vec(dv), f(af), b(wv)
  {
    TEST_EXIT(dv)("No vector!\n");

680
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
681
682
  }

683
684
685
686
687
688
689
690
  VecAtQP_FOT::VecAtQP_FOT(DOFVectorBase<double> *dv,
			   AbstractFunction<double, double> *af,
			   int bIdx)
    : FirstOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

    bOne = bIdx;
691
    auxFeSpaces.insert(dv->getFESpace());
692
693
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
694
695
696
697
698
699
  VectorGradient_FOT::VectorGradient_FOT(DOFVectorBase<double> *dv,
					 AbstractFunction<WorldVector<double>, WorldVector<double> > *af)
    : FirstOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

700
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
701
702
703
704
705
706
707
708
  }

  VectorFct_FOT::VectorFct_FOT(DOFVectorBase<double> *dv,
			       AbstractFunction<WorldVector<double>, double> *fct)
    : FirstOrderTerm(fct->getDegree()), vec(dv), vecFct(fct) 
  {
    TEST_EXIT(dv)("No vector!\n");

709
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
710
711
712
713
714
715
716
717
718
  }

  VecGrad_FOT::VecGrad_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
			   BinaryAbstractFunction<WorldVector<double>, double, WorldVector<double> > *fct)
    : FirstOrderTerm(fct->getDegree()), vec1(dv1), vec2(dv2), vecFct(fct) 
  {
    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");

719
720
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());    
Thomas Witkowski's avatar
Thomas Witkowski committed
721
722
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
723
724
725
  Vec2AndGradAtQP_FOT::Vec2AndGradAtQP_FOT(DOFVectorBase<double> *dv1, 
					   DOFVectorBase<double> *dv2,
					   TertiaryAbstractFunction<double, double, double, WorldVector<double> > *f_, WorldVector<double> *b_)
726
    : FirstOrderTerm(f_->getDegree()), 
Thomas Witkowski's avatar
Thomas Witkowski committed
727
728
729
730
731
      vec1(dv1), 
      vec2(dv2), 
      f(f_), 
      b(b_)
  {   
732
733
    auxFeSpaces.insert(dv1->getFESpace()); 
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
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
  }

  void Vec2AndGradAtQP_FOT::initElement(const ElInfo* elInfo, 
					SubAssembler* subAssembler,
					Quadrature *quad) 
  { 
    vec1AtQPs = subAssembler->getVectorAtQPs(vec1, elInfo, quad);
    vec2AtQPs = subAssembler->getVectorAtQPs(vec2, elInfo, quad);
    gradAtQPs1 = getGradientsAtQPs(vec1, elInfo, subAssembler, quad);
  }
  
  
  void Vec2AndGradAtQP_FOT::getLb(const ElInfo *elInfo, int nPoints, VectorOfFixVecs<DimVec<double> >& Lb) const {
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
    for (int iq = 0; iq < nPoints; iq++) {
      if (b)
	lb(Lambda, *b, Lb[iq], (*f)(vec1AtQPs[iq], vec2AtQPs[iq],gradAtQPs1[iq]));
      else
	l1(Lambda, Lb[iq], (*f)(vec1AtQPs[iq], vec2AtQPs[iq], gradAtQPs1[iq]));
    }
  }
  
  void Vec2AndGradAtQP_FOT::eval(int nPoints,
				 const double *uhAtQP,
				 const WorldVector<double> *grdUhAtQP,
				 const WorldMatrix<double> *D2UhAtQP,
				 double *result,
				 double fac) const
  {   
    if (grdUhAtQP)
      for (int iq = 0; iq < nPoints; iq++)
	result[iq] += fac * 
	  (*f)(vec1AtQPs[iq], vec2AtQPs[iq], gradAtQPs1[iq]) * 
	  ((*b) * grdUhAtQP[iq]);
  }

  FctVecAtQP_FOT::FctVecAtQP_FOT(DOFVectorBase<double> *dv,
				 AbstractFunction<double, WorldVector<double> > *f_,
				 WorldVector<double> *b_)
    : FirstOrderTerm(f_->getDegree()), vec(dv), f(f_), b(b_)
  {
775
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
  }


  void FctVecAtQP_FOT::initElement(const ElInfo* elInfo, 
				   SubAssembler* subAssembler,
				   Quadrature *quad) 
  { 
    vecAtQPs = subAssembler->getVectorAtQPs(vec, elInfo, quad);
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }


  void FctVecAtQP_FOT::getLb(const ElInfo *elInfo, int nPoints, 
			     VectorOfFixVecs<DimVec<double> >& Lb) const 
  {
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
    for (int iq = 0; iq < nPoints; iq++) {
      if (b)
	lb(Lambda, *b, Lb[iq], (*f)(coordsAtQPs[iq]) * (vecAtQPs[iq]));
      else
796
	l1(Lambda, Lb[iq], (*f)(coordsAtQPs[iq]) * (vecAtQPs[iq]));      
Thomas Witkowski's avatar
Thomas Witkowski committed
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
    }
  }
  
  void FctVecAtQP_FOT::eval(int nPoints,
			    const double              *uhAtQP,
			    const WorldVector<double> *grdUhAtQP,
			    const WorldMatrix<double> *D2UhAtQP,
			    double *result,
			    double fac) const
  {
    if (grdUhAtQP)
      for (int iq = 0; iq < nPoints; iq++)
	result[iq] += 
	  fac * (*f)(coordsAtQPs[iq]) * (vecAtQPs[iq]) * ((*b) * grdUhAtQP[iq]);
  }

  Vec2AtQP_FOT::Vec2AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
			     WorldVector<double> *b_)
815
    : FirstOrderTerm(0), vec1(dv1), vec2(dv2), b(b_)
Thomas Witkowski's avatar
Thomas Witkowski committed
816
  {   
817
818
    auxFeSpaces.insert(dv1->getFESpace()); 
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
819
820
  }

821
822
  Vec2AtQP_FOT::Vec2AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
			     int bIdx)
823
    : FirstOrderTerm(0), vec1(dv1), vec2(dv2)
824
825
  {   
    bOne = bIdx;
826
827
    auxFeSpaces.insert(dv1->getFESpace()); 
    auxFeSpaces.insert(dv2->getFESpace());
828
829
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
830
831
832
833
834
835
836
837
  void Vec2AtQP_FOT::initElement(const ElInfo* elInfo, 
				 SubAssembler* subAssembler,
				 Quadrature *quad) 
  { 
    vec1AtQPs = subAssembler->getVectorAtQPs(vec1, elInfo, quad);
    vec2AtQPs = subAssembler->getVectorAtQPs(vec2, elInfo, quad);
  }
    
838
839
  void Vec2AtQP_FOT::getLb(const ElInfo *elInfo, int nPoints, 
			   VectorOfFixVecs<DimVec<double> >& Lb) const 
Thomas Witkowski's avatar
Thomas Witkowski committed
840
841
  {
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
842
843
844
845
846
847

    if (bOne > -1) {
      for (int iq = 0; iq < nPoints; iq++)
	lb_one(Lambda, Lb[iq], vec1AtQPs[iq] * vec2AtQPs[iq]);
    } else if (b) {
      for (int iq = 0; iq < nPoints; iq++)
Thomas Witkowski's avatar
Thomas Witkowski committed
848
	lb(Lambda, *b, Lb[iq], vec1AtQPs[iq] * vec2AtQPs[iq]);
849
850
    } else {
      for (int iq = 0; iq < nPoints; iq++)
Thomas Witkowski's avatar
Thomas Witkowski committed
851
	l1(Lambda, Lb[iq], vec1AtQPs[iq] * vec2AtQPs[iq]);
Thomas Witkowski's avatar
Thomas Witkowski committed
852
853
854
855
    }
  }
  
  void Vec2AtQP_FOT::eval(int nPoints,
856
			  const double *uhAtQP,
Thomas Witkowski's avatar
Thomas Witkowski committed
857
858
859
860
861
862
863
			  const WorldVector<double> *grdUhAtQP,
			  const WorldMatrix<double> *D2UhAtQP,
			  double *result,
			  double fac) const
  {
    if (grdUhAtQP)
      for (int iq = 0; iq < nPoints; iq++) 
Thomas Witkowski's avatar
Thomas Witkowski committed
864
	result[iq] += fac * vec1AtQPs[iq] * vec2AtQPs[iq] * ((*b) * grdUhAtQP[iq]);
Thomas Witkowski's avatar
Thomas Witkowski committed
865
866
867
868
  }

  Vec3FctAtQP_FOT::Vec3FctAtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,DOFVectorBase<double> *dv3,
				   BinaryAbstractFunction<double, double, double> *f_,
869
				   WorldVector<double> *bvec)
870
    : FirstOrderTerm(f_->getDegree()), 
871
872
873
874
875
876
      vec1(dv1), 
      vec2(dv2), 
      vec3(dv3), 
      f(f_),
      b(bvec)
  { 
877
878
879
    auxFeSpaces.insert(dv1->getFESpace()); 
    auxFeSpaces.insert(dv2->getFESpace()); 
    auxFeSpaces.insert(dv3->getFESpace());   
880
881
882
883
884
  }

  Vec3FctAtQP_FOT::Vec3FctAtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,DOFVectorBase<double> *dv3,
				   BinaryAbstractFunction<double, double, double> *f_,
				   int b)
885
    : FirstOrderTerm(f_->getDegree()), 
886
887
888
889
      vec1(dv1), 
      vec2(dv2), 
      vec3(dv3), 
      f(f_)
Thomas Witkowski's avatar
Thomas Witkowski committed
890
  { 
891
    bOne = b;
892
893
894
    auxFeSpaces.insert(dv1->getFESpace()); 
    auxFeSpaces.insert(dv2->getFESpace()); 
    auxFeSpaces.insert(dv3->getFESpace());   
Thomas Witkowski's avatar
Thomas Witkowski committed
895
896
897
898
899
900
901
902
903
904
905
906
  }

  void Vec3FctAtQP_FOT::initElement(const ElInfo* elInfo, 
				    SubAssembler* subAssembler,
				    Quadrature *quad) 
  { 
    vec1AtQPs = subAssembler->getVectorAtQPs(vec1, elInfo, quad);
    vec2AtQPs = subAssembler->getVectorAtQPs(vec2, elInfo, quad);
    vec3AtQPs = subAssembler->getVectorAtQPs(vec3, elInfo, quad);
  }
  
  
907
908
  void Vec3FctAtQP_FOT::getLb(const ElInfo *elInfo, int nPoints, 
			      VectorOfFixVecs<DimVec<double> >& Lb) const 
Thomas Witkowski's avatar
Thomas Witkowski committed
909
910
  {
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
911
912
913
914
915
916
917
918
919
920
    if (bOne > -1) {
      for (int iq = 0; iq < nPoints; iq++)
	lb_one(Lambda, Lb[iq], vec1AtQPs[iq] * (*f)(vec2AtQPs[iq], vec3AtQPs[iq]));
    } else {
      for (int iq = 0; iq < nPoints; iq++) {
	if (b)
	  lb(Lambda, *b, Lb[iq], vec1AtQPs[iq] * (*f)(vec2AtQPs[iq], vec3AtQPs[iq]));
	else
	  l1(Lambda, Lb[iq], vec1AtQPs[iq] * (*f)(vec2AtQPs[iq], vec3AtQPs[iq]));
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
921
922
923
924
    }
  }

  void Vec3FctAtQP_FOT::eval(int nPoints,
925
			     const double *uhAtQP,
Thomas Witkowski's avatar
Thomas Witkowski committed
926
927
928
929
930
931
932
933
934
935
936
937
938
			     const WorldVector<double> *grdUhAtQP,
			     const WorldMatrix<double> *D2UhAtQP,
			     double *result,
			     double fac) const
  {
    if (grdUhAtQP)
      for (int iq = 0; iq < nPoints; iq++)
	result[iq] += fac * 
	  (vec1AtQPs[iq]) * (*f)(vec2AtQPs[iq] ,vec3AtQPs[iq]) * 
	  ((*b) * grdUhAtQP[iq]);
  }


Thomas Witkowski's avatar
Thomas Witkowski committed
939
940
941
942
943
944
945
946
947
948
949
950
951
952
  General_FOT::General_FOT(std::vector<DOFVectorBase<double>*> vecs,
			   std::vector<DOFVectorBase<double>*> grads,
			   TertiaryAbstractFunction<WorldVector<double>, 
			   WorldVector<double>,
			   std::vector<double>, 
			   std::vector<WorldVector<double> > > *af)
    : FirstOrderTerm(af->getDegree()), vecs_(vecs), grads_(grads), f_(af)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

953
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
954
955
956
957
958
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

959
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
    }   
  }

  GeneralParametric_FOT::GeneralParametric_FOT(std::vector<DOFVectorBase<double>*> vecs,
					       std::vector<DOFVectorBase<double>*> grads,
					       QuartAbstractFunction<WorldVector<double>, 
					       WorldVector<double>,
					       WorldVector<double>,
					       std::vector<double>, 
					       std::vector<WorldVector<double> > > *af)
    : FirstOrderTerm(af->getDegree()), vecs_(vecs), grads_(grads), f_(af)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

978
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
979
980
981
982
983
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

984
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
    }   
  }

  MatrixFct_SOT::MatrixFct_SOT(DOFVectorBase<double> *dv, 
			       AbstractFunction<WorldMatrix<double>, double> *fct,
			       AbstractFunction<WorldVector<double>, WorldMatrix<double> > *div,
			       bool sym)
    : SecondOrderTerm(fct->getDegree()), 
      vec(dv), 
      matrixFct(fct), 
      divFct(div),
      symmetric(sym)
  {
    setSymmetric(symmetric);

    TEST_EXIT(dv)("No vector!\n");

1002
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
  }

  VecAtQP_SOT::VecAtQP_SOT(DOFVectorBase<double> *dv, 
			   AbstractFunction<double, double> *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    setSymmetric(true);

    TEST_EXIT(dv)("No vector!\n");

1013
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
  }

  Vec2AtQP_SOT::Vec2AtQP_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, 
			     BinaryAbstractFunction<double, double, double> *af)
    : SecondOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), f(af)
  {
    setSymmetric(true);

    TEST_EXIT(dv1)("No first vector!\n");
    TEST_EXIT(dv2)("No second vector!\n");

1025
1026
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1027
1028
1029
1030
1031
1032
  }

  MatrixGradient_SOT::MatrixGradient_SOT(DOFVectorBase<double> *dv,
					 AbstractFunction<WorldMatrix<double>, WorldVector<double> > *af,
					 AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
					 bool symm) 
1033
1034
1035
1036
1037
1038
    : SecondOrderTerm(af->getDegree()), 
      vec(dv), 
      f(af), 
      divFct(divAf),
      gradAtQPs(NULL),
      symmetric(symm)
Thomas Witkowski's avatar
Thomas Witkowski committed
1039
1040
1041
1042
1043
  {
    setSymmetric(symmetric);

    TEST_EXIT(dv)("No vector!\n");

1044
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1045
1046
1047
1048
1049
1050
1051
1052
  }

  FctGradient_SOT::FctGradient_SOT(DOFVectorBase<double> *dv,
				   AbstractFunction<double, WorldVector<double> > *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

1053
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1054
1055
1056
1057
1058
1059
1060
1061
  }

  VecAndGradientAtQP_SOT::VecAndGradientAtQP_SOT(DOFVectorBase<double> *dv,
						 BinaryAbstractFunction<double, double, WorldVector<double> > *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

1062
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
  }

  VecMatrixGradientAtQP_SOT::VecMatrixGradientAtQP_SOT(DOFVectorBase<double> *dv,
						       BinaryAbstractFunction<WorldMatrix<double>, double, WorldVector<double> > *af,
						       AbstractFunction<WorldVector<double>, WorldMatrix<double> > *divAf,
						       bool symm)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af), 
      divFct(divAf), symmetric(symm)
  {
    setSymmetric(symmetric);

    TEST_EXIT(dv)("No vector!\n");

1076
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1077
1078
1079
1080
1081
1082
1083
1084
1085
  }

  VecGradCoordsAtQP_SOT::VecGradCoordsAtQP_SOT(DOFVectorBase<double> *dv,
					       TertiaryAbstractFunction<double, double,
					       WorldVector<double>, WorldVector<double> > *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    TEST_EXIT(dv)("No vector!\n");

1086
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
  }

  VecAndCoordsAtQP_SOT::VecAndCoordsAtQP_SOT(DOFVectorBase<double> *dv, 
					     BinaryAbstractFunction<double, double, WorldVector<double> > *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af)
  {
    setSymmetric(true);

    TEST_EXIT(dv)("No vector!\n");

1097
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
  }

  MatrixGradientAndCoords_SOT::MatrixGradientAndCoords_SOT(DOFVectorBase<double> *dv,
							   BinaryAbstractFunction<WorldMatrix<double>,
							   WorldVector<double>, WorldVector<double> > *af,
							   AbstractFunction<WorldVector<double>,
							   WorldMatrix<double> > *divAf,
							   bool symm) 
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af), divFct(divAf), symmetric(symm)
  {
    setSymmetric(symmetric);

    TEST_EXIT(dv)("No vector!\n");

1112
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1113
1114
  }

1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133

  MatrixVec2_SOT::MatrixVec2_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, 
			       BinaryAbstractFunction<double, double, double> *f,
			       WorldMatrix<double> Af,
			       bool sym)
    : SecondOrderTerm(f->getDegree()), 
      vec1(dv1),
      vec2(dv2), 
      fct(f), 
      A(Af),
      symmetric(sym)
  {
    FUNCNAME("MatrixVec2_SOT::MatrixVec2_SOT()");

    setSymmetric(symmetric);

    TEST_EXIT_DBG(dv1)("No vector!\n");
    TEST_EXIT_DBG(dv2)("No vector!\n");
    
1134
1135
    auxFeSpaces.insert(dv1->getFESpace());
    auxFeSpaces.insert(dv2->getFESpace());
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
  }

  void MatrixVec2_SOT::initElement(const ElInfo* elInfo, 
				  SubAssembler* subAssembler,
				  Quadrature *quad) 
  {
    vec1AtQPs = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vec2AtQPs = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
  }
  
  void MatrixVec2_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
			       DimMat<double> **LALt) const 
  {      
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
    for (int iq = 0; iq < nPoints; iq++)
      lalt(Lambda, A, *(LALt[iq]), symmetric, (*fct)(vec1AtQPs[iq], vec2AtQPs[iq]));
  }

  void MatrixVec2_SOT::eval(int nPoints,
			    const double *uhAtQP,
			    const WorldVector<double> *grdUhAtQP,
			    const WorldMatrix<double> *D2UhAtQP,
			    double *result,
			    double factor) const
  {
    int dow = Global::getGeo(WORLD);
    
    for (int iq = 0; iq < nPoints; iq++) {
      double resultQP = 0.0;

      if (D2UhAtQP)
	for (int i = 0; i < dow; i++)
	  for (int j = 0; j < dow; j++)
	    resultQP += A[i][j] * D2UhAtQP[iq][j][i];
    
      result[iq] += resultQP * factor * (*fct)(vec1AtQPs[iq], vec2AtQPs[iq]);
    }
  }

1175
1176
  void MatrixVec2_SOT::weakEval(const std::vector<WorldVector<double> > &grdUhAtQP,
				std::vector<WorldVector<double> > &result) const
1177
  {
1178
1179
1180
    int nPoints = grdUhAtQP.size();
    for (int iq = 0; iq < nPoints; iq++)
      result[iq] += A * grdUhAtQP[iq] * (*fct)(vec1AtQPs[iq], vec2AtQPs[iq]);
1181
1182
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
  General_SOT::General_SOT(std::vector<DOFVectorBase<double>*> vecs,
			   std::vector<DOFVectorBase<double>*> grads,
			   TertiaryAbstractFunction<WorldMatrix<double>, 
  			     WorldVector<double>,
			     std::vector<double>, 
			     std::vector<WorldVector<double> > > *f,
			   AbstractFunction<WorldVector<double>, 
			     WorldMatrix<double> > *divFct,
			     bool symmetric)
      : SecondOrderTerm(f->getDegree()),
	vecs_(vecs),
	grads_(grads),
	f_(f),
	divFct_(divFct),
	symmetric_(symmetric)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

1205
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1206
1207
1208
1209
1210
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

1211
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
    }
  }

  GeneralParametric_SOT::GeneralParametric_SOT(std::vector<DOFVectorBase<double>*> vecs,
					       std::vector<DOFVectorBase<double>*> grads,
					       QuartAbstractFunction<WorldMatrix<double>, 
					         WorldVector<double>,
					         WorldVector<double>,
					         std::vector<double>, 
					         std::vector<WorldVector<double> > > *f,
					       AbstractFunction<WorldVector<double>, 
					         WorldMatrix<double> > *divFct,
					       bool symmetric)
    : SecondOrderTerm(f->getDegree()),
      vecs_(vecs),
      grads_(grads),
      f_(f),
      divFct_(divFct),
      symmetric_(symmetric)
  {
    vecsAtQPs_.resize(vecs_.size());
    gradsAtQPs_.resize(grads_.size());

    for (int i = 0; i < static_cast<int>(vecs.size()); i++) {
      TEST_EXIT(vecs[i])("One vector is NULL!\n");

1238
      auxFeSpaces.insert(vecs[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1239
1240
1241
1242
1243
    }   

    for (int i = 0; i < static_cast<int>(grads.size()); i++) {
      TEST_EXIT(grads[i])("One gradient vector is NULL!\n");

1244
      auxFeSpaces.insert(grads[i]->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1245
1246
1247
1248
1249
1250
1251
1252
1253
    }
  }

  VecAndGradAtQP_SOT::VecAndGradAtQP_SOT(DOFVectorBase<double> *dv,
					 BinaryAbstractFunction<double, double, WorldVector<double> > *af)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af) 
  {
    TEST_EXIT(dv)("No vector!\n");

1254
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
  }

  VecAtQP_IJ_SOT::VecAtQP_IJ_SOT(DOFVectorBase<double> *dv, 
				 AbstractFunction<double, double> *af,
				 int x_i, int x_j)
    : SecondOrderTerm(af->getDegree()), vec(dv), f(af), xi(x_i), xj(x_j)
  {
    setSymmetric(xi == xj);

    TEST_EXIT(dv)("No vector!\n");

1266
    auxFeSpaces.insert(dv->getFESpace());
Thomas Witkowski's avatar
Thomas Witkowski committed
1267
1268
  }

1269
1270
1271
1272
  void MatrixFct_SOT::initElement(const ElInfo* elInfo, 
				  SubAssembler* subAssembler,
				  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1273
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1274
1275
1276
1277
  }
 
  void VecAtQP_SOT::initElement(const ElInfo* elInfo, 
				SubAssembler* subAssembler,
Thomas Witkowski's avatar
Thomas Witkowski committed
1278
				Quadrature* quad) 
1279
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1280
1281
1282
1283
1284
1285
1286
1287
1288
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
  }

  void VecAtQP_SOT::initElement(const ElInfo* smallElInfo, 
				const ElInfo* largeElInfo,
				SubAssembler* subAssembler,
				Quadrature* quad) 
  {
    vecAtQPs = getVectorAtQPs(vec, smallElInfo, largeElInfo, subAssembler, quad);
1289
  }
1290
1291
1292
1293
1294

  void Vec2AtQP_SOT::initElement(const ElInfo* elInfo, 
				 SubAssembler* subAssembler,
				 Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1295
1296
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
1297
  }
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
 
  void CoordsAtQP_SOT::initElement(const ElInfo* elInfo, 
				   SubAssembler* subAssembler,
				   Quadrature *quad) 
  {
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }

  void MatrixGradient_SOT::initElement(const ElInfo* elInfo, 
				       SubAssembler* subAssembler,
				       Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1310
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1311
1312
  }

1313
1314
1315
1316
1317
1318
1319
1320
  void MatrixGradient_SOT::initElement(const ElInfo* smallElInfo, 
				       const ElInfo* largeElInfo,
				       SubAssembler* subAssembler,
				       Quadrature *quad) 
  {
    gradAtQPs = getGradientsAtQPs(vec, smallElInfo, largeElInfo, subAssembler, quad);
  }

1321
1322
1323
1324
  void FctGradient_SOT::initElement(const ElInfo* elInfo, 
				    SubAssembler* subAssembler,
				    Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1325
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1326
1327
1328
1329
1330
1331
  }

  void VecAndGradientAtQP_SOT::initElement(const ElInfo* elInfo, 
					   SubAssembler* subAssembler,
					   Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1332
1333
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1334
1335
  }

1336
1337
1338
1339
  void VecMatrixGradientAtQP_SOT::initElement(const ElInfo* elInfo, 
					      SubAssembler* subAssembler,
					      Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1340
1341
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1342
1343
  }
  
1344
1345
1346
1347
  void VecAndCoordsAtQP_SOT::initElement(const ElInfo* elInfo, 
					 SubAssembler* subAssembler,
					 Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1348
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1349
1350
1351
1352
1353
1354
1355
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }
 
  void MatrixGradientAndCoords_SOT::initElement(const ElInfo* elInfo, 
						SubAssembler* subAssembler,
						Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1356
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1357
1358
1359
1360
1361
1362
1363
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);  
  }

  void VecGradCoordsAtQP_SOT::initElement(const ElInfo* elInfo, 
					  SubAssembler* subAssembler,
					  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1364
1365
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1366
1367
1368
1369
1370
1371
1372
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);  
  }

  void VecAtQP_FOT::initElement(const ElInfo* elInfo, 
				SubAssembler* subAssembler,
				Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1373
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
  }

  void CoordsAtQP_FOT::initElement(const ElInfo* elInfo, 
				   SubAssembler* subAssembler,
				   Quadrature *quad) 
  {
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }

  void VecCoordsAtQP_FOT::initElement(const ElInfo* elInfo, 
				      SubAssembler* subAssembler,
				      Quadrature *quad) 
  {
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }

  void VectorGradient_FOT::initElement(const ElInfo* elInfo, 
				       SubAssembler* subAssembler,
				       Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1394
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1395
1396
1397
1398
1399
1400
  }

  void VectorFct_FOT::initElement(const ElInfo* elInfo, 
				  SubAssembler* subAssembler,
				  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1401
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
  }
 
  void VecFctAtQP_FOT::initElement(const ElInfo* elInfo, 
				   SubAssembler* subAssembler,
				   Quadrature *quad) 
  {
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }

  void VecAtQP_ZOT::initElement(const ElInfo* elInfo, 
				SubAssembler* subAssembler,
				Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1415
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1416
1417
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
1418
1419
1420
1421
1422
1423
1424
1425
1426
  void VecAtQP_ZOT::initElement(const ElInfo* smallElInfo,
				const ElInfo* largeElInfo,
				SubAssembler* subAssembler,
				Quadrature *quad)
  {
    vecAtQPs = getVectorAtQPs(vec, smallElInfo, largeElInfo, subAssembler, quad);
  }


1427
1428
1429
1430
  void MultVecAtQP_ZOT::initElement(const ElInfo* elInfo, 
				    SubAssembler* subAssembler,
				    Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1431
1432
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
1433
1434
1435
1436
1437
1438
  }

  void Vec2AtQP_ZOT::initElement(const ElInfo* elInfo, 
				 SubAssembler* subAssembler,
				 Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1439
1440
1441
1442
1443
1444
1445
1446
1447
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
  }

  void Vec2AtQP_ZOT::initElement(const ElInfo* smallElInfo, 
				 const ElInfo* largeElInfo,
				 SubAssembler* subAssembler,
				 Quadrature *quad)
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1448
    TEST_EXIT(vec1->getFESpace() == vec2->getFESpace())("Not yet implemented!\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
1449
1450
1451

    vecAtQPs1 = getVectorAtQPs(vec1, smallElInfo, largeElInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, smallElInfo, largeElInfo, subAssembler, quad);
1452
1453
  }

1454
1455
1456
1457
  void Vec3AtQP_ZOT::initElement(const ElInfo* elInfo, 
				 SubAssembler* subAssembler,
				 Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1458
1459
1460
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
    vecAtQPs3 = getVectorAtQPs(vec3, elInfo, subAssembler, quad);
1461
1462
  }

1463
1464
1465
1466
  void VecAndCoordsAtQP_ZOT::initElement(const ElInfo* elInfo, 
					 SubAssembler* subAssembler,
					 Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1467
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
1468
1469
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }
1470
1471
1472
1473
1474
  
  void Vec2AndGradAtQP_ZOT::initElement(const ElInfo* elInfo, 
					SubAssembler* subAssembler,
					Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1475
1476
1477
    vecAtQPs1 = getVectorAtQPs(vec1, elInfo, subAssembler, quad);
    vecAtQPs2 = getVectorAtQPs(vec2, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec1, elInfo, subAssembler, quad);
1478
1479
  }

1480
1481
1482
1483
  void FctGradientCoords_ZOT::initElement(const ElInfo* elInfo, 
					  SubAssembler* subAssembler,
					  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1484
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1485
1486
1487
1488
1489
1490
1491
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }
 
  void VecGradCoordsAtQP_ZOT::initElement(const ElInfo* elInfo, 
					  SubAssembler* subAssembler,
					  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1492
1493
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1494
1495
1496
1497
1498
1499
1500
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }
 
  void VecAndGradAtQP_ZOT::initElement(const ElInfo* elInfo, 
				       SubAssembler* subAssembler,
				       Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1501
1502
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1503
1504
1505
1506
1507
1508
  }
 
  void VecAndGradVecAtQP_ZOT::initElement(const ElInfo* elInfo, 
					  SubAssembler* subAssembler,
					  Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1509
1510
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    gradAtQPs = getGradientsAtQPs(vecGrd, elInfo, subAssembler, quad);
1511
1512
1513
1514
1515
1516
  }

  void VecAndGradVec2AtQP_ZOT::initElement(const ElInfo* elInfo, 
					   SubAssembler* subAssembler,
					   Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1517
1518
1519
    vecAtQPs = getVectorAtQPs(vec, elInfo, subAssembler, quad);
    grad1AtQPs = getGradientsAtQPs(vecGrd1, elInfo, subAssembler, quad);
    grad2AtQPs = getGradientsAtQPs(vecGrd2, elInfo, subAssembler, quad);
1520
1521
1522
1523
1524
1525
  }
 
  void FctGradient_ZOT::initElement(const ElInfo* elInfo, 
				    SubAssembler* subAssembler,
				    Quadrature *quad) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
1526
    gradAtQPs = getGradientsAtQPs(vec, elInfo, subAssembler, quad);
1527
1528
1529
1530
  }
 
  void CoordsAtQP_ZOT::initElement(const ElInfo* elInfo, 
				   SubAssembler* subAssembler,
1531
1532
				   Quadrature *quad) 
  {
1533
1534
1535
    coordsAtQPs = subAssembler->getCoordsAtQPs(elInfo, quad);
  }

1536
1537
1538
  void MatrixFct_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
			      DimMat<double> **LALt) const 
  {
1539
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1540
    for (int iq = 0; iq < nPoints; iq++)
1541
1542
1543
      lalt(Lambda, (*matrixFct)(vecAtQPs[iq]), *(LALt[iq]), symmetric, 1.0);
  }

1544
1545
1546
  void VecAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
			    DimMat<double> **LALt) const 
  {
1547
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1548
    for (int iq = 0; iq < nPoints; iq++)
1549
1550
      l1lt(Lambda, *(LALt[iq]), (*f)(vecAtQPs[iq]));
  }
1551

1552
1553
1554
  void Vec2AtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
			     DimMat<double> **LALt) const 
  {
1555
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1556
    for (int iq = 0; iq < nPoints; iq++)
1557
1558
1559
      l1lt(Lambda, *(LALt[iq]), (*f)(vecAtQPs1[iq], vecAtQPs2[iq]));
  }

1560
1561
1562
  void CoordsAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
			       DimMat<double> **LALt) const 
  {
1563
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1564
    for (int iq = 0; iq < nPoints; iq++)
1565
1566
1567
      l1lt(Lambda, (*LALt[iq]), (*g)(coordsAtQPs[iq]));
  }

1568
1569
1570
  void MatrixGradient_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
				   DimMat<double> **LALt) const 
  {
1571
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1572
    for (int iq = 0; iq < nPoints; iq++)
1573
1574
1575
      lalt(Lambda, (*f)(gradAtQPs[iq]), (*LALt[iq]), symmetric, 1.0);
  }

1576
1577
1578
  void FctGradient_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
				DimMat<double> **LALt) const 
  {
1579
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1580
    for (int iq = 0; iq < nPoints; iq++)
1581
1582
1583
      l1lt(Lambda, *(LALt[iq]), (*f)(gradAtQPs[iq]));
  }
  
Thomas Witkowski's avatar
Thomas Witkowski committed
1584
  void VecAndGradientAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints,
1585
1586
				       DimMat<double> **LALt) const 
  {
1587
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1588
    for (int iq = 0; iq < nPoints; iq++)
1589
1590
1591
      l1lt(Lambda, *(LALt[iq]), (*f)(vecAtQPs[iq], gradAtQPs[iq]));
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
1592
  void VecMatrixGradientAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints,
1593
1594
					  DimMat<double> **LALt) const 
  {
1595
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1596
    for (int iq = 0; iq < nPoints; iq++)
1597
1598
1599
      lalt(Lambda, (*f)(vecAtQPs[iq], gradAtQPs[iq]), (*LALt[iq]), symmetric, 1.0);
  }

1600
1601
1602
1603
  void VecAndCoordsAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints, 
				     DimMat<double> **LALt) const 
  { 
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1604
    for (int iq = 0; iq < nPoints; iq++)
1605
1606
1607
      l1lt(Lambda, *(LALt[iq]), (*f)(vecAtQPs[iq], coordsAtQPs[iq]));
  }
  
Thomas Witkowski's avatar
Thomas Witkowski committed
1608
  void MatrixGradientAndCoords_SOT::getLALt(const ElInfo *elInfo, int nPoints,
1609
1610
					    DimMat<double> **LALt) const 
  {
1611
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1612
    for (int iq = 0; iq < nPoints; iq++)
1613
1614
1615
      lalt(Lambda, (*f)(gradAtQPs[iq], coordsAtQPs[iq]), (*LALt[iq]), symmetric, 1.0);
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
1616
  void VecGradCoordsAtQP_SOT::getLALt(const ElInfo *elInfo, int nPoints,
1617
1618
				      DimMat<double> **LALt) const 
  {
1619
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1620
    for (int iq = 0; iq < nPoints; iq++)
1621
1622
1623
      l1lt(Lambda, *(LALt[iq]), (*f)(vecAtQPs[iq], gradAtQPs[iq], coordsAtQPs[iq]));
  }

1624
1625
1626
  void VecAtQP_FOT::getLb(const ElInfo *elInfo, int nPoints, 
			  VectorOfFixVecs<DimVec<double> >& Lb) const 
  {
1627
    const DimVec<WorldVector<double> > &Lambda = elInfo->getGrdLambda();
1628
1629
1630
1631
1632
1633

    if (bOne > -1) {
      for (int iq = 0; iq < nPoints; iq++)
	lb_one(Lambda, Lb[iq], (*f)(vecAtQPs[iq]));
    } else if (b) {
      for (int iq = 0; iq < nPoints; iq++)
1634
	lb(Lambda, *b, Lb[iq], (*f)(vecAtQPs[iq]));
1635
1636
    } else {
      for (int iq = 0; iq < nPoints; iq++)
1637
	l1(Lambda, Lb[iq], (*f)(vecAtQPs[iq]));