1#ifndef included_BDFIntegrator_h_
2#define included_BDFIntegrator_h_
7#include "AMP/time_integrators/ImplicitIntegrator.h"
30 std::shared_ptr<AMP::TimeIntegrator::TimeIntegratorParameters> parameters );
49 const double old_dt )
override;
71 std::shared_ptr<const AMP::TimeIntegrator::TimeIntegratorParameters> parameters )
override;
79 std::shared_ptr<AMP::LinearAlgebra::Vector> in,
80 std::shared_ptr<AMP::LinearAlgebra::Vector> out )
override;
102 std::string
type()
const override {
return "BDFIntegrator"; }
224 std::shared_ptr<AMP::LinearAlgebra::Vector> y,
225 std::vector<double> &
norms );
236 const std::string &
prefix,
238 const std::string &
norm );
294 std::vector<std::vector<double>>
d_LTE;
353 double d_new_time = std::numeric_limits<double>::signaling_NaN();
368 double d_time_atol = std::numeric_limits<double>::signaling_NaN();
371 double d_time_rtol = std::numeric_limits<double>::signaling_NaN();
Class to manage reading/writing restart data.
std::list< double > d_l2errorNorms_E
std::vector< double > d_integrator_order
truncation error order for time integrators
void setIterationCounts(const int nli, const int li)
void integratorSpecificInitialize(void) override
void writeRestart(int64_t fid) const override
Write restart data to file.
int integratorSpecificAdvanceSolution(const double dt, const bool first_step, std::shared_ptr< AMP::LinearAlgebra::Vector > in, std::shared_ptr< AMP::LinearAlgebra::Vector > out) override
int d_linear_iterations
records number of linear iterations at current timestep
std::shared_ptr< AMP::LinearAlgebra::Vector > d_scratch_vector
the next vector is used for scratch or intermediate storage
void reset(std::shared_ptr< const AMP::TimeIntegrator::TimeIntegratorParameters > parameters) override
void estimateBETimeDerivative(void)
estimates the BE time derivative using the approach in Gresho and Sani
int d_solver_converged_reason
convergence reason returned by solver
bool integratorSpecificCheckNewSolution(const int solver_retcode) override
std::shared_ptr< AMP::LinearAlgebra::Vector > d_integrator_source_vector
int d_enable_picontrol_regrid_steps
the number of timesteps after a regrid before the pi controller is enabled
double d_timeErrorEstimateRatio
truncation error ratio to previous step
int getNumberOfStepRejections(void)
returns the total number of timestep rejections
double getNextDtConstant(const bool good_solution, const int solver_retcode)
void evaluateForwardEulerPredictor(void)
bool d_is_new_timestep
boolean flag to determine if a new timestep has started
bool d_vectors_registered_for_mgmt
boolean to ensure registerVectorsForMemoryManagement is called once
double calculateLTEScalingFactor(void)
int d_evaluatefunction_count
counter to track number of nonlinear function calls
void evaluatePredictor(void)
evaluates the predictor and stores in the predictor energy and temperature variables
void printVectorComponentNorms(const std::shared_ptr< AMP::LinearAlgebra::Vector > &vec, const std::string &prefix, const std::string &postfix, const std::string &norm)
std::shared_ptr< AMP::LinearAlgebra::Vector > getTimeHistorySourceTerm() override
static std::unique_ptr< AMP::TimeIntegrator::TimeIntegrator > createTimeIntegrator(std::shared_ptr< AMP::TimeIntegrator::TimeIntegratorParameters > parameters)
void initializeVariables(bool is_from_restart)
std::list< double > d_l2errorNorms_T
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_prev_solutions
std::shared_ptr< AMP::LinearAlgebra::Vector > d_prev_function_vector
the next vector will store the old rhs at the previous time level
bool d_use_predictor
boolean flag to use a predictor for the initial guess at each timestep
int d_final_constant_timestep_current_step
int getFunctionEvaluationCount(void)
std::string type() const override
Return the name of the TimeIntegrator.
std::vector< double > getTimeHistoryScalings(void) override
Scaling factors for previous time history vectors.
bool d_use_constant_time_interpolation
boolean flag used to do constant time interpolation, used after regrids
size_t d_integrator_index
index into d_integrator_names showing what is the current integrator
BDFIntegrator(int64_t fid, AMP::IO::RestartManager *manager)
Read restart data to file.
double d_time_rtol
relative tolerance for the truncation error based strategy
double getNextDtFinalConstant(const bool good_solution, const int solver_retcode)
bool d_use_bdf1_estimator_on_regrid
std::string d_pi_controller_type
type of PI controller, current options are "H211b", "PI.4.7", and "Deadbeat"
double d_time_atol
absolute tolerance for the truncation error based strategy
double d_target_relative_change
std::vector< std::string > d_var_names
names of variables to associate with different components of a vector
int d_number_initial_fixed_steps
int d_current_steprejects
keeps track of successive step rejections at a given timestep
void setPredictorType(const std::string &predictor="")
double estimateDtWithTruncationErrorEstimates(double current_dt, bool good_solution)
estimate timestep based on truncation error estimates
std::shared_ptr< AMP::LinearAlgebra::Vector > d_timederivative_vector
the next vector will store the current estimate for the time derivative
bool d_use_initial_predictor
bool d_reset_after_restart
boolean flag to detect a call to reset immediately following restart
std::shared_ptr< AMP::LinearAlgebra::Vector > d_predictor_vector
the next vector will store the predictor for the next timestep
std::vector< int > d_nonlinearIterations
vector to keep track of the number of nonlinear iterations
double d_prevTimeTruncationErrorEstimate
truncation error estimate at previous step
void evaluateLeapFrogPredictor(void)
double getGamma(void) override
bool d_use_pi_controller
boolean flag to enable or disable the use of a PI based timestep controller
void calculateScaledLTENorm(std::shared_ptr< AMP::LinearAlgebra::Vector > x, std::shared_ptr< AMP::LinearAlgebra::Vector > y, std::vector< double > &norms)
void registerDataManagerCallback(DataManagerCallBack callBackFn)
bool d_is_after_regrid
state of simulation, whether it is immediately after a regrid
void computeIntegratorSourceTerm(void)
std::vector< double > d_times
vector to the store the simulation times
std::string d_bdf_starting_integrator
the one step method used to start up BDF2, options are "Backward Euler" or "CN"
double d_DtGrowthUpperBound
upper bound on factor by which timestep can be increased
double d_DtCutLowerBound
max factor to cut timestep by when a timestep is rejected
double getNextDtTruncationError(const bool good_solution, const int solver_retcode)
double d_alpha
ratio of current to previous timestep
std::shared_ptr< AMP::LinearAlgebra::Vector > d_old_td_vector
the next vector will store the old time derivative at previous time level
void estimateCNTimeDerivative(void)
estimates the CN time derivative using the approach in Gresho and Sani
std::vector< int > d_linearIterations
vector to keep track of the number of linear iterations
size_t d_max_integrator_index
index into d_integrator_names that shows what is the max BDF order
double d_gamma
factor to multiply rhs by
int d_bdf1_eps_regrid_steps
number of steps to use bdf1 error estimator after regrid
bool d_control_timestep_variation
boolean to minimize the number of timestep changes in the truncation error strategy
void setInitialGuess(const bool first_step, const double current_time, const double current_dt, const double old_dt) override
void setRegridStatus(bool is_after_regrid)
std::string d_timeTruncationErrorNormType
norm type used for truncation error calculation
double d_new_time
double containing t_{n+1}
std::vector< std::string > d_integrator_names
names of time integrators
void printStatistics(std::ostream &os=AMP::pout) override
print the statistics on the implicit equations
bool d_log_statistics
whether to log statistics about time integrator
double getNextDtPredefined(const bool good_solution, const int solver_retcode)
void getFromInput(std::shared_ptr< AMP::Database > input_db)
int d_current_stepaccepts
keeps track of successive step acceptances
std::vector< double > d_integrator_steps
vector of previous timesteps
double getTimeOperatorScaling(void)
return the factor getGamma() used to scale the rhs operator
void setMultiPhysicsScalings(void)
double d_timeTruncationErrorEstimate
truncation error estimate in time over both E and T
std::vector< int > d_step_accepted
vector to keep track of whether the step is accepted
std::shared_ptr< AMP::LinearAlgebra::Vector > d_current_function_vector
the next vector will store the rhs at the current time level
std::shared_ptr< AMP::LinearAlgebra::Vector > d_scratch_function_vector
the next vector is used for scratch or intermediate storage for rhs
int d_nonlinear_iterations
records number of nonlinear iterations at current timestep
void integratorSpecificUpdateSolution(const double new_time) override
std::string d_implicit_integrator
string for the time integrator being used, options are "Backward Euler", "BDF2", or "CN"
std::vector< std::vector< double > > d_LTE
vector of vectors to store the local truncation errors for components
void registerVectorsForMemoryManagement(void)
DataManagerCallBack d_registerVectorForManagement
bool d_calculateTimeTruncError
calculate time truncation error if enabled
std::vector< double > d_problem_scales
fixed used defined scales for time error scaling
std::vector< std::string > d_vector_names
names of variables to associate with different vectors
void evaluateBDFInterpolantPredictor(void)
evaluates a predictor based on an interpolating polynomial
bool d_combine_timestep_estimators
boolean flag to combine different time error estimators
std::string d_initial_predictor_type
initial predictor type
bool d_auto_component_scaling
enable auto scaling if true
std::vector< double > d_a
time history scalings
void calculateTemporalTruncationError(void)
void setTimeHistoryScalings() override
const auto & getTimeHistoryVectors()
void setIsNewTimeStep(bool bval)
std::string d_timestep_strategy
BDFIntegrator(AMP::TimeIntegrator::TimeIntegratorParameters::shared_ptr)
bool d_prevSuccessiveRejects
boolean flag to keep track of successive time step rejections
std::string d_predictor_type
predictor to use with predictor corrector approach
void estimateTimeDerivative(void)
wrapper for estimating the time derivative after a succesful step
void evaluateAB2Predictor(void)
evaluates the AB2 predictor and stores in the predictor energy and temperature variables
double integratorSpecificGetNextDt(const bool good_solution, const int solver_retcode) override
double d_first_initial_dt
double storing the first dt before any restart
std::string d_time_error_scaling
int d_timesteps_after_regrid
keeps track of the number of timesteps after the last regrid
void estimateBDF2TimeDerivative(void)
estimates the BDF2 time derivative using the approach in Gresho and Sani
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register any child objects.
int d_number_of_time_intervals
void estimateFrontSpeed()
std::vector< double > d_timesteps
vector to store the timesteps
size_t sizeOfTimeHistory() const override
Manage implicit time integration.
std::shared_ptr< AMP::TimeIntegrator::TimeIntegratorParameters > shared_ptr
Convience typedef.
Abstract base class for time integration.
std::shared_ptr< AMP::TimeIntegrator::TimeIntegrator > shared_ptr
Convience typedef.
std::function< void(std::shared_ptr< AMP::LinearAlgebra::Vector >)> DataManagerCallBack
constexpr double norm(const std::array< double, N > &x)