oomph::IMRBase Class Referenceabstract

Implicit midpoint rule base class for the two implementations. More...

#include <implicit_midpoint_rule.h>

+ Inheritance diagram for oomph::IMRBase:

Public Member Functions

 IMRBase (const bool &adaptive=false)
 Constructor with initialisation. More...
 
virtual ~IMRBase ()
 Destructor. More...
 
virtual void set_weights ()=0
 Setup weights for time derivative calculations. More...
 
virtual unsigned nprev_values_for_value_at_evaluation_time () const =0
 
unsigned order () const
 Actual order (accuracy) of the scheme. More...
 
unsigned ndt () const
 Number of timestep increments that are required by the scheme. More...
 
unsigned nprev_values () const
 ??ds More...
 
void shift_time_values (Data *const &data_pt)
 
void shift_time_positions (Node *const &node_pt)
 
void set_error_weights ()
 
void set_predictor_weights ()
 
void assign_initial_values_impulsive (Data *const &data_pt)
 not implemented (??ds TODO) More...
 
void assign_initial_positions_impulsive (Node *const &node_pt)
 
void calculate_predicted_positions (Node *const &node_pt)
 
double temporal_error_in_position (Node *const &node_pt, const unsigned &i)
 
void calculate_predicted_values (Data *const &data_pt)
 
double temporal_error_in_value (Data *const &data_pt, const unsigned &i)
 
- 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...
 
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)
 

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

Implicit midpoint rule base class for the two implementations.

Constructor & Destructor Documentation

◆ IMRBase()

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

Constructor with initialisation.

48  : TimeStepper(2, 1) // initialise weights later
49  {
51  Is_steady = false;
52  Type = "Midpoint method";
54 
55  // If adaptive then we are storing predicted values in slot
56  // 4. Otherwise we aren't storing them so leave it as -1.
57  if (adaptive)
58  {
60  }
61 
62 
63  // Storage for weights needs to be 2x(2 + 0/2) (the +2 is extra history
64  // for ebdf3 predictor if adaptive). This means we provide ways to
65  // calculate the zeroth and first derivatives and in calculations we
66  // use 2 + 0/2 time values.
67 
68  // But actually (for some reason...) the amount of data storage
69  // allocated for the timestepper in each node is determined by the
70  // size of weight. So we need to store an extra dummy entry in order
71  // to have storage space for the predicted value at t_{n+1}.
72 
73  // Just leave space for predictor values anyway, it's not expensive.
74  Weight.resize(2, 5, 0.0);
75 
76  // Assume that set_weights() or make_steady() is called before use to
77  // set up the values stored in Weight.
78  }
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
bool Predict_by_explicit_step
Definition: timesteppers.h:260
std::string Type
Definition: timesteppers.h:241
bool Is_steady
Definition: timesteppers.h:251
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, oomph::TimeStepper::Adaptive_Flag, oomph::TimeStepper::Is_steady, oomph::TimeStepper::Predict_by_explicit_step, oomph::TimeStepper::Predictor_storage_index, oomph::DenseMatrix< T >::resize(), oomph::TimeStepper::Type, and oomph::TimeStepper::Weight.

◆ ~IMRBase()

virtual oomph::IMRBase::~IMRBase ( )
inlinevirtual

Destructor.

81 {}

Member Function Documentation

◆ assign_initial_positions_impulsive()

void oomph::IMRBase::assign_initial_positions_impulsive ( Node *const &  node_pt)
inlinevirtual

Initialiset the positions for the node corresponding to an impulsive start

Implements oomph::TimeStepper.

