Public Types | Public Member Functions | Private Attributes | List of all members
oomph::BDF< NSTEPS > Class Template Reference

Templated class for BDF-type time-steppers with fixed or variable timestep. 1st time derivative recovered directly from the previous function values. Template parameter represents the number of previous timesteps stored, so that BDF<1> is the classical first order backward Euler scheme. Need to reset weights after every change in timestep. More...

#include <timesteppers.h>

+ Inheritance diagram for oomph::BDF< NSTEPS >:

Public Types

typedef double(* InitialConditionFctPt) (const double &t)
 Typedef for function that returns the (scalar) initial value at a given value of the continuous time t. More...
 

Public Member Functions

 BDF (const bool &adaptive=false)
 Constructor for the case when we allow adaptive timestepping. More...
 
 BDF (const BDF &)
 Broken copy constructor. More...
 
void operator= (const BDF &)
 Broken assignment operator. More...
 
unsigned order () const
 Return the actual order of the scheme. More...
 
void assign_initial_values_impulsive (Data *const &data_pt)
 Initialise the time-history for the Data values, corresponding to an impulsive start. More...
 
void assign_initial_positions_impulsive (Node *const &node_pt)
 Initialise the time-history for the nodal positions corresponding to an impulsive start. More...
 
void assign_initial_data_values (Data *const &data_pt, Vector< InitialConditionFctPt > initial_value_fct)
 Initialise the time-history for the Data values, corresponding to given time history, specified by Vector of function pointers. More...
 
void shift_time_values (Data *const &data_pt)
 This function updates the Data's time history so that we can advance to the next timestep. For BDF schemes, we simply push the values backwards... More...
 
void shift_time_positions (Node *const &node_pt)
 This function advances the time history of the positions at a node. More...
 
void set_weights ()
 Set the weights. More...
 
unsigned nprev_values () const
 Number of previous values available. More...
 
unsigned ndt () const
 Number of timestep increments that need to be stored by the scheme. More...
 
void set_predictor_weights ()
 Function to set the predictor weights. More...
 
void calculate_predicted_positions (Node *const &node_pt)
 Function to calculate predicted positions at a node. More...
 
void calculate_predicted_values (Data *const &data_pt)
 Function to calculate predicted data values in a Data object. More...
 
void set_error_weights ()
 Function to set the error weights. More...
 
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Compute the error in the position i at a node. More...
 
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Compute the error in the value i in a Data structure. More...
 
template<>
void set_weights ()
 Assign the values of the weights. More...
 
template<>
void set_predictor_weights ()
 Set the predictor weights (Gresho and Sani pg. 270) More...
 
template<>
void calculate_predicted_values (Data *const &data_pt)
 
template<>
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
template<>
void set_error_weights ()
 Set the error weights (Gresho and Sani pg. 270) More...
 
template<>
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
template<>
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Function to calculate the error in the data value i. More...
 
template<>
void set_weights ()
 
template<>
void set_predictor_weights ()
 
template<>
void calculate_predicted_values (Data *const &data_pt)
 
template<>
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
template<>
void set_error_weights ()
 Function that sets the error weights. More...
 
template<>
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
template<>
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Function to calculate the error in the data value i. More...
 
template<>
void set_weights ()
 Assign the values of the weights; pass the value of the timestep. More...
 
template<>
void set_predictor_weights ()
 Calculate the predictor weights. More...
 
template<>
void calculate_predicted_values (Data *const &data_pt)
 
template<>
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
template<>
void set_error_weights ()
 Function that sets the error weights. More...
 
template<>
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
template<>
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Function to calculate the error in the data value i. More...
 
- Public Member Functions inherited from oomph::TimeStepper
 TimeStepper (const unsigned &tstorage, const unsigned &max_deriv)
 Constructor. Pass the amount of storage required by timestepper (present value + history values) and the order of highest time-derivative. More...
 
 TimeStepper ()
 Broken empty constructor. More...
 
 TimeStepper (const TimeStepper &)
 Broken copy constructor. More...
 
void operator= (const TimeStepper &)
 Broken assignment operator. More...
 
virtual ~TimeStepper ()
 virtual destructor More...
 
unsigned highest_derivative () const
 Highest order derivative that the scheme can compute. More...
 
double & time ()
 Return current value of continous time. More...
 
double time () const
 Return current value of continous time. More...
 
virtual unsigned nprev_values_for_value_at_evaluation_time () const
 Number of previous values needed to calculate the value at the current time. i.e. how many previous values must we loop over to calculate the values at the evaluation time. For most methods this is 1, i.e. just use the value at t_{n+1}. See midpoint method for a counter-example. More...
 
