oomph::IMRByBDF Class Reference

#include <implicit_midpoint_rule.h>

+ Inheritance diagram for oomph::IMRByBDF:

Public Member Functions

 IMRByBDF (const bool &adaptive=false)
 Constructor with initialisation. More...
 
virtual ~IMRByBDF ()
 Destructor. More...
 
void set_weights ()
 Setup weights for time derivative calculations. More...
 
unsigned nprev_values_for_value_at_evaluation_time () const
 
void actions_before_timestep (Problem *problem_pt)
 Half the timestep before starting solve. More...
 
void actions_after_timestep (Problem *problem_pt)
 
- Public Member Functions inherited from oomph::IMRBase
 IMRBase (const bool &adaptive=false)
 Constructor with initialisation. More...
 
virtual ~IMRBase ()
 Destructor. More...
 
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...
 

Public Attributes

bool Update_pinned
 Should we update pinned variables after the half-step? More...
 

Private Member Functions

 IMRByBDF (const IMRByBDF &dummy)
 Inaccessible copy constructor. More...
 
void operator= (const IMRByBDF &dummy)
 Inaccessible assignment operator. 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

Implementation of implicit midpoint rule by taking half a step of bdf1 then applying an update to all dofs. This implementation should work with any existing problem for which the BDF methods work.

The exception is when multiple different time steppers are being used simultaneously for different parts of the problem. In this case the IMR class should be used.

Constructor & Destructor Documentation

◆ IMRByBDF() [1/2]

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

Constructor with initialisation.

223  : IMRBase(adaptive)
224  {
225  Update_pinned = true;
226  }
IMRBase(const bool &adaptive=false)
Constructor with initialisation.
Definition: implicit_midpoint_rule.h:47
bool Update_pinned
Should we update pinned variables after the half-step?
Definition: implicit_midpoint_rule.h:256
int adaptive
Definition: jeffery_hamel.cc:106

References Update_pinned.

◆ ~IMRByBDF()

virtual oomph::IMRByBDF::~IMRByBDF ( )
inlinevirtual

Destructor.

229 {}

◆ IMRByBDF() [2/2]

oomph::IMRByBDF::IMRByBDF ( const IMRByBDF dummy)
inlineprivate

Inaccessible copy constructor.

260 {}

Member Function Documentation

◆ actions_after_timestep()

void oomph::IMRByBDF::actions_after_timestep ( Problem problem_pt)
virtual

Take problem from t={n+1/2} to t=n+1 by algebraic update and restore time step.

Reimplemented from oomph::TimeStepper.

205  {
206 #ifdef PARANOID
207  // Do it as dofs too to compare
208  const unsigned ndof = problem_pt->ndof();
209  DoubleVector dof_n, dof_np1;
210  problem_pt->get_dofs(1, dof_n);
211  problem_pt->get_dofs(dof_np1);
212 
213  for (unsigned i = 0; i < ndof; i++)
214  {
215  dof_np1[i] += dof_np1[i] - dof_n[i];
216  }
217 #endif
218 
219  // First deal with global data
220  for (unsigned i = 0, ni = problem_pt->nglobal_data(); i < ni; i++)
221  {
222  post_midpoint_update(problem_pt->global_data_pt(i), Update_pinned);
223  }
224 
225  // Next element internal data
226  for (unsigned i = 0, ni = problem_pt->mesh_pt()->nelement(); i < ni; i++)
227  {
228  GeneralisedElement* ele_pt = problem_pt->mesh_pt()->element_pt(i);
229  for (unsigned j = 0, nj = ele_pt->ninternal_data(); j < nj; j++)
230  {
231  post_midpoint_update(ele_pt->internal_data_pt(j), Update_pinned);
232  }
233  }
234 
235  // Now the nodes
236  for (unsigned i = 0, ni = problem_pt->mesh_pt()->nnode(); i < ni; i++)
237  {
238  post_midpoint_update(problem_pt->mesh_pt()->node_pt(i), Update_pinned);
239  }
240 
241  // Update time
242  problem_pt->time_pt()->time() += problem_pt->time_pt()->dt();
243 
244  // Return step size to its full value
245  problem_pt->time_pt()->dt() *= 2;
246 
247 #ifdef PARANOID
248  using namespace StringConversion;
249  DoubleVector actual_dof_np1;
250  problem_pt->get_dofs(actual_dof_np1);
251 
252  for (unsigned j = 0; j < actual_dof_np1.nrow(); j++)
253  {
254  if (std::abs(actual_dof_np1[j] - dof_np1[j]) > 1e-8)
255  {
256  std::string err = "Got different values doing midpoint update via "
257  "extracted dofs than doing it in place!";
258  err += to_string(actual_dof_np1[j]) + " vs " + to_string(dof_np1[j]);
259  throw OomphLibError(
261  }
262  }
263 
264 #endif
265  }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
int i
Definition: BiCGSTAB_step_by_step.cpp:9
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
void post_midpoint_update(Data *dat_pt, const bool &update_pinned)
Definition: implicit_midpoint_rule.cc:186
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References abs(), oomph::Time::dt(), e(), oomph::Mesh::element_pt(), oomph::Problem::get_dofs(), oomph::Problem::global_data_pt(), i, oomph::GeneralisedElement::internal_data_pt(), j, oomph::Problem::mesh_pt(), oomph::Problem::ndof(), oomph::Mesh::nelement(), oomph::Problem::nglobal_data(), oomph::GeneralisedElement::ninternal_data(), oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::DistributableLinearAlgebraObject::nrow(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::post_midpoint_update(), oomph::Global_string_for_annotation::string(), oomph::Time::time(), oomph::Problem::time_pt(), oomph::StringConversion::to_string(), and Update_pinned.

◆ actions_before_timestep()

void oomph::IMRByBDF::actions_before_timestep ( Problem problem_pt)
virtual

Half the timestep before starting solve.

Reimplemented from oomph::TimeStepper.

141  {
142  // Check that this is the only time stepper
143 #ifdef PARANOID
144  if (problem_pt->ntime_stepper() != 1)
145  {
146  std::string err = "This implementation of midpoint can only work with a ";
147  err += "single time stepper, try using IMR instead (but check ";
148  err += "your Jacobian and residual calculations very carefully for "
149  "compatability).";
150  throw OomphLibError(
152  }
153 #endif
154 
155  time_pt()->dt() /= 2;
156  time_pt()->time() -= time_pt()->dt();
157 
158  // Set the weights again because we just changed the step size
159  set_weights();
160 
161 
162  if (problem_pt->use_predictor_values_as_initial_guess())
163  {
164  // Shift the initial guess to the midpoint so that it is an initial
165  // guess for the newton step that we actually take.
166 
167  // Optimisation possiblity: here we update all values three time
168  // (initial prediction, copy into initial guess, interpolate to
169  // midpoint), could probably avoid this with more fancy code if
170  // needed.
171 
172  // Get dofs at previous time step
173  DoubleVector dof_n;
174  problem_pt->get_dofs(1, dof_n);
175 
176  // Update dofs at current step to be the average of current and previous
177  for (unsigned i = 0; i < problem_pt->ndof(); i++)
178  {
179  problem_pt->dof(i) = (problem_pt->dof(i) + dof_n[i]) / 2;
180  }
181  }
182  }
void set_weights()
Setup weights for time derivative calculations.
Definition: implicit_midpoint_rule.h:232
Time *const & time_pt() const
Access function for the pointer to time (const version)
Definition: timesteppers.h:572
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123

References oomph::Problem::dof(), oomph::Time::dt(), oomph::Problem::get_dofs(), i, oomph::Problem::ndof(), oomph::Problem::ntime_stepper(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, set_weights(), oomph::Global_string_for_annotation::string(), oomph::Time::time(), oomph::TimeStepper::time_pt(), and oomph::Problem::use_predictor_values_as_initial_guess().

◆ nprev_values_for_value_at_evaluation_time()

unsigned oomph::IMRByBDF::nprev_values_for_value_at_evaluation_time ( ) const
inlinevirtual

Number of history values to interpolate over to get the "current" value. Evaluation time is the end of the bdf1 "half-step", so only need one value as normal.

Implements oomph::IMRBase.

244  {
245  return 1;
246  }

◆ operator=()

void oomph::IMRByBDF::operator= ( const IMRByBDF dummy)
inlineprivate

Inaccessible assignment operator.

263 {}

◆ set_weights()

void oomph::IMRByBDF::set_weights ( )
inlinevirtual

Setup weights for time derivative calculations.

Implements oomph::IMRBase.

233  {
234  // Use weights from bdf1
235  double dt = Time_pt->dt(0);
236  Weight(1, 0) = 1.0 / dt;
237  Weight(1, 1) = -1.0 / dt;
238  }
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
Definition: timesteppers.h:237
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234

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

Referenced by actions_before_timestep().

Member Data Documentation

◆ Update_pinned

bool oomph::IMRByBDF::Update_pinned

Should we update pinned variables after the half-step?

Referenced by actions_after_timestep(), and IMRByBDF().


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