132  {
133  std::string err = "Not implemented";
134  throw OomphLibError(
136  }
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ assign_initial_values_impulsive()

void oomph::IMRBase::assign_initial_values_impulsive ( Data *const &  data_pt)
inlinevirtual

not implemented (??ds TODO)

Implements oomph::TimeStepper.

126  {
127  std::string err = "Not implemented";
128  throw OomphLibError(
130  }

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ calculate_predicted_positions()

void oomph::IMRBase::calculate_predicted_positions ( Node *const &  node_pt)
inlinevirtual

Do the predictor step for the positions at a node (currently empty — overwrite for a specific scheme)

Reimplemented from oomph::TimeStepper.

140  {
141  std::string err = "Not implemented";
142  throw OomphLibError(
144  }

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ calculate_predicted_values()

void oomph::IMRBase::calculate_predicted_values ( Data *const &  data_pt)
virtual

Dummy - just check that the values that problem::calculate_predicted_values() has been called right.

Reimplemented from oomph::TimeStepper.

112  {
113  if (adaptive_flag())
114  {
115  // Can't do it here, but we can check that the predicted values have
116  // been updated.
118  }
119  }
void check_predicted_values_up_to_date() const
Check that the predicted values are the ones we want.
Definition: timesteppers.h:423
bool adaptive_flag() const
Function to indicate whether the scheme is adaptive (false by default)
Definition: timesteppers.h:623

References oomph::TimeStepper::adaptive_flag(), and oomph::TimeStepper::check_predicted_values_up_to_date().

◆ ndt()

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

Number of timestep increments that are required by the scheme.

Implements oomph::TimeStepper.

98  {
99  return nprev_values();
100  }
unsigned nprev_values() const
??ds
Definition: implicit_midpoint_rule.h:103

References nprev_values().

Referenced by shift_time_positions(), and shift_time_values().

◆ nprev_values()

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

??ds

Implements oomph::TimeStepper.

104  {
105  return 4;
106  }

Referenced by ndt().

◆ nprev_values_for_value_at_evaluation_time()

virtual unsigned oomph::IMRBase::nprev_values_for_value_at_evaluation_time ( ) const
pure virtual

Number of history values to interpolate over to get the "current" value.

Reimplemented from oomph::TimeStepper.

Implemented in oomph::IMRByBDF, and oomph::IMR.

◆ order()

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

Actual order (accuracy) of the scheme.

Reimplemented from oomph::TimeStepper.

92  {
93  return 2;
94  }

◆ set_error_weights()

void oomph::IMRBase::set_error_weights ( )
inlinevirtual

Set the weights for the error computation. This is not used by midpoint rule.

Reimplemented from oomph::TimeStepper.

118 {}

◆ set_predictor_weights()

void oomph::IMRBase::set_predictor_weights ( )
inlinevirtual

Set the weights for the predictor previous timestep. This is not used by midpint rule.

Reimplemented from oomph::TimeStepper.

122 {}

◆ set_weights()

virtual void oomph::IMRBase::set_weights ( )
pure virtual

Setup weights for time derivative calculations.

Implements oomph::TimeStepper.

Implemented in oomph::IMRByBDF, and oomph::IMR.

◆ shift_time_positions()

void oomph::IMRBase::shift_time_positions ( Node *const &  node_pt)
virtual

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

This function advances the time history of the positions at a node. ??ds Untested: I have no problems with moving nodes.

Implements oomph::TimeStepper.

58  {
59  // Find the number of coordinates
60  unsigned n_dim = node_pt->ndim();
61  // Find the number of position types
62  unsigned n_position_type = node_pt->nposition_type();
63 
64  // Find number of stored timesteps
65  unsigned n_tstorage = ntstorage();
66 
67  // Storage for the velocity
68  double velocity[n_position_type][n_dim];
69 
70  // If adaptive, find the velocities
71  if (adaptive_flag())
72  {
73  // Loop over the variables
74  for (unsigned i = 0; i < n_dim; i++)
75  {
76  for (unsigned k = 0; k < n_position_type; k++)
77  {
78  // Initialise velocity to zero
79  velocity[k][i] = 0.0;
80  // Loop over all history data
81  for (unsigned t = 0; t < n_tstorage; t++)
82  {
83  velocity[k][i] += Weight(1, t) * node_pt->x_gen(t, k, i);
84  }
85  }
86  }
87  }
88 
89  // Loop over the positions
90  for (unsigned i = 0; i < n_dim; i++)
91  {
92  // If the position is not a copy
93  if (node_pt->position_is_a_copy(i) == false)
94  {
95  // Loop over the position types
96  for (unsigned k = 0; k < n_position_type; k++)
97  {
98  // Loop over stored times, and set values to previous values
99  for (unsigned t = ndt(); t > 0; t--)
100  {
101  node_pt->x_gen(t, k, i) = node_pt->x_gen(t - 1, k, i);
102  }
103  }
104  }
105  }
106  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
unsigned ndt() const
Number of timestep increments that are required by the scheme.
Definition: implicit_midpoint_rule.h:97
unsigned ntstorage() const
Definition: timesteppers.h:601
char char char int int * k
Definition: level2_impl.h:374
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107
t
Definition: plotPSD.py:36

References oomph::TimeStepper::adaptive_flag(), i, k, oomph::Node::ndim(), ndt(), 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::IMRBase::shift_time_values ( Data *const &  data_pt)
virtual

This function advances the Data's time history so that we can move on to the next timestep

Implements oomph::TimeStepper.

40  {
41  // Loop over the values, set previous values to the previous value, if
42  // not a copy.
43  for (unsigned j = 0, nj = data_pt->nvalue(); j < nj; j++)
44  {
45  if (!data_pt->is_a_copy(j))
46  {
47  for (unsigned t = ndt(); t > 0; t--)
48  {
49  data_pt->set_value(t, j, data_pt->value(t - 1, j));
50  }
51  }
52  }
53  }
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

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

◆ temporal_error_in_position()

double oomph::IMRBase::temporal_error_in_position ( Node *const &  node_pt,
const unsigned i 
)
inlinevirtual

Compute the error in the position i at a node zero here – overwrite for specific scheme.

Reimplemented from oomph::TimeStepper.

147  {
148  std::string err = "Not implemented";
149  throw OomphLibError(
151  }

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ temporal_error_in_value()

double oomph::IMRBase::temporal_error_in_value ( Data *const &  data_pt,
const unsigned i 
)
virtual

Compute the error in the value i in a Data structure zero here – overwrite for specific scheme.

Reimplemented from oomph::TimeStepper.

124  {
125  if (adaptive_flag())
126  {
127  // predicted value is more accurate so just compare with that
128  return data_pt->value(i) - data_pt->value(Predictor_storage_index, i);
129  }
130  else
131  {
132  std::string err("Tried to get the temporal error from a non-adaptive");
133  err += " time stepper.";
134  throw OomphLibError(
136  }
137  }

References oomph::TimeStepper::adaptive_flag(), i, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::TimeStepper::Predictor_storage_index, oomph::Global_string_for_annotation::string(), and oomph::Data::value().


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