Commit 71358a8d authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

ART - AdaptiveSolver

- now uses UL int instead of ULL int for time frame portion
- now automatically limits max adaptation level to 31
parent 553e4f29
......@@ -64,7 +64,7 @@ namespace ITAPropagationPathSim
bool bActive = true; //!< If this is set to false, the adaptation is bypassed and the integration step size is therefore constant
double dMaxError = 0.015;
double dUncriticalError = 0.005;
unsigned int iMaxAdaptationLevel = 32; //! Maximum times, the time step is halfed
unsigned int iMaxAdaptationLevel = 31; //! Maximum times, the time step is halfed. Maximum valid value = 31.
};
struct ITA_PROPAGATION_PATH_SIM_API Settings {
......
......@@ -6,9 +6,16 @@
// STD
#include <cmath>
#include <algorithm>
using namespace ITAPropagationPathSim::AtmosphericRayTracing;
Simulation::CAdaptiveSolver::CAdaptiveSolver(const Settings& settings)
: rSettings(settings)
, maxDtPortion( (unsigned long int) 1 << std::min(rSettings.adaptiveIntegration.iMaxAdaptationLevel, MaxAllowedAdaptationLevel) )
{
}
void Simulation::CAdaptiveSolver::Process(const VistaVector3D& r, const VistaVector3D& s, const ITAGeo::CStratifiedAtmosphere& atmosphere, VistaVector3D& rNew, VistaVector3D& sNew)
{
if (rSettings.adaptiveIntegration.bActive)
......@@ -89,15 +96,15 @@ bool Simulation::CAdaptiveSolver::TryDecreaseTimeStep()
void Simulation::CAdaptiveSolver::UpdateTimeFramePortion()
{
iTimeFramePortion += (long long int)1 << (rSettings.adaptiveIntegration.iMaxAdaptationLevel - iDtAdaptationLevel);
iTimeFramePortion += (unsigned long int)1 << (rSettings.adaptiveIntegration.iMaxAdaptationLevel - iDtAdaptationLevel);
if (iTimeFramePortion >= maxDtPortion)
iTimeFramePortion = 0;
}
bool Simulation::CAdaptiveSolver::IncreasedDtFitsInRestOfTimeFrame() const
{
const unsigned long long int newDtPortion = (long long int) 1 << (rSettings.adaptiveIntegration.iMaxAdaptationLevel - (iDtAdaptationLevel - 1));
const unsigned long long int leftDtPortion = (maxDtPortion - iTimeFramePortion);
const unsigned long long int moduloDtPortion = leftDtPortion % newDtPortion;
const unsigned long int newDtPortion = (unsigned long int) 1 << (rSettings.adaptiveIntegration.iMaxAdaptationLevel - (iDtAdaptationLevel - 1));
const unsigned long int leftDtPortion = (maxDtPortion - iTimeFramePortion);
const unsigned long int moduloDtPortion = leftDtPortion % newDtPortion;
return moduloDtPortion == 0;
//return ((maxDtPortion - iTimeFramePortion) % newDtPortion) == 0;
}
\ No newline at end of file
......@@ -33,17 +33,19 @@ namespace ITAPropagationPathSim
{
class CAdaptiveSolver
{
public:
static const unsigned int MaxAllowedAdaptationLevel = 31; //! Maximum allowed value for Simulation::AdaptiveIntegrationSettings.iMaxAdaptationLevel. TODO: Move to Simulation::Settings?
private:
const Settings rSettings;
double dCurrentDt = rSettings.dIntegrationTimeStep;
unsigned int iDtAdaptationLevel = 0;
const unsigned long long int maxDtPortion = (long long int) 1 << rSettings.adaptiveIntegration.iMaxAdaptationLevel; //! = 2 ^ iMaxAdaptionLevel
unsigned long long int iTimeFramePortion = 0; //! Portion of processed time of an unadapted time step. Integer between 0 and maxDtPortion.
const unsigned long int maxDtPortion; //! = 2 ^ iMaxAdaptionLevel
unsigned long int iTimeFramePortion = 0; //! Portion of processed time of an unadapted time step. Integer between 0 and maxDtPortion.
bool bIncreaseDtInNextStep = false; //! Indicates whether the error is small enough that the timestep can be increased during next step.
public:
CAdaptiveSolver(const Settings& settings) : rSettings(settings) {}
CAdaptiveSolver(const Settings& settings);
public:
double CurrentStepSize() const { return dCurrentDt; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment