Plugins
time_extrapolation.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2016: G-CSC, Goethe University Frankfurt
3  * Author: Arne Naegel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef TIME_EXTRAPOLATION_H_
34 #define TIME_EXTRAPOLATION_H_
35 
36 #include <vector>
37 #include <cmath>
38 
39 // ug libraries
40 #include "common/common.h"
42 
45 
50 
53 
54 
55 
56 namespace ug{
57 
58 /*
59  std::vector<size_t> steps {1, 2, 4};
60  timex = new AitkenNevilleTimex(steps);
61 
62  //
63  timex.set_solution(sol0, 0); // single step
64  timex.set_solution(sol1, 1); // double step
65  timex.set_solution(sol2, 2); // four step
66 
67  timex.set_estimator(L2NormEstimator())
68  timex.set_estimator(InfNormEstimator())
69  timex.set_estimator(RelativeEstimator())
70  //
71  timex.apply() // updating sol1 and sol2
72 
73  timex.get_error_estimate()
74 
75  */
76 
77 namespace tools {
78 
79 
81  inline void VecScaleAddWithNormRel(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
82  {
83  const double update = alpha2*vFine + alpha3*vCoarse;
84  vUpdate = vUpdate + update;
85  norm = std::max(norm, 0.5*fabs(update)/(1.0+fabs(vFine)+fabs(vCoarse)));
86  }
87 
89  template<typename vector_t, template <class T> class TE_VEC>
90  inline void VecScaleAddWithNormRel(TE_VEC<vector_t> &vUpdate, double alpha2, const TE_VEC<vector_t> &vFine, double alpha3, const TE_VEC<vector_t> &vCoarse, double &norm)
91  {
92  for(size_t i=0; i<vUpdate.size(); i++)
93  VecScaleAddWithNormRel(vUpdate[i], alpha2, vFine[i], alpha3, vCoarse[i], norm);
94  }
95 
97  inline void VecScaleAddWithNormInf(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
98  {
99  const double update = alpha2*vFine + alpha3*vCoarse;
100  vUpdate = vUpdate + update;
101  norm = std::max(norm, fabs(update));
102  }
103 
105  template<typename vector_t, template <class T> class TE_VEC>
106  inline void VecScaleAddWithNormInf(TE_VEC<vector_t> &vUpdate, double alpha2, const TE_VEC<vector_t> &vFine, double alpha3, const TE_VEC<vector_t> &vCoarse, double &norm, const int delta=1, const int offset=0)
107  {
108  // std::cerr << norm << " "<< delta << offset << std::endl;
109  for(size_t i=offset; i<vUpdate.size(); i+=delta)
110  VecScaleAddWithNormInf(vUpdate[i], alpha2, vFine[i], alpha3, vCoarse[i], norm);
111 
112  // std::cerr << norm << std::endl;
113  }
114 
115 
117  inline void VecScaleAddWithNorm2(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
118  {
119  const double update = alpha2*vFine + alpha3*vCoarse;
120  vUpdate = vUpdate+ update;
121  norm += update*update;
122  }
123 
125  template<typename vector_t, template <class T> class TE_VEC>
126  inline void VecScaleAddWithNorm2(TE_VEC<vector_t> &vUpdate, double alpha2, const TE_VEC<vector_t> &vFine, double alpha3, const TE_VEC<vector_t> &vCoarse, double &norm, const int delta=1, const int offset=0)
127  {
128  for(size_t i=offset; i<vUpdate.size(); i+=delta)
129  VecScaleAddWithNorm2(vUpdate[i], alpha2, vFine[i], alpha3, vCoarse[i], norm);
130  }
131 
132 
133 
134 }
135 
137 
140 template <class TVector>
142 {
143 public:
144  // constructor
145  ISubDiagErrorEst() : m_est(0.0) {};
146 
147  // destructor
148  virtual ~ISubDiagErrorEst() {};
149 
151  virtual bool update(SmartPtr<TVector> vUpdate, number alpha2, SmartPtr<TVector> vFine, SmartPtr<TVector> vCoarse) = 0;
152 
155  void reset_estimate() { m_est=0.0; };
156 
157  virtual std::string config_string() const {return "ISubDiagErrorEst";}
158 
159 protected:
161 };
162 
163 
165 
167 template <class TVector>
168 class NormInfEstimator : public ISubDiagErrorEst<TVector>
169 {
170 protected:
172  int m_stride;
173  int m_offset;
174 
175 public:
176  // constructor
178  ISubDiagErrorEst<TVector>(), m_stride(1), m_offset(0) {};
179 
180 
181  // apply
182  bool update(SmartPtr<TVector> vUpdate, number alpha2, SmartPtr<TVector> vFine, SmartPtr<TVector> vCoarse)
183  {
184  const int delta = m_stride;
185  const int offset = m_offset;
186  base_type::m_est=0.0;
187  tools::VecScaleAddWithNormInf(*vUpdate, alpha2, *vFine, -alpha2, *vCoarse, base_type::m_est, delta, offset);
188  return true;
189  }
190 
191  // offset (e.g., component to work on for systems w/ CPU1)
192  void set_offset(int offset) {m_offset=offset;}
193 
194  // delta (e.g., total number components for systems w/ CPU1)
195  void set_stride(int delta) {m_stride=delta;}
196 
197 };
198 
199 
201 template <class TVector>
202 class Norm2Estimator : public ISubDiagErrorEst<TVector>
203 {
204 protected:
206  int m_stride;
207  int m_offset;
208 
209 public:
210  // constructor
212  ISubDiagErrorEst<TVector>(), m_stride(1), m_offset(0) {};
213  Norm2Estimator(int stride) :
214  ISubDiagErrorEst<TVector>(), m_stride(stride), m_offset(0) {};
215  Norm2Estimator(int delta, int offset) :
216  ISubDiagErrorEst<TVector>(), m_stride(delta), m_offset (offset) {};
217 
218  // apply
219  bool update(SmartPtr<TVector> vUpdate, number alpha2, SmartPtr<TVector> vFine, SmartPtr<TVector> vCoarse)
220  {
221  const int delta = m_stride;
222  const int offset = m_offset;
223  base_type::m_est=0.0;
224  tools::VecScaleAddWithNorm2(*vUpdate, alpha2, *vFine, -alpha2, *vCoarse, base_type::m_est, delta, offset);
225 #ifdef UG_PARALLEL
226  double locEst = base_type::m_est;
227  double globEst =0.0;
228  vUpdate->layouts()->proc_comm().allreduce(&locEst, &globEst, 1, PCL_DT_DOUBLE, PCL_RO_SUM);
229  base_type::m_est = globEst;
230 #endif
232  return true;
233  }
234 
235  // offset (e.g., component to work on for systems w/ CPU1)
236  void set_offset(int offset) { m_offset=offset;}
237 
238  // delta (e.g., total number components for systems w/ CPU1)
239  void set_stride(int delta) { m_stride=delta;}
240 
241 };
242 
243 
245 template <class TVector>
246 class NormRelEstimator : public ISubDiagErrorEst<TVector>
247 {
248 protected:
250 
251 public:
252  // constructor
254 
255  // apply w/ rel norm
256  bool update(SmartPtr<TVector> vUpdate, number alpha2, SmartPtr<TVector> vFine, SmartPtr<TVector> vCoarse)
257  {
259  tools::VecScaleAddWithNormRel(*vUpdate, alpha2, *vFine, -alpha2, *vCoarse, base_type::m_est);
260  return true;
261  }
262 };
263 
264 /*
265 template<class TVector>
266 class VectorDebugWritingEstimator
267  : public VectorDebugWritingObject<TVector>
268 {
269 public:
271  typedef TVector vector_type;
272 
273 public:
274  VectorDebugWritingEstimator()
275  : VectorDebugWritingObject<vector_type>() {}
276 
277  VectorDebugWritingEstimator(SmartPtr<IVectorDebugWriter<vector_type> > spDebugWriter)
278  : VectorDebugWritingObject<vector_type>(spDebugWriter) {}
279 
280  int get_call_id() { return m_dgbCall; }
281  void inc_call_id() { m_dgbCall++; }
282 
283 protected:
285  int m_dgbCall;
286 };
287 */
288 
289 
290 
291 
293 template <typename TGridFunction>
295 : public IComponentSpace<TGridFunction>
296 {
297  public:
299 
300  SupErrorEvaluator(const char *fctNames) : base_type(fctNames) {};
301  //SupErrorEvaluator(const char *fctNames, number scale) : base_type(fctNames, 1, scale) {};
302  SupErrorEvaluator(const char *fctNames, const char* ssNames /*, number scale*/)
303  : base_type(fctNames, ssNames, 1/*, scale*/) {};
305 
306 
309 
311  { return norm(*uFine); }
312 
313  double norm(TGridFunction& uFine)
314  {
315  // gather subsets in group
316  SubsetGroup ssGrp(uFine.domain()->subset_handler());
317  if (base_type::m_ssNames != NULL)
319  else
320  ssGrp.add_all();
321 
322  double maxVal = 0.0;
323 
324  // loop subsets
325  for (size_t i = 0; i < ssGrp.size(); ++i)
326  {
327  // get subset index
328  const int si = ssGrp[i];
329 
330  // loop elements of subset and dim
331  switch (ssGrp.dim(i))
332  {
333  case DIM_SUBSET_EMPTY_GRID: break;
334  case 0: maxVal = std::max(maxVal, findFctMaxOnSubset<Vertex>(uFine, si)); break;
335  case 1: maxVal = std::max(maxVal, findFctMaxOnSubset<Edge>(uFine, si)); break;
336  case 2: maxVal = std::max(maxVal, findFctMaxOnSubset<Face>(uFine, si)); break;
337  case 3: maxVal = std::max(maxVal, findFctMaxOnSubset<Volume>(uFine, si)); break;
338  default: UG_THROW("SupErrorEvaluator::norm: Dimension " << ssGrp.dim(i) << " not supported.");
339  }
340  }
341 
342  #ifdef UG_PARALLEL
343  // max over processes
344  if (pcl::NumProcs() > 1)
345  {
347  number local = maxVal;
348  com.allreduce(&local, &maxVal, 1, PCL_DT_DOUBLE, PCL_RO_MAX);
349  }
350  #endif
351 
352  // return the result
353  return maxVal;
354  }
355 
356  double norm2(TGridFunction& uFine)
357  { double norm1 = norm(uFine); return norm1*norm1;}
358 
359  double distance(TGridFunction& uFine, TGridFunction& uCoarse)
360  {
361  UG_COND_THROW(uFine.dof_distribution().get() != uCoarse.dof_distribution().get(),
362  "Coarse and fine solutions do not have the same underlying dof distro.");
363 
364  SmartPtr<TGridFunction> uErr = uCoarse.clone();
365  uErr->operator-=(uFine);
366  return norm(*uErr);
367  }
368 
369  double distance2(TGridFunction& uFine, TGridFunction& uCoarse)
370  { double dist = distance(uFine, uCoarse); return dist*dist;}
371 
372  protected:
373  template <typename TBaseElem>
374  number findFctMaxOnSubset(const TGridFunction& u, int si) const
375  {
376  ConstSmartPtr<DoFDistribution> dd = u.dof_distribution();
377 
378  size_t fct;
379  try {fct = dd->fct_id_by_name(base_type::m_fctNames.c_str());}
380  UG_CATCH_THROW("Function index could not be determined.\n"
381  "Bear in mind that only one function can be evaluated in this error evaluator.");
382 
383  number maxVal = 0.0;
384  typename DoFDistribution::traits<TBaseElem>::const_iterator it = dd->begin<TBaseElem>(si);
385  typename DoFDistribution::traits<TBaseElem>::const_iterator itEnd = dd->end<TBaseElem>(si);
386  for (; it != itEnd; ++it)
387  {
388  std::vector<DoFIndex> vInd;
389 
390  // we compare against all indices on the element
391  // which means most indices will be compared against quite often
392  // but as this is a sup norm, this is not a problem (only in terms of performance)
393  size_t nInd = dd->dof_indices(*it, fct, vInd, false, false);
394  for (size_t i = 0; i < nInd; ++i)
395  maxVal = std::max(maxVal, fabs(DoFRef(u, vInd[i])));
396  }
397 
398  return maxVal;
399  }
400 };
401 
402 
403 
408 template <typename TDataIn, typename TGridFunction>
410  : public StdIntegrand<number, TGridFunction::dim, DeltaSquareIntegrand<TDataIn, TGridFunction> >
411 {
412  public:
413  // world dimension of grid function
414  static const int worldDim = TGridFunction::dim;
415 
416  // data type
417  typedef TDataIn data_type;
418 
419  private:
420 
421  static number product(const number &x, const number &y)
422  {return x*y;}
423 
425  {return VecDot(x,y);}
426 
427 
428  // data to integrate
430 
431  // grid function
432  const TGridFunction* m_pGridFct1;
433  const TGridFunction* m_pGridFct2;
434 
435  // time
437 
438  public:
441  const TGridFunction* pGridFct1, const TGridFunction* pGridFct2,
442  number time)
443  : m_spData(spData), m_pGridFct1(pGridFct1), m_pGridFct2(pGridFct2), m_time(time)
444  {
445  m_spData->set_function_pattern(pGridFct1->function_pattern());
446  };
447 
450  : m_spData(spData), m_pGridFct1(NULL), m_pGridFct2(NULL), m_time(time)
451  {
452  if(m_spData->requires_grid_fct())
453  UG_THROW("UserDataDeltaIntegrand: Missing GridFunction, but "
454  " data requires grid function.")
455  };
456 
457 
458 
459 
460  template <int elemDim>
461  void get_values(TDataIn vValue[],
463  const TGridFunction& gridFct,
464  const MathVector<worldDim> vGlobIP[],
465  GridObject* pElem,
466  const MathVector<worldDim> vCornerCoords[],
467  const MathVector<elemDim> vLocIP[],
468  const MathMatrix<elemDim, worldDim> vJT[],
469  const size_t numIP)
470  {
471  // collect local solution, if required
472  if(spData->requires_grid_fct())
473  {
474  // create storage
475  LocalIndices ind;
476  LocalVector u;
477 
478  // get global indices
479  gridFct.indices(pElem, ind);
480 
481  // adapt local algebra
482  u.resize(ind);
483 
484  // read local values of u
485  GetLocalVector(u, gridFct);
486  std::cout << u << std::endl;
487 
488  // compute data
489  try{
490  (*spData)(vValue, vGlobIP, m_time, this->m_si, pElem,
491  vCornerCoords, vLocIP, numIP, &u, &vJT[0]);
492  }
493  UG_CATCH_THROW("UserDataDeltaIntegrand: Cannot evaluate data.");
494  }
495  else
496  {
497  // compute data
498  try{
499  (*spData)(vValue, vGlobIP, m_time, this->m_si, numIP);
500  }
501  UG_CATCH_THROW("UserDataDeltaIntegrand: Cannot evaluate data.");
502  }
503 
504  };
505 
506 
508  template <int elemDim>
509  void evaluate(number vValue[],
510  const MathVector<worldDim> vGlobIP[],
511  GridObject* pElem,
512  const MathVector<worldDim> vCornerCoords[],
513  const MathVector<elemDim> vLocIP[],
514  const MathMatrix<elemDim, worldDim> vJT[],
515  const size_t numIP)
516  {
517  std::vector<TDataIn> v1(numIP);
518 
519  get_values<elemDim>(&v1[0], m_spData, *m_pGridFct1, vGlobIP, pElem, vCornerCoords, vLocIP, vJT, numIP);
520  std::cout << "--- got v1!" << std::endl;
521 
522  if (m_pGridFct2 != NULL)
523  {
524  std::vector<TDataIn> v2(numIP);
525  /* m_spGridFct->set(0.5);
526  m_spGridFct2->set(0.5);*/
527  get_values<elemDim>(&v2[0], m_spData, *m_pGridFct2, vGlobIP, pElem, vCornerCoords, vLocIP, vJT, numIP);
528  std::cout << "--- got v2!" << std::endl;
529 
530  for (size_t ip=0; ip<numIP; ++ip)
531  {
532 
533  std::cout << std::setprecision(12) << v1[ip] <<" "<< std::setprecision(12) << v2[ip] << std::endl;
534  v1[ip] -= v2[ip];
535  vValue[ip] = this->product(v1[ip], v1[ip]);
536 
537  }
538  } else {
539 
540  for (size_t ip=0; ip<numIP; ++ip)
541  { vValue[ip] = this->product(v1[ip], v1[ip]); }
542 
543  }
544  };
545 };
546 
548 
549 template <typename TGridFunction, typename TDataInput>
550 class UserDataSpace : public IComponentSpace<TGridFunction>
551 {
552 public:
555 
556  UserDataSpace(const char *fctNames) : base_type(fctNames) {};
557  UserDataSpace(const char *fctNames, int order) : base_type(fctNames, order) {};
559 
561  { m_userData = spData; }
562 
563 
567 
568  double norm2(TGridFunction& uFine)
569  {
570  DeltaSquareIntegrand<TDataInput, TGridFunction> spIntegrand(m_userData, &uFine, NULL, 0.0);
571  return IntegrateSubsets(spIntegrand, uFine, base_type::m_ssNames, base_type::m_quadorder, "best");
572  }
573 
574  double distance2(TGridFunction& uFine, TGridFunction& uCoarse)
575  {
576  DeltaSquareIntegrand<TDataInput, TGridFunction> spIntegrand(m_userData, &uFine, &uCoarse, 0.0);
577  std::cerr << "uFine="<<(void*) (&uFine) << ", uCoarse="<< (void*) (&uCoarse) << std::endl;
578  return IntegrateSubsets(spIntegrand, uFine, base_type::m_ssNames, base_type::m_quadorder, "best");
579  }
580 
581 protected:
583 };
584 
585 
586 /*
588 template <class TDomain, class TAlgebra>
589 class GridFunctionEstimator :
590  public ISubDiagErrorEst<typename TAlgebra::vector_type>
591 {
592 protected:
593  typedef typename TAlgebra::vector_type TVector;
594  typedef GridFunction<TDomain, TAlgebra> grid_function_type;
595  typedef IErrorEvaluator<grid_function_type> evaluator_type;
596 
597  std::vector<SmartPtr<evaluator_type> > m_evaluators;
598  number m_refNormValue;
599 
600 public:
601  typedef ISubDiagErrorEst<TVector> base_type;
602 
603  // constructor
604  ScaledGridFunctionEstimator() : m_refNormValue(0.0) {}
605  ScaledGridFunctionEstimator(number ref) : m_refNormValue(ref) {}
606 
607  void add(SmartPtr<evaluator_type> eval)
608  {
609  m_evaluators.push_back(eval);
610  }
611 
612  // apply w/ rel norm
613  bool update(SmartPtr<TVector> vUpdate, number alpha, SmartPtr<TVector> vFine, SmartPtr<TVector> vCoarse)
614  {
615  // typedef ScaleAddLinker<number, TDomain::dim, number> linker_type;
616  typedef GridFunctionNumberData<TGridFunction> TNumberData;
617 
618  // try upcast
619  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
620  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
621  if (uFine.invalid() || uCoarse.invalid()) return false;
622 
623  // error estimate
624  if (m_refNormValue<=0.0)
625  {
626  // relative error estimator
627  //number unorm = L2Norm(uFine, m_fctNames.c_str(), m_quadorder);
628  //number enorm = alpha*L2Error(uFine, m_fctNames.c_str(), uCoarse, m_fctNames.c_str() ,m_quadorder);
629  number unorm = 0.0;
630  number enorm = 0.0;
631  double est = 0.0;
632  for (typename std::vector<evaluator_type>::iterator it = m_evaluators.begin(); it!= m_evaluators.end(); ++it)
633  {
634  enorm = alpha * it->distance(uFine, uCoarse);
635  unorm = std::max(it->norm(uFine), 1e-10);
636  est += (enorm*enorm)/(unorm*unorm);
637  std::cerr << "unorm=" << unorm << "enorm=" << enorm << "est="<<est << std::endl;
638  }
639 
640  base_type::m_est = sqrt(est)/m_evaluators.size();
641  std::cerr << "eps="<< base_type::m_est << std::endl;
642 
643  }
644  else
645  {
646  // weighted error estimator
647  number enorm = 0.0;
648  for (typename std::vector<evaluator_type>::iterator it = m_evaluators.begin(); it!= m_evaluators.end(); ++it)
649  {
650  enorm += alpha * it->distance(uFine, uCoarse);
651  }
652  base_type::m_est = enorm/m_refNormValue;
653 
654  std::cerr << "unorm (FIXED)=" << m_refNormValue << "enorm=" << enorm << "eps="<< base_type::m_est << std::endl;
655 
656  }
657 
658  // update
659  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
660  return true;
661  }
662 
663  void set_reference_norm(number norm)
664  {m_refNormValue = norm; }
665 
666 
668  std::string config_string() const
669  {
670  std::stringstream ss;
671  ss << "GridFunctionEstimator:\n";
672  for (typename std::vector<GridFunctionEvaluator>::const_iterator it = m_evaluators.begin(); it!= m_evaluators.end(); ++it)
673  {
674  ss << it->config_string();
675  }
676  return ss.str();
677  }
678 };
679 */
680 
682 
687 template <class TDomain, class TAlgebra>
689  public ISubDiagErrorEst<typename TAlgebra::vector_type>
690 {
691 protected:
692  typedef typename TAlgebra::vector_type TVector;
693 public:
697  //typedef CompositeSpace<grid_function_type> composite_type;
698 
699 protected:
700  typedef std::pair<SmartPtr<subspace_type>, number> weighted_obj_type;
701 
703  std::vector<weighted_obj_type> m_spWeightedSubspaces;
704 
705 
706 public:
708  {}
709 
710 
712  {}
713 
715  void add(SmartPtr<subspace_type> spSubspace)
716  { m_spWeightedSubspaces.push_back(std::make_pair(spSubspace, 1.0)); }
717 
718  void add(SmartPtr<subspace_type> spSubspace, number sigma)
719  { m_spWeightedSubspaces.push_back(std::make_pair(spSubspace, sigma)); }
720 
721 
724  {
725  // typedefs
728 
729  // upcast to GridFunction
730  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
731  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
732  if (uFine.invalid() || uCoarse.invalid()) return false;
733 
734  // error estimate
735  if (m_refNormValue<=0.0)
736  {
737  // relative error estimator
738  number unorm2 = 0.0;
739  number enorm2 = 0.0;
740  for (typename std::vector<weighted_obj_type>::iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
741  {
742  const double sigma = it->second;
743  const double norm2 = it->first->norm2(*uFine);
744  const double dist2 = alpha * alpha * (it->first->distance2(*uFine, *uCoarse));
745  unorm2 += sigma * norm2;
746  enorm2 += sigma * dist2;
747 
748  UG_LOG("unorm=" << norm2 << "\tenorm=" << dist2 << "\tsigma=" << sigma << std::endl);
749  }
750 
751  base_type::m_est = sqrt(enorm2/unorm2);
752  UG_LOG(">>> unorm2=" << unorm2 << "\tenorm2=" << enorm2 << "\teps="<< base_type::m_est << std::endl);
753  }
754  else
755  {
756  // weighted error estimator
757  number enorm2 = 0.0;
758  for (typename std::vector<weighted_obj_type>::iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
759  {
760  const double sigma = it->second;
761  const double dist2 = alpha * alpha * (it->first->distance2(*uFine, *uCoarse));
762  enorm2 += sigma*dist2;
763  }
764 
765  base_type::m_est = sqrt(enorm2)/m_refNormValue;
766  UG_LOG("unorm (FIXED)=" << m_refNormValue << "enorm2=" << enorm2 << "eps="<< base_type::m_est << std::endl);
767  }
768 
769  // update
770  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
771  return true;
772  }
773 
775  {m_refNormValue = norm; }
776 
777 
779  std::string config_string() const
780  {
781  std::stringstream ss;
782  ss << "GridFunctionEstimator:\n";
783  for (typename std::vector<weighted_obj_type>::const_iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
784  {
785  ss << it->second << "*" << it->first->config_string();
786  }
787  return ss.str();
788  }
789 };
790 
792 template <class TDomain, class TAlgebra>
794  public ISubDiagErrorEst<typename TAlgebra::vector_type>
795 {
796 protected:
797  typedef typename TAlgebra::vector_type TVector;
798 
799 public:
804 
805  // constructor
807 
808  // add (single subspace)
809  void add(SmartPtr<subspace_type> spSubspace)
810  { m_spSubspaces.push_back(spSubspace); }
811 
812  // add subspaces (from container)
813  void add(SmartPtr<composite_type> spCompositeSpace)
814  {
815  typedef typename composite_type::weighted_obj_type weighted_obj_type;
816  const std::vector<weighted_obj_type> &spaces = spCompositeSpace->get_subspaces();
817  for (typename std::vector<weighted_obj_type>::const_iterator it = spaces.begin(); it != spaces.end(); ++it)
818  {
819  m_spSubspaces.push_back(it->first);
820  }
821  }
822 
823 
824  // apply w/ rel norm
826  {
827 
828  // upcast
829  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
830  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
831  if (uFine.invalid() || uCoarse.invalid()) return false;
832 
833  // error estimate
834  number est = 0.0;
835  for (typename std::vector<SmartPtr<subspace_type> >::iterator it = m_spSubspaces.begin();
836  it!= m_spSubspaces.end(); ++it)
837  {
838  // use sub-diagonal error estimator (i.e. multiply with alpha)
839  double enorm2 = (alpha*alpha) * (*it)->distance2(*uFine, *uCoarse);
840  double unorm2 = std::max((*it)->norm2(*uFine), 1e-10*enorm2);
841  est += (enorm2)/(unorm2);
842  UG_LOGN("unorm2=" << unorm2 << "\tenorm2=" << enorm2 << "\tratio2="<< (enorm2)/(unorm2) << "est2=" << est);
843  }
844 
845  base_type::m_est = sqrt(est)/m_spSubspaces.size();
846  UG_LOGN("eps="<< base_type::m_est);
847 
848  // update
849  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
850  return true;
851  }
852 
853 
855  std::string config_string() const
856  {
857  std::stringstream ss;
858  ss << "ScaledGridFunctionEstimator:\n";
859  for (typename std::vector<SmartPtr<subspace_type> >::const_iterator it = m_spSubspaces.begin();
860  it!= m_spSubspaces.end(); ++it)
861  {
862  ss << (*it)->config_string();
863  }
864  return ss.str();
865  }
866 
867 protected:
868 
869  std::vector<SmartPtr<subspace_type> > m_spSubspaces;
870 
871 };
872 
873 
875 
876 template <class TDomain, class TAlgebra>
878  public ISubDiagErrorEst<typename TAlgebra::vector_type>
879 {
880 protected:
881  typedef typename TAlgebra::vector_type TVector;
882 
883 public:
888 
889  // constructor
891 
893  { m_strictRelativeError = b; }
894 
895  // add (single subspace)
896  void add(SmartPtr<subspace_type> spSubspace)
897  { m_spSubspaces.push_back(spSubspace); }
898 
899  // add subspaces (from container)
900  void add(SmartPtr<composite_type> spCompositeSpace)
901  {
902  typedef typename composite_type::weighted_obj_type weighted_obj_type;
903  const std::vector<weighted_obj_type> &spaces = spCompositeSpace->get_subspaces();
904  for (typename std::vector<weighted_obj_type>::const_iterator it = spaces.begin(); it != spaces.end(); ++it)
905  {
906  m_spSubspaces.push_back(it->first);
907  }
908  }
909 
910 
911  // apply w/ rel norm
913  {
914 
915  // upcast
916  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
917  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
918  if (uFine.invalid() || uCoarse.invalid()) return false;
919 
920  // error estimate
921  double enorm2 = 0.0;
922  double unorm2 = 0.0;
923  const double SMALL = 1e-10;
924 
925  double max_rel = 0.0;
926 
927 
928 
929  for (typename std::vector<SmartPtr<subspace_type> >::iterator it = m_spSubspaces.begin();
930  it!= m_spSubspaces.end(); ++it)
931  {
932  // use sub-diagonal error estimator (i.e. multiply with alpha)
933  double cmp_e2 = (alpha*alpha) * (*it)->distance2(*uFine, *uCoarse);
934  double cmp_u2 = (*it)->norm2(*uFine);
935 
936  // |delta_i|/|u_i|
937  max_rel = std::max(max_rel, cmp_e2/
938  (cmp_u2 + SMALL/ (1.0+cmp_e2+cmp_u2)));
939  //std::max(cmp_u2, SMALL*cmp_e2));
940 
941  enorm2 += cmp_e2;
942  unorm2 += cmp_u2;
943 
944  UG_LOGN("ui-2=" << cmp_u2 << "\tei-2=" << cmp_e2<<
945  "\tunorm2=" << unorm2 << "\tenorm2=" << enorm2 <<
946  "\tratio2="<< (enorm2)/(unorm2) <<
947  "\tmax. rel (squared) ="<< max_rel);
948  }
949 
950  //prevent division by zero
951  base_type::m_est = (m_strictRelativeError) ? sqrt(max_rel) :
952  sqrt(enorm2/std::max(unorm2, SMALL*enorm2));
953  UG_LOGN("eps="<< base_type::m_est);
954 
955  // update
956  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
957  return true;
958  }
959 
960 
962  std::string config_string() const
963  {
964  std::stringstream ss;
965  ss << "CompositeGridFunctionEstimator:\n";
966  for (typename std::vector<SmartPtr<subspace_type> >::const_iterator it = m_spSubspaces.begin();
967  it!= m_spSubspaces.end(); ++it)
968  {
969  ss << (*it)->config_string();
970  }
971  return ss.str();
972  }
973 
974 protected:
975 
976  std::vector<SmartPtr<subspace_type> > m_spSubspaces;
978 };
979 
980 
981 
982 template <typename TVector>
984 {
985  public:
987  typedef TVector vector_type;
988 
989  public:
990 
992  AitkenNevilleTimex(std::vector<size_t> nsteps)
993  : m_stepsize(0.0),
994  m_subdiag (make_sp(new Norm2Estimator<TVector>())),
995  m_num_steps(nsteps),
996  m_solution(nsteps.size()),
997  m_subdiag_error_est(nsteps.size(), INFINITY)
998  {};
999 
1000  AitkenNevilleTimex(std::vector<size_t> nsteps, SmartPtr<ISubDiagErrorEst<vector_type> > error)
1001  : m_stepsize(0.0),
1002  m_subdiag(error),
1003  m_num_steps(nsteps),
1004  m_solution(nsteps.size()),
1005  m_subdiag_error_est(nsteps.size(), INFINITY)
1006  {};
1007 
1008  virtual ~AitkenNevilleTimex() {}
1009 
1012 
1015  { m_solution[i] = soli; }
1016 
1019  { return m_solution[i]; }
1020 
1023  {
1024  m_subdiag = subdiag;
1025  }
1026 
1027 
1028  const std::vector<number>& get_error_estimates() const
1029  {return m_subdiag_error_est; }
1030 
1033  { return m_subdiag_error_est[k];}
1034 
1035 
1037  /*number get_error_estimate()
1038  {
1039  std::vector<number>::iterator best = std::min_element(m_subdiag_error_est.begin(), m_subdiag_error_est.end());
1040  return *best;
1041  }
1042 
1044  int get_best_index() const
1045  {
1046  std::vector<number>::iterator best = std::min_element(m_subdiag_error_est.begin(), m_subdiag_error_est.end());
1047  //std::cout << "min element at: " << std::distance(std::begin(m_subdiag_error_est), best);
1048  return std::distance(m_subdiag_error_est.begin(), best);
1049  }
1050 
1051  */
1052 
1063  void apply(size_t nstages, bool with_error=true)
1064  {
1065  UG_ASSERT(nstages <= m_solution.size(),
1066  "Dimensions do not match:" << nstages << ">" << m_solution.size());
1067 
1068  if (with_error)
1069  {
1070  // reset (for safety reasons...)
1071  for (size_t k=1; k<m_solution.size(); ++k)
1072  { m_subdiag_error_est[k] = INFINITY; }
1073  }
1074 
1075  //m_subdiag_error_est[0] = ;
1076  // process columns (left to right)
1077  for (size_t k=1; k<nstages; ++k)
1078  {
1079 
1080  // process rows (bottom-up -> recycling memory)
1081  for (size_t i=nstages-1; i>=k; --i)
1082  {
1083  UG_ASSERT(m_solution[i].valid(), "Invalid SmarPtr!");
1084  UG_ASSERT(m_solution[i-1].valid(), "Invalid SmarPtr!");
1085 
1086  SmartPtr<vector_type> solcoarse = m_solution[i-1];
1087  SmartPtr<vector_type> solfine = m_solution[i];
1088 
1089  // (2^p -1)
1090  // m_solution[i] += (1.0/scal)*(m_solution[i]- m_solution[i-1]);
1091  const number scaling = ((1.0*m_num_steps[i])/(1.0*m_num_steps[i-k])-1.0);
1092  UG_LOG("scaling="<<i << ","<< k <<
1093  ": ns["<<i<<"]="<< m_num_steps[i] <<
1094  "ns2["<<i-k<<"]=" << m_num_steps[i-k] <<"=" << scaling << std::endl);
1095 
1096  if (with_error && (i==k))
1097  {
1098  // compute subdiagonal error estimate
1099  m_subdiag->update(solfine, (1.0/scaling), solfine, solcoarse);
1100  number subdiag_error_est=m_subdiag->get_current_estimate();
1101 
1102  //m_subdiag_error_est[k] = sqrt(subdiag_error_est*scaling);
1103  m_subdiag_error_est[k]=subdiag_error_est; //*scaling;
1104 
1105  UG_LOG(" ErrorEst["<< k<<"]=" << m_subdiag_error_est[k] << ";" << std::endl);
1106  }
1107  else
1108  {
1109  // standard case
1110  VecScaleAdd(*solfine, (1.0+1.0/scaling), *solfine,
1111  -(1.0/scaling), *solcoarse);
1112 
1113  }
1114  } // rows i
1115 
1116  } // columns k
1117 
1118  }
1119 
1121  void apply()
1122  {
1123  //UG_ASSERT(m_num_steps.size() == m_solution.size(), "Dimensions do not match");
1124  const size_t nstages = m_num_steps.size();
1125  apply(nstages);
1126  }
1127 
1128 
1129 
1130 protected:
1131  number substep(size_t i) {return m_stepsize/m_num_steps[i];}
1132 
1133 private:
1136  static const int m_order=1;
1137 
1140 
1142  std::vector<size_t> m_num_steps;
1143 
1145  std::vector<SmartPtr<vector_type> > m_solution;
1146 
1148  std::vector<number> m_subdiag_error_est;
1149 
1150 
1151 };
1152 
1153 
1154 
1156 /*
1157 class TimeStepEstimator{
1158 
1159 public:
1160  TimeStepEstimator(double tol) :
1161  m_rho(0.9), m_gamma(2.0), m_tol(tol)
1162  {
1163 
1164  }
1165 
1166  bool check(double eps, double &factor)
1167  {
1168  if (eps>=tol) return false;
1169 
1170  double val = (m_rho*m_tol)/eps;
1171  factor = pow(val, m_gamma);
1172 
1173  }
1174 
1175 
1176 private:
1177  double m_rho;
1178  double m_gamma;
1179  double m_tol;
1180 };
1181 */
1182 
1183 }
1184 #endif
bool invalid() const
size_t allreduce(const size_t &t, pcl::ReduceOperation op) const
Definition: time_extrapolation.h:984
static const int m_order
Definition: time_extrapolation.h:1136
void apply()
apply for all stages
Definition: time_extrapolation.h:1121
void set_error_estimate(SmartPtr< ISubDiagErrorEst< vector_type > > subdiag)
set error estimator
Definition: time_extrapolation.h:1022
void apply(size_t nstages, bool with_error=true)
best error estimate
Definition: time_extrapolation.h:1063
number m_stepsize
Definition: time_extrapolation.h:1135
void set_solution(SmartPtr< vector_type > soli, int i)
set solution (for stage i)
Definition: time_extrapolation.h:1014
const std::vector< number > & get_error_estimates() const
Definition: time_extrapolation.h:1028
std::vector< number > m_subdiag_error_est
Definition: time_extrapolation.h:1148
SmartPtr< ISubDiagErrorEst< vector_type > > m_subdiag
Definition: time_extrapolation.h:1139
std::vector< size_t > m_num_steps
Definition: time_extrapolation.h:1142
SmartPtr< vector_type > get_solution(size_t i)
get solution (on stage i)
Definition: time_extrapolation.h:1018
std::vector< SmartPtr< vector_type > > m_solution
Definition: time_extrapolation.h:1145
AitkenNevilleTimex(std::vector< size_t > nsteps)
Definition: time_extrapolation.h:992
number get_global_stepsize()
Definition: time_extrapolation.h:1011
virtual ~AitkenNevilleTimex()
Definition: time_extrapolation.h:1008
number get_error_estimate(int k) const
error estimate on stage k
Definition: time_extrapolation.h:1032
TVector vector_type
vector type of solutions
Definition: time_extrapolation.h:987
number substep(size_t i)
Definition: time_extrapolation.h:1131
void set_global_stepsize(number H)
Definition: time_extrapolation.h:1010
AitkenNevilleTimex(std::vector< size_t > nsteps, SmartPtr< ISubDiagErrorEst< vector_type > > error)
Definition: time_extrapolation.h:1000
Evaluate difference between two functions (w.r.t various norms)
Definition: time_extrapolation.h:879
bool m_strictRelativeError
Definition: time_extrapolation.h:977
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_extrapolation.h:885
std::vector< SmartPtr< subspace_type > > m_spSubspaces
Definition: time_extrapolation.h:976
void add(SmartPtr< subspace_type > spSubspace)
Definition: time_extrapolation.h:896
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:884
bool update(SmartPtr< TVector > vUpdate, number alpha, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
Definition: time_extrapolation.h:912
void add(SmartPtr< composite_type > spCompositeSpace)
Definition: time_extrapolation.h:900
CompositeGridFunctionEstimator()
Definition: time_extrapolation.h:890
IComponentSpace< grid_function_type > subspace_type
Definition: time_extrapolation.h:886
TAlgebra::vector_type TVector
Definition: time_extrapolation.h:881
void use_strict_relative_norms(bool b)
Definition: time_extrapolation.h:892
CompositeSpace< grid_function_type > composite_type
Definition: time_extrapolation.h:887
std::string config_string() const
print config string
Definition: time_extrapolation.h:962
std::pair< SmartPtr< obj_type >, number > weighted_obj_type
Definition: time_extrapolation.h:411
SmartPtr< UserData< TDataIn, worldDim > > m_spData
Definition: time_extrapolation.h:429
static number product(const MathVector< worldDim > &x, const MathVector< worldDim > &y)
Definition: time_extrapolation.h:424
const TGridFunction * m_pGridFct2
Definition: time_extrapolation.h:433
number m_time
Definition: time_extrapolation.h:436
DeltaSquareIntegrand(SmartPtr< UserData< TDataIn, worldDim > > spData, number time)
constructor
Definition: time_extrapolation.h:449
static number product(const number &x, const number &y)
Definition: time_extrapolation.h:421
DeltaSquareIntegrand(SmartPtr< UserData< TDataIn, worldDim > > spData, const TGridFunction *pGridFct1, const TGridFunction *pGridFct2, number time)
constructor
Definition: time_extrapolation.h:440
static const int worldDim
Definition: time_extrapolation.h:414
void get_values(TDataIn vValue[], ConstSmartPtr< UserData< TDataIn, worldDim > > spData, const TGridFunction &gridFct, const MathVector< worldDim > vGlobIP[], GridObject *pElem, const MathVector< worldDim > vCornerCoords[], const MathVector< elemDim > vLocIP[], const MathMatrix< elemDim, worldDim > vJT[], const size_t numIP)
Definition: time_extrapolation.h:461
TDataIn data_type
Definition: time_extrapolation.h:417
const TGridFunction * m_pGridFct1
Definition: time_extrapolation.h:432
void evaluate(number vValue[], const MathVector< worldDim > vGlobIP[], GridObject *pElem, const MathVector< worldDim > vCornerCoords[], const MathVector< elemDim > vLocIP[], const MathMatrix< elemDim, worldDim > vJT[], const size_t numIP)
Definition: time_extrapolation.h:509
Evaluate using continuous norms.
Definition: time_extrapolation.h:690
bool update(SmartPtr< TVector > vUpdate, number alpha, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
apply w/ rel norm
Definition: time_extrapolation.h:723
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:694
void set_reference_norm(number norm)
Definition: time_extrapolation.h:774
TAlgebra::vector_type TVector
Definition: time_extrapolation.h:692
GridFunctionEstimator()
Definition: time_extrapolation.h:707
IGridFunctionSpace< grid_function_type > subspace_type
Definition: time_extrapolation.h:696
std::pair< SmartPtr< subspace_type >, number > weighted_obj_type
Definition: time_extrapolation.h:700
std::vector< weighted_obj_type > m_spWeightedSubspaces
Definition: time_extrapolation.h:703
std::string config_string() const
print config string
Definition: time_extrapolation.h:779
void add(SmartPtr< subspace_type > spSubspace, number sigma)
Definition: time_extrapolation.h:718
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_extrapolation.h:695
GridFunctionEstimator(double ref)
Definition: time_extrapolation.h:711
void add(SmartPtr< subspace_type > spSubspace)
add sub-space component
Definition: time_extrapolation.h:715
number m_refNormValue
Definition: time_extrapolation.h:702
Interface for sub-diagonal error estimator (w.r.t time in Aitken-Neville scheme)
Definition: time_extrapolation.h:142
number m_est
Definition: time_extrapolation.h:160
virtual std::string config_string() const
Definition: time_extrapolation.h:157
number get_current_estimate()
get estimate
Definition: time_extrapolation.h:154
void reset_estimate()
Definition: time_extrapolation.h:155
virtual ~ISubDiagErrorEst()
Definition: time_extrapolation.h:148
virtual bool update(SmartPtr< TVector > vUpdate, number alpha2, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)=0
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
ISubDiagErrorEst()
Definition: time_extrapolation.h:145
void resize(const LocalIndices &ind)
Evaluate using (algebraic) L2 norm.
Definition: time_extrapolation.h:203
int m_offset
Definition: time_extrapolation.h:207
int m_stride
Definition: time_extrapolation.h:206
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:205
void set_stride(int delta)
Definition: time_extrapolation.h:239
void set_offset(int offset)
Definition: time_extrapolation.h:236
bool update(SmartPtr< TVector > vUpdate, number alpha2, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
Definition: time_extrapolation.h:219
Norm2Estimator(int delta, int offset)
Definition: time_extrapolation.h:215
Norm2Estimator()
Definition: time_extrapolation.h:211
Norm2Estimator(int stride)
Definition: time_extrapolation.h:213
Evaluate using (algebraic) infinity norm.
Definition: time_extrapolation.h:169
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:171
NormInfEstimator()
Definition: time_extrapolation.h:177
bool update(SmartPtr< TVector > vUpdate, number alpha2, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
Definition: time_extrapolation.h:182
int m_stride
Definition: time_extrapolation.h:172
void set_offset(int offset)
Definition: time_extrapolation.h:192
int m_offset
Definition: time_extrapolation.h:173
void set_stride(int delta)
Definition: time_extrapolation.h:195
Evaluate using (algebraic) L2 norm.
Definition: time_extrapolation.h:247
NormRelEstimator()
Definition: time_extrapolation.h:253
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:249
bool update(SmartPtr< TVector > vUpdate, number alpha2, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
Definition: time_extrapolation.h:256
Evaluate difference between two functions (w.r.t various norms)
Definition: time_extrapolation.h:795
CompositeSpace< grid_function_type > composite_type
Definition: time_extrapolation.h:803
void add(SmartPtr< composite_type > spCompositeSpace)
Definition: time_extrapolation.h:813
IComponentSpace< grid_function_type > subspace_type
Definition: time_extrapolation.h:802
bool update(SmartPtr< TVector > vUpdate, number alpha, SmartPtr< TVector > vFine, SmartPtr< TVector > vCoarse)
compute update vUpdate = vFine + alpha * (vFine- vCoarse) AND estimate error | alpha * (vFine- vCoars...
Definition: time_extrapolation.h:825
TAlgebra::vector_type TVector
Definition: time_extrapolation.h:797
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:800
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_extrapolation.h:801
std::vector< SmartPtr< subspace_type > > m_spSubspaces
Definition: time_extrapolation.h:869
void add(SmartPtr< subspace_type > spSubspace)
Definition: time_extrapolation.h:809
ScaledGridFunctionEstimator()
Definition: time_extrapolation.h:806
std::string config_string() const
print config string
Definition: time_extrapolation.h:855
void add(const char *name)
size_t size() const
int dim(size_t i) const
Definition: time_extrapolation.h:296
IComponentSpace< TGridFunction > base_type
Definition: time_extrapolation.h:298
double norm2(TGridFunction &uFine)
Definition: time_extrapolation.h:356
~SupErrorEvaluator()
Definition: time_extrapolation.h:304
SupErrorEvaluator(const char *fctNames, const char *ssNames)
Definition: time_extrapolation.h:302
double distance(TGridFunction &uFine, TGridFunction &uCoarse)
Definition: time_extrapolation.h:359
number findFctMaxOnSubset(const TGridFunction &u, int si) const
Definition: time_extrapolation.h:374
SupErrorEvaluator(const char *fctNames)
Definition: time_extrapolation.h:300
double distance2(TGridFunction &uFine, TGridFunction &uCoarse)
Definition: time_extrapolation.h:369
double norm(TGridFunction &uFine)
Definition: time_extrapolation.h:313
double norm(SmartPtr< TGridFunction > uFine)
Definition: time_extrapolation.h:310
Evaluate the difference for a (dependent) UserData type induced by different grid functions.
Definition: time_extrapolation.h:551
void set_user_data(SmartPtr< input_user_data_type > spData)
Definition: time_extrapolation.h:560
UserDataSpace(const char *fctNames)
Definition: time_extrapolation.h:556
double norm2(TGridFunction &uFine)
Definition: time_extrapolation.h:568
IComponentSpace< TGridFunction > base_type
Definition: time_extrapolation.h:553
SmartPtr< input_user_data_type > m_userData
Definition: time_extrapolation.h:582
~UserDataSpace()
Definition: time_extrapolation.h:558
UserDataSpace(const char *fctNames, int order)
Definition: time_extrapolation.h:557
double distance2(TGridFunction &uFine, TGridFunction &uCoarse)
Definition: time_extrapolation.h:574
UserData< TDataInput, TGridFunction::dim > input_user_data_type
Definition: time_extrapolation.h:554
ParallelVector< Vector< double > > vector_type
static const int dim
#define PCL_RO_SUM
#define PCL_DT_DOUBLE
#define PCL_RO_MAX
int NumProcs()
vector< string > TokenizeString(const char *str, const char delimiter=',')
#define UG_ASSERT(expr, msg)
#define UG_CATCH_THROW(msg)
#define UG_THROW(msg)
#define UG_LOG(msg)
#define UG_LOGN(msg)
#define UG_COND_THROW(cond, msg)
double number
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
int local(bglp_vertex_descriptor p)
void VecScaleAddWithNorm2(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
calculates vUpdate = vUpdate + alpha2*vFine + alpha3*vCoarse. for doubles
Definition: time_extrapolation.h:117
void VecScaleAddWithNormRel(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
calculates vUpdate = vUpdate + alpha2*vFine + alpha3*vCoarse. for doubles
Definition: time_extrapolation.h:81
void VecScaleAddWithNormInf(double &vUpdate, double alpha2, const double &vFine, double alpha3, const double &vCoarse, double &norm)
calculates vUpdate = vUpdate + alpha2*vFine + alpha3*vCoarse. for doubles
Definition: time_extrapolation.h:97
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
const number SMALL
number IntegrateSubsets(IIntegrand< number, TGridFunction::dim > &spIntegrand, TGridFunction &spGridFct, const char *subsets, int quadOrder, std::string quadType=std::string())
void GetLocalVector(LocalVector &lvec, const TVector &vec)
void VecScaleAdd(double &dest, double alpha1, const double &v1, double alpha2, const double &v2)
DIM_SUBSET_EMPTY_GRID
SmartPtr< T, FreePolicy > make_sp(T *inst)
SurfaceView::traits< TElem >::const_iterator const_iterator
function ProblemDisc new(problemDesc, dom)