30 #ifndef OOMPH_TIME_STEPPERS_HEADER
31 #define OOMPH_TIME_STEPPERS_HEADER
35 #include <oomph-lib-config.h>
50 class ExplicitTimeStepper;
101 unsigned ndt =
Dt.size();
112 unsigned n_dt = dt_.size();
113 for (
unsigned i = 0;
i < n_dt;
i++)
136 double&
dt(
const unsigned&
t = 0)
143 double dt(
const unsigned&
t = 0)
const
150 double time(
const unsigned&
t = 0)
const
155 using namespace StringConversion;
164 for (
unsigned i = 0;
i <
t;
i++)
176 unsigned n_dt =
Dt.size();
183 for (
unsigned i = (n_dt - 1);
i > 0;
i--)
281 Adaptive_Flag(false),
283 Shut_up_in_assign_initial_data_values(false),
284 Predict_by_explicit_step(false)
287 Weight.resize(max_deriv + 1, tstorage, 0.0);
295 Predictor_storage_index = -1;
297 Explicit_predictor_pt = 0;
303 throw OomphLibError(
"Don't call default constructor for TimeStepper!",
352 virtual unsigned ndt()
const = 0;
398 return Predict_by_explicit_step;
405 return Explicit_predictor_pt;
412 Explicit_predictor_pt = _pred_pt;
419 Predicted_time = new_time;
429 "Predicted values are not from the correct time step",
444 if (Predictor_storage_index > 0)
446 return unsigned(Predictor_storage_index);
450 std::string err =
"Predictor storage index is negative, this probably";
451 err +=
" means it hasn't been set for this timestepper.";
456 return unsigned(Predictor_storage_index);
464 Shut_up_in_assign_initial_data_values =
false;
471 Shut_up_in_assign_initial_data_values =
true;
503 Data*
const& data_pt,
507 unsigned nvalue = data_pt->
nvalue();
508 deriv.assign(nvalue, 0.0);
511 for (
unsigned j = 0;
j < nvalue;
j++)
513 deriv[
j] = time_derivative(
i, data_pt,
j);
519 Data*
const& data_pt,
523 unsigned n_tstorage = ntstorage();
526 for (
unsigned t = 0;
t < n_tstorage;
t++)
537 Node*
const& node_pt,
541 unsigned nvalue = node_pt->
nvalue();
542 deriv.assign(nvalue, 0.0);
545 for (
unsigned j = 0;
j < nvalue;
j++)
547 deriv[
j] = time_derivative(
i, node_pt,
j);
556 Node*
const& node_pt,
560 unsigned n_tstorage = ntstorage();
563 for (
unsigned t = 0;
t < n_tstorage;
t++)
565 deriv += weight(
i,
t) * node_pt->
value(
t,
j);
578 "Time_pt is null, probably because it is a steady time stepper.");
594 virtual double weight(
const unsigned&
i,
const unsigned&
j)
const
625 return Adaptive_Flag;
679 template<
unsigned NSTEPS>
716 unsigned n_value = data_pt->
nvalue();
718 for (
unsigned j = 0;
j < n_value;
j++)
723 for (
unsigned t = 1;
t <= NSTEPS;
t++)
736 unsigned n_dim = node_pt->
ndim();
741 for (
unsigned i = 0;
i < n_dim;
i++)
746 for (
unsigned k = 0;
k < n_position_type;
k++)
748 for (
unsigned t = 1;
t <= NSTEPS;
t++)
760 typedef double (*InitialConditionFctPt)(
const double&
t);
769 unsigned n_time_value = ntstorage();
772 unsigned n_value = data_pt->
nvalue();
775 for (
unsigned t = 0;
t < n_time_value;
t++)
778 double time_local =
Time_pt->time(
t);
781 for (
unsigned j = 0;
j < n_value;
j++)
783 data_pt->
set_value(
t,
j, initial_value_fct[
j](time_local));
794 unsigned n_value = data_pt->
nvalue();
797 for (
unsigned j = 0;
j < n_value;
j++)
803 for (
unsigned t = NSTEPS;
t > 0;
t--)
816 unsigned n_dim = node_pt->
ndim();
821 for (
unsigned i = 0;
i < n_dim;
i++)
826 for (
unsigned k = 0;
k < n_position_type;
k++)
829 for (
unsigned t = NSTEPS;
t > 0;
t--)
842 unsigned max_deriv = highest_derivative();
843 for (
unsigned i = 0;
i < max_deriv;
i++)
845 for (
unsigned j = 0;
j < NSTEPS;
j++)
868 double weight(
const unsigned&
i,
const unsigned&
j)
const
870 if ((
i == 0) && (
j == 0))
910 template<
unsigned NSTEPS>
937 "Can't remember the order of the Newmark scheme";
938 error_message +=
" -- I think it's 2nd order...\n";
947 void assign_initial_values_impulsive(
Data*
const& data_pt);
951 void assign_initial_positions_impulsive(
Node*
const& node_pt);
955 typedef double (*InitialConditionFctPt)(
const double&
t);
960 void assign_initial_data_values(
961 Data*
const& data_pt,
971 typedef double (*NodeInitialConditionFctPt)(
const double&
t,
977 void assign_initial_data_values(
978 Node*
const& node_pt,
1005 void assign_initial_data_values_stage1(
const unsigned t_deriv,
1006 Data*
const& data_pt);
1017 void assign_initial_data_values_stage2(
Data*
const& data_pt);
1022 void shift_time_values(
Data*
const& data_pt);
1026 void shift_time_positions(
Node*
const& node_pt);
1072 template<
unsigned NSTEPS>
1081 this->
Type =
"NewmarkBDF";
1082 Degrade_to_bdf1_for_first_derivs =
false;
1083 Newmark_veloc_weight.resize(NSTEPS + 3);
1097 void shift_time_values(
Data*
const& data_pt);
1101 void shift_time_positions(
Node*
const& node_pt);
1107 Degrade_to_bdf1_for_first_derivs =
true;
1114 Degrade_to_bdf1_for_first_derivs =
false;
1124 Newmark_veloc_weight[0] = this->
Beta1 * dt * this->
Weight(2, 0);
1125 Newmark_veloc_weight[1] = this->
Beta1 * dt * this->
Weight(2, 1);
1126 for (
unsigned t = 2;
t <= NSTEPS;
t++)
1128 Newmark_veloc_weight[
t] = 0.0;
1130 Newmark_veloc_weight[NSTEPS + 1] =
1131 1.0 + this->
Beta1 * dt * this->
Weight(2, NSTEPS + 1);
1132 Newmark_veloc_weight[NSTEPS + 2] =
1163 template<
unsigned NSTEPS>
1202 Adaptive_Flag =
true;
1206 Predictor_weight.resize(NSTEPS + 2);
1209 Weight.resize(2, NSTEPS + 3, 0.0);
1212 Predictor_storage_index = NSTEPS + 2;
1237 unsigned n_value = data_pt->
nvalue();
1239 for (
unsigned j = 0;
j < n_value;
j++)
1244 for (
unsigned t = 1;
t <= NSTEPS;
t++)
1250 if (adaptive_flag())
1266 unsigned n_dim = node_pt->
ndim();
1271 for (
unsigned i = 0;
i < n_dim;
i++)
1278 for (
unsigned k = 0;
k < n_position_type;
k++)
1281 for (
unsigned t = 1;
t <= NSTEPS;
t++)
1287 if (adaptive_flag())
1290 node_pt->
x_gen(NSTEPS + 1,
k,
i) = 0.0;
1302 typedef double (*InitialConditionFctPt)(
const double&
t);
1311 unsigned n_time_value = ntstorage();
1314 unsigned n_value = data_pt->
nvalue();
1317 for (
unsigned t = 0;
t < n_time_value;
t++)
1320 double time_local =
Time_pt->time(
t);
1323 for (
unsigned j = 0;
j < n_value;
j++)
1325 data_pt->
set_value(
t,
j, initial_value_fct[
j](time_local));
1336 unsigned n_value = data_pt->
nvalue();
1341 const unsigned nt_value = nprev_values();
1344 if (adaptive_flag())
1346 time_derivative(1, data_pt,
velocity);
1350 for (
unsigned j = 0;
j < n_value;
j++)
1356 for (
unsigned t = nt_value;
t > 0;
t--)
1362 if (adaptive_flag())
1376 unsigned n_dim = node_pt->
ndim();
1381 unsigned n_tstorage = ntstorage();
1384 double velocity[n_position_type][n_dim];
1387 if (adaptive_flag())
1390 for (
unsigned i = 0;
i < n_dim;
i++)
1392 for (
unsigned k = 0;
k < n_position_type;
k++)
1397 for (
unsigned t = 0;
t < n_tstorage;
t++)
1406 for (
unsigned i = 0;
i < n_dim;
i++)
1412 for (
unsigned k = 0;
k < n_position_type;
k++)
1415 for (
unsigned t = NSTEPS;
t > 0;
t--)
1421 if (adaptive_flag())
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: timesteppers.h:1165
void shift_time_values(Data *const &data_pt)
Definition: timesteppers.h:1333
void calculate_predicted_positions(Node *const &node_pt)
Function to calculate predicted positions at a node.
void assign_initial_positions_impulsive(Node *const &node_pt)
Definition: timesteppers.h:1263
void calculate_predicted_values(Data *const &data_pt)
Function to calculate predicted data values in a Data object.
BDF(const bool &adaptive=false)
Constructor for the case when we allow adaptive timestepping.
Definition: timesteppers.h:1193
void assign_initial_values_impulsive(Data *const &data_pt)
Definition: timesteppers.h:1234
void set_weights()
Set the weights.
double Error_weight
Private data for the error weight.
Definition: timesteppers.h:1189
unsigned ndt() const
Number of timestep increments that need to be stored by the scheme.
Definition: timesteppers.h:1440
unsigned order() const
Return the actual order of the scheme.
Definition: timesteppers.h:1227
void operator=(const BDF &)=delete
Broken assignment operator.
Vector< double > Predictor_weight
Private data for the predictor weights.
Definition: timesteppers.h:1186
void set_predictor_weights()
Function to set the predictor weights.
double temporal_error_in_value(Data *const &data_pt, const unsigned &i)
Compute the error in the value i in a Data structure.
void shift_time_positions(Node *const &node_pt)
Definition: timesteppers.h:1373
BDF(const BDF &)=delete
Broken copy constructor.
void assign_initial_data_values(Data *const &data_pt, Vector< InitialConditionFctPt > initial_value_fct)
Definition: timesteppers.h:1307
double temporal_error_in_position(Node *const &node_pt, const unsigned &i)
Compute the error in the position i at a node.
unsigned nprev_values() const
Number of previous values available.
Definition: timesteppers.h:1434
void set_error_weights()
Function to set the error weights.
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
virtual bool is_a_copy() const
Definition: nodes.h:253
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483
double value(const unsigned &i) const
Definition: nodes.h:293
A Base class for explicit timesteppers.
Definition: explicit_timesteppers.h:132
Definition: timesteppers.h:1074
void set_weights()
Set weights.
void disable_degrade_first_derivatives_to_bdf1()
Disable degradation to first order BDF.
Definition: timesteppers.h:1112
NewmarkBDF(const NewmarkBDF &)=delete
Broken copy constructor.
bool Degrade_to_bdf1_for_first_derivs
Definition: timesteppers.h:1139
NewmarkBDF()
Definition: timesteppers.h:1079
void operator=(const NewmarkBDF &)=delete
Broken assignment operator.
Vector< double > Newmark_veloc_weight
Definition: timesteppers.h:1145
void set_newmark_veloc_weights(const double &dt)
Definition: timesteppers.h:1122
void enable_degrade_first_derivatives_to_bdf1()
Definition: timesteppers.h:1105
Definition: timesteppers.h:912
double Beta2
Second Newmark parameter (usually 0.5)
Definition: timesteppers.h:1049
Newmark()
Definition: timesteppers.h:917
unsigned nprev_values() const
Number of previous values available.
Definition: timesteppers.h:1032
unsigned ndt() const
Number of timestep increments that need to be stored by the scheme.
Definition: timesteppers.h:1038
double Beta1
First Newmark parameter (usually 0.5)
Definition: timesteppers.h:1046
unsigned order() const
The actual order (accuracy of the scheme)
Definition: timesteppers.h:934
void operator=(const Newmark &)=delete
Broken assignment operator.
Newmark(const Newmark &)=delete
Broken copy constructor.
double & x_gen(const unsigned &k, const unsigned &i)
Definition: nodes.h:1126
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
virtual bool position_is_a_copy() const
Return whether any position coordinate has been copied (always false)
Definition: nodes.h:1113
unsigned nposition_type() const
Definition: nodes.h:1016
double value(const unsigned &i) const
Definition: nodes.cc:2408
Definition: oomph_definitions.h:222
Definition: oomph_definitions.h:267
Definition: problem.h:151
Definition: timesteppers.h:681
void assign_initial_values_impulsive(Data *const &data_pt)
Definition: timesteppers.h:713
void set_weights()
Set weights.
Definition: timesteppers.h:839
double weight(const unsigned &i, const unsigned &j) const
Dummy: Access function for j-th weight for the i-th derivative.
Definition: timesteppers.h:868
void operator=(const Steady &)=delete
Broken assignment operator.
void shift_time_positions(Node *const &node_pt)
Definition: timesteppers.h:813
static double One
Static variable to hold the value 1.0.
Definition: timesteppers.h:882
static Time Dummy_time
Definition: timesteppers.h:888
Steady(const Steady &)=delete
Broken copy constructor.
Steady()
Definition: timesteppers.h:687
void assign_initial_data_values(Data *const &data_pt, Vector< InitialConditionFctPt > initial_value_fct)
Definition: timesteppers.h:765
void shift_time_values(Data *const &data_pt)
Definition: timesteppers.h:791
static double Zero
Static variable to hold the value 0.0.
Definition: timesteppers.h:885
unsigned order() const
Definition: timesteppers.h:706
unsigned nprev_values() const
Number of previous values available.
Definition: timesteppers.h:856
void assign_initial_positions_impulsive(Node *const &node_pt)
Definition: timesteppers.h:733
unsigned ndt() const
Number of timestep increments that need to be stored by the scheme.
Definition: timesteppers.h:862
Definition: timesteppers.h:231
virtual unsigned ndt() const =0
Number of timestep increments that are required by the scheme.
virtual void shift_time_values(Data *const &data_pt)=0
virtual void set_weights()=0
TimeStepper(const TimeStepper &)=delete
Broken copy constructor.
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
Definition: timesteppers.h:237
virtual unsigned nprev_values() const =0
Number of previous values available: 0 for static, 1 for BDF<1>,...
virtual void calculate_predicted_values(Data *const &data_pt)
Definition: timesteppers.h:634
bool Shut_up_in_assign_initial_data_values
Definition: timesteppers.h:256
virtual unsigned order() const
Actual order (accuracy) of the scheme.
Definition: timesteppers.h:324
virtual double temporal_error_in_value(Data *const &data_pt, const unsigned &i)
Definition: timesteppers.h:654
virtual void set_predictor_weights()
Definition: timesteppers.h:630
virtual void calculate_predicted_positions(Node *const &node_pt)
Definition: timesteppers.h:638
bool Predict_by_explicit_step
Definition: timesteppers.h:260
unsigned predictor_storage_index() const
Definition: timesteppers.h:438
Time *& time_pt()
Definition: timesteppers.h:588
void enable_warning_in_assign_initial_data_values()
Definition: timesteppers.h:462
virtual void actions_before_timestep(Problem *problem_pt)
Definition: timesteppers.h:662
void check_predicted_values_up_to_date() const
Check that the predicted values are the ones we want.
Definition: timesteppers.h:423
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234
unsigned ntstorage() const
Definition: timesteppers.h:601
std::string Type
Definition: timesteppers.h:241
virtual void actions_after_timestep(Problem *problem_pt)
Definition: timesteppers.h:666
void time_derivative(const unsigned &i, Node *const &node_pt, Vector< double > &deriv)
Definition: timesteppers.h:536
ExplicitTimeStepper * Explicit_predictor_pt
Definition: timesteppers.h:265
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
Definition: timesteppers.h:594
virtual void shift_time_positions(Node *const &node_pt)=0
bool Is_steady
Definition: timesteppers.h:251
virtual unsigned nprev_values_for_value_at_evaluation_time() const
Definition: timesteppers.h:359
bool adaptive_flag() const
Function to indicate whether the scheme is adaptive (false by default)
Definition: timesteppers.h:623
TimeStepper()
Broken empty constructor.
Definition: timesteppers.h:301
void operator=(const TimeStepper &)=delete
Broken assignment operator.
virtual void assign_initial_values_impulsive(Data *const &data_pt)=0
void disable_warning_in_assign_initial_data_values()
Definition: timesteppers.h:469
void time_derivative(const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
Definition: timesteppers.h:502
void make_steady()
Definition: timesteppers.h:374
TimeStepper(const unsigned &tstorage, const unsigned &max_deriv)
Definition: timesteppers.h:279
unsigned highest_derivative() const
Highest order derivative that the scheme can compute.
Definition: timesteppers.h:318
virtual void undo_make_steady()
Definition: timesteppers.h:482
double time() const
Return current value of continous time.
Definition: timesteppers.h:338
ExplicitTimeStepper * explicit_predictor_pt()
Definition: timesteppers.h:403
virtual void assign_initial_positions_impulsive(Node *const &node_pt)=0
double time_derivative(const unsigned &i, Data *const &data_pt, const unsigned &j)
Evaluate i-th derivative of j-th value in Data.
Definition: timesteppers.h:518
double & time()
Return current value of continous time.
Definition: timesteppers.h:332
void update_predicted_time(const double &new_time)
Definition: timesteppers.h:417
bool predict_by_explicit_step() const
Definition: timesteppers.h:396
virtual double temporal_error_in_position(Node *const &node_pt, const unsigned &i)
Definition: timesteppers.h:646
const DenseMatrix< double > * weights_pt() const
Get a (const) pointer to the weights.
Definition: timesteppers.h:475
std::string type() const
Definition: timesteppers.h:490
bool is_steady() const
Definition: timesteppers.h:389
virtual void set_error_weights()
Definition: timesteppers.h:642
double time_derivative(const unsigned &i, Node *const &node_pt, const unsigned &j)
Definition: timesteppers.h:555
double Predicted_time
Definition: timesteppers.h:269
Time *const & time_pt() const
Access function for the pointer to time (const version)
Definition: timesteppers.h:572
int Predictor_storage_index
Definition: timesteppers.h:273
bool Adaptive_Flag
Definition: timesteppers.h:245
void set_predictor_pt(ExplicitTimeStepper *_pred_pt)
Definition: timesteppers.h:410
Definition: timesteppers.h:63
double Continuous_time
Pointer to the value of the continuous time.
Definition: timesteppers.h:66
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136
Time(const Time &)=delete
Broken copy constructor.
void operator=(const Time &)=delete
Broken assignment operator.
Vector< double > Dt
Vector that stores the values of the current and previous timesteps.
Definition: timesteppers.h:69
double time(const unsigned &t=0) const
Definition: timesteppers.h:150
double dt(const unsigned &t=0) const
Definition: timesteppers.h:143
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123
void initialise_dt(const Vector< double > &dt_)
Definition: timesteppers.h:107
void shift_dt()
Definition: timesteppers.h:174
void initialise_dt(const double &dt_)
Set all timesteps to the same value, dt.
Definition: timesteppers.h:99
unsigned ndt() const
Return the number of timesteps stored.
Definition: timesteppers.h:129
void resize(const unsigned &n_dt)
Definition: timesteppers.h:93
Time()
Definition: timesteppers.h:74
~Time()
Destructor: empty.
Definition: timesteppers.h:120
Time(const unsigned &ndt)
Definition: timesteppers.h:78
char char char int int * k
Definition: level2_impl.h:374
Time * Time_pt
Pointer to the global time object.
Definition: turek_flag_non_fsi.cc:91
double Beta1
Thermal conductivity in outer annular region.
Definition: stefan_boltzmann.cc:130
int adaptive
Definition: jeffery_hamel.cc:106
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107
double Weight
NOTE: WE IMPOSE EITHER THESE ...
Definition: heated_linear_solid_contact_with_gravity.cc:2838
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
double Zero
Definition: pseudosolid_node_update_elements.cc:35
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
Type
Type of JSON value.
Definition: rapidjson.h:513
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2