oomph::SelfStartingBDF2 Class Reference

Self-starting BDF2 timestepper class. More...

#include <self_starting_BDF2_timestepper.h>

+ Inheritance diagram for oomph::SelfStartingBDF2:

Public Types

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

Public Member Functions

 SelfStartingBDF2 (const bool &adaptive=false)
 
 SelfStartingBDF2 (const SelfStartingBDF2 &)
 Broken copy constructor. More...
 
void operator= (const SelfStartingBDF2 &)
 Broken assignment operator. More...
 
unsigned order () const
 Return the actual order of the scheme. More...
 
void turn_on_bdf1_mode ()
 
bool bdf1_mode ()
 Flag to indicate if the timestepper is working in BDF1 mode. More...
 
void turn_off_bdf1_mode ()
 
void undo_make_steady ()
 
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 ()
 
void set_weights_bdf1 ()
 Set the weights to those corresponding to BDF1. More...
 
void set_weights_bdf2 ()
 Set the weights to those corresponding to BDF2. 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_bdf1 ()
 Function to set the predictor weights corresponding to BDF1. More...
 
void set_predictor_weights_bdf2 ()
 Function to set the predictor weights corresponding to BDF2. More...
 
void calculate_predicted_positions_bdf1 (Node *const &node_pt)
 Function to calculate predicted positions at a node (BDF1) More...
 
void calculate_predicted_positions_bdf2 (Node *const &node_pt)
 Function to calculate predicted positions at a node (BDF2) More...
 
void calculate_predicted_values_bdf1 (Data *const &data_pt)
 Function to calculate predicted data values in a Data object (BDF1) More...
 
void calculate_predicted_values_bdf2 (Data *const &data_pt)
 Function to calculate predicted data values in a Data object (BDF2) More...
 
void set_error_weights_bdf1 ()
 Function to set the error weights corresponding to BDF1. More...
 
void set_error_weights_bdf2 ()
 Function to set the error weights corresponding to BDF2. More...
 
double temporal_error_in_position_bdf1 (Node *const &node_pt, const unsigned &i)
 Compute the error in the position i at a node (BDF1) More...
 
double temporal_error_in_position_bdf2 (Node *const &node_pt, const unsigned &i)
 Compute the error in the position i at a node (BDF2) More...
 
double temporal_error_in_value_bdf1 (Data *const &data_pt, const unsigned &i)
 Compute the error in the value i in a Data structure (BDF1) More...
 
double temporal_error_in_value_bdf2 (Data *const &data_pt, const unsigned &i)
 Compute the error in the value i in a Data structure (BDF2) 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...
 
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 set_predictor_weights ()
 
virtual void calculate_predicted_values (Data *const &data_pt)
 
virtual void calculate_predicted_positions (Node *const &node_pt)
 
virtual void set_error_weights ()
 
virtual double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 
virtual double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 
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...
 
bool BDF1_mode
 

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

Self-starting BDF2 timestepper class.

Member Typedef Documentation

◆ InitialConditionFctPt

