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);
89 if (!(scalContent.second.est_sum < scalContent.second.spaceTolerance))
105 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
115 if (!(
timeEstCombined(scalContent.first) < scalContent.second.timeTolerance))
130 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
140 if (!(
timeEstCombined(scalContent.first) < scalContent.second.timeErrLow))
151 scalContent(key).est_t_max * scalContent(key).fac_max +
152 scalContent(key).est_t_sum * scalContent(key).fac_sum;
155 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
158 return tTimeEstCombined(to_string(tp));
287 scalContent(key).est_sum = e;
290 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
299 scalContent(key).est_max = e;
302 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
311 scalContent(key).est_t_max = e;
314 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
323 scalContent(key).est_t_sum = e;
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));
347 return scalContent(key).est_t_sum;
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));
371 return scalContent(key).est_t_max;
374 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
375 double timeEstmax(
const TP& tp)
383 return scalContent(key).est_t_sum;
386 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
398 void setTimeEst(
double value)
406 return scalContent(key).spaceTolerance;
409 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
418 scalContent(key).spaceTolerance = tol;
421 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
430 return scalContent(key).timeTolerance;
433 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
442 return scalContent(key).timeRelativeTolerance;
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());
560 return scalContent(key).timeErrLow;
563 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
575 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
587 template <
class TP, REQUIRES( Concepts::PreTreePath<TP> )>
594 void allowRefinement(
bool allow, Key key)
596 scalContent(key).refinementAllowed = allow;
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)
608 scalContent(key).coarsenAllowed = allow;
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;
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;
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 setNumberOfTimesteps(int num)
Sets nTimesteps.
Definition: AdaptInfo.hpp:273
double lastProcessedTimestep_
Last processed time step size of finished iteration.
Definition: AdaptInfo.hpp:733
void setTimeIteration(int it)
Sets timeIteration_.
Definition: AdaptInfo.hpp:225
double estTSum(Key key) const
Returns est_t_sum.
Definition: AdaptInfo.hpp:345
int solverIterations_
number of iterations needed of linear or nonlinear solver
Definition: AdaptInfo.hpp:752
void setTimeEstMax(double e, Key key)
Sets est_max.
Definition: AdaptInfo.hpp:309
double timeEst() const
Returns timeEst_ the estimated overall time error.
Definition: AdaptInfo.hpp:393
double timeTolerance(Key key) const
Returns timeTolerance.
Definition: AdaptInfo.hpp:428
void setMaxTimeIteration(int it)
Sets maxTimeIteration_.
Definition: AdaptInfo.hpp:249
double timeRelativeTolerance
Relative time tolerance.
Definition: AdaptInfo.hpp:63
void setTimestepNumber(int num)
Sets timestepNumber.
Definition: AdaptInfo.hpp:261
void printTimeErrorLowInfo() const
Print debug information about time error and its bound.
Definition: AdaptInfo.cpp:49
bool reachedEndTime() const
Definition: AdaptInfo.hpp:500
bool isRefinementAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition: AdaptInfo.hpp:582
Stores adapt infos for a scalar problem or for one component of a vector valued problem.
Definition: AdaptInfo.hpp:35
double timestep_
Time step size to be used.
Definition: AdaptInfo.hpp:730
double timeRelativeTolerance(Key key) const
Returns timeRelativeTolerance.
Definition: AdaptInfo.hpp:440
AdaptInfo(std::string const &name)
Constructor.
Definition: AdaptInfo.cpp:30
double estMax(Key key) const
Returns est_max.
Definition: AdaptInfo.hpp:357
double timeEstCombined(Key key) const
Definition: AdaptInfo.hpp:148
double endTime() const
Returns endTime_.
Definition: AdaptInfo.hpp:552
std::map< Key, ScalContent > scalContents_
Scalar adapt infos.
Definition: AdaptInfo.hpp:767
double spaceTolerance(Key key) const
Returns spaceTolerance.
Definition: AdaptInfo.hpp:404
void incTimestepIteration()
Increments timestepIteration_ by 1;.
Definition: AdaptInfo.hpp:207
int timestepNumber_
Number of current time step.
Definition: AdaptInfo.hpp:742
int timeIteration_
Current time iteration.
Definition: AdaptInfo.hpp:715
void setSpaceTolerance(Key key, double tol)
Sets spaceTolerance.
Definition: AdaptInfo.hpp:416
void setSpaceIteration(int it)
Sets spaceIteration_.
Definition: AdaptInfo.hpp:171
double maxTimestep_
Maximal step size.
Definition: AdaptInfo.hpp:739
int maxTimestepIteration() const
Returns maxTimestepIteration_.
Definition: AdaptInfo.hpp:213
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
int maxTimestepIteration_
Maximal number of iterations for choosing a timestep.
Definition: AdaptInfo.hpp:712
double fac_max
factors to combine max and integral time estimate
Definition: AdaptInfo.hpp:54
void setEndTime(double time)
Sets endTime_ = time.
Definition: AdaptInfo.hpp:540
double est_max
maximal local error estimate.
Definition: AdaptInfo.hpp:48
double minTimestep_
Minimal step size.
Definition: AdaptInfo.hpp:736
double timeEst_
overall time error estimate
Definition: AdaptInfo.hpp:770
double est_t_sum
Sum of all time error estimates.
Definition: AdaptInfo.hpp:45
double timeErrLow(Key key) const
Returns timeErrLow.
Definition: AdaptInfo.hpp:558
int spaceIteration_
Current space iteration.
Definition: AdaptInfo.hpp:700
void incTimeIteration()
Increments timesIteration_ by 1;.
Definition: AdaptInfo.hpp:237
double est_sum
Sum of all error estimates.
Definition: AdaptInfo.hpp:42
int timestepIteration() const
Returns timestepIteration_.
Definition: AdaptInfo.hpp:201
int maxSolverIterations_
maximal number of iterations needed of linear or nonlinear solver
Definition: AdaptInfo.hpp:755
int maxSpaceIteration() const
Returns maxSpaceIteration_.
Definition: AdaptInfo.hpp:177
int timeIteration() const
Returns timeIteration_.
Definition: AdaptInfo.hpp:231
double startTime() const
Returns startTime_.
Definition: AdaptInfo.hpp:546
double setTime(double t)
Sets time_.
Definition: AdaptInfo.hpp:452
ScalContent(std::string const &prefix)
Constructor.
Definition: AdaptInfo.cpp:14
void setMinTimestep(double t)
Sets minTimestep_.
Definition: AdaptInfo.hpp:510
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
int timestepNumber() const
Returns timestepNumber_.
Definition: AdaptInfo.hpp:255
double time_
Actual time, end of time interval for current time step.
Definition: AdaptInfo.hpp:721
void setEstMax(double e, Key key)
Sets est_max.
Definition: AdaptInfo.hpp:297
void reset()
Resets all variables to zero (or something equivalent)
Definition: AdaptInfo.cpp:67
double timeErrLow
Lower bound for the time error.
Definition: AdaptInfo.hpp:66
int numberOfTimesteps() const
Returns nTimesteps_.
Definition: AdaptInfo.hpp:267
double spaceTolerance
Tolerance for the (absolute or relative) error.
Definition: AdaptInfo.hpp:57
void maxSpaceIteration(int it)
Sets maxSpaceIteration_.
Definition: AdaptInfo.hpp:183
double globalTimeTolerance_
tolerance for the overall time error
Definition: AdaptInfo.hpp:764
bool isCoarseningAllowed(Key key) const
Returns whether coarsening is allowed or not.
Definition: AdaptInfo.hpp:570
int maxSpaceIteration_
maximal allowed number of iterations of the adaptive procedure; if maxIteration <= 0...
Definition: AdaptInfo.hpp:706
int refinementAllowed
true if refinement is allowed, false otherwise.
Definition: AdaptInfo.hpp:72
void maxTimestep(double t)
Sets maxTimestep_.
Definition: AdaptInfo.hpp:522
virtual bool spaceToleranceReached() const
Returns whether space tolerance is reached.
Definition: AdaptInfo.hpp:86
int spaceIteration() const
Returns spaceIteration_.
Definition: AdaptInfo.hpp:165
void setMaxTimestepIteration(int it)
Sets maxTimestepIteration.
Definition: AdaptInfo.hpp:219
Holds adapt parameters and infos about the problem.
Definition: AdaptInfo.hpp:25
int timestepIteration_
Current timestep iteration.
Definition: AdaptInfo.hpp:709
std::string name_
Name.
Definition: AdaptInfo.hpp:697
double startTime_
Initial time.
Definition: AdaptInfo.hpp:724
void setTimestepIteration(int it)
Sets timestepIteration_.
Definition: AdaptInfo.hpp:195
int maxTimeIteration_
Maximal number of time iterations.
Definition: AdaptInfo.hpp:718
double minTimestep() const
Gets minTimestep_.
Definition: AdaptInfo.hpp:516
double endTime_
Final time.
Definition: AdaptInfo.hpp:727
void setStartTime(double time)
Sets startTime_ = time.
Definition: AdaptInfo.hpp:534
int coarsenAllowed
true if coarsening is allowed, false otherwise.
Definition: AdaptInfo.hpp:69
void incSpaceIteration()
Increments spaceIteration_ by 1;.
Definition: AdaptInfo.hpp:189
double maxTimestep() const
Gets maxTimestep_.
Definition: AdaptInfo.hpp:528
virtual bool spaceToleranceReached(Key key) const
Returns whether space tolerance of component associated with key is reached.
Definition: AdaptInfo.hpp:97
double est_t_max
Maximum of all time error estimates.
Definition: AdaptInfo.hpp:51
virtual ~AdaptInfo()=default
Destructor.
double const & time() const
Gets time_.
Definition: AdaptInfo.hpp:464
double setTimestep(double t)
Sets timestep_.
Definition: AdaptInfo.hpp:470
virtual bool timeToleranceReached(Key key) const
Returns whether time tolerance of component associated with key is reached.
Definition: AdaptInfo.hpp:122
virtual bool timeErrorLow() const
Returns whether time error is under its lower bound.
Definition: AdaptInfo.hpp:137
double estSum(Key key) const
Returns est_sum.
Definition: AdaptInfo.hpp:333
double timeEstSum(Key key) const
Returns est_t_sum.
Definition: AdaptInfo.hpp:381
double timeTolerance
Time tolerance.
Definition: AdaptInfo.hpp:60
void setTimeEstSum(double e, Key key)
Sets est_t_sum.
Definition: AdaptInfo.hpp:321
int maxTimeIteration() const
Returns maxTimeIteration_.
Definition: AdaptInfo.hpp:243
void setEstSum(double e, Key key)
Sets est_sum.
Definition: AdaptInfo.hpp:285
virtual bool timeToleranceReached() const
Returns whether time tolerance is reached.
Definition: AdaptInfo.hpp:112
double const & timestep() const
Gets timestep_.
Definition: AdaptInfo.hpp:483
double timeEstMax(Key key) const
Returns est_max.
Definition: AdaptInfo.hpp:369
void incTimestepNumber()
Increments timestepNumber_ by 1;.
Definition: AdaptInfo.hpp:279