ResidualEstimator.cc 16.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


13
14
15
16
17
18
#include "ResidualEstimator.h"
#include "Operator.h"
#include "DOFMatrix.h"
#include "DOFVector.h"
#include "Assembler.h"
#include "Traverse.h"
19
#include "Initfile.h"
20

21
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
Thomas Witkowski's avatar
Thomas Witkowski committed
22
#include <mpi.h>
23
24
#endif

25
26
namespace AMDiS {

27
  ResidualEstimator::ResidualEstimator(std::string name, int r) 
28
    : Estimator(name, r),
29
30
      C0(0.0), 
      C1(0.0), 
31
      C2(0.0), 
32
      C3(0.0),
33
      jumpResidualOnly(false)
34
  {
35
36
    FUNCNAME("ResidualEstimator::ResidualEstimator()");

37
38
39
40
    Parameters::get(name + "->C0", C0);
    Parameters::get(name + "->C1", C1);
    Parameters::get(name + "->C2", C2);
    Parameters::get(name + "->C3", C3);
41
42
43
44
45

    C0 = C0 > 1.e-25 ? sqr(C0) : 0.0;
    C1 = C1 > 1.e-25 ? sqr(C1) : 0.0;
    C2 = C2 > 1.e-25 ? sqr(C2) : 0.0;
    C3 = C3 > 1.e-25 ? sqr(C3) : 0.0;
46

47
48
49
    if (C1 != 0.0 && C0 == 0.0 && C3 == 0.0)
      jumpResidualOnly = true;
      
50
    TEST_EXIT(C2 == 0.0)("C2 is not used! Please remove it or set it to 0.0!\n");
51
52
  }

53

54
55
56
  void ResidualEstimator::init(double ts)
  {
    FUNCNAME("ResidualEstimator::init()");
57

58
    timestep = ts;
Thomas Witkowski's avatar
Thomas Witkowski committed
59
    nSystems = static_cast<int>(uh.size());
60

Thomas Witkowski's avatar
Thomas Witkowski committed
61
    TEST_EXIT_DBG(nSystems > 0)("no system set\n");
62
63

    dim = mesh->getDim();
64
65
    basFcts = new const BasisFunction*[nSystems];
    quadFast = new FastQuadrature*[nSystems];
66
67

    degree = 0;
Thomas Witkowski's avatar
Thomas Witkowski committed
68
    for (int system = 0; system < nSystems; system++) {
69
      basFcts[system] = uh[system]->getFeSpace()->getBasisFcts();
70
      degree = std::max(degree, basFcts[system]->getDegree());
71
72
73
74
    }
    degree *= 2;

    quad = Quadrature::provideQuadrature(dim, degree);
Thomas Witkowski's avatar
Thomas Witkowski committed
75
    nPoints = quad->getNumPoints();
76
77

    Flag flag = INIT_PHI | INIT_GRD_PHI;
78
79
    if (degree > 2)
      flag |= INIT_D2_PHI;    
80

81
    for (int system = 0; system < nSystems; system++)
82
83
      quadFast[system] = FastQuadrature::provideFastQuadrature(basFcts[system], 
							       *quad, 
84
							       flag);    
85
  
86
87
88
89
    uhEl.resize(nSystems);
    uhNeigh.resize(nSystems);
    if (timestep)
      uhOldEl.resize(nSystems);
90

Thomas Witkowski's avatar
Thomas Witkowski committed
91
    for (int system = 0; system < nSystems; system++) {
92
93
      uhEl[system].change_dim(basFcts[system]->getNumber()); 
      uhNeigh[system].change_dim(basFcts[system]->getNumber());
94
      if (timestep)
95
	uhOldEl[system].change_dim(basFcts[system]->getNumber());
96
97
    }

98
99
100
101
    if (timestep) {
      uhQP.change_dim(nPoints);
      uhOldQP.change_dim(nPoints);
    }
102
103

    riq.change_dim(nPoints);
104

105
    // clear error indicators and mark elements for jumpRes
106
107
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL);
108
    while (elInfo) {
109
110
111
      // SIMON: DEL LINE BELOW
      elInfo->getElement()->setEstimation(0.0, row);

112
113
114
115
116
117
118
119
      elInfo->getElement()->setMark(1);
      elInfo = stack.traverseNext(elInfo);
    }

