oomph::NewmarkBDF< NSTEPS > Class Template Reference

#include <timesteppers.h>

+ Inheritance diagram for oomph::NewmarkBDF< NSTEPS >:

Public Member Functions

 NewmarkBDF ()
 
 NewmarkBDF (const NewmarkBDF &)=delete
 Broken copy constructor. More...
 
void operator= (const NewmarkBDF &)=delete
 Broken assignment operator. More...
 
void set_weights ()
 Set weights. More...
 
void shift_time_values (Data *const &data_pt)
 
void shift_time_positions (Node *const &node_pt)
 
void enable_degrade_first_derivatives_to_bdf1 ()
 
void disable_degrade_first_derivatives_to_bdf1 ()
 Disable degradation to first order BDF. More...
 
void set_weights ()
 Set weights. More...
 
void set_weights ()
 Set weights. More...
 
void set_weights ()
 Set weights. More...
 
- Public Member Functions inherited from oomph::Newmark< NSTEPS >
 Newmark ()
 
 Newmark (const Newmark &)=delete
 Broken copy constructor. More...
 
void operator= (const Newmark &)=delete
 Broken assignment operator. More...
 
unsigned order () const
 The actual order (accuracy of the scheme) More...
 
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, Vector< InitialConditionFctPt > initial_veloc_fct, Vector< InitialConditionFctPt > initial_accel_fct)
 
void assign_initial_data_values (Node *const &node_pt, Vector< NodeInitialConditionFctPt > initial_value_fct, Vector< NodeInitialConditionFctPt > initial_veloc_fct, Vector< NodeInitialConditionFctPt > initial_accel_fct)
 
void assign_initial_data_values_stage1 (const unsigned t_deriv, Data *const &data_pt)
 
void assign_initial_data_values_stage2 (Data *const &data_pt)
 
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...
 
- 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...
 
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 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 Member Functions

void set_newmark_veloc_weights (const double &dt)
 

Private Attributes

bool Degrade_to_bdf1_for_first_derivs
 
Vector< doubleNewmark_veloc_weight
 

Additional Inherited Members

- Public Types inherited from oomph::Newmark< NSTEPS >
typedef double(* InitialConditionFctPt) (const double &t)
 
typedef double(* NodeInitialConditionFctPt) (const double &t, const Vector< double > &x)
 
- Protected Attributes inherited from oomph::Newmark< NSTEPS >
double Beta1
 First Newmark parameter (usually 0.5) More...
 
double Beta2
 Second Newmark parameter (usually 0.5) More...
 
- 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

template<unsigned NSTEPS>
class oomph::NewmarkBDF< NSTEPS >

////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// Newmark scheme for second time deriv with first derivatives calculated using BDF. . Stored data represents

  • t=0: value at at present time, Time_pt->time()
  • t=1: value at previous time, Time_pt->time()-dt
  • ...
  • t=NSTEPS: value at previous time, Time_pt->time()-NSTEPS*dt
  • t=NSTEPS+1: 1st time deriv (= "velocity") at previous time, Time_pt->time()-dt
  • t=NSTEPS+2: 2nd time deriv (= "acceleration") at previous time, Time_pt->time()-dt

NSTEPS=1 gives normal Newmark.

Constructor & Destructor Documentation

◆ NewmarkBDF() [1/2]

template<unsigned NSTEPS>
oomph::NewmarkBDF< NSTEPS >::NewmarkBDF ( )
inline

Constructor: Pass pointer to global time. We set up a timestepping scheme with NSTEPS+2 doubles to represent the history and the highest deriv is 2.

1080  {
1081  this->Type = "NewmarkBDF";
1083  Newmark_veloc_weight.resize(NSTEPS + 3);
1084  }
bool Degrade_to_bdf1_for_first_derivs
Definition: timesteppers.h:1139
Vector< double > Newmark_veloc_weight
Definition: timesteppers.h:1145
std::string Type
Definition: timesteppers.h:241

◆ NewmarkBDF() [2/2]

template<unsigned NSTEPS>
oomph::NewmarkBDF< NSTEPS >::NewmarkBDF ( const NewmarkBDF< NSTEPS > &  )
delete

Broken copy constructor.

Member Function Documentation

◆ disable_degrade_first_derivatives_to_bdf1()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::disable_degrade_first_derivatives_to_bdf1 ( )
inline

Disable degradation to first order BDF.

1113  {
1115  }

◆ enable_degrade_first_derivatives_to_bdf1()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::enable_degrade_first_derivatives_to_bdf1 ( )
inline

Degrade scheme to first order BDF (for first derivs/veloc); usually for start-up.

1106  {
1108  }

◆ operator=()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::operator= ( const NewmarkBDF< NSTEPS > &  )
delete

Broken assignment operator.

◆ set_newmark_veloc_weights()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::set_newmark_veloc_weights ( const double dt)
inlineprivate

Set original Newmark weights for velocities (needed when shifting history values – they're used when updating the previous accelerations and doing this with bdf can make the scheme unstable...

1123  {
1124  Newmark_veloc_weight[0] = this->Beta1 * dt * this->Weight(2, 0);
1125  Newmark_veloc_weight[1] = this->Beta1 * dt * this->Weight(2, 1);
1126  for (unsigned t = 2; t <= NSTEPS; t++)
1127  {
1128  Newmark_veloc_weight[t] = 0.0;
1129  }
1130  Newmark_veloc_weight[NSTEPS + 1] =
1131  1.0 + this->Beta1 * dt * this->Weight(2, NSTEPS + 1);
1132  Newmark_veloc_weight[NSTEPS + 2] =
1133  dt * (1.0 - this->Beta1) +
1134  this->Beta1 * dt * this->Weight(2, NSTEPS + 2);
1135  }
double Beta1
First Newmark parameter (usually 0.5)
Definition: timesteppers.h:1046
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
Definition: timesteppers.h:237
t
Definition: plotPSD.py:36

References GlobalParameters::Beta1, oomph::Time::dt(), plotPSD::t, and ProblemParameters::Weight.

◆ set_weights() [1/4]

void oomph::NewmarkBDF< 1 >::set_weights ( )
virtual

Set weights.

Reimplemented from oomph::Newmark< NSTEPS >.

1186  {
1187  // Set Newmark weights for second derivatives
1188  double dt = Time_pt->dt(0);
1189  Weight(2, 0) = 2.0 / (Beta2 * dt * dt);
1190  Weight(2, 1) = -2.0 / (Beta2 * dt * dt);
1191  Weight(2, 2) = -2.0 / (dt * Beta2);
1192  Weight(2, 3) = (Beta2 - 1.0) / Beta2;
1193 
1194  // Set BDF weights for first derivatives
1195  Weight(1, 0) = 1.0 / dt;
1196  Weight(1, 1) = -1.0 / dt;
1197  Weight(1, 2) = 0.0;
1198  Weight(1, 3) = 0.0;
1199 
1200  // Orig Newmark weights for first derivs.
1202  }
void set_newmark_veloc_weights(const double &dt)
Definition: timesteppers.h:1122
double Beta2
Second Newmark parameter (usually 0.5)
Definition: timesteppers.h:1049
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136

References Flag_definition::Time_pt, and ProblemParameters::Weight.

◆ set_weights() [2/4]

void oomph::NewmarkBDF< 2 >::set_weights ( )
virtual

Set weights.

Reimplemented from oomph::Newmark< NSTEPS >.

1209  {
1210  // Set Newmark weights for second derivatives
1211  double dt = Time_pt->dt(0);
1212  Weight(2, 0) = 2.0 / (Beta2 * dt * dt);
1213  Weight(2, 1) = -2.0 / (Beta2 * dt * dt);
1214  Weight(2, 2) = 0.0;
1215  Weight(2, 3) = -2.0 / (dt * Beta2);
1216  Weight(2, 4) = (Beta2 - 1.0) / Beta2;
1217 
1218  // Set BDF weights for first derivatives
1220  {
1221  this->Weight(1, 0) = 1.0 / dt;
1222  this->Weight(1, 1) = -1.0 / dt;
1223  unsigned nweights = this->Weight.ncol();
1224  for (unsigned i = 2; i < nweights; i++)
1225  {
1226  this->Weight(1, i) = 0.0;
1227  }
1228  }
1229  else
1230  {
1231  double dtprev = Time_pt->dt(1);
1232  Weight(1, 0) = 1.0 / dt + 1.0 / (dt + dtprev);
1233  Weight(1, 1) = -(dt + dtprev) / (dt * dtprev);
1234  Weight(1, 2) = dt / ((dt + dtprev) * dtprev);
1235  Weight(1, 3) = 0.0;
1236  Weight(1, 4) = 0.0;
1237  }
1238 
1239  // Orig Newmark weights for first derivs.
1241  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
unsigned long ncol() const
Return the number of columns of the matrix.
Definition: matrices.h:491

References i, Flag_definition::Time_pt, and ProblemParameters::Weight.

◆ set_weights() [3/4]

void oomph::NewmarkBDF< 4 >::set_weights ( )
virtual

Set weights.

Reimplemented from oomph::Newmark< NSTEPS >.

1248  {
1249  // Set Newmark weights for second derivatives
1250  double dt = Time_pt->dt(0);
1251  Weight(2, 0) = 2.0 / (Beta2 * dt * dt);
1252  Weight(2, 1) = -2.0 / (Beta2 * dt * dt);
1253  Weight(2, 2) = 0.0;
1254  Weight(2, 3) = 0.0;
1255  Weight(2, 4) = 0.0;
1256  Weight(2, 5) = -2.0 / (dt * Beta2);
1257  Weight(2, 6) = (Beta2 - 1.0) / Beta2;
1258 
1259  // Set BDF weights for first derivatives
1260 #ifdef PARANOID
1261  for (unsigned i = 0; i < Time_pt->ndt(); i++)
1262  {
1263  if (dt != Time_pt->dt(i))
1264  {
1265  throw OomphLibError("BDF4 currently only works for fixed timesteps \n",
1268  }
1269  }
1270 #endif
1271 
1272  // Set BDF weights for first derivatives
1274  {
1275  this->Weight(1, 0) = 1.0 / dt;
1276  this->Weight(1, 1) = -1.0 / dt;
1277  unsigned nweights = this->Weight.ncol();
1278  for (unsigned i = 2; i < nweights; i++)
1279  {
1280  this->Weight(1, i) = 0.0;
1281  }
1282  }
1283  else
1284  {
1285  Weight(1, 0) = 25.0 / 12.0 / dt;
1286  Weight(1, 1) = -48.0 / 12.0 / dt;
1287  Weight(1, 2) = 36.0 / 12.0 / dt;
1288  Weight(1, 3) = -16.0 / 12.0 / dt;
1289  Weight(1, 4) = 3.0 / 12.0 / dt;
1290  Weight(1, 5) = 0.0;
1291  Weight(1, 6) = 0.0;
1292  }
1293 
1294  // Orig Newmark weights for first derivs.
1296  }
unsigned ndt() const
Return the number of timesteps stored.
Definition: timesteppers.h:129
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References i, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Flag_definition::Time_pt, and ProblemParameters::Weight.

◆ set_weights() [4/4]

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::set_weights ( )
virtual

Set weights.

Reimplemented from oomph::Newmark< NSTEPS >.

◆ shift_time_positions()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::shift_time_positions ( Node *const &  node_pt)
virtual

This function updates a nodal time history so that we can advance to the next timestep.

Reimplemented from oomph::Newmark< NSTEPS >.

1129  {
1130  // Find the number of coordinates
1131  unsigned n_dim = node_pt->ndim();
1132  // Find the number of position types
1133  unsigned n_position_type = node_pt->nposition_type();
1134 
1135  // Storage for the velocity and acceleration
1136  double veloc[n_position_type][n_dim];
1137  double accel[n_position_type][n_dim];
1138 
1139  // Find number of stored time values
1140  unsigned n_tstorage = this->ntstorage();
1141 
1142  // Loop over the variables
1143  for (unsigned i = 0; i < n_dim; i++)
1144  {
1145  for (unsigned k = 0; k < n_position_type; k++)
1146  {
1147  veloc[k][i] = accel[k][i] = 0.0;
1148  // Loop over all the history data
1149  for (unsigned t = 0; t < n_tstorage; t++)
1150  {
1151  veloc[k][i] += Newmark_veloc_weight[t] * node_pt->x_gen(t, k, i);
1152  accel[k][i] += this->weight(2, t) * node_pt->x_gen(t, k, i);
1153  }
1154  }
1155  }
1156 
1157  // Loop over the position variables
1158  for (unsigned i = 0; i < n_dim; i++)
1159  {
1160  // If not a copy
1161  if (node_pt->position_is_a_copy(i) == false)
1162  {
1163  // Loop over position types
1164  for (unsigned k = 0; k < n_position_type; k++)
1165  {
1166  // Set previous values/veloc/accel to present values/veloc/accel,
1167  // if not a copy
1168  for (unsigned t = NSTEPS; t > 0; t--)
1169  {
1170  node_pt->x_gen(t, k, i) = node_pt->x_gen(t - 1, k, i);
1171  }
1172 
1173  node_pt->x_gen(NSTEPS + 1, k, i) = veloc[k][i];
1174  node_pt->x_gen(NSTEPS + 2, k, i) = accel[k][i];
1175  }
1176  }
1177  }
1178  }
unsigned ntstorage() const
Definition: timesteppers.h:601
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
Definition: timesteppers.h:594
char char char int int * k
Definition: level2_impl.h:374

References i, k, oomph::Node::ndim(), oomph::Node::nposition_type(), oomph::Node::position_is_a_copy(), plotPSD::t, and oomph::Node::x_gen().

◆ shift_time_values()

template<unsigned NSTEPS>
void oomph::NewmarkBDF< NSTEPS >::shift_time_values ( Data *const &  data_pt)
virtual

This function updates the Data's time history so that we can advance to the next timestep.

Reimplemented from oomph::Newmark< NSTEPS >.

1083  {
1084  // Find number of values stored
1085  unsigned n_value = data_pt->nvalue();
1086 
1087  // Storage for the velocity and acceleration
1088  Vector<double> veloc(n_value, 0.0);
1089  Vector<double> accel(n_value, 0.0);
1090 
1091  // Find number of stored time values
1092  unsigned n_tstorage = this->ntstorage();
1093 
1094  // Loop over the variables
1095  for (unsigned i = 0; i < n_value; i++)
1096  {
1097  // Loop over all the history data
1098  for (unsigned t = 0; t < n_tstorage; t++)
1099  {
1100  veloc[i] += Newmark_veloc_weight[t] * data_pt->value(t, i);
1101  accel[i] += this->weight(2, t) * data_pt->value(t, i);
1102  }
1103  }
1104 
1105 
1106  // Loop over values
1107  for (unsigned j = 0; j < n_value; j++)
1108  {
1109  // Set previous values/veloc/accel to present values/veloc/accel,
1110  // if not a copy
1111  if (data_pt->is_a_copy(j) == false)
1112  {
1113  for (unsigned t = NSTEPS; t > 0; t--)
1114  {
1115  data_pt->set_value(t, j, data_pt->value(t - 1, j));
1116  }
1117  data_pt->set_value(NSTEPS + 1, j, veloc[j]);
1118  data_pt->set_value(NSTEPS + 2, j, accel[j]);
1119  }
1120  }
1121  }
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

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

Member Data Documentation

◆ Degrade_to_bdf1_for_first_derivs

template<unsigned NSTEPS>
bool oomph::NewmarkBDF< NSTEPS >::Degrade_to_bdf1_for_first_derivs
private

Boolean flag to indicate degradation of scheme to first order BDF (for first derivs/veloc); usually for start-up.

◆ Newmark_veloc_weight

template<unsigned NSTEPS>
Vector<double> oomph::NewmarkBDF< NSTEPS >::Newmark_veloc_weight
private

Original Newmark weights for velocities (needed when shifting history values – they're used when updating the previous accelerations and doing this with bdf can make the scheme unstable...


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