void make_steady ()
 Function to make the time stepper temporarily steady. This is trivially achieved by setting all the weights to zero. More...
 
bool is_steady () const
 Flag to indicate if a timestepper has been made steady (possibly temporarily to switch off time-dependence) More...
 
bool predict_by_explicit_step () const
 Flag: is adaptivity done by taking a separate step using an ExplicitTimeStepper object? More...
 
ExplicitTimeStepperexplicit_predictor_pt ()
 
void set_predictor_pt (ExplicitTimeStepper *_pred_pt)
 
void update_predicted_time (const double &new_time)
 
void check_predicted_values_up_to_date () const
 Check that the predicted values are the ones we want. More...
 
unsigned predictor_storage_index () const
 Return the time-index in each Data where predicted values are stored if the timestepper is adaptive. More...
 
void enable_warning_in_assign_initial_data_values ()
 Enable the output of warnings due to possible fct pointer vector size mismatch in assign_initial_data_values (Default) More...
 
void disable_warning_in_assign_initial_data_values ()
 Disable the output of warnings due to possible fct pointer vector size mismatch in assign_initial_data_values. More...
 
const DenseMatrix< double > * weights_pt () const
 Get a (const) pointer to the weights. More...
 
virtual void undo_make_steady ()
 Reset the is_steady status of a specific TimeStepper to its default and re-assign the weights. More...
 
std::string type () const
 Return string that indicates the type of the timestepper (e.g. "BDF", "Newmark", etc.) More...
 
