oomph::BDF< NSTEPS > Class Template Reference

#include <timesteppers.h>

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

Public Types

typedef double(* InitialConditionFctPt) (const double &t)
 

Public Member Functions

 BDF (const bool &adaptive=false)
 Constructor for the case when we allow adaptive timestepping. More...
 
 BDF (const BDF &)=delete
 Broken copy constructor. More...
 
void operator= (const BDF &)=delete
 Broken assignment operator. More...
 
unsigned order () const
 Return the actual order of the scheme. More...
 
void assign_initial_values_impulsive (Data *const &data_pt)
 
void assign_initial_positions_impulsive (Node *const &node_pt)
 
void assign_initial_data_values (Data *const &data_pt, Vector< InitialConditionFctPt > initial_value_fct)
 
void shift_time_values (Data *const &data_pt)
 
void shift_time_positions (Node *const &node_pt)
 
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...
 
void set_weights ()
 Assign the values of the weights. More...
 
void set_predictor_weights ()
 Set the predictor weights (Gresho and Sani pg. 270) More...
 
void calculate_predicted_values (Data *const &data_pt)
 
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
void set_error_weights ()
 Set the error weights (Gresho and Sani pg. 270) More...
 
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Function to calculate the error in the data value i. More...
 
void set_weights ()
 
void set_predictor_weights ()
 
void calculate_predicted_values (Data *const &data_pt)
 
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
void set_error_weights ()
 Function that sets the error weights. More...
 
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 Function to calculate the error in the data value i. More...
 
void set_weights ()
 Assign the values of the weights; pass the value of the timestep. More...
 
void set_predictor_weights ()
 Calculate the predictor weights. More...
 
void calculate_predicted_values (Data *const &data_pt)
 
void calculate_predicted_positions (Node *const &node_pt)
 Calculate predictions for the positions. More...
 
void set_error_weights ()
 Function that sets the error weights. More...
 
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 Function to compute the error in position i at node. More...
 
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)
 
 TimeStepper ()
 Broken empty constructor. More...
 
 TimeStepper (const TimeStepper &)=delete
 Broken copy constructor. More...
 
void operator= (const TimeStepper &)=delete
 Broken assignment operator. More...
 
virtual ~TimeStepper ()
 virtual destructor More...
 
unsigned highest_derivative () const
 Highest order derivative that the scheme can compute. More...
 
doubletime ()
 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
 
void make_steady ()
 
bool is_steady () const
 
bool predict_by_explicit_step () const
 
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
 
void enable_warning_in_assign_initial_data_values ()
 
void disable_warning_in_assign_initial_data_values ()
 
const DenseMatrix< double > * weights_pt () const
 Get a (const) pointer to the weights. More...
 
virtual void undo_make_steady ()
 
std::string type () const
 
void time_derivative (const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
 
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)
 
double time_derivative (const unsigned &i, Node *const &node_pt, const unsigned &j)
 
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
 
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< doublePredictor_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< doubleWeight
 Storage for the weights associated with the timestepper. More...
 
std::string Type
 
bool Adaptive_Flag
 
bool Is_steady
 
bool Shut_up_in_assign_initial_data_values
 
bool Predict_by_explicit_step
 
ExplicitTimeStepperExplicit_predictor_pt
 
double Predicted_time
 
int Predictor_storage_index
 

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.

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.

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.

1193  : TimeStepper(NSTEPS + 1, 1)
1194  {
1195  Type = "BDF";
1196 
1197  // If it's adaptive, we need to allocate additional space to
1198  // carry along a prediction and an acceleration
1199  if (adaptive)
1200  {
1201  // Set the adaptive flag to be true
1202  Adaptive_Flag = true;
1203 
1204  // Set the size of the Predictor_Weights Vector N.B. The size is
1205  // correct for BDF1 and 2, but may be wrong for others.
1206  Predictor_weight.resize(NSTEPS + 2);
1207 
1208  // Resize the weights to the appropriate size
1209  Weight.resize(2, NSTEPS + 3, 0.0);
1210 
1211  // Storing predicted values in slot after other information
1212  Predictor_storage_index = NSTEPS + 2;
1213  }
1214 
1215  // Set the weight for the zero-th derivative
1216  Weight(0, 0) = 1.0;
1217  }
Vector< double > Predictor_weight
Private data for the predictor weights.
Definition: timesteppers.h:1186
void resize(const unsigned long &n)
Definition: matrices.h:498
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
Definition: timesteppers.h:237
std::string Type
Definition: timesteppers.h:241
TimeStepper()
Broken empty constructor.
Definition: timesteppers.h:301
int Predictor_storage_index
Definition: timesteppers.h:273
bool Adaptive_Flag
Definition: timesteppers.h:245
int adaptive
Definition: jeffery_hamel.cc:106