    est_sum = 0.0;
    est_max = 0.0;
    est_t_sum = 0.0;
    est_t_max = 0.0;
120

121
    traverseFlag = 
122
123
124
125
126
127
      Mesh::FILL_NEIGH      |
      Mesh::FILL_COORDS     |
      Mesh::FILL_OPP_COORDS |
      Mesh::FILL_BOUND      |
      Mesh::FILL_GRD_LAMBDA |
      Mesh::FILL_DET        |
128
      Mesh::CALL_LEAF_EL;
129
130
    neighInfo = mesh->createNewElInfo();

131
    // === Prepare date for computing jump residual. ===
132
133
134
135
136
137
138
139
140
141
    if (C1 > 0.0 && dim > 1) {
      surfaceQuad = Quadrature::provideQuadrature(dim - 1, degree);
      nPointsSurface = surfaceQuad->getNumPoints();
      grdUhEl.resize(nPointsSurface);
      grdUhNeigh.resize(nPointsSurface);
      jump.resize(nPointsSurface);
      localJump.resize(nPointsSurface);
      nNeighbours = Global::getGeo(NEIGH, dim);
      lambdaNeigh = new DimVec<WorldVector<double> >(dim, NO_INIT);
      lambda = new DimVec<double>(dim, NO_INIT);
142
143
144
145
146

      secondOrderTerms.resize(nSystems);
      for (int system = 0; system < nSystems; system++) {
	secondOrderTerms[system] = false;

147
148
149
	if (matrix[system] == NULL)
	  continue;

150
151
152
153
	for (std::vector<Operator*>::iterator it = matrix[system]->getOperators().begin();
	     it != matrix[system]->getOperators().end(); ++it)
	  secondOrderTerms[system] = secondOrderTerms[system] || (*it)->secondOrderTerms();
      }
154
    }
155
156
  }

157