void time_derivative (const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
 Evaluate i-th derivative of all values in Data and return in Vector deriv[]. More...
 
double time_derivative (const unsigned &i, Data *const &data_pt, const unsigned &j)
 Evaluate i-th derivative of j-th value in Data. More...
 
void time_derivative (const unsigned &i, Node *const &node_pt, Vector< double > &deriv)
 Evaluate i-th derivative of all values in Node and return in Vector deriv[] (this can't be simply combined with time_derivative(.., Data, ...) because of differences with haning nodes). More...
 
double time_derivative (const unsigned &i, Node *const &node_pt, const unsigned &j)
 Evaluate i-th derivative of j-th value in Node. Note the use of the node's value() function so that hanging nodes are taken into account (this is why the functions for Data and Node cannot be combined through simple polymorphism: value is not virtual). More...
 
Time *const & time_pt () const
 Access function for the pointer to time (const version) More...
 
Time *& time_pt ()
 
virtual double weight (const unsigned &i, const unsigned &j) const
 Access function for j-th weight for the i-th derivative. More...
 
unsigned ntstorage () const
 Return the number of doubles required to represent history (one for steady) More...
 
bool adaptive_flag () const
 Function to indicate whether the scheme is adaptive (false by default) More...
 
virtual void actions_before_timestep (Problem *problem_pt)
 
virtual void actions_after_timestep (Problem *problem_pt)
 

Private Attributes

Vector< double > Predictor_weight
 Private data for the predictor weights. More...
 
double Error_weight
 Private data for the error weight. More...
 

Additional Inherited Members

- Protected Attributes inherited from oomph::TimeStepper
TimeTime_pt
 Pointer to discrete time storage scheme. More...
 
DenseMatrix< double > Weight
 Storage for the weights associated with the timestepper. More...
 
std::string Type
 String that indicates the type of the timestepper (e.g. "BDF", "Newmark", etc.) More...
 
bool Adaptive_Flag
 Boolean variable to indicate whether the timestepping scheme can be adaptive. More...
 
bool Is_steady
 Bool to indicate if the timestepper is steady, i.e. its time-derivatives evaluate to zero. This status may be achieved temporarily by calling make_steady(). It can be reset to the appropriate default by the function undo_make_steady(). More...
 
bool Shut_up_in_assign_initial_data_values
 Boolean to indicate if the timestepper will output warnings when setting possibly an incorrect number of initial data values from function pointers. More...
 
bool Predict_by_explicit_step
 Flag: is adaptivity done by taking a separate step using an ExplicitTimeStepper object? More...
 
ExplicitTimeStepperExplicit_predictor_pt
 
double Predicted_time
 
int Predictor_storage_index
 The time-index in each Data object where predicted values are stored. -1 if not set. More...
 

Detailed Description

template<unsigned NSTEPS>
class oomph::BDF< NSTEPS >

Templated class for BDF-type time-steppers with fixed or variable timestep. 1st time derivative recovered directly from the previous function values. Template parameter represents the number of previous timesteps stored, so that BDF<1> is the classical first order backward Euler scheme. Need to reset weights after every change in timestep.

Definition at line 1141 of file timesteppers.h.

Member Typedef Documentation

◆ InitialConditionFctPt

template<unsigned NSTEPS>
typedef double(* oomph::BDF< NSTEPS >::InitialConditionFctPt) (const double &t)

Typedef for function that returns the (scalar) initial value at a given value of the continuous time t.

Definition at line 1284 of file timesteppers.h.

Constructor & Destructor Documentation

◆ BDF() [1/2]

template<unsigned NSTEPS>
oomph::BDF< NSTEPS >::BDF ( const bool &  adaptive = false)
inline

Constructor for the case when we allow adaptive timestepping.

Definition at line 1172 of file timesteppers.h.

◆ BDF() [2/2]

template<unsigned NSTEPS>
oomph::BDF< NSTEPS >::BDF ( const BDF< NSTEPS > &  )
inline

Broken copy constructor.

Definition at line 1200 of file timesteppers.h.

References oomph::BrokenCopy::broken_copy().

Member Function Documentation

◆ assign_initial_data_values()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::assign_initial_data_values ( Data *const &  data_pt,
Vector< InitialConditionFctPt initial_value_fct 
)
inline

Initialise the time-history for the Data values, corresponding to given time history, specified by Vector of function pointers.

Definition at line 1289 of file timesteppers.h.

References oomph::Data::nvalue(), oomph::Data::set_value(), and t.

◆ assign_initial_positions_impulsive()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::assign_initial_positions_impulsive ( Node *const &  node_pt)
inlinevirtual

Initialise the time-history for the nodal positions corresponding to an impulsive start.

Implements oomph::TimeStepper.

Definition at line 1245 of file timesteppers.h.

References i, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::Node::position_is_a_copy(), t, and oomph::Node::x_gen().

◆ assign_initial_values_impulsive()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::assign_initial_values_impulsive ( Data *const &  data_pt)
inlinevirtual

Initialise the time-history for the Data values, corresponding to an impulsive start.

Implements oomph::TimeStepper.

Definition at line 1216 of file timesteppers.h.

References oomph::Data::is_a_copy(), oomph::Data::nvalue(), oomph::Data::set_value(), t, and oomph::Data::value().

◆ calculate_predicted_positions() [1/4]

template<>
void oomph::BDF< 1 >::calculate_predicted_positions ( Node *const &  node_pt)
virtual

◆ calculate_predicted_positions() [2/4]

template<>
void oomph::BDF< 2 >::calculate_predicted_positions ( Node *const &  node_pt)
virtual

◆ calculate_predicted_positions() [3/4]

template<>
void oomph::BDF< 4 >::calculate_predicted_positions ( Node *const &  node_pt)
virtual

Calculate predictions for the positions.

Reimplemented from oomph::TimeStepper.

Definition at line 457 of file timesteppers.cc.

◆ calculate_predicted_positions() [4/4]

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::calculate_predicted_positions ( Node *const &  node_pt)
virtual

Function to calculate predicted positions at a node.

Reimplemented from oomph::TimeStepper.

◆ calculate_predicted_values() [1/4]

template<>
void oomph::BDF< 1 >::calculate_predicted_values ( Data *const &  data_pt)
virtual

Calculate the predicted values and store them at the appropriate location in the data structure This function must be called after the time-values have been shifted!

Reimplemented from oomph::TimeStepper.

Definition at line 119 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), i, oomph::Data::is_a_copy(), oomph::Data::nvalue(), oomph::TimeStepper::Predictor_storage_index, oomph::Data::set_value(), and oomph::Data::value().

◆ calculate_predicted_values() [2/4]

template<>
void oomph::BDF< 2 >::calculate_predicted_values ( Data *const &  data_pt)
virtual

Calculate the predicted values and store them at the appropriate location in the data structure This function must be called after the time-values have been shifted!

Reimplemented from oomph::TimeStepper.

Definition at line 279 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), i, oomph::Data::is_a_copy(), oomph::Data::nvalue(), oomph::TimeStepper::Predictor_storage_index, oomph::Data::set_value(), and oomph::Data::value().

◆ calculate_predicted_values() [3/4]

template<>
void oomph::BDF< 4 >::calculate_predicted_values ( Data *const &  data_pt)
virtual

Calculate the predicted values and store them at the appropriate location in the data structure This function must be called after the time-values have been shifted!