References Global_Physical_Variables::adaptive, and ProblemParameters::Weight.

◆ BDF() [2/2]

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

Broken copy constructor.

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.

1309  {
1310  // The time history stores the previous function values
1311  unsigned n_time_value = ntstorage();
1312 
1313  // Find number of values stored
1314  unsigned n_value = data_pt->nvalue();
1315 
1316  // Loop over current and stored timesteps
1317  for (unsigned t = 0; t < n_time_value; t++)
1318  {
1319  // Get corresponding continous time
1320  double time_local = Time_pt->time(t);
1321 
1322  // Loop over values
1323  for (unsigned j = 0; j < n_value; j++)
1324  {
1325  data_pt->set_value(t, j, initial_value_fct[j](time_local));
1326  }
1327  }
1328  }
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234
unsigned ntstorage() const
Definition: timesteppers.h:601
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123
t
Definition: plotPSD.py:36
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References j, oomph::Data::nvalue(), oomph::Data::set_value(), plotPSD::t, and Flag_definition::Time_pt.

◆ 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.

1264  {
1265  // Find the dimension of the node
1266  unsigned n_dim = node_pt->ndim();
1267  // Find the number of position types at the node
1268  unsigned n_position_type = node_pt->nposition_type();
1269 
1270  // Loop over the position variables
1271  for (unsigned i = 0; i < n_dim; i++)
1272  {
1273  // If the position is not copied
1274  // We copy entire coordinates at once
1275  if (node_pt->position_is_a_copy(i) == false)
1276  {
1277  // Loop over the position types
1278  for (unsigned k = 0; k < n_position_type; k++)
1279  {
1280  // Set previous values to the initial value, if not a copy
1281  for (unsigned t = 1; t <= NSTEPS; t++)
1282  {
1283  node_pt->x_gen(t, k, i) = node_pt->x_gen(k, i);
1284  }
1285 
1286  // If it's adaptive
1287  if (adaptive_flag())
1288  {
1289  // Initial mesh velocity is zero
1290  node_pt->x_gen(NSTEPS + 1, k, i) = 0.0;
1291  // Initial prediction is the value
1292  node_pt->x_gen(NSTEPS + 2, k, i) = node_pt->x_gen(k, i);
1293  }
1294  }
1295  }
1296  }
1297  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
bool adaptive_flag() const
Function to indicate whether the scheme is adaptive (false by default)
Definition: timesteppers.h:623
char char char int int * k
Definition: level2_impl.h:374

References i, k, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::Node::position_is_a_copy(), plotPSD::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.

1235  {
1236  // Find number of values stored
1237  unsigned n_value = data_pt->nvalue();
1238  // Loop over values
1239  for (unsigned j = 0; j < n_value; j++)
1240  {
1241  // Set previous values to the initial value, if not a copy
1242  if (data_pt->is_a_copy(j) == false)
1243  {
1244  for (unsigned t = 1; t <= NSTEPS; t++)
1245  {
1246  data_pt->set_value(t, j, data_pt->value(j));
1247  }
1248 
1249  // If it's adaptive
1250  if (adaptive_flag())
1251  {
1252  // Initial velocity is zero
1253  data_pt->set_value(NSTEPS + 1, j, 0.0);
1254  // Initial prediction is the value
1255  data_pt->set_value(NSTEPS + 2, j, data_pt->value(j));
1256  }
1257  }
1258  }
1259  }

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

◆ calculate_predicted_positions() [1/4]

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

Calculate predictions for the positions.

Reimplemented from oomph::TimeStepper.

149  {
150  // Only do this if adaptive
151  if (adaptive_flag())
152  {
153  // Find number of dimensions of the problem
154  unsigned n_dim = node_pt->ndim();
155  // Loop over the dimensions
156  for (unsigned j = 0; j < n_dim; j++)
157  {
158  // If the node is not copied
159  if (node_pt->position_is_a_copy(j) == false)
160  {
161  // Initialise the predictor to zero
162  double predicted_value = 0.0;
163  // Now loop over all the stored data and add appropriate values
164  // to the predictor
165  for (unsigned i = 1; i < 3; i++)
166  {
167  predicted_value += node_pt->x(i, j) * Predictor_weight[i];
168  }
169  // Store the predicted value
170  node_pt->x(Predictor_storage_index, j) = predicted_value;
171  }
172  }
173  }
174  }

References i, j, oomph::Node::ndim(), oomph::Node::position_is_a_copy(), and oomph::Node::x().

◆ calculate_predicted_positions() [2/4]

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

Calculate predictions for the positions.

Reimplemented from oomph::TimeStepper.

311  {
312  // Only do this if adaptive
313  if (adaptive_flag())
314  {
315  // Find number of dimensions of the problem
316  unsigned n_dim = node_pt->ndim();
317  // Loop over the dimensions
318  for (unsigned j = 0; j < n_dim; j++)
319  {
320  // If the node is not copied
321  if (node_pt->position_is_a_copy(j) == false)
322  {
323  // Initialise the predictor to zero
324  double predicted_value = 0.0;
325  // Now loop over all the stored data and add appropriate values
326  // to the predictor
327  for (unsigned i = 1; i < 4; i++)
328  {
329  predicted_value += node_pt->x(i, j) * Predictor_weight[i];
330  }
331  // Store the predicted value
332  node_pt->x(Predictor_storage_index, j) = predicted_value;
333  }
334  }
335  }
336  }

References i, j, oomph::Node::ndim(), oomph::Node::position_is_a_copy(), and oomph::Node::x().

◆ calculate_predicted_positions() [3/4]

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

Calculate predictions for the positions.

Reimplemented from oomph::TimeStepper.

454  {
455  throw OomphLibError(
456  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
457  }
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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]

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.

116  {
117  // If it's adaptive calculate the values
118  if (adaptive_flag())
119  {
120  // Find number of values
121  unsigned n_value = data_pt->nvalue();
122  // Loop over the values
123  for (unsigned j = 0; j < n_value; j++)
124  {
125  // If the value is not copied
126  if (data_pt->is_a_copy(j) == false)
127  {
128  // Now Initialise the predictor to zero
129  double predicted_value = 0.0;
130  // Now loop over all the stored data and add appropriate values
131  // to the predictor
132  for (unsigned i = 1; i < 3; i++)
133  {
134  predicted_value += data_pt->value(i, j) * Predictor_weight[i];
135  }
136  // Store the predicted value
137  data_pt->set_value(Predictor_storage_index, j, predicted_value);
138  }
139  }
140  }
141  }

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

◆ calculate_predicted_values() [2/4]

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.

278  {
279  // If it's adaptive calculate the values
280  if (adaptive_flag())
281  {
282  // Find number of values
283  unsigned n_value = data_pt->nvalue();
284  // Loop over the values
285  for (unsigned j = 0; j < n_value; j++)
286  {
287  // If the value is not copied
288  if (data_pt->is_a_copy(j) == false)
289  {
290  // Now Initialise the predictor to zero
291  double predicted_value = 0.0;
292  // Now loop over all the stored data and add appropriate values
293  // to the predictor
294  for (unsigned i = 1; i < 4; i++)
295  {
296  predicted_value += data_pt->value(i, j) * Predictor_weight[i];
297  }
298  // Store the predicted value
299  // Note that predictor is stored as the FIFTH entry in this scheme
300  data_pt->set_value(Predictor_storage_index, j, predicted_value);
301  }
302  }
303  }
304  }

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

◆ calculate_predicted_values() [3/4]

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.

446  {
447  throw OomphLibError(
448  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
449  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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.

1441  {
1442  return NSTEPS;
1443  }

◆ nprev_values()

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

Number of previous values available.

Implements oomph::TimeStepper.

1435  {
1436  return NSTEPS;
1437  }

◆ operator=()

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

Broken assignment operator.

◆ order()

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

Return the actual order of the scheme.

Reimplemented from oomph::TimeStepper.

1228  {
1229  return NSTEPS;
1230  }

◆ set_error_weights() [1/4]

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

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

Reimplemented from oomph::TimeStepper.

182  {
183  Error_weight = 0.5;
184  }
double Error_weight
Private data for the error weight.
Definition: timesteppers.h:1189

◆ set_error_weights() [2/4]

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

Function that sets the error weights.

Reimplemented from oomph::TimeStepper.

344  {
345  if (adaptive_flag())
346  {
347  double dt = Time_pt->dt(0);
348  double dtprev = Time_pt->dt(1);
349  // Calculate the error weight
350  Error_weight =
351  pow((1.0 + dtprev / dt), 2.0) /
352  (1.0 + 3.0 * (dtprev / dt) + 4.0 * pow((dtprev / dt), 2.0) +
353  2.0 * pow((dtprev / dt), 3.0));
354  }
355  }
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625

References Eigen::ArrayBase< Derived >::pow(), and Flag_definition::Time_pt.

◆ set_error_weights() [3/4]

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

Function that sets the error weights.

Reimplemented from oomph::TimeStepper.

462  {
463  throw OomphLibError(
464  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
465  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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]

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

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

Reimplemented from oomph::TimeStepper.

93  {
94  // If it's adaptive set the predictor weights
95  if (adaptive_flag())
96  {
97  double dt = Time_pt->dt(0);
98 
99  // Set the predictor weights
100  Predictor_weight[0] = 0.0;
101  Predictor_weight[1] = 1.0;
102 
103  // Velocity weight
104  Predictor_weight[2] = dt;
105  }
106  }

References oomph::Time::dt(), and Flag_definition::Time_pt.

◆ set_predictor_weights() [2/4]

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.

254  {
255  // If it's adaptive set the predictor weights
256  if (adaptive_flag())
257  {
258  // Read the value of the previous timesteps
259  double dt = Time_pt->dt(0);
260  double dtprev = Time_pt->dt(1);
261 
262  // Set the predictor weights
263  Predictor_weight[0] = 0.0;
264  Predictor_weight[1] = 1.0 - (dt * dt) / (dtprev * dtprev);
265  Predictor_weight[2] = (dt * dt) / (dtprev * dtprev);
266  // Acceleration term
267  Predictor_weight[3] = (1.0 + dt / dtprev) * dt;
268  }
269  }

References Flag_definition::Time_pt.

◆ set_predictor_weights() [3/4]

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

Calculate the predictor weights.

Reimplemented from oomph::TimeStepper.

430  {
431  // Read the value of the previous timesteps
432  // double dt=Time_pt->dt(0);
433  // double dtprev=Time_pt->dt(1);
434 
435  throw OomphLibError(
436  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
437  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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]

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

Assign the values of the weights.

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

Implements oomph::TimeStepper.

81  {
82  double dt = Time_pt->dt(0);
83  Weight(1, 0) = 1.0 / dt;
84  Weight(1, 1) = -1.0 / dt;
85  }

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

◆ set_weights() [2/4]

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.

233  {
234  double dt = Time_pt->dt(0);
235  double dtprev = Time_pt->dt(1);
236  Weight(1, 0) = 1.0 / dt + 1.0 / (dt + dtprev);
237  Weight(1, 1) = -(dt + dtprev) / (dt * dtprev);
238  Weight(1, 2) = dt / ((dt + dtprev) * dtprev);
239 
240  if (adaptive_flag())
241  {
242  Weight(1, 3) = 0.0;
243  Weight(1, 4) = 0.0;
244  }
245  }

References Flag_definition::Time_pt, and ProblemParameters::Weight.

◆ set_weights() [3/4]

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

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

Implements oomph::TimeStepper.

403  {
404 #ifdef PARANOID
405  double dt0 = Time_pt->dt(0);
406  for (unsigned i = 0; i < Time_pt->ndt(); i++)
407  {
408  if (dt0 != Time_pt->dt(i))
409  {
410  throw OomphLibError("BDF4 currently only works for fixed timesteps \n",
413  }
414  }
415 #endif
416  double dt = Time_pt->dt(0);
417  Weight(1, 0) = 25.0 / 12.0 / dt;
418  Weight(1, 1) = -48.0 / 12.0 / dt;
419  Weight(1, 2) = 36.0 / 12.0 / dt;
420  Weight(1, 3) = -16.0 / 12.0 / dt;
421  Weight(1, 4) = 3.0 / 12.0 / dt;
422  }
unsigned ndt() const
Return the number of timesteps stored.
Definition: timesteppers.h:129

References i, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Flag_definition::Time_pt, and ProblemParameters::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.

1374  {
1375  // Find the number of coordinates
1376  unsigned n_dim = node_pt->ndim();
1377  // Find the number of position types
1378  unsigned n_position_type = node_pt->nposition_type();
1379 
1380  // Find number of stored timesteps
1381  unsigned n_tstorage = ntstorage();
1382 
1383  // Storage for the velocity
1384  double velocity[n_position_type][n_dim];
1385 
1386  // If adaptive, find the velocities
1387  if (adaptive_flag())
1388  {
1389  // Loop over the variables
1390  for (unsigned i = 0; i < n_dim; i++)
1391  {
1392  for (unsigned k = 0; k < n_position_type; k++)
1393  {
1394  // Initialise velocity to zero
1395  velocity[k][i] = 0.0;
1396  // Loop over all history data
1397  for (unsigned t = 0; t < n_tstorage; t++)
1398  {
1399  velocity[k][i] += Weight(1, t) * node_pt->x_gen(t, k, i);
1400  }
1401  }
1402  }
1403  }
1404 
1405  // Loop over the positions
1406  for (unsigned i = 0; i < n_dim; i++)
1407  {
1408  // If the position is not a copy
1409  if (node_pt->position_is_a_copy(i) == false)
1410  {
1411  // Loop over the position types
1412  for (unsigned k = 0; k < n_position_type; k++)
1413  {
1414  // Loop over stored times, and set values to previous values
1415  for (unsigned t = NSTEPS; t > 0; t--)
1416  {
1417  node_pt->x_gen(t, k, i) = node_pt->x_gen(t - 1, k, i);
1418  }
1419 
1420  // If we are using the adaptive scheme, set the velocity
1421  if (adaptive_flag())
1422  {
1423  node_pt->x_gen(NSTEPS + 1, k, i) = velocity[k][i];
1424  }
1425  }
1426  }
1427  }
1428  }
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107

References i, k, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::Node::position_is_a_copy(), plotPSD::t, Jeffery_Solution::velocity(), ProblemParameters::Weight, 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.

1334  {
1335  // Find number of values stored
1336  unsigned n_value = data_pt->nvalue();
1337  // Storage for velocity need to be here to be in scope
1338  Vector<double> velocity(n_value);
1339 
1340  // Find the number of history values that are stored
1341  const unsigned nt_value = nprev_values();
1342 
1343  // If adaptive, find the velocities
1344  if (adaptive_flag())
1345  {
1346  time_derivative(1, data_pt, velocity);
1347  }
1348 
1349  // Loop over the values
1350  for (unsigned j = 0; j < n_value; j++)
1351  {
1352  // Set previous values to the previous value, if not a copy
1353  if (data_pt->is_a_copy(j) == false)
1354  {
1355  // Loop over times, in reverse order
1356  for (unsigned t = nt_value; t > 0; t--)
1357  {
1358  data_pt->set_value(t, j, data_pt->value(t - 1, j));
1359  }
1360 
1361  // If we are using the adaptive scheme
1362  if (adaptive_flag())
1363  {
1364  // Set the velocity
1365  data_pt->set_value(nt_value + 1, j, velocity[j]);
1366  }
1367  }
1368  }
1369  }
unsigned nprev_values() const
Number of previous values available.
Definition: timesteppers.h:1434
void time_derivative(const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
Definition: timesteppers.h:502

References oomph::Data::is_a_copy(), j, oomph::Data::nvalue(), oomph::Data::set_value(), plotPSD::t, oomph::Data::value(), and Jeffery_Solution::velocity().

◆ temporal_error_in_position() [1/4]

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.

192  {
193  if (adaptive_flag())
194  {
195  // Just return the error
196  return Error_weight *
197  (node_pt->x(i) - node_pt->x(Predictor_storage_index, i));
198  }
199  else
200  {
201  return 0.0;
202  }
203  }

References i, and oomph::Node::x().

◆ temporal_error_in_position() [2/4]

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.

364  {
365  if (adaptive_flag())
366  {
367  // Just return the error
368  return Error_weight *
369  (node_pt->x(i) - node_pt->x(Predictor_storage_index, i));
370  }
371  else
372  {
373  return 0.0;
374  }
375  }

References i, and oomph::Node::x().

◆ temporal_error_in_position() [3/4]

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.

473  {
474  throw OomphLibError(
475  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
476  return 0.0;
477  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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]

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.

212  {
213  if (adaptive_flag())
214  {
215  // Just return the error
216  return Error_weight *
217  (data_pt->value(i) - data_pt->value(Predictor_storage_index, i));
218  }
219  else
220  {
221  return 0.0;
222  }
223  }

References i, and oomph::Data::value().

◆ temporal_error_in_value() [2/4]

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.

384  {
385  if (adaptive_flag())
386  {
387  // Just return the error
388  return Error_weight *
389  (data_pt->value(i) - data_pt->value(Predictor_storage_index, i));
390  }
391  else
392  {
393  return 0.0;
394  }
395  }

References i, and oomph::Data::value().

◆ temporal_error_in_value() [3/4]

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.

486  {
487  throw OomphLibError(
488  "Not implemented yet", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
489  return 0.0;
490  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ 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.

◆ Predictor_weight

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

Private data for the predictor weights.


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