158
159
160
161
  void ResidualEstimator::exit(bool output)
  {
    FUNCNAME("ResidualEstimator::exit()");

162
163
164
165
166
167
168
169
170
171
172
173
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    double send_est_sum = est_sum;
    double send_est_max = est_max;
    double send_est_t_sum = est_t_sum;
    double send_est_t_max = est_t_max;

    MPI::COMM_WORLD.Allreduce(&send_est_sum, &est_sum, 1, MPI_DOUBLE, MPI_SUM);
    MPI::COMM_WORLD.Allreduce(&send_est_max, &est_max, 1, MPI_DOUBLE, MPI_MAX);
    MPI::COMM_WORLD.Allreduce(&send_est_t_sum, &est_t_sum, 1, MPI_DOUBLE, MPI_SUM);
    MPI::COMM_WORLD.Allreduce(&send_est_t_max, &est_t_max, 1, MPI_DOUBLE, MPI_MAX);
#endif

174
175
176
177
    est_sum = sqrt(est_sum);
    est_t_sum = sqrt(est_t_sum);

    if (output) {
178
      MSG("estimate for component %d = %.8e\n", row, est_sum);
179
      if (C3)
180
	MSG("time estimate for component %d = %.8e\n", row, est_t_sum);
181
182
    }

183
184
    delete [] basFcts;
    delete [] quadFast;
185

186
    if (C1 && (dim > 1)) {
187
188
      delete lambdaNeigh;
      delete lambda;
189
190
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
191
    delete neighInfo;
192
193
  }

194

195
  void ResidualEstimator::estimateElement(ElInfo *elInfo, DualElInfo *dualElInfo)
196
  {    
197
198
    FUNCNAME("ResidualEstimator::estimateElement()");

Thomas Witkowski's avatar
Thomas Witkowski committed
199
    TEST_EXIT_DBG(nSystems > 0)("no system set\n");
200

Thomas Witkowski's avatar
Thomas Witkowski committed
201
    Element *el = elInfo->getElement();
202
203
    double est_el = el->getEstimation(row);
    // SIMON    double est_el = 0.0;
204
205
    std::vector<Operator*>::iterator it;
    std::vector<double*>::iterator itfac;
206

207
    // === Init assemblers. ===
Thomas Witkowski's avatar
Thomas Witkowski committed
208
    for (int system = 0; system < nSystems; system++) {
209
210
211
      if (matrix[system] == NULL) 
	continue;

212
213
214
215
216
      DOFMatrix *dofMat = const_cast<DOFMatrix*>(matrix[system]);
      DOFVector<double> *dofVec = const_cast<DOFVector<double>*>(fh[system]);

      for (it = dofMat->getOperatorsBegin(), itfac = dofMat->getOperatorEstFactorBegin();
	   it != dofMat->getOperatorsEnd(); ++it, ++itfac)
217
218
219
220
221
222
223
	if (*itfac == NULL || **itfac != 0.0) {	  
	  // If the estimator must only compute the jump residual but there are no
	  // second order terms in the operator, it can be skipped.
	  if (jumpResidualOnly && (*it)->secondOrderTerms() == false)
	    continue;
	  
	  if (dualElInfo)
224
225
226
	    (*it)->getAssembler()->initElement(dualElInfo->smallElInfo, 
					       dualElInfo->largeElInfo,
					       quad);
227
	  else
228
	    (*it)->getAssembler()->initElement(elInfo, NULL, quad);	  
229
	}
230

231
      if (C0 > 0.0)
232
	for (it = dofVec->getOperatorsBegin(); it != dofVec->getOperatorsEnd(); ++it) {
233
	  if (dualElInfo)
234
235
236
	    (*it)->getAssembler()->initElement(dualElInfo->smallElInfo, 
					       dualElInfo->largeElInfo,
					       quad);
237
	  else
238
	    (*it)->getAssembler()->initElement(elInfo, NULL, quad);	  
239
	}
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
    }


    // === Compute element residuals and time error estimation. ===
    if (C0 || C3)
      est_el += computeElementResidual(elInfo, dualElInfo);

    // === Compute jump residuals. ===
    if (C1 && dim > 1)
      est_el += computeJumpResidual(elInfo, dualElInfo);

    // === Update global residual variables. ===
    el->setEstimation(est_el, row);
    el->setMark(0);
    est_sum += est_el;
255
    est_max = std::max(est_max, est_el);
256
257
258
259
260
261
262
263
  }


  double ResidualEstimator::computeElementResidual(ElInfo *elInfo, 
						   DualElInfo *dualElInfo)
  {
    FUNCNAME("ResidualEstimator::computeElementResidual()");

264
    TEST_EXIT(!dualElInfo)("Not yet implemented!\n");
265
266
267
268
269

    std::vector<Operator*>::iterator it;
    std::vector<double*>::iterator itfac;
    double det = elInfo->getDet();
    double h2 = h2_from_det(det, dim);
270
    riq = 0.0;
271
272
273
274
275

    for (int system = 0; system < nSystems; system++) {
      if (matrix[system] == NULL) 
	continue;

276
      if (timestep && uhOld[system]) {
277
	TEST_EXIT_DBG(uhOld[system])("no uhOld\n");
278
	uhOld[system]->getLocalVector(elInfo->getElement(), uhOldEl[system]);
279
  
280
281
282
	// === Compute time error. ===

	if (C0 > 0.0 || C3 > 0.0) {   
283
284
285
	  uh[system]->getVecAtQPs(elInfo, NULL, quadFast[system], uhQP);
	  uhOld[system]->getVecAtQPs(elInfo, NULL, quadFast[system], uhOldQP);
	  
286
	  if (C3 > 0.0 && system == std::max(row, 0)) {
287
	    double result = 0.0;
Thomas Witkowski's avatar
Thomas Witkowski committed
288
	    for (int iq = 0; iq < nPoints; iq++) {
289
	      double tiq = (uhQP[iq] - uhOldQP[iq]);
290
	      result += quad->getWeight(iq) * tiq * tiq;
291
	    }
292
	    double v = C3 * det * result;
293
	    est_t_sum += v;
294
	    est_t_max = std::max(est_t_max, v);
295
296
297
	  }
	}
      }
298
           
299
      // === Compute element residual. ===
300
301
302
303
      if (C0 > 0.0) {
	DOFMatrix *dofMat = const_cast<DOFMatrix*>(matrix[system]);
	DOFVector<double> *dofVec = const_cast<DOFVector<double>*>(fh[system]);
  
Thomas Witkowski's avatar
Thomas Witkowski committed
304
	for (it = dofMat->getOperatorsBegin(), itfac = dofMat->getOperatorEstFactorBegin();
305
	     it != dofMat->getOperatorsEnd();  ++it, ++itfac) {
306
	  if (*itfac == NULL || **itfac != 0.0) {
307
	    if ((*it)->zeroOrderTerms()) {
308
	      uhQP.change_dim(nPoints);
309
310
	      uh[system]->getVecAtQPs(elInfo, NULL, quadFast[system], uhQP);
	    }
311
	    if ((*it)->firstOrderTermsGrdPsi() || (*it)->firstOrderTermsGrdPhi()) {
312
313
	      grdUhQp.change_dim(nPoints);
	      uh[system]->getGrdAtQPs(elInfo, NULL, quadFast[system], grdUhQp);
314
	    }
315
	    if (degree > 2 && (*it)->secondOrderTerms()) {
316
317
	      D2UhQp.change_dim(nPoints);
	      uh[system]->getD2AtQPs(elInfo, NULL, quadFast[system], D2UhQp);
318
	    }
319
320
321
	  }
	}
	
322
323
	// === Compute the element residual and store it in irq. ===

324
	r(elInfo,
Thomas Witkowski's avatar
Thomas Witkowski committed
325
	  nPoints, 
326
	  uhQP,
327
328
	  grdUhQp,
	  D2UhQp,
329
	  uhOldQP,
330
331
	  grdUhOldQp,  // not used
	  D2UhOldQp,  // not used
Thomas Witkowski's avatar
Thomas Witkowski committed
332
333
	  dofMat, 
	  dofVec,
334
	  quad,
335
	  riq);
336
337
338
339
      }     
    }

    // add integral over r square
340
    double result = 0.0;
341
    for (int iq = 0; iq < nPoints; iq++)
342
      result += quad->getWeight(iq) * riq[iq] * riq[iq];
343
   
344
    if (timestep != 0.0 || norm == NO_NORM || norm == L2_NORM)
345
      result = C0 * h2 * h2 * det * result;
346
    else
347
      result = C0 * h2 * det * result;
348
    
349
350
    return result;
  }
351

352

353
354
355
356
357
358
359
360
361
362
363
  double ResidualEstimator::computeJumpResidual(ElInfo *elInfo, 
						DualElInfo *dualElInfo)
  {
    FUNCNAME("ResidualEstimator::computeJumpResidual()");

    double result = 0.0;
    int dow = Global::getGeo(WORLD);
    Element *el = elInfo->getElement();
    const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda();
    double det = elInfo->getDet();
    double h2 = h2_from_det(det, dim);
364

365
366
    for (int face = 0; face < nNeighbours; face++) {  
      Element *neigh = const_cast<Element*>(elInfo->getNeighbour(face));
367

368
369
      if (!(neigh && neigh->getMark()))
	continue;
370

371
372
      int oppV = elInfo->getOppVertex(face);
	
373
374
      el->sortFaceIndices(face, faceIndEl);
      neigh->sortFaceIndices(oppV, faceIndNeigh);	
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
      neighInfo->setElement(const_cast<Element*>(neigh));
      neighInfo->setFillFlag(Mesh::FILL_COORDS);
      
      for (int i = 0; i < dow; i++)
	neighInfo->getCoord(oppV)[i] = elInfo->getOppCoord(face)[i];
      
      // periodic leaf data ?
      ElementData *ldp = el->getElementData()->getElementData(PERIODIC);	
      bool periodicCoords = false;
      
      if (ldp) {
	typedef std::list<LeafDataPeriodic::PeriodicInfo> PerInfList;
	PerInfList& infoList = dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList();
	
	for (PerInfList::iterator it = infoList.begin(); it != infoList.end(); ++it) {
	  if (it->elementSide == face) {
391
	    for (int i = 0; i < dim; i++) {
392
393
	      int i1 = faceIndEl[i];
	      int i2 = faceIndNeigh[i];
394
	      
395
396
397
398
	      int j = 0;
	      for (; j < dim; j++)
		if (i1 == el->getVertexOfPosition(INDEX_OF_DIM(dim - 1, dim), face, j))
		  break;
399
	      
400
	      TEST_EXIT_DBG(j != dim)("vertex i1 not on face ???\n");
401
	      
402
	      neighInfo->getCoord(i2) = (*(it->periodicCoords))[j];
403
	    }
404
405
	    periodicCoords = true;
	    break;
406
	  }
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
	}
      }  // if (ldp)
      
      if (!periodicCoords) {
	for (int i = 0; i < dim; i++) {
	  int i1 = faceIndEl[i];
	  int i2 = faceIndNeigh[i];
	  for (int j = 0; j < dow; j++)
	    neighInfo->getCoord(i2)[j] = elInfo->getCoord(i1)[j];
	}
      }
	
      Parametric *parametric = mesh->getParametric();
      if (parametric)
	neighInfo = parametric->addParametricInfo(neighInfo);	  
422

423
424
425
426
427
428
429
430
      double detNeigh = abs(neighInfo->calcGrdLambda(*lambdaNeigh));
           
      for (int iq = 0; iq < nPointsSurface; iq++)
	jump[iq].set(0.0);     
      
      for (int system = 0; system < nSystems; system++) {
	if (matrix[system] == NULL || secondOrderTerms[system] == false) 
	  continue;
431
	      
432
	uh[system]->getLocalVector(el, uhEl[system]);	
433
434
435
436
437
438
439
	uh[system]->getLocalVector(neigh, uhNeigh[system]);
	  
	for (int iq = 0; iq < nPointsSurface; iq++) {
	  (*lambda)[face] = 0.0;
	  for (int i = 0; i < dim; i++)
	    (*lambda)[faceIndEl[i]] = surfaceQuad->getLambda(iq, i);
	  
440
	  basFcts[system]->evalGrdUh(*lambda, grdLambda, uhEl[system], grdUhEl[iq]);
441
442
443
444
445
	  
	  (*lambda)[oppV] = 0.0;
	  for (int i = 0; i < dim; i++)
	    (*lambda)[faceIndNeigh[i]] = surfaceQuad->getLambda(iq, i);		  
	  
446
	  basFcts[system]->evalGrdUh(*lambda, *lambdaNeigh, uhNeigh[system], grdUhNeigh[iq]);
447
448
449
450
451
452
453
454
455
456
457
458
459
460
	  
	  grdUhEl[iq] -= grdUhNeigh[iq];
	} // for iq				
	
	std::vector<double*>::iterator fac;
	std::vector<Operator*>::iterator it;
	DOFMatrix *mat = const_cast<DOFMatrix*>(matrix[system]);
        for (it = mat->getOperatorsBegin(), fac = mat->getOperatorEstFactorBegin(); 
	     it != mat->getOperatorsEnd(); ++it, ++fac) {
	
	  if (*fac == NULL || **fac != 0.0) {
	    for (int iq = 0; iq < nPointsSurface; iq++)
	      localJump[iq].set(0.0);
	    
461
	    (*it)->weakEvalSecondOrder(grdUhEl, localJump);
462

463
464
465
466
467
468
469
470
471
472
473
474
475
476
	    double factor = *fac ? **fac : 1.0;
	    if (factor != 1.0)
	      for (int i = 0; i < nPointsSurface; i++)
		localJump[i] *= factor;
	    
	    for (int i = 0; i < nPointsSurface; i++)
	      jump[i] += localJump[i];
	  }		
	} // for (it = ...
      } // for system
    
      double val = 0.0;
      for (int iq = 0; iq < nPointsSurface; iq++)
	val += surfaceQuad->getWeight(iq) * (jump[iq] * jump[iq]);
Thomas Witkowski's avatar
Thomas Witkowski committed
477

478
479
      double d = 0.5 * (det + detNeigh);
   
480
      if (norm == NO_NORM || norm == L2_NORM)
481
	val *= C1 * h2_from_det(d, dim) * d;
482
      else
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
	val *= C1 * d;
      
      if (parametric)
	neighInfo = parametric->removeParametricInfo(neighInfo);
      
      neigh->setEstimation(neigh->getEstimation(row) + val, row);
      result += val;
    } // for face
    
    double val = fh[std::max(row, 0)]->getBoundaryManager()->
      boundResidual(elInfo, matrix[std::max(row, 0)], uh[std::max(row, 0)]);    
    if (norm == NO_NORM || norm == L2_NORM)
      val *= C1 * h2;
    else
      val *= C1;   
    result += val;
499

500
    return result;
501
502
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
503

504
  void r(const ElInfo *elInfo,
Thomas Witkowski's avatar
Thomas Witkowski committed
505
	 int nPoints,
506
507
508
509
510
511
	 const mtl::dense_vector<double>& uhIq,
	 const mtl::dense_vector<WorldVector<double> > &grdUhIq,
	 const mtl::dense_vector<WorldMatrix<double> > &D2UhIq,
	 const mtl::dense_vector<double>& uhOldIq,
	 const mtl::dense_vector<WorldVector<double> > &grdUhOldIq,
	 const mtl::dense_vector<WorldMatrix<double> > &D2UhOldIq,
512
513
514
	 DOFMatrix *A, 
	 DOFVector<double> *fh,
	 Quadrature *quad,
515
	 ElementVector& result)
516
  {
517
518
    std::vector<Operator*>::iterator it;
    std::vector<double*>::iterator fac;
519
520

    // lhs
Thomas Witkowski's avatar
Thomas Witkowski committed
521
522
    for (it = A->getOperatorsBegin(), fac = A->getOperatorEstFactorBegin(); 
	 it != A->getOperatorsEnd(); ++it, ++fac) {
523
524
525
     
      double factor = *fac ? **fac : 1.0;

526
      if (factor) {
527
528
529
530
531
532
	if (num_rows(D2UhIq) > 0)
	  (*it)->evalSecondOrder(nPoints, uhIq, grdUhIq, D2UhIq, result, -factor);	

	if (num_rows(grdUhIq) > 0) {
	  (*it)->evalFirstOrderGrdPsi(nPoints, uhIq, grdUhIq, D2UhIq, result, factor);
	  (*it)->evalFirstOrderGrdPhi(nPoints, uhIq, grdUhIq, D2UhIq, result, factor);
533
534
	}
	
535
	if (num_rows(uhIq) > 0)
Thomas Witkowski's avatar
Thomas Witkowski committed
536
	  (*it)->evalZeroOrder(nPoints, uhIq, grdUhIq, D2UhIq, result, factor);	
537
538
539
540
      }
    }
    
    // rhs
Thomas Witkowski's avatar
Thomas Witkowski committed
541
542
    for (it = fh->getOperatorsBegin(), fac = fh->getOperatorEstFactorBegin(); 
	 it != fh->getOperatorsEnd(); ++it, ++fac) {
543

544
545
      double factor = *fac ? **fac : 1.0;

546
547
      if (factor) {
	if ((*it)->getUhOld()) {
548
	  if (num_rows(D2UhOldIq) > 0)
Thomas Witkowski's avatar
Thomas Witkowski committed
549
550
	    (*it)->evalSecondOrder(nPoints, uhOldIq, grdUhOldIq, D2UhOldIq, result, factor);
	  
551
	  if (num_rows(grdUhOldIq) > 0) {
Thomas Witkowski's avatar
Thomas Witkowski committed
552
553
	    (*it)->evalFirstOrderGrdPsi(nPoints, uhOldIq, grdUhOldIq, D2UhOldIq, result, -factor);
	    (*it)->evalFirstOrderGrdPhi(nPoints, uhOldIq, grdUhOldIq, D2UhOldIq, result, -factor);
554
	  }
Thomas Witkowski's avatar
Thomas Witkowski committed
555

556
	  if (num_rows(uhOldIq) > 0)
Thomas Witkowski's avatar
Thomas Witkowski committed
557
	    (*it)->evalZeroOrder(nPoints, uhOldIq, grdUhOldIq, D2UhOldIq, result, -factor);	  
558
	} else {
559
	  ElementVector fx(nPoints, 0.0);
Thomas Witkowski's avatar
Thomas Witkowski committed
560
	  (*it)->getC(elInfo, nPoints, fx);
561

562
	  for (int iq = 0; iq < nPoints; iq++)
563
564
565
566
567
568
569
570
	    result[iq] -= factor * fx[iq];
	}
      }
    }    
  }


}