Reimplemented from oomph::TimeStepper.

Definition at line 447 of file timesteppers.cc.

◆ calculate_predicted_values() [4/4]

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::calculate_predicted_values ( Data *const &  data_pt)
virtual

Function to calculate predicted data values in a Data object.

Reimplemented from oomph::TimeStepper.

◆ ndt()

template<unsigned NSTEPS>
unsigned oomph::BDF< NSTEPS >::ndt ( ) const
inlinevirtual

Number of timestep increments that need to be stored by the scheme.

Implements oomph::TimeStepper.

Definition at line 1418 of file timesteppers.h.

References i.

◆ nprev_values()

template<unsigned NSTEPS>
unsigned oomph::BDF< NSTEPS >::nprev_values ( ) const
inlinevirtual

Number of previous values available.

Implements oomph::TimeStepper.

Definition at line 1415 of file timesteppers.h.

◆ operator=()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::operator= ( const BDF< NSTEPS > &  )
inline

Broken assignment operator.

Definition at line 1206 of file timesteppers.h.

References oomph::BrokenCopy::broken_assign().

◆ order()

template<unsigned NSTEPS>
unsigned oomph::BDF< NSTEPS >::order ( ) const
inlinevirtual

Return the actual order of the scheme.

Reimplemented from oomph::TimeStepper.

Definition at line 1212 of file timesteppers.h.

◆ set_error_weights() [1/4]

template<>
void oomph::BDF< 1 >::set_error_weights ( )
virtual

Set the error weights (Gresho and Sani pg. 270)

Reimplemented from oomph::TimeStepper.

Definition at line 185 of file timesteppers.cc.

◆ set_error_weights() [2/4]

template<>
void oomph::BDF< 2 >::set_error_weights ( )
virtual

Function that sets the error weights.

Reimplemented from oomph::TimeStepper.

Definition at line 345 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::Time::dt(), and oomph::TimeStepper::Time_pt.

◆ set_error_weights() [3/4]

template<>
void oomph::BDF< 4 >::set_error_weights ( )
virtual

Function that sets the error weights.

Reimplemented from oomph::TimeStepper.

Definition at line 466 of file timesteppers.cc.

◆ set_error_weights() [4/4]

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::set_error_weights ( )
virtual

Function to set the error weights.

Reimplemented from oomph::TimeStepper.

◆ set_predictor_weights() [1/4]

template<>
void oomph::BDF< 1 >::set_predictor_weights ( )
virtual

Set the predictor weights (Gresho and Sani pg. 270)

Reimplemented from oomph::TimeStepper.

Definition at line 96 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::Time::dt(), and oomph::TimeStepper::Time_pt.

◆ set_predictor_weights() [2/4]

template<>
void oomph::BDF< 2 >::set_predictor_weights ( )
virtual

Calculate the predictor weights. The scheme used is from Gresho & Sani, Incompressible Flow and the Finite Element Method (advection-diffusion and isothermal laminar flow), 1998, pg. 715.

Reimplemented from oomph::TimeStepper.

Definition at line 255 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::Time::dt(), and oomph::TimeStepper::Time_pt.

◆ set_predictor_weights() [3/4]

template<>
void oomph::BDF< 4 >::set_predictor_weights ( )
virtual

Calculate the predictor weights.

Reimplemented from oomph::TimeStepper.

Definition at line 430 of file timesteppers.cc.

◆ set_predictor_weights() [4/4]

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::set_predictor_weights ( )
virtual

Function to set the predictor weights.

Reimplemented from oomph::TimeStepper.

◆ set_weights() [1/4]

template<>
void oomph::BDF< 1 >::set_weights ( )
virtual

Assign the values of the weights.

Implements oomph::TimeStepper.

Definition at line 84 of file timesteppers.cc.

References oomph::Time::dt(), oomph::TimeStepper::Time_pt, and oomph::TimeStepper::Weight.

◆ set_weights() [2/4]

template<>
void oomph::BDF< 2 >::set_weights ( )
virtual

Assign the values of the weights. The scheme used is from Gresho & Sani, Incompressible Flow and the Finite Element Method (advection-diffusion and isothermal laminar flow), 1998, pg. 715 (with some algebraic rearrangement).

Implements oomph::TimeStepper.

Definition at line 234 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::Time::dt(), oomph::TimeStepper::Time_pt, and oomph::TimeStepper::Weight.

◆ set_weights() [3/4]

template<>
void oomph::BDF< 4 >::set_weights ( )
virtual

Assign the values of the weights; pass the value of the timestep.

