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));
290 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
302 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
314 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
326 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
335 return scalContent(key).
est_sum;
338 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
339 double estSum(
const TP& tp)
341 return estSum(to_string(tp));
350 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
359 return scalContent(key).
est_max;
362 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
363 double estMax(
const TP& tp)
365 return estMax(to_string(tp));
374 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
375 double timeEstmax(
const TP& tp)
386 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
398 void setTimeEst(
double value)
409 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
421 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
433 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
445 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
488 void setLastProcessedTimestep(
double t)
493 double lastProcessedTimestep()
const
505 return !(std::abs(
time_ -
endTime_) > std::numeric_limits<double>::epsilon());
563 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
572 return (scalContent(key).coarsenAllowed == 1);
575 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
584 return (scalContent(key).refinementAllowed == 1);
587 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
594 void allowRefinement(
bool allow, Key key)
599 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
600 void allowRefinement(
bool allow,
const TP& tp)
602 return allowRefinement(allow, to_string(tp));
606 void allowCoarsening(
bool allow, Key key)
611 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
612 void allowCoarsening(
bool allow,
const TP& tp)
614 return allowCoarsening(allow, to_string(tp));
622 void setSolverIterations(
int it)
627 int solverIterations()
const
632 void setMaxSolverIterations(
int it)
637 int maxSolverIterations()
const
642 void setSolverTolerance(
double tol)
644 solverTolerance_ = tol;
647 double solverTolerance()
const
649 return solverTolerance_;
652 void setSolverResidual(
double res)
654 solverResidual_ = res;
657 double solverResidual()
const
659 return solverResidual_;
662 void setGlobalTimeTolerance(
double tol)
667 double globalTimeTolerance()
const
681 time_ = newStartTime;
689 ScalContent& scalContent(Key key)
const
691 auto result =
scalContents_.emplace(std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(
name_ +
"[" + key +
"]") );
692 return result.first->second;
736 double minTimestep_ = std::sqrt(std::numeric_limits<double>::epsilon());
758 double solverTolerance_ = 1.e-8;
761 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
ScalContent(std::string const &prefix)
Constructor.
Definition: AdaptInfo.cpp:14
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:540
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:534
double const & timestep() const
Gets timestep_.
Definition: AdaptInfo.hpp:483
void incTimestepNumber()
Increments timestepNumber_ by 1;.
Definition: AdaptInfo.hpp:279
double timeErrLow(Key key) const
Returns timeErrLow.
Definition: AdaptInfo.hpp:558
std::map< Key, ScalContent > scalContents_
Scalar adapt infos.
Definition: AdaptInfo.hpp:767
bool isCoarseningAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition: AdaptInfo.hpp:570
double setTimestep(double t)
Sets timestep_.
Definition: AdaptInfo.hpp:470
int maxTimeIteration_
Maximal number of time iterations.
Definition: AdaptInfo.hpp:718
double endTime() const
Returns endTime_.
Definition: AdaptInfo.hpp:552
void setTimeIteration(int it)
Sets timeIteration_.
Definition: AdaptInfo.hpp:225
int timestepIteration_
Current timestep iteration.
Definition: AdaptInfo.hpp:709
virtual bool spaceToleranceReached() const
Returns whether space tolerance is reached.
Definition: AdaptInfo.hpp:86
bool reachedEndTime() const
Definition: AdaptInfo.hpp:500
double timeRelativeTolerance(Key key) const
Returns timeRelativeTolerance.
Definition: AdaptInfo.hpp:440
bool isRefinementAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition: AdaptInfo.hpp:582
int maxSpaceIteration_
maximal allowed number of iterations of the adaptive procedure; if maxIteration <= 0,...
Definition: AdaptInfo.hpp:706
double time_
Actual time, end of time interval for current time step.
Definition: AdaptInfo.hpp:721
double endTime_
Final time.
Definition: AdaptInfo.hpp:727
std::string name_
Name.
Definition: AdaptInfo.hpp:697
void incTimeIteration()
Increments timesIteration_ by 1;.
Definition: AdaptInfo.hpp:237
AdaptInfo(std::string const &name)
Constructor.
Definition: AdaptInfo.cpp:30
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:516
double spaceTolerance(Key key) const
Returns spaceTolerance.
Definition: AdaptInfo.hpp:404
int timeIteration() const
Returns timeIteration_.
Definition: AdaptInfo.hpp:231
double startTime() const
Returns startTime_.
Definition: AdaptInfo.hpp:546
double timeEst() const
Returns timeEst_ the estimated overall time error.
Definition: AdaptInfo.hpp:393
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:730
int maxTimeIteration() const
Returns maxTimeIteration_.
Definition: AdaptInfo.hpp:243
double timeEstMax(Key key) const
Returns est_max.
Definition: AdaptInfo.hpp:369
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:452
int timestepIteration() const
Returns timestepIteration_.
Definition: AdaptInfo.hpp:201
int timestepNumber_
Number of current time step.
Definition: AdaptInfo.hpp:742
double maxTimestep() const
Gets maxTimestep_.
Definition: AdaptInfo.hpp:528
double globalTimeTolerance_
tolerance for the overall time error
Definition: AdaptInfo.hpp:764
void setEstMax(double e, Key key)
Sets est_max.
Definition: AdaptInfo.hpp:297
int maxSolverIterations_
maximal number of iterations needed of linear or nonlinear solver
Definition: AdaptInfo.hpp:755
double timeEst_
overall time error estimate
Definition: AdaptInfo.hpp:770
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:677
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:333
int maxSpaceIteration() const
Returns maxSpaceIteration_.
Definition: AdaptInfo.hpp:177
double lastProcessedTimestep_
Last processed time step size of finished iteration.
Definition: AdaptInfo.hpp:733
void setEstSum(double e, Key key)
Sets est_sum.
Definition: AdaptInfo.hpp:285
void setMaxTimestepIteration(int it)
Sets maxTimestepIteration.
Definition: AdaptInfo.hpp:219
void setTimeEstSum(double e, Key key)
Sets est_t_sum.
Definition: AdaptInfo.hpp:321
double timeEstCombined(Key key) const
Definition: AdaptInfo.hpp:148
int spaceIteration_
Current space iteration.
Definition: AdaptInfo.hpp:700
double estMax(Key key) const
Returns est_max.
Definition: AdaptInfo.hpp:357
double minTimestep_
Minimal step size.
Definition: AdaptInfo.hpp:736
double timeTolerance(Key key) const
Returns timeTolerance.
Definition: AdaptInfo.hpp:428
double startTime_
Initial time.
Definition: AdaptInfo.hpp:724
void setTimeEstMax(double e, Key key)
Sets est_max.
Definition: AdaptInfo.hpp:309
void setNumberOfTimesteps(int num)
Sets nTimesteps.
Definition: AdaptInfo.hpp:273
double const & time() const
Gets time_.
Definition: AdaptInfo.hpp:464
int numberOfTimesteps() const
Returns nTimesteps_.
Definition: AdaptInfo.hpp:267
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:749
void reset()
Resets all variables to zero (or something equivalent)
Definition: AdaptInfo.cpp:67
void setMinTimestep(double t)
Sets minTimestep_.
Definition: AdaptInfo.hpp:510
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:715
int solverIterations_
number of iterations needed of linear or nonlinear solver
Definition: AdaptInfo.hpp:752
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:416
int maxTimestepIteration_
Maximal number of iterations for choosing a timestep.
Definition: AdaptInfo.hpp:712
double maxTimestep_
Maximal step size.
Definition: AdaptInfo.hpp:739
double timeEstSum(Key key) const
Returns est_t_sum.
Definition: AdaptInfo.hpp:381
void incTimestepIteration()
Increments timestepIteration_ by 1;.
Definition: AdaptInfo.hpp:207
void setMaxTimestep(double t)
Sets maxTimestep_.
Definition: AdaptInfo.hpp:522
double estTSum(Key key) const
Returns est_t_sum.
Definition: AdaptInfo.hpp:345