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  // add subspaces (from container)
722 /* void add(SmartPtr<composite_type> spCompositeSpace)
723  {
724  typedef typename composite_type::weighted_obj_type weighted_obj_type;
725  const std::vector<weighted_obj_type> &spaces = spCompositeSpace->get_subspaces();
726  for (typename std::vector<weighted_obj_type>::const_iterator it = spaces.begin(); it != spaces.end(); ++it)
727  {
728  add(it->first, it->second);
729  }
730  }*/
731 
732 
735  {
736  // typedefs
739 
740  // upcast to GridFunction
741  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
742  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
743  if (uFine.invalid() || uCoarse.invalid()) return false;
744 
745  // error estimate
746  if (m_refNormValue<=0.0)
747  {
748  // relative error estimator
749  number unorm2 = 0.0;
750  number enorm2 = 0.0;
751  for (typename std::vector<weighted_obj_type>::iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
752  {
753  const double sigma = it->second;
754  const double norm2 = it->first->norm2(*uFine);
755  const double dist2 = alpha * alpha * (it->first->distance2(*uFine, *uCoarse));
756  unorm2 += sigma * norm2;
757  enorm2 += sigma * dist2;
758 
759  UG_LOG("unorm=" << norm2 << "\tenorm=" << dist2 << "\tsigma=" << sigma << std::endl);
760  }
761 
762  base_type::m_est = sqrt(enorm2/unorm2);
763  UG_LOG(">>> unorm2=" << unorm2 << "\tenorm2=" << enorm2 << "\teps="<< base_type::m_est << std::endl);
764  }
765  else
766  {
767  // weighted error estimator
768  number enorm2 = 0.0;
769  for (typename std::vector<weighted_obj_type>::iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
770  {
771  const double sigma = it->second;
772  const double dist2 = alpha * alpha * (it->first->distance2(*uFine, *uCoarse));
773  enorm2 += sigma*dist2;
774  }
775 
776  base_type::m_est = sqrt(enorm2)/m_refNormValue;
777  UG_LOG("unorm (FIXED)=" << m_refNormValue << "enorm2=" << enorm2 << "eps="<< base_type::m_est << std::endl);
778  }
779 
780  // update
781  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
782  return true;
783  }
784 
786  {m_refNormValue = norm; }
787 
788 
790  std::string config_string() const
791  {
792  std::stringstream ss;
793  ss << "GridFunctionEstimator:\n";
794  for (typename std::vector<weighted_obj_type>::const_iterator it = m_spWeightedSubspaces.begin(); it!= m_spWeightedSubspaces.end(); ++it)
795  {
796  ss << it->second << "*" << it->first->config_string();
797  }
798  return ss.str();
799  }
800 };
801 
803 template <class TDomain, class TAlgebra>
805  public ISubDiagErrorEst<typename TAlgebra::vector_type>
806 {
807 protected:
808  typedef typename TAlgebra::vector_type TVector;
809 
810 public:
815 
816  // constructor
818 
819  // add (single subspace)
820  void add(SmartPtr<subspace_type> spSubspace)
821  { m_spSubspaces.push_back(spSubspace); }
822 
823  // add subspaces (from container)
824  void add(SmartPtr<composite_type> spCompositeSpace)
825  {
826  typedef typename composite_type::weighted_obj_type weighted_obj_type;
827  const std::vector<weighted_obj_type> &spaces = spCompositeSpace->get_subspaces();
828  for (typename std::vector<weighted_obj_type>::const_iterator it = spaces.begin(); it != spaces.end(); ++it)
829  {
830  m_spSubspaces.push_back(it->first);
831  }
832  }
833 
834 
835  // apply w/ rel norm
837  {
838 
839  // upcast
840  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
841  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
842  if (uFine.invalid() || uCoarse.invalid()) return false;
843 
844  // error estimate
845  number est = 0.0;
846  for (typename std::vector<SmartPtr<subspace_type> >::iterator it = m_spSubspaces.begin();
847  it!= m_spSubspaces.end(); ++it)
848  {
849  // use sub-diagonal error estimator (i.e. multiply with alpha)
850  double enorm2 = (alpha*alpha) * (*it)->distance2(*uFine, *uCoarse);
851  double unorm2 = std::max((*it)->norm2(*uFine), 1e-10*enorm2);
852  est += (enorm2)/(unorm2);
853  UG_LOGN("unorm2=" << unorm2 << "\tenorm2=" << enorm2 << "\tratio2="<< (enorm2)/(unorm2) << "est2=" << est);
854  }
855 
856  base_type::m_est = sqrt(est)/m_spSubspaces.size();
857  UG_LOGN("eps="<< base_type::m_est);
858 
859  // update
860  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
861  return true;
862  }
863 
864 
866  std::string config_string() const
867  {
868  std::stringstream ss;
869  ss << "ScaledGridFunctionEstimator:\n";
870  for (typename std::vector<SmartPtr<subspace_type> >::const_iterator it = m_spSubspaces.begin();
871  it!= m_spSubspaces.end(); ++it)
872  {
873  ss << (*it)->config_string();
874  }
875  return ss.str();
876  }
877 
878 protected:
879 
880  std::vector<SmartPtr<subspace_type> > m_spSubspaces;
881 
882 };
883 
884 
886 
887 template <class TDomain, class TAlgebra>
889  public ISubDiagErrorEst<typename TAlgebra::vector_type>
890 {
891 protected:
892  typedef typename TAlgebra::vector_type TVector;
893 
894 public:
899 
900  // constructor
902 
903  // add (single subspace)
904  void add(SmartPtr<subspace_type> spSubspace)
905  { m_spSubspaces.push_back(spSubspace); }
906 
907  // add subspaces (from container)
908  void add(SmartPtr<composite_type> spCompositeSpace)
909  {
910  typedef typename composite_type::weighted_obj_type weighted_obj_type;
911  const std::vector<weighted_obj_type> &spaces = spCompositeSpace->get_subspaces();
912  for (typename std::vector<weighted_obj_type>::const_iterator it = spaces.begin(); it != spaces.end(); ++it)
913  {
914  m_spSubspaces.push_back(it->first);
915  }
916  }
917 
918 
919  // apply w/ rel norm
921  {
922 
923  // upcast
924  SmartPtr<grid_function_type> uFine = vFine.template cast_dynamic<grid_function_type>();
925  SmartPtr<grid_function_type> uCoarse = vCoarse.template cast_dynamic<grid_function_type>();
926  if (uFine.invalid() || uCoarse.invalid()) return false;
927 
928  // error estimate
929  double enorm2 = 0.0;
930  double unorm2 = 0.0;
931  for (typename std::vector<SmartPtr<subspace_type> >::iterator it = m_spSubspaces.begin();
932  it!= m_spSubspaces.end(); ++it)
933  {
934  // use sub-diagonal error estimator (i.e. multiply with alpha)
935  enorm2 += (alpha*alpha) * (*it)->distance2(*uFine, *uCoarse);
936  unorm2 += (*it)->norm2(*uFine);
937  UG_LOGN("unorm2=" << unorm2 << "\tenorm2=" << enorm2 << "\t(ratio2="<< (enorm2)/(unorm2) << ")");
938  }
939 
940  //prevent division by zero
941  base_type::m_est = sqrt(enorm2/std::max(unorm2, 1e-10*enorm2));
942  UG_LOGN("eps="<< base_type::m_est);
943 
944  // update
945  VecScaleAdd(*vUpdate, 1.0+alpha, *vFine, -alpha, *vCoarse);
946  return true;
947  }
948 
949 
951  std::string config_string() const
952  {
953  std::stringstream ss;
954  ss << "CompositeGridFunctionEstimator:\n";
955  for (typename std::vector<SmartPtr<subspace_type> >::const_iterator it = m_spSubspaces.begin();
956  it!= m_spSubspaces.end(); ++it)
957  {
958  ss << (*it)->config_string();
959  }
960  return ss.str();
961  }
962 
963 protected:
964 
965  std::vector<SmartPtr<subspace_type> > m_spSubspaces;
966 
967 };
968 
969 
970 
971 template <typename TVector>
973 {
974  public:
976  typedef TVector vector_type;
977 
978  public:
979 
981  AitkenNevilleTimex(std::vector<size_t> nsteps)
982  : m_stepsize(0.0),
983  m_subdiag (make_sp(new Norm2Estimator<TVector>())),
984  m_num_steps(nsteps),
985  m_solution(nsteps.size()),
986  m_subdiag_error_est(nsteps.size(), INFINITY)
987  {};
988 
989  AitkenNevilleTimex(std::vector<size_t> nsteps, SmartPtr<ISubDiagErrorEst<vector_type> > error)
990  : m_stepsize(0.0),
991  m_subdiag(error),
992  m_num_steps(nsteps),
993  m_solution(nsteps.size()),
994  m_subdiag_error_est(nsteps.size(), INFINITY)
995  {};
996 
997  virtual ~AitkenNevilleTimex() {}
998 
1001 
1004  { m_solution[i] = soli; }
1005 
1008  { return m_solution[i]; }
1009 
1012  {
1013  m_subdiag = subdiag;
1014  }
1015 
1016 
1017  const std::vector<number>& get_error_estimates() const
1018  {return m_subdiag_error_est; }
1019 
1022  { return m_subdiag_error_est[k];}
1023 
1024 
1026  /*number get_error_estimate()
1027  {
1028  std::vector<number>::iterator best = std::min_element(m_subdiag_error_est.begin(), m_subdiag_error_est.end());
1029  return *best;
1030  }
1031 
1033  int get_best_index() const
1034  {
1035  std::vector<number>::iterator best = std::min_element(m_subdiag_error_est.begin(), m_subdiag_error_est.end());
1036  //std::cout << "min element at: " << std::distance(std::begin(m_subdiag_error_est), best);
1037  return std::distance(m_subdiag_error_est.begin(), best);
1038  }
1039 
1040  */
1041 
1052  void apply(size_t nstages, bool with_error=true)
1053  {
1054  UG_ASSERT(nstages <= m_solution.size(),
1055  "Dimensions do not match:" << nstages << ">" << m_solution.size());
1056 
1057  if (with_error)
1058  {
1059  // reset (for safety reasons...)
1060  for (size_t k=1; k<m_solution.size(); ++k)
1061  { m_subdiag_error_est[k] = INFINITY; }
1062  }
1063 
1064  //m_subdiag_error_est[0] = ;
1065  // process columns (left to right)
1066  for (size_t k=1; k<nstages; ++k)
1067  {
1068 
1069  // process rows (bottom-up -> recycling memory)
1070  for (size_t i=nstages-1; i>=k; --i)
1071  {
1072  UG_ASSERT(m_solution[i].valid(), "Invalid SmarPtr!");
1073  UG_ASSERT(m_solution[i-1].valid(), "Invalid SmarPtr!");
1074 
1075  SmartPtr<vector_type> solcoarse = m_solution[i-1];
1076  SmartPtr<vector_type> solfine = m_solution[i];
1077 
1078  // (2^p -1)
1079  // m_solution[i] += (1.0/scal)*(m_solution[i]- m_solution[i-1]);
1080  const number scaling = ((1.0*m_num_steps[i])/(1.0*m_num_steps[i-k])-1.0);
1081  UG_LOG("scaling="<<i << ","<< k <<
1082  ": ns["<<i<<"]="<< m_num_steps[i] <<
1083  "ns2["<<i-k<<"]=" << m_num_steps[i-k] <<"=" << scaling << std::endl);
1084 
1085  if (with_error && (i==k))
1086  {
1087  // compute subdiagonal error estimate
1088  m_subdiag->update(solfine, (1.0/scaling), solfine, solcoarse);
1089  number subdiag_error_est=m_subdiag->get_current_estimate();
1090 
1091  //m_subdiag_error_est[k] = sqrt(subdiag_error_est*scaling);
1092  m_subdiag_error_est[k]=subdiag_error_est; //*scaling;
1093 
1094  UG_LOG(" ErrorEst["<< k<<"]=" << m_subdiag_error_est[k] << ";" << std::endl);
1095  }
1096  else
1097  {
1098  // standard case
1099  VecScaleAdd(*solfine, (1.0+1.0/scaling), *solfine,
1100  -(1.0/scaling), *solcoarse);
1101 
1102  }
1103  } // rows i
1104 
1105  } // columns k
1106 
1107  }
1108 
1110  void apply()
1111  {
1112  //UG_ASSERT(m_num_steps.size() == m_solution.size(), "Dimensions do not match");
1113  const size_t nstages = m_num_steps.size();
1114  apply(nstages);
1115  }
1116 
1117 
1118 
1119 protected:
1120  number substep(size_t i) {return m_stepsize/m_num_steps[i];}
1121 
1122 private:
1125  static const int m_order=1;
1126 
1129 
1131  std::vector<size_t> m_num_steps;
1132 
1134  std::vector<SmartPtr<vector_type> > m_solution;
1135 
1137  std::vector<number> m_subdiag_error_est;
1138 
1139 
1140 };
1141 
1142 
1143 
1145 /*
1146 class TimeStepEstimator{
1147 
1148 public:
1149  TimeStepEstimator(double tol) :
1150  m_rho(0.9), m_gamma(2.0), m_tol(tol)
1151  {
1152 
1153  }
1154 
1155  bool check(double eps, double &factor)
1156  {
1157  if (eps>=tol) return false;
1158 
1159  double val = (m_rho*m_tol)/eps;
1160  factor = pow(val, m_gamma);
1161 
1162  }
1163 
1164 
1165 private:
1166  double m_rho;
1167  double m_gamma;
1168  double m_tol;
1169 };
1170 */
1171 
1172 }
1173 #endif
bool invalid() const
size_t allreduce(const size_t &t, pcl::ReduceOperation op) const
Definition: time_extrapolation.h:973
static const int m_order
Definition: time_extrapolation.h:1125
void apply()
apply for all stages
Definition: time_extrapolation.h:1110
void set_error_estimate(SmartPtr< ISubDiagErrorEst< vector_type > > subdiag)
set error estimator
Definition: time_extrapolation.h:1011
void apply(size_t nstages, bool with_error=true)
best error estimate
Definition: time_extrapolation.h:1052
number m_stepsize
Definition: time_extrapolation.h:1124
void set_solution(SmartPtr< vector_type > soli, int i)
set solution (for stage i)
Definition: time_extrapolation.h:1003
const std::vector< number > & get_error_estimates() const
Definition: time_extrapolation.h:1017
std::vector< number > m_subdiag_error_est
Definition: time_extrapolation.h:1137
SmartPtr< ISubDiagErrorEst< vector_type > > m_subdiag
Definition: time_extrapolation.h:1128
std::vector< size_t > m_num_steps
Definition: time_extrapolation.h:1131
SmartPtr< vector_type > get_solution(size_t i)
get solution (on stage i)
Definition: time_extrapolation.h:1007
std::vector< SmartPtr< vector_type > > m_solution
Definition: time_extrapolation.h:1134
AitkenNevilleTimex(std::vector< size_t > nsteps)
Definition: time_extrapolation.h:981
number get_global_stepsize()
Definition: time_extrapolation.h:1000
virtual ~AitkenNevilleTimex()
Definition: time_extrapolation.h:997
number get_error_estimate(int k) const
error estimate on stage k
Definition: time_extrapolation.h:1021
TVector vector_type
vector type of solutions
Definition: time_extrapolation.h:976
number substep(size_t i)
Definition: time_extrapolation.h:1120
void set_global_stepsize(number H)
Definition: time_extrapolation.h:999
AitkenNevilleTimex(std::vector< size_t > nsteps, SmartPtr< ISubDiagErrorEst< vector_type > > error)
Definition: time_extrapolation.h:989
Evaluate difference between two functions (w.r.t various norms)
Definition: time_extrapolation.h:890
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_extrapolation.h:896
std::vector< SmartPtr< subspace_type > > m_spSubspaces
Definition: time_extrapolation.h:965
void add(SmartPtr< subspace_type > spSubspace)
Definition: time_extrapolation.h:904
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:895
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:920
void add(SmartPtr< composite_type > spCompositeSpace)
Definition: time_extrapolation.h:908
CompositeGridFunctionEstimator()
Definition: time_extrapolation.h:901
IComponentSpace< grid_function_type > subspace_type
Definition: time_extrapolation.h:897
TAlgebra::vector_type TVector
Definition: time_extrapolation.h:892
CompositeSpace< grid_function_type > composite_type
Definition: time_extrapolation.h:898
std::string config_string() const
print config string
Definition: time_extrapolation.h:951
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:734
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:694
void set_reference_norm(number norm)
Definition: time_extrapolation.h:785
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:790
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:806
CompositeSpace< grid_function_type > composite_type
Definition: time_extrapolation.h:814
void add(SmartPtr< composite_type > spCompositeSpace)
Definition: time_extrapolation.h:824
IComponentSpace< grid_function_type > subspace_type
Definition: time_extrapolation.h:813
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:836
TAlgebra::vector_type TVector
Definition: time_extrapolation.h:808
ISubDiagErrorEst< TVector > base_type
Definition: time_extrapolation.h:811
GridFunction< TDomain, TAlgebra > grid_function_type
Definition: time_extrapolation.h:812
std::vector< SmartPtr< subspace_type > > m_spSubspaces
Definition: time_extrapolation.h:880
void add(SmartPtr< subspace_type > spSubspace)
Definition: time_extrapolation.h:820
ScaledGridFunctionEstimator()
Definition: time_extrapolation.h:817
std::string config_string() const
print config string
Definition: time_extrapolation.h:866
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)
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)