12#include <amdis/Output.hpp>
13#include <amdis/common/ConceptsBase.hpp>
14#include <amdis/typetree/TreePath.hpp>
28 using Key = std::string;
77 explicit AdaptInfo(std::string
const& name);
105 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
130 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
152 scalContent(key).
est_t_sum * scalContent(key).fac_sum;
155 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
158 return tTimeEstCombined(to_string(tp));
293 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
305 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
317 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
329 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
338 return scalContent(key).
est_sum;
341 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
342 double estSum(
const TP& tp)
344 return estSum(to_string(tp));
353 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
362 return scalContent(key).
est_max;
365 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
366 double estMax(
const TP& tp)
368 return estMax(to_string(tp));
377 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
378 double timeEstmax(
const TP& tp)
389 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
401 void setTimeEst(
double value)
412 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
424 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
436 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
448 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
491 void setLastProcessedTimestep(
double t)
496 double lastProcessedTimestep()
const
508 return !(std::abs(
time_ -
endTime_) > std::numeric_limits<double>::epsilon());
566 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
575 return (scalContent(key).coarsenAllowed == 1);
578 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
587 return (scalContent(key).refinementAllowed == 1);
590 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
597 void allowRefinement(
bool allow, Key key)
602 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
603 void allowRefinement(
bool allow,
const TP& tp)
605 return allowRefinement(allow, to_string(tp));
609 void allowCoarsening(
bool allow, Key key)
614 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
615 void allowCoarsening(
bool allow,
const TP& tp)
617 return allowCoarsening(allow, to_string(tp));
625 void setSolverIterations(
int it)
630 int solverIterations()
const
635 void setMaxSolverIterations(
int it)
640 int maxSolverIterations()
const
645 void setSolverTolerance(
double tol)
647 solverTolerance_ = tol;
650 double solverTolerance()
const
652 return solverTolerance_;
655 void setSolverResidual(
double res)
657 solverResidual_ = res;
660 double solverResidual()
const
662 return solverResidual_;
665 void setGlobalTimeTolerance(
double tol)
670 double globalTimeTolerance()
const
684 time_ = newStartTime;
692 ScalContent& scalContent(Key key)
const
694 auto result =
scalContents_.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(
name_ +
"[" + key +
"]") );
695 return result.first->second;
739 double minTimestep_ = std::sqrt(std::numeric_limits<double>::epsilon());
761 double solverTolerance_ = 1.e-8;
764 double solverResidual_ = 0.0;
Stores adapt infos for a scalar problem or for one component of a vector valued problem.
Definition AdaptInfo.hpp:36
int coarsenAllowed
true if coarsening is allowed, false otherwise.
Definition AdaptInfo.hpp:69
double timeErrLow
Lower bound for the time error.
Definition AdaptInfo.hpp:66
double est_t_sum
Sum of all time error estimates.
Definition AdaptInfo.hpp:45
double est_t_max
Maximum of all time error estimates.
Definition AdaptInfo.hpp:51
double spaceTolerance
Tolerance for the (absolute or relative) error.
Definition AdaptInfo.hpp:57
double timeRelativeTolerance
Relative time tolerance.
Definition AdaptInfo.hpp:63
double est_max
maximal local error estimate.
Definition AdaptInfo.hpp:48
double timeTolerance
Time tolerance.
Definition AdaptInfo.hpp:60
double est_sum
Sum of all error estimates.
Definition AdaptInfo.hpp:42
double fac_max
factors to combine max and integral time estimate
Definition AdaptInfo.hpp:54
int refinementAllowed
true if refinement is allowed, false otherwise.
Definition AdaptInfo.hpp:72
Holds adapt parameters and infos about the problem.
Definition AdaptInfo.hpp:26
void setEndTime(double time)
Sets endTime_ = time.
Definition AdaptInfo.hpp:543
void setMaxTimeIteration(int it)
Sets maxTimeIteration_.
Definition AdaptInfo.hpp:249
int spaceIteration() const
Returns spaceIteration_.
Definition AdaptInfo.hpp:165
void incSpaceIteration()
Increments spaceIteration_ by 1;.
Definition AdaptInfo.hpp:189
void setSpaceIteration(int it)
Sets spaceIteration_.
Definition AdaptInfo.hpp:171
int maxTimestepIteration() const
Returns maxTimestepIteration_.
Definition AdaptInfo.hpp:213
void setStartTime(double time)
Sets startTime_ = time.
Definition AdaptInfo.hpp:537
double const & timestep() const
Gets timestep_.
Definition AdaptInfo.hpp:486
void incTimestepNumber()
Increments timestepNumber_ by 1;.
Definition AdaptInfo.hpp:282
double timeErrLow(Key key) const
Returns timeErrLow.
Definition AdaptInfo.hpp:561
std::map< Key, ScalContent > scalContents_
Scalar adapt infos.
Definition AdaptInfo.hpp:770
bool isCoarseningAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition AdaptInfo.hpp:573
double setTimestep(double t)
Sets timestep_.
Definition AdaptInfo.hpp:473
int maxTimeIteration_
Maximal number of time iterations.
Definition AdaptInfo.hpp:721
double endTime() const
Returns endTime_.
Definition AdaptInfo.hpp:555
void setTimeIteration(int it)
Sets timeIteration_.
Definition AdaptInfo.hpp:225
int timestepIteration_
Current timestep iteration.
Definition AdaptInfo.hpp:712
virtual bool spaceToleranceReached() const
Returns whether space tolerance is reached.
Definition AdaptInfo.hpp:86
bool reachedEndTime() const
Definition AdaptInfo.hpp:503
double timeRelativeTolerance(Key key) const
Returns timeRelativeTolerance.
Definition AdaptInfo.hpp:443
bool isRefinementAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition AdaptInfo.hpp:585
int maxSpaceIteration_
maximal allowed number of iterations of the adaptive procedure; if maxIteration <= 0,...
Definition AdaptInfo.hpp:709
double time_
Actual time, end of time interval for current time step.
Definition AdaptInfo.hpp:724
double endTime_
Final time.
Definition AdaptInfo.hpp:730
std::string name_
Name.
Definition AdaptInfo.hpp:700
void incTimeIteration()
Increments timesIteration_ by 1;.
Definition AdaptInfo.hpp:237
virtual bool spaceToleranceReached(Key key) const
Returns whether space tolerance of component associated with key is reached.
Definition AdaptInfo.hpp:97
double minTimestep() const
Gets minTimestep_.
Definition AdaptInfo.hpp:519
double spaceTolerance(Key key) const
Returns spaceTolerance.
Definition AdaptInfo.hpp:407
int timeIteration() const
Returns timeIteration_.
Definition AdaptInfo.hpp:231
double startTime() const
Returns startTime_.
Definition AdaptInfo.hpp:549
double timeEst() const
Returns timeEst_ the estimated overall time error.
Definition AdaptInfo.hpp:396
int timestepNumber() const
Returns timestepNumber_.
Definition AdaptInfo.hpp:255
void printTimeErrorLowInfo() const
Print debug information about time error and its bound.
Definition AdaptInfo.cpp:49
double timestep_
Time step size to be used.
Definition AdaptInfo.hpp:733
int maxTimeIteration() const
Returns maxTimeIteration_.
Definition AdaptInfo.hpp:243
double timeEstMax(Key key) const
Returns est_max.
Definition AdaptInfo.hpp:372
virtual bool timeToleranceReached() const
Returns whether time tolerance is reached.
Definition AdaptInfo.hpp:112
void setTimestepIteration(int it)
Sets timestepIteration_.
Definition AdaptInfo.hpp:195
double setTime(double t)
Sets time_.
Definition AdaptInfo.hpp:455
int timestepIteration() const
Returns timestepIteration_.
Definition AdaptInfo.hpp:201
int timestepNumber_
Number of current time step.
Definition AdaptInfo.hpp:745
double maxTimestep() const
Gets maxTimestep_.
Definition AdaptInfo.hpp:531
double globalTimeTolerance_
tolerance for the overall time error
Definition AdaptInfo.hpp:767
void setEstMax(double e, Key key)
Sets est_max.
Definition AdaptInfo.hpp:300
int maxSolverIterations_
maximal number of iterations needed of linear or nonlinear solver
Definition AdaptInfo.hpp:758
double timeEst_
overall time error estimate
Definition AdaptInfo.hpp:773
void resetTimeValues(double newTimeStep, double newStartTime, double newEndTime)
Resets timestep, current time and time boundaries without any check. Is used by the parareal algorith...
Definition AdaptInfo.hpp:680
virtual bool timeToleranceReached(Key key) const
Returns whether time tolerance of component associated with key is reached.
Definition AdaptInfo.hpp:122
void setTimestepNumber(int num)
Sets timestepNumber.
Definition AdaptInfo.hpp:261
double estSum(Key key) const
Returns est_sum.
Definition AdaptInfo.hpp:336
int maxSpaceIteration() const
Returns maxSpaceIteration_.
Definition AdaptInfo.hpp:177
double lastProcessedTimestep_
Last processed time step size of finished iteration.
Definition AdaptInfo.hpp:736
void setEstSum(double e, Key key)
Sets est_sum.
Definition AdaptInfo.hpp:288
void setMaxTimestepIteration(int it)
Sets maxTimestepIteration.
Definition AdaptInfo.hpp:219
void setTimeEstSum(double e, Key key)
Sets est_t_sum.
Definition AdaptInfo.hpp:324
double timeEstCombined(Key key) const
Definition AdaptInfo.hpp:148
int spaceIteration_
Current space iteration.
Definition AdaptInfo.hpp:703
double estMax(Key key) const
Returns est_max.
Definition AdaptInfo.hpp:360
double minTimestep_
Minimal step size.
Definition AdaptInfo.hpp:739
double timeTolerance(Key key) const
Returns timeTolerance.
Definition AdaptInfo.hpp:431
double startTime_
Initial time.
Definition AdaptInfo.hpp:727
void setTimeEstMax(double e, Key key)
Sets est_max.
Definition AdaptInfo.hpp:312
void setNumberOfTimesteps(int num)
Sets nTimesteps.
Definition AdaptInfo.hpp:276
double const & time() const
Gets time_.
Definition AdaptInfo.hpp:467
int numberOfTimesteps() const
Returns nTimesteps_.
Definition AdaptInfo.hpp:270
int nTimesteps_
Per default this value is 0 and not used. If it is set to a non-zero value, the computation of the st...
Definition AdaptInfo.hpp:752
void reset()
Resets all variables to zero (or something equivalent)
Definition AdaptInfo.cpp:67
void setMinTimestep(double t)
Sets minTimestep_.
Definition AdaptInfo.hpp:513
virtual bool timeErrorLow() const
Returns whether time error is under its lower bound.
Definition AdaptInfo.hpp:137
int timeIteration_
Current time iteration.
Definition AdaptInfo.hpp:718
int solverIterations_
number of iterations needed of linear or nonlinear solver
Definition AdaptInfo.hpp:755
virtual ~AdaptInfo()=default
Destructor.
void maxSpaceIteration(int it)
Sets maxSpaceIteration_.
Definition AdaptInfo.hpp:183
void setSpaceTolerance(Key key, double tol)
Sets spaceTolerance.
Definition AdaptInfo.hpp:419
int maxTimestepIteration_
Maximal number of iterations for choosing a timestep.
Definition AdaptInfo.hpp:715
double maxTimestep_
Maximal step size.
Definition AdaptInfo.hpp:742
double timeEstSum(Key key) const
Returns est_t_sum.
Definition AdaptInfo.hpp:384
void incTimestepIteration()
Increments timestepIteration_ by 1;.
Definition AdaptInfo.hpp:207
void setMaxTimestep(double t)
Sets maxTimestep_.
Definition AdaptInfo.hpp:525
double estTSum(Key key) const
Returns est_t_sum.
Definition AdaptInfo.hpp:348