Implements oomph::TimeStepper.

Definition at line 402 of file timesteppers.cc.

References oomph::Time::dt(), i, oomph::Time::ndt(), oomph::TimeStepper::Time_pt, and oomph::TimeStepper::Weight.

◆ set_weights() [4/4]

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::set_weights ( )
virtual

Set the weights.

Implements oomph::TimeStepper.

◆ shift_time_positions()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::shift_time_positions ( Node *const &  node_pt)
inlinevirtual

This function advances the time history of the positions at a node.

Implements oomph::TimeStepper.

Definition at line 1354 of file timesteppers.h.

References i, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::Node::position_is_a_copy(), t, and oomph::Node::x_gen().

◆ shift_time_values()

template<unsigned NSTEPS>
void oomph::BDF< NSTEPS >::shift_time_values ( Data *const &  data_pt)
inlinevirtual

This function updates the Data's time history so that we can advance to the next timestep. For BDF schemes, we simply push the values backwards...

Implements oomph::TimeStepper.

Definition at line 1317 of file timesteppers.h.

References oomph::Data::is_a_copy(), oomph::Data::nvalue(), oomph::Data::set_value(), t, and oomph::Data::value().

◆ temporal_error_in_position() [1/4]

template<>
double oomph::BDF< 1 >::temporal_error_in_position ( Node *const &  node_pt,
const unsigned &  i 
)
virtual

Function to compute the error in position i at node.

Reimplemented from oomph::TimeStepper.

Definition at line 194 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::TimeStepper::Predictor_storage_index, and oomph::Node::x().

◆ temporal_error_in_position() [2/4]

template<>
double oomph::BDF< 2 >::temporal_error_in_position ( Node *const &  node_pt,
const unsigned &  i 
)
virtual

Function to compute the error in position i at node.

Reimplemented from oomph::TimeStepper.

Definition at line 363 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::TimeStepper::Predictor_storage_index, and oomph::Node::x().

◆ temporal_error_in_position() [3/4]

template<>
double oomph::BDF< 4 >::temporal_error_in_position ( Node *const &  node_pt,
const unsigned &  i 
)
virtual

Function to compute the error in position i at node.

Reimplemented from oomph::TimeStepper.

Definition at line 477 of file timesteppers.cc.

◆ temporal_error_in_position() [4/4]

template<unsigned NSTEPS>
double oomph::BDF< NSTEPS >::temporal_error_in_position ( Node *const &  node_pt,
const unsigned &  i 
)
virtual

Compute the error in the position i at a node.

Reimplemented from oomph::TimeStepper.

◆ temporal_error_in_value() [1/4]

template<>
double oomph::BDF< 1 >::temporal_error_in_value ( Data *const &  data_pt,
const unsigned &  i 
)
virtual

Function to calculate the error in the data value i.

Reimplemented from oomph::TimeStepper.

Definition at line 213 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::TimeStepper::Predictor_storage_index, and oomph::Data::value().

◆ temporal_error_in_value() [2/4]

template<>
double oomph::BDF< 2 >::temporal_error_in_value ( Data *const &  data_pt,
const unsigned &  i 
)
virtual

Function to calculate the error in the data value i.

Reimplemented from oomph::TimeStepper.

Definition at line 383 of file timesteppers.cc.

References oomph::TimeStepper::adaptive_flag(), oomph::TimeStepper::Predictor_storage_index, and oomph::Data::value().

◆ temporal_error_in_value() [3/4]

template<>
double oomph::BDF< 4 >::temporal_error_in_value ( Data *const &  data_pt,
const unsigned &  i 
)
virtual

Function to calculate the error in the data value i.

Reimplemented from oomph::TimeStepper.

Definition at line 491 of file timesteppers.cc.

◆ temporal_error_in_value() [4/4]

template<unsigned NSTEPS>
double oomph::BDF< NSTEPS >::temporal_error_in_value ( Data *const &  data_pt,
const unsigned &  i 
)
virtual

Compute the error in the value i in a Data structure.

Reimplemented from oomph::TimeStepper.

Member Data Documentation

◆ Error_weight

template<unsigned NSTEPS>
double oomph::BDF< NSTEPS >::Error_weight
private

Private data for the error weight.

Definition at line 1167 of file timesteppers.h.

◆ Predictor_weight

template<unsigned NSTEPS>
Vector<double> oomph::BDF< NSTEPS >::Predictor_weight
private

Private data for the predictor weights.

Definition at line 1164 of file timesteppers.h.


The documentation for this class was generated from the following file: