oomph::RungeKutta< ORDER > Class Template Reference

#include <explicit_timesteppers.h>

+ Inheritance diagram for oomph::RungeKutta< ORDER >:

Public Member Functions

 RungeKutta ()
 Constructor, set the type. More...
 
 RungeKutta (const RungeKutta &)=delete
 Broken copy constructor. More...
 
void operator= (const RungeKutta &)=delete
 Broken assignment operator. More...
 
void timestep (ExplicitTimeSteppableObject *const &object_pt, const double &dt)
 Function that is used to advance time in the object. More...
 
void timestep (ExplicitTimeSteppableObject *const &object_pt, const double &dt)
 Explicit specialisation for fourth-order RK scheme. More...
 
void timestep (ExplicitTimeSteppableObject *const &object_pt, const double &dt)
 Explicit specialisation for second-order RK scheme. More...
 
- Public Member Functions inherited from oomph::ExplicitTimeStepper
 ExplicitTimeStepper ()
 Empty Constructor. More...
 
 ExplicitTimeStepper (const ExplicitTimeStepper &)=delete
 Broken copy constructor. More...
 
void operator= (const ExplicitTimeStepper &)=delete
 Broken assignment operator. More...
 
virtual ~ExplicitTimeStepper ()
 Empty virtual destructor — no memory is allocated in this class. More...
 

Additional Inherited Members

- Protected Attributes inherited from oomph::ExplicitTimeStepper
std::string Type
 

Detailed Description

template<unsigned ORDER>
class oomph::RungeKutta< ORDER >

=========================================================== Standard Runge Kutta Timestepping

Constructor & Destructor Documentation

◆ RungeKutta() [1/2]

template<unsigned ORDER>
oomph::RungeKutta< ORDER >::RungeKutta ( )
inline

Constructor, set the type.

191  {
192  Type = "RungeKutta";
193  }
std::string Type
Definition: explicit_timesteppers.h:136

References oomph::ExplicitTimeStepper::Type.

◆ RungeKutta() [2/2]

template<unsigned ORDER>
oomph::RungeKutta< ORDER >::RungeKutta ( const RungeKutta< ORDER > &  )
delete

Broken copy constructor.

Member Function Documentation

◆ operator=()

template<unsigned ORDER>
void oomph::RungeKutta< ORDER >::operator= ( const RungeKutta< ORDER > &  )
delete

Broken assignment operator.

◆ timestep() [1/3]

void oomph::RungeKutta< 4 >::timestep ( ExplicitTimeSteppableObject *const &  object_pt,
const double dt 
)
virtual

Explicit specialisation for fourth-order RK scheme.

Implements oomph::ExplicitTimeStepper.

205  {
206  object_pt->actions_before_explicit_timestep();
207 
208  // Stage 1
209  // ============================================================
210  object_pt->actions_before_explicit_stage();
211 
212  // Store the initial values and initial time
213  DoubleVector u;
214  object_pt->get_dofs(u);
215 
216  // Now get the first unknowns
217  DoubleVector k1;
218  object_pt->get_dvaluesdt(k1);
219 
220  // Add to the residuals
221  object_pt->add_to_dofs(0.5 * dt, k1);
222  // Increment the time
223  object_pt->time() += 0.5 * dt;
224  object_pt->actions_after_explicit_stage();
225 
226 
227  // Stage 2
228  // ============================================================
229  object_pt->actions_before_explicit_stage();
230 
231  // Get the next unknowns
232  DoubleVector k2;
233  object_pt->get_dvaluesdt(k2);
234 
235  // Now reset the residuals
236  object_pt->set_dofs(u);
237  object_pt->add_to_dofs(0.5 * dt, k2);
238  // Time remains the same
239  object_pt->actions_after_explicit_stage();
240 
241  // Stage 3
242  // ============================================================
243  object_pt->actions_before_explicit_stage();
244 
245  // Get the next unknowns
246  DoubleVector k3;
247  object_pt->get_dvaluesdt(k3);
248 
249  // Now reset the residuals
250  object_pt->set_dofs(u);
251  object_pt->add_to_dofs(dt, k3);
252  // Increment the time (now at initial_time + dt)
253  object_pt->time() += 0.5 * dt;
254  object_pt->actions_after_explicit_stage();
255 
256  // Stage 4
257  // ============================================================
258  object_pt->actions_before_explicit_stage();
259 
260  // Get the final unknowns
261  DoubleVector k4;
262  object_pt->get_dvaluesdt(k4);
263 
264  // Set the final values of the unknowns
265  object_pt->set_dofs(u);
266  object_pt->add_to_dofs((dt / 6.0), k1);
267  object_pt->add_to_dofs((dt / 3.0), k2);
268  object_pt->add_to_dofs((dt / 3.0), k3);
269  object_pt->add_to_dofs((dt / 6.0), k4);
270  object_pt->actions_after_explicit_stage();
271 
272  object_pt->actions_after_explicit_timestep();
273  }
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26

References oomph::ExplicitTimeSteppableObject::actions_after_explicit_stage(), oomph::ExplicitTimeSteppableObject::actions_after_explicit_timestep(), oomph::ExplicitTimeSteppableObject::actions_before_explicit_stage(), oomph::ExplicitTimeSteppableObject::actions_before_explicit_timestep(), oomph::ExplicitTimeSteppableObject::add_to_dofs(), oomph::ExplicitTimeSteppableObject::get_dofs(), oomph::ExplicitTimeSteppableObject::get_dvaluesdt(), oomph::ExplicitTimeSteppableObject::set_dofs(), and oomph::ExplicitTimeSteppableObject::time().

◆ timestep() [2/3]

void oomph::RungeKutta< 2 >::timestep ( ExplicitTimeSteppableObject *const &  object_pt,
const double dt 
)
virtual

Explicit specialisation for second-order RK scheme.

Implements oomph::ExplicitTimeStepper.

281  {
282  object_pt->actions_before_explicit_timestep();
283 
284  // Stage 1
285  // ============================================================
286  object_pt->actions_before_explicit_stage();
287 
288  // Store the initial values
289  DoubleVector u;
290  object_pt->get_dofs(u);
291 
292  // Get f1 (time derivative at t0, y0) and add to dofs
294  object_pt->get_dvaluesdt(f1);
295  object_pt->add_to_dofs(dt, f1);
296 
297  // Advance time to t1 = t0 + dt
298  object_pt->time() += dt;
299 
300  object_pt->actions_after_explicit_stage();
301 
302 
303  // Stage 2
304  // ============================================================
305  object_pt->actions_before_explicit_stage();
306 
307  // get f2 (with t=t1, y = y0 + h f0)
309  object_pt->get_dvaluesdt(f2);
310 
311  // Final answer is starting dofs + h/2 * (f1 + f2)
312  object_pt->set_dofs(u);
313  object_pt->add_to_dofs(0.5 * dt, f1);
314  object_pt->add_to_dofs(0.5 * dt, f2);
315 
316  object_pt->actions_after_explicit_stage();
317 
318  // Done, do actions
319  object_pt->actions_after_explicit_timestep();
320  }
double f2(const Vector< double > &coord)
f2 function, in front of the C2 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:233
double f1(const Vector< double > &coord)
f1 function, in front of the C1 unknown
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:147

References oomph::ExplicitTimeSteppableObject::actions_after_explicit_stage(), oomph::ExplicitTimeSteppableObject::actions_after_explicit_timestep(), oomph::ExplicitTimeSteppableObject::actions_before_explicit_stage(), oomph::ExplicitTimeSteppableObject::actions_before_explicit_timestep(), oomph::ExplicitTimeSteppableObject::add_to_dofs(), Global_parameters::f1(), Global_parameters::f2(), oomph::ExplicitTimeSteppableObject::get_dofs(), oomph::ExplicitTimeSteppableObject::get_dvaluesdt(), oomph::ExplicitTimeSteppableObject::set_dofs(), and oomph::ExplicitTimeSteppableObject::time().

◆ timestep() [3/3]

template<unsigned ORDER>
void oomph::RungeKutta< ORDER >::timestep ( ExplicitTimeSteppableObject *const &  object_pt,
const double dt 
)
virtual

Function that is used to advance time in the object.

Implements oomph::ExplicitTimeStepper.

192  {
193  std::ostringstream error_stream;
194  error_stream << "Timestep not implemented for order " << ORDER << "\n";
195  throw OomphLibError(
196  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
197  }
#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.


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