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