typedef double(* oomph::SelfStartingBDF2::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

◆ SelfStartingBDF2() [1/2]

oomph::SelfStartingBDF2::SelfStartingBDF2 ( const bool adaptive = false)
inline

Constructor for the case when we allow adaptive timestepping. Set BDF1_mode flag to false (default is BDF2 mode)

57  : TimeStepper(3,1), BDF1_mode(false)
58  {
59  Type="BDF";
60 
61  // If it's adaptive, we need to allocate additional space to
62  // carry along a prediction and an acceleration
63  if(adaptive)
64  {
65  // Set the adaptive flag to be true
66  Adaptive_Flag = true;
67 
68  // Set the size of the Predictor_Weights Vector
69  // N.B. The size is correct for BDF<2>, but may be wrong for others
70  Predictor_weight.resize(4);
71 
72  // The order of the scheme is 1, i.e. Weights has two entries
73 
74  //Resize the weights to the appropriate size
75  Weight.resize(2,5);
76 
77  // Initialise
78  for(unsigned i=0;i<2;i++)
79  {
80  // Initialise each weight to zero
81  for(unsigned j=0;j<5;j++)
82  {
83  Weight(i,j) = 0.0;
84  }
85  }
86  // Set the weight for the zero-th derivative
87  Weight(0,0) = 1.0;
88  }
89  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
void resize(const unsigned long &n)
Definition: matrices.h:498
bool BDF1_mode
Definition: self_starting_BDF2_timestepper.h:51
Vector< double > Predictor_weight
Private data for the predictor weights.
Definition: self_starting_BDF2_timestepper.h:41
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
bool Adaptive_Flag
Definition: timesteppers.h:245
int adaptive
Definition: jeffery_hamel.cc:106
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Global_Physical_Variables::adaptive, oomph::TimeStepper::Adaptive_Flag, i, j, Predictor_weight, oomph::DenseMatrix< T >::resize(), oomph::TimeStepper::Type, and oomph::TimeStepper::Weight.

◆ SelfStartingBDF2() [2/2]

oomph::SelfStartingBDF2::SelfStartingBDF2 ( const SelfStartingBDF2 )
inline

Broken copy constructor.

93  {
94  BrokenCopy::broken_copy("SelfStartingBDF2");
95  }
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212

References oomph::BrokenCopy::broken_copy().

Member Function Documentation

◆ assign_initial_data_values()

void oomph::SelfStartingBDF2::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.

231  {
232  // The time history stores the previous function values
233  const unsigned n_time_value = ntstorage();
234 
235  // Find number of values stored
236  const unsigned n_value = data_pt->nvalue();
237 
238  // Loop over current and stored timesteps
239  for(unsigned t=0;t<n_time_value;t++)
240  {
241  // Get corresponding continous time
242  double time = Time_pt->time(t);
243 
244  // Loop over values
245  for(unsigned j=0;j<n_value;j++)
246  {
247  data_pt->set_value(t,j,initial_value_fct[j](time));
248  }
249  }
250  }
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234
unsigned ntstorage() const
Definition: timesteppers.h:601
double & time()
Return current value of continous time.
Definition: timesteppers.h:332
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123
t
Definition: plotPSD.py:36

References j, oomph::TimeStepper::ntstorage(), oomph::Data::nvalue(), oomph::Data::set_value(), plotPSD::t, oomph::Time::time(), oomph::TimeStepper::time(), and oomph::TimeStepper::Time_pt.

◆ assign_initial_positions_impulsive()

void oomph::SelfStartingBDF2::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.

185  {
186  // Find the dimension of the node
187  const unsigned n_dim = node_pt->ndim();
188  // Find the number of position types at the node
189  const unsigned n_position_type = node_pt->nposition_type();
190 
191  // Loop over the position variables
192  for(unsigned i=0;i<n_dim;i++)
193  {
194  // If the position is not copied
195  // We copy entire coordinates at once
196  if(node_pt->position_is_a_copy(i) == false)
197  {
198  // Loop over the position types
199  for(unsigned k=0;k<n_position_type;k++)
200  {
201  // Set previous values to the initial value, if not a copy
202  for(unsigned t=1;t<=2;t++)
203  {
204  node_pt->x_gen(t,k,i) = node_pt->x_gen(k,i);
205  }
206 
207  // If it's adaptive
208  if(adaptive_flag())
209  {
210  // Initial mesh velocity is zero
211  node_pt->x_gen(3,k,i) = 0.0;
212  // Initial prediction is the value
213  node_pt->x_gen(4,k,i) = node_pt->x_gen(k,i);
214  }
215  }
216  }
217  }
218  }
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 oomph::TimeStepper::adaptive_flag(), 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()

void oomph::SelfStartingBDF2::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.

154  {
155  // Find number of values stored
156  const unsigned n_value = data_pt->nvalue();
157 
158  // Loop over values
159  for(unsigned j=0;j<n_value;j++)
160  {
161  // Set previous values to the initial value, if not a copy
162  if(data_pt->is_a_copy(j) == false)
163  {
164  for(unsigned t=1;t<=2;t++)
165  {
166  data_pt->set_value(t,j,data_pt->value(j));
167  }
168 
169  // If it's adaptive
170  if(adaptive_flag())
171  {
172  // Initial velocity is zero
173  data_pt->set_value(3,j,0.0);
174  // Initial prediction is the value
175  data_pt->set_value(4,j,data_pt->value(j));
176  }
177  }
178  }
179  }

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

◆ bdf1_mode()

bool oomph::SelfStartingBDF2::bdf1_mode ( )
inline

Flag to indicate if the timestepper is working in BDF1 mode.

120 { return BDF1_mode; }

References BDF1_mode.

◆ calculate_predicted_positions_bdf1()

void oomph::SelfStartingBDF2::calculate_predicted_positions_bdf1 ( Node *const &  node_pt)

Function to calculate predicted positions at a node (BDF1)

Calculate predictions for the positions (BDF1)

469  {
470  throw OomphLibError("Not implemented yet",
471  "SelfStartingBDF2::calculate_predicted_positions_bdf1()",
473  }
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61

References OOMPH_EXCEPTION_LOCATION.

◆ calculate_predicted_positions_bdf2()

void oomph::SelfStartingBDF2::calculate_predicted_positions_bdf2 ( Node *const &  node_pt)

Function to calculate predicted positions at a node (BDF2)

Calculate predictions for the positions (BDF2)

594  {
595  //Only do this if adaptive
596  if(adaptive_flag())
597  {
598  //Find number of dimensions of the problem
599  unsigned n_dim = node_pt->ndim();
600  //Loop over the dimensions
601  for(unsigned j=0;j<n_dim;j++)
602  {
603  //If the node is not copied
604  if(node_pt->position_is_a_copy(j) == false)
605  {
606  //Initialise the predictor to zero
607  double predicted_value = 0.0;
608  //Now loop over all the stored data and add appropriate values
609  //to the predictor
610  for(unsigned i=1;i<4;i++)
611  {
612  predicted_value += node_pt->x(i,j)*Predictor_weight[i];
613  }
614  //Store the predicted value
615  //Note that predictor is stored as the FIFTH entry in this scheme
616  node_pt->x(4,j) = predicted_value;
617  }
618  }
619  }
620  }

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

◆ calculate_predicted_values_bdf1()

void oomph::SelfStartingBDF2::calculate_predicted_values_bdf1 ( Data *const &  data_pt)

Function to calculate predicted data values in a Data object (BDF1)

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

457  {
458  throw OomphLibError("Not implemented yet",
459  "SelfStartingBDF2::calculate_predicted_weights_bdf1()",
461  }

References OOMPH_EXCEPTION_LOCATION.

◆ calculate_predicted_values_bdf2()

void oomph::SelfStartingBDF2::calculate_predicted_values_bdf2 ( Data *const &  data_pt)

Function to calculate predicted data values in a Data object (BDF2)

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

561  {
562  //If it's adaptive calculate the values
563  if(adaptive_flag())
564  {
565  //Find number of values
566  unsigned n_value = data_pt->nvalue();
567  //Loop over the values
568  for(unsigned j=0;j<n_value;j++)
569  {
570  //If the value is not copied
571  if(data_pt->is_a_copy(j) == false)
572  {
573  //Now Initialise the predictor to zero
574  double predicted_value = 0.0;
575  //Now loop over all the stored data and add appropriate values
576  //to the predictor
577  for(unsigned i=1;i<4;i++)
578  {
579  predicted_value += data_pt->value(i,j)*Predictor_weight[i];
580  }
581  //Store the predicted value
582  //Note that predictor is stored as the FIFTH entry in this scheme
583  data_pt->set_value(4,j,predicted_value);
584  }
585  }
586  }
587  }

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

◆ ndt()

unsigned oomph::SelfStartingBDF2::ndt ( ) const
inlinevirtual

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

Implements oomph::TimeStepper.

365 { return 2; }

◆ nprev_values()

unsigned oomph::SelfStartingBDF2::nprev_values ( ) const
inlinevirtual

Number of previous values available.

Implements oomph::TimeStepper.

362 { return 2; }

◆ operator=()

void oomph::SelfStartingBDF2::operator= ( const SelfStartingBDF2 )
inline

Broken assignment operator.

99  {
100  BrokenCopy::broken_assign("SelfStartingBDF2");
101  }
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:195

References oomph::BrokenCopy::broken_assign().

◆ order()

unsigned oomph::SelfStartingBDF2::order ( ) const
inlinevirtual

Return the actual order of the scheme.

Reimplemented from oomph::TimeStepper.

104 { return 2; }

◆ set_error_weights_bdf1()

void oomph::SelfStartingBDF2::set_error_weights_bdf1 ( )

Function to set the error weights corresponding to BDF1.

Function that sets the error weights (BDF1)

480  {
481  throw OomphLibError("Not implemented yet",
482  "SelfStartingBDF2::set_error_weights_bdf1()",
484  }

References OOMPH_EXCEPTION_LOCATION.

◆ set_error_weights_bdf2()

void oomph::SelfStartingBDF2::set_error_weights_bdf2 ( )

Function to set the error weights corresponding to BDF2.

Function that sets the error weights (BDF2)

627  {
628  if(adaptive_flag())
629  {
630  double dt=Time_pt->dt(0);
631  double dtprev=Time_pt->dt(1);
632  //Calculate the error weight
633  Error_weight = pow((1.0 + dtprev/dt),2.0)/
634  (1.0 + 3.0*(dtprev/dt) + 4.0*pow((dtprev/dt),2.0) +
635  2.0*pow((dtprev/dt),3.0));
636  }
637  }
double Error_weight
Private data for the error weight.
Definition: self_starting_BDF2_timestepper.h:44
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 oomph::TimeStepper::adaptive_flag(), oomph::Time::dt(), Error_weight, Eigen::bfloat16_impl::pow(), and oomph::TimeStepper::Time_pt.

◆ set_predictor_weights_bdf1()

void oomph::SelfStartingBDF2::set_predictor_weights_bdf1 ( )

Function to set the predictor weights corresponding to BDF1.

Calculate the predictor weights (BDF1)

440  {
441  //Read the value of the previous timesteps
442  //double dt=Time_pt->dt(0);
443  //double dtprev=Time_pt->dt(1);
444 
445  throw OomphLibError("Not implemented yet",
446  "SelfStartingBDF2::set_predictor_weights_bdf1()",
448  }

References OOMPH_EXCEPTION_LOCATION.

◆ set_predictor_weights_bdf2()

void oomph::SelfStartingBDF2::set_predictor_weights_bdf2 ( )

Function to set the predictor weights corresponding to BDF2.

Calculate the predictor weights (BDF2)

538  {
539  //If it's adaptive set the predictor weights
540  if(adaptive_flag())
541  {
542  //Read the value of the previous timesteps
543  double dt=Time_pt->dt(0);
544  double dtprev=Time_pt->dt(1);
545 
546  //Set the predictor weights
547  Predictor_weight[0] = 0.0;
548  Predictor_weight[1] = 1.0 - (dt*dt)/(dtprev*dtprev);
549  Predictor_weight[2] = (dt*dt)/(dtprev*dtprev);
550  //Acceleration term
551  Predictor_weight[3] = (1.0 + dt/dtprev)*dt;
552  }
553  }

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

◆ set_weights()

void oomph::SelfStartingBDF2::set_weights ( )
inlinevirtual

Implementation of pure virtual function in base class. Set weights corresponding to either a BDF1 scheme or a BDF2 scheme, depending on the flag.

Implements oomph::TimeStepper.

350  {
351  if(BDF1_mode) { set_weights_bdf1(); }
352  else { set_weights_bdf2(); }
353  }
void set_weights_bdf1()
Set the weights to those corresponding to BDF1.
Definition: self_starting_BDF2_timestepper.h:423
void set_weights_bdf2()
Set the weights to those corresponding to BDF2.
Definition: self_starting_BDF2_timestepper.h:519

References BDF1_mode, set_weights_bdf1(), and set_weights_bdf2().

◆ set_weights_bdf1()

void oomph::SelfStartingBDF2::set_weights_bdf1 ( )

Set the weights to those corresponding to BDF1.

Assign the values of the weights (BDF1)

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

424  {
425  // Set BDF1 weights as normal
426  double dt=Time_pt->dt(0);
427  Weight(1,0) = 1.0/dt;
428  Weight(1,1) = -1.0/dt;
429 
430  // Set weight associated with history value 2 to zero so that it has
431  // no effect on the dudt calculation
432  Weight(1,2) = 0.0;
433  }

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

Referenced by set_weights(), turn_on_bdf1_mode(), and undo_make_steady().

◆ set_weights_bdf2()

void oomph::SelfStartingBDF2::set_weights_bdf2 ( )

Set the weights to those corresponding to BDF2.

Assign the values of the weights; pass the value of the timestep (BDF2)

520  {
521  double dt=Time_pt->dt(0);
522  double dtprev=Time_pt->dt(1);
523  Weight(1,0) = 1.0/dt + 1.0/(dt + dtprev);
524  Weight(1,1) = -(dt + dtprev)/(dt*dtprev);
525  Weight(1,2) = dt/((dt+dtprev)*dtprev);
526 
527  if(adaptive_flag())
528  {
529  Weight(1,3) = 0.0;
530  Weight(1,4) = 0.0;
531  }
532  }

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

Referenced by set_weights(), turn_off_bdf1_mode(), and undo_make_steady().

◆ shift_time_positions()

void oomph::SelfStartingBDF2::shift_time_positions ( Node *const &  node_pt)
inlinevirtual

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

Implements oomph::TimeStepper.

290  {
291  // Find the number of coordinates
292  const unsigned n_dim = node_pt->ndim();
293  // Find the number of position types
294  const unsigned n_position_type = node_pt->nposition_type();
295 
296  // Find number of stored timesteps
297  const unsigned n_tstorage = ntstorage();
298 
299  // Storage for the velocity
300  double velocity[n_position_type][n_dim];
301 
302  // If adaptive, find the velocities
303  if(adaptive_flag())
304  {
305  // Loop over the variables
306  for(unsigned i=0;i<n_dim;i++)
307  {
308  for(unsigned k=0;k<n_position_type;k++)
309  {
310  // Initialise velocity to zero
311  velocity[k][i] =0.0;
312  // Loop over all history data
313  for(unsigned t=0;t<n_tstorage;t++)
314  {
315  velocity[k][i] += Weight(1,t)*node_pt->x_gen(t,k,i);
316  }
317  }
318  }
319  }
320 
321  // Loop over the positions
322  for(unsigned i=0;i<n_dim;i++)
323  {
324  // If the position is not a copy
325  if(node_pt->position_is_a_copy(i) == false)
326  {
327  // Loop over the position types
328  for(unsigned k=0;k<n_position_type;k++)
329  {
330  // Loop over stored times, and set values to previous values
331  for(unsigned t=2;t>0;t--)
332  {
333  node_pt->x_gen(t,k,i) = node_pt->x_gen(t-1,k,i);
334  }
335 
336  // If we are using the adaptive scheme, set the velocity
337  if(adaptive_flag())
338  {
339  node_pt->x_gen(3,k,i) = velocity[k][i];
340  }
341  }
342  }
343  }
344  }
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107

References oomph::TimeStepper::adaptive_flag(), i, k, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::TimeStepper::ntstorage(), oomph::Node::position_is_a_copy(), plotPSD::t, Jeffery_Solution::velocity(), oomph::TimeStepper::Weight, and oomph::Node::x_gen().

◆ shift_time_values()

void oomph::SelfStartingBDF2::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.

256  {
257  // Find number of values stored
258  const unsigned n_value = data_pt->nvalue();
259  // Storage for velocity need to be here to be in scope
260  Vector<double> velocity(n_value);
261 
262  // If adaptive, find the velocities
263  if(adaptive_flag()) { time_derivative(1,data_pt,velocity); }
264 
265  // Loop over the values
266  for(unsigned j=0;j<n_value;j++)
267  {
268  // Set previous values to the previous value, if not a copy
269  if(data_pt->is_a_copy(j) == false)
270  {
271  // Loop over times, in reverse order
272  for(unsigned t=2;t>0;t--)
273  {
274  data_pt->set_value(t,j,data_pt->value(t-1,j));
275  }
276 
277  // If we are using the adaptive scheme
278  if(adaptive_flag())
279  {
280  // Set the velocity
281  data_pt->set_value(3,j,velocity[j]);
282  }
283  }
284  }
285  }
void time_derivative(const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
Definition: timesteppers.h:502

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

◆ temporal_error_in_position_bdf1()

double oomph::SelfStartingBDF2::temporal_error_in_position_bdf1 ( Node *const &  node_pt,
const unsigned i 
)

Compute the error in the position i at a node (BDF1)

Function to compute the error in position i at node (BDF1)

491  {
492  throw OomphLibError("Not implemented yet",
493  "SelfStartingBDF2::temporal_error_in_position_bdf1()",
495  return 0.0;
496  }

References OOMPH_EXCEPTION_LOCATION.

◆ temporal_error_in_position_bdf2()

double oomph::SelfStartingBDF2::temporal_error_in_position_bdf2 ( Node *const &  node_pt,
const unsigned i 
)

Compute the error in the position i at a node (BDF2)

Function to compute the error in position i at node (BDF2)

645  {
646  if(adaptive_flag())
647  {
648  //Just return the error
649  return Error_weight*(node_pt->x(i) - node_pt->x(4,i));
650  }
651  else
652  {
653  return 0.0;
654  }
655  }

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

◆ temporal_error_in_value_bdf1()

double oomph::SelfStartingBDF2::temporal_error_in_value_bdf1 ( Data *const &  data_pt,
const unsigned i 
)

Compute the error in the value i in a Data structure (BDF1)

Function to calculate the error in the data value i (BDF1)

504  {
505  throw OomphLibError("Not implemented yet",
506  "SelfStartingBDF2::temporal_error_in_value_bdf1()",
508  return 0.0;
509  }

References OOMPH_EXCEPTION_LOCATION.

◆ temporal_error_in_value_bdf2()

double oomph::SelfStartingBDF2::temporal_error_in_value_bdf2 ( Data *const &  data_pt,
const unsigned i 
)

Compute the error in the value i in a Data structure (BDF2)

Function to calculate the error in the data value i (BDF2)

663  {
664  if(adaptive_flag())
665  {
666  //Just return the error
667  return Error_weight*(data_pt->value(i) - data_pt->value(4,i));
668  }
669  else
670  {
671  return 0.0;
672  }
673  }

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

◆ turn_off_bdf1_mode()

void oomph::SelfStartingBDF2::turn_off_bdf1_mode ( )
inline

Reset the timestepper to BDF2: Set the "BDF1_mode" flag to false and re-compute the weights

125  {
126  // Update flag
127  BDF1_mode = false;
128 
129  // Reset_weights
131  }

References BDF1_mode, and set_weights_bdf2().

◆ turn_on_bdf1_mode()

void oomph::SelfStartingBDF2::turn_on_bdf1_mode ( )
inline

Function to make the time stepper temporarily work as if it is BDF1. This is trivially achieved by resetting the weights to those of BDF1, before setting the weight corresponding to history value 2 to zero.

111  {
112  // Update flag
113  BDF1_mode = true;
114 
115  // Reset weights
117  }

References BDF1_mode, and set_weights_bdf1().

◆ undo_make_steady()

void oomph::SelfStartingBDF2::undo_make_steady ( )
inlinevirtual

Reset the is_steady status to its default (false) and re-compute the weights

Reimplemented from oomph::TimeStepper.

136  {
137  // Update flag
138  Is_steady = false;
139 
140  // Reset weights
141  if(BDF1_mode)
142  {
144  }
145  else
146  {
148  }
149  }
bool Is_steady
Definition: timesteppers.h:251

References BDF1_mode, oomph::TimeStepper::Is_steady, set_weights_bdf1(), and set_weights_bdf2().

Member Data Documentation

◆ BDF1_mode

bool oomph::SelfStartingBDF2::BDF1_mode
private

Bool to indicate if the timestepper is in ‘BDF1’ mode i.e. it behaves just as if it were a BDF1 timestepper. This status may be achieved temporarily by calling turn_on_bdf1_mode(). It's reset to the default BDF2 behaviour by calling turn_off_bdf1_mode().

Referenced by bdf1_mode(), set_weights(), turn_off_bdf1_mode(), turn_on_bdf1_mode(), and undo_make_steady().

◆ Error_weight

double oomph::SelfStartingBDF2::Error_weight
private

Private data for the error weight.

Referenced by set_error_weights_bdf2(), temporal_error_in_position_bdf2(), and temporal_error_in_value_bdf2().

◆ Predictor_weight

Vector<double> oomph::SelfStartingBDF2::Predictor_weight
private

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