oomph::Time Class Reference

#include <timesteppers.h>

Public Member Functions

 Time ()
 
 Time (const unsigned &ndt)
 
 Time (const Time &)=delete
 Broken copy constructor. More...
 
void operator= (const Time &)=delete
 Broken assignment operator. More...
 
void resize (const unsigned &n_dt)
 
void initialise_dt (const double &dt_)
 Set all timesteps to the same value, dt. More...
 
void initialise_dt (const Vector< double > &dt_)
 
 ~Time ()
 Destructor: empty. More...
 
doubletime ()
 Return the current value of the continuous time. More...
 
unsigned ndt () const
 Return the number of timesteps stored. More...
 
doubledt (const unsigned &t=0)
 
double dt (const unsigned &t=0) const
 
double time (const unsigned &t=0) const
 
void shift_dt ()
 

Private Attributes

double Continuous_time
 Pointer to the value of the continuous time. More...
 
Vector< doubleDt
 Vector that stores the values of the current and previous timesteps. More...
 

Detailed Description

Class to keep track of discrete/continous time. It is essential to have a single Time object when using multiple time-stepping schemes; e.g., in fluid-structure interaction problems, it is common to use different schemes for the fluid and solid domains. Storage is allocated for the current value of the (continuous) time and a limited history of previous timesteps. The number of previous timesteps must be equal to the number required by the "highest order" scheme.

Constructor & Destructor Documentation

◆ Time() [1/3]

oomph::Time::Time ( )
inline

Constructor: Do not allocate any storage for previous timesteps, but set the initial value of the time to zero

74 : Continuous_time(0.0) {}
double Continuous_time
Pointer to the value of the continuous time.
Definition: timesteppers.h:66

◆ Time() [2/3]

oomph::Time::Time ( const unsigned ndt)
inline

Constructor: Pass the number of timesteps to be stored and set the initial value of time to zero.

78  : Continuous_time(0.0)
79  {
80  // Allocate memory for the timestep storage and initialise values to one
81  // to avoid division by zero.
82  Dt.resize(ndt, 1.0);
83  }
Vector< double > Dt
Vector that stores the values of the current and previous timesteps.
Definition: timesteppers.h:69
unsigned ndt() const
Return the number of timesteps stored.
Definition: timesteppers.h:129

References Dt, and ndt().

◆ Time() [3/3]

oomph::Time::Time ( const Time )
delete

Broken copy constructor.

◆ ~Time()

oomph::Time::~Time ( )
inline

Destructor: empty.

120 {}

Member Function Documentation

◆ dt() [1/2]

◆ dt() [2/2]

double oomph::Time::dt ( const unsigned t = 0) const
inline

Return the value of the t-th stored timestep (t=0: present; t>0: previous), const version.

144  {
145  return Dt[t];
146  }

References Dt, and plotPSD::t.

◆ initialise_dt() [1/2]

void oomph::Time::initialise_dt ( const double dt_)
inline

Set all timesteps to the same value, dt.

100  {
101  unsigned ndt = Dt.size();
102  Dt.assign(ndt, dt_);
103  }

References Dt, and ndt().

Referenced by oomph::Problem::initialise_dt().

◆ initialise_dt() [2/2]

void oomph::Time::initialise_dt ( const Vector< double > &  dt_)
inline

Set the value of the timesteps to be equal to the values passed in a vector

108  {
109  // Assign the values from the vector dt_, but preserve the size of Dt and
110  // any Dt[i] s.t. i > dt_.size() (which is why we can't just use
111  // assignment operator).
112  unsigned n_dt = dt_.size();
113  for (unsigned i = 0; i < n_dt; i++)
114  {
115  Dt[i] = dt_[i];
116  }
117  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9

References Dt, and i.

◆ ndt()

unsigned oomph::Time::ndt ( ) const
inline

Return the number of timesteps stored.

130  {
131  return Dt.size();
132  }

References Dt.

Referenced by oomph::Problem::add_time_stepper_pt(), oomph::Problem::copy(), oomph::Problem::dump(), initialise_dt(), Time(), and time().

◆ operator=()

void oomph::Time::operator= ( const Time )
delete

Broken assignment operator.

◆ resize()

void oomph::Time::resize ( const unsigned n_dt)
inline

Resize the vector holding the number of previous timesteps and initialise the new values to zero.

94  {
95  Dt.resize(n_dt, 0.0);
96  }

References Dt.

Referenced by oomph::Problem::add_time_stepper_pt(), oomph::Problem::copy(), and oomph::Problem::read().

◆ shift_dt()

void oomph::Time::shift_dt ( )
inline

Update all stored values of dt by shifting each value along the array. This function must be called before starting to solve at a new time level.

175  {
176  unsigned n_dt = Dt.size();
177  // Return straight away if there are no stored timesteps
178  if (n_dt == 0)
179  {
180  return;
181  }
182  // Start from the end of the array and shift every entry back by one
183  for (unsigned i = (n_dt - 1); i > 0; i--)
184  {
185  Dt[i] = Dt[i - 1];
186  }
187  }

References Dt, and i.

Referenced by oomph::Problem::shift_time_values().

◆ time() [1/2]

double& oomph::Time::time ( )
inline

Return the current value of the continuous time.

124  {
125  return Continuous_time;
126  }

References Continuous_time.

Referenced by AxisymOscillatingDisk::accel(), oomph::PseudoBucklingRing::accel(), oomph::IMRByBDF::actions_after_timestep(), oomph::IMRByBDF::actions_before_timestep(), oomph::Problem::adaptive_unsteady_newton_solve(), oomph::SelfStartingBDF2::assign_initial_data_values(), oomph::PeriodicOrbitTimeDiscretisation::assign_initial_data_values(), oomph::LinearElasticityEquationsBase< DIM >::body_force(), oomph::TimeHarmonicLinearElasticityEquationsBase< DIM >::body_force(), oomph::PVDEquationsBase< DIM >::body_force(), oomph::TimeStepper::check_predicted_values_up_to_date(), oomph::Problem::copy(), oomph::Problem::doubly_adaptive_unsteady_newton_solve_helper(), oomph::Problem::dump(), oomph::AxisymmetricLinearElasticityEquations::fill_in_generic_contribution_to_residuals_axisymmetric_linear_elasticity(), oomph::AxisymmetricPoroelasticityEquations::fill_in_generic_residual_contribution(), oomph::AxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_axi_nst(), oomph::RefineableAxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_axi_nst(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_axi_nst(), oomph::RefineableGeneralisedNewtonianAxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_axi_nst(), oomph::LinearisedAxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_linearised_axi_nst(), oomph::RefineableLinearisedAxisymmetricNavierStokesEquations::fill_in_generic_residual_contribution_linearised_axi_nst(), oomph::PeriodicOrbitEquations::fill_in_generic_residual_contribution_orbit(), oomph::RefineableSphericalNavierStokesEquations::fill_in_generic_residual_contribution_spherical_nst(), oomph::SphericalNavierStokesEquations::fill_in_generic_residual_contribution_spherical_nst(), oomph::AxisymmetricNavierStokesEquations::get_dresidual_dnodal_coordinates(), oomph::RefineableAxisymmetricNavierStokesEquations::get_dresidual_dnodal_coordinates(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::get_dresidual_dnodal_coordinates(), oomph::RefineableGeneralisedNewtonianAxisymmetricNavierStokesEquations::get_dresidual_dnodal_coordinates(), oomph::AdvectionDiffusionReactionEquations< NREAGENT, DIM >::get_wind_adv_diff_react(), oomph::ODEProblem::my_set_initial_condition(), oomph::PeriodicOrbitEquations::orbit_output(), oomph::UnsteadyHeatBaseFaceElement< ELEMENT >::output(), oomph::UnsteadyHeatFluxPseudoMeltElement< ELEMENT >::output(), oomph::AxisymmetricLinearElasticityTractionElement< ELEMENT >::output(), oomph::AxisymmetricNavierStokesTractionElement< ELEMENT >::output(), oomph::AxisymmetricPoroelasticityTractionElement< ELEMENT >::output(), oomph::FSILinearisedAxisymPoroelasticTractionElement< POROELASTICITY_BULK_ELEMENT, NAVIER_STOKES_BULK_ELEMENT >::output(), oomph::SolarRadiationBase::output_atmospheric_radiation(), oomph::SurfaceMeltElement< ELEMENT >::output_melt(), oomph::StefanBoltzmannUnsteadyHeatFluxElement< ELEMENT >::output_stefan_boltzmann_radiation(), OscillatingCylinder::position(), Leaflet::position(), Flag_definition::TopOfFlag::position(), Flag_definition::BottomOfFlag::position(), Flag_definition::TipOfFlag::position(), OscillatingWall::position(), MyEllipse::position(), AxisymOscillatingDisk::position(), oomph::PseudoBucklingRing::position(), oomph::Problem::read(), oomph::AxisymmetricNavierStokesTractionElement< ELEMENT >::scalar_value_paraview(), oomph::SolidICProblem::set_newmark_initial_condition_consistently(), oomph::SolidICProblem::set_newmark_initial_condition_directly(), oomph::SolidICProblem::set_static_initial_condition(), oomph::Problem::time(), oomph::PeriodicOrbitEquations::time(), oomph::IMRODEElement::time_interpolate_time(), oomph::TemplateFreeContactElementBase::traction_fct(), oomph::Problem::unsteady_newton_solve(), oomph::SegregatableFSIProblem::unsteady_segregated_solve(), AxisymOscillatingDisk::veloc(), and oomph::PseudoBucklingRing::veloc().

◆ time() [2/2]

double oomph::Time::time ( const unsigned t = 0) const
inline

Return the value of the continuous time at the t-th previous time level (t=0: current; t>0 previous).

151  {
152 #ifdef PARANOID
153  if (t > ndt())
154  {
155  using namespace StringConversion;
156  std::string error_msg = "Timestep " + to_string(t) + " out of range!";
157  throw OomphLibError(
159  }
160 #endif
161  // Load the current value of the time
162  double time_local = Continuous_time;
163  // Loop over the t previous timesteps and subtract each dt
164  for (unsigned i = 0; i < t; i++)
165  {
166  time_local -= Dt[i];
167  }
168  return time_local;
169  }
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
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References Continuous_time, Dt, i, ndt(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Global_string_for_annotation::string(), plotPSD::t, and oomph::StringConversion::to_string().

Member Data Documentation

◆ Continuous_time

double oomph::Time::Continuous_time
private

Pointer to the value of the continuous time.

Referenced by time().

◆ Dt

Vector<double> oomph::Time::Dt
private

Vector that stores the values of the current and previous timesteps.

Referenced by dt(), initialise_dt(), ndt(), resize(), shift_dt(), Time(), and time().


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