55 template<
unsigned NSTEPS>
58 template<
unsigned NSTEPS>
61 template<
unsigned NSTEPS>
104 Predictor_weight[0] = 0.0;
105 Predictor_weight[1] = 1.0;
108 Predictor_weight[2] = dt;
125 unsigned n_value = data_pt->
nvalue();
127 for(
unsigned j=0;j<n_value;j++)
133 double predicted_value = 0.0;
136 for(
unsigned i=1;
i<3;
i++)
138 predicted_value += data_pt->
value(
i,j)*Predictor_weight[
i];
158 unsigned n_dim = node_pt->
ndim();
160 for(
unsigned j=0;j<n_dim;j++)
166 double predicted_value = 0.0;
169 for(
unsigned i=1;
i<3;
i++)
171 predicted_value += node_pt->
x(
i,j)*Predictor_weight[
i];
218 return Error_weight*(data_pt->
value(i)
238 Weight(1,0) = 1.0/dt + 1.0/(dt + dtprev);
239 Weight(1,1) = -(dt + dtprev)/(dt*dtprev);
240 Weight(1,2) = dt/((dt+dtprev)*dtprev);
265 Predictor_weight[0] = 0.0;
266 Predictor_weight[1] = 1.0 - (dt*dt)/(dtprev*dtprev);
267 Predictor_weight[2] = (dt*dt)/(dtprev*dtprev);
269 Predictor_weight[3] = (1.0 + dt/dtprev)*dt;
285 unsigned n_value = data_pt->
nvalue();
287 for(
unsigned j=0;j<n_value;j++)
293 double predicted_value = 0.0;
296 for(
unsigned i=1;
i<4;
i++)
298 predicted_value += data_pt->
value(
i,j)*Predictor_weight[
i];
318 unsigned n_dim = node_pt->
ndim();
320 for(
unsigned j=0;j<n_dim;j++)
326 double predicted_value = 0.0;
329 for(
unsigned i=1;
i<4;
i++)
331 predicted_value += node_pt->
x(
i,j)*Predictor_weight[
i];
352 Error_weight = pow((1.0 + dtprev/dt),2.0)/
353 (1.0 + 3.0*(dtprev/dt) + 4.0*pow((dtprev/dt),2.0) +
354 2.0*pow((dtprev/dt),3.0));
388 return Error_weight*(data_pt->
value(i)
411 "BDF4 currently only works for fixed timesteps \n",
412 OOMPH_CURRENT_FUNCTION,
413 OOMPH_EXCEPTION_LOCATION);
418 Weight(1,0) = 25.0/12.0/dt;
419 Weight(1,1) = -48.0/12.0/dt;
420 Weight(1,2) = 36.0/12.0/dt;
421 Weight(1,3) = -16.0/12.0/dt;
422 Weight(1,4) = 3.0/12.0/dt;
437 OOMPH_CURRENT_FUNCTION,
438 OOMPH_EXCEPTION_LOCATION);
450 OOMPH_CURRENT_FUNCTION,
451 OOMPH_EXCEPTION_LOCATION);
460 OOMPH_CURRENT_FUNCTION,
461 OOMPH_EXCEPTION_LOCATION);
469 OOMPH_CURRENT_FUNCTION,
470 OOMPH_EXCEPTION_LOCATION);
481 OOMPH_CURRENT_FUNCTION,
482 OOMPH_EXCEPTION_LOCATION);
494 OOMPH_CURRENT_FUNCTION,
495 OOMPH_EXCEPTION_LOCATION);
512 template<
unsigned NSTEPS>
516 unsigned n_value = data_pt->
nvalue();
519 for(
unsigned j=0;j<n_value;j++)
524 for (
unsigned t=1;
t<=NSTEPS;
t++)
541 template<
unsigned NSTEPS>
545 unsigned n_dim = node_pt->
ndim();
550 for(
unsigned i=0;
i<n_dim;
i++)
556 for(
unsigned k=0;k<n_position_type;k++)
559 for (
unsigned t=1;
t<=NSTEPS;
t++)
565 node_pt->
x_gen(NSTEPS+1,k,
i) = 0.0;
566 node_pt->
x_gen(NSTEPS+2,k,
i) = 0.0;
579 template<
unsigned NSTEPS>
593 if(initial_value_fct.size() != initial_veloc_fct.size() ||
594 initial_value_fct.size() != initial_accel_fct.size())
597 "The Vectors of fcts for values, velocities and acceleration must be the same size",
598 OOMPH_CURRENT_FUNCTION,
599 OOMPH_EXCEPTION_LOCATION);
604 unsigned n_fcts = initial_value_fct.size();
609 unsigned n_value = data_pt->
nvalue();
612 std::stringstream message;
613 message <<
"There are more data values than initial value fcts.\n";
614 message <<
"Only the first " << n_fcts <<
" data values will be set\n";
616 OOMPH_CURRENT_FUNCTION,
617 OOMPH_EXCEPTION_LOCATION);
622 for(
unsigned j=0;j<n_fcts;j++)
624 if (initial_value_fct[j]==0)
629 std::stringstream message;
630 message <<
"Ignoring value " << j <<
" in assignment of ic.\n";
632 "Newmark<NSTEPS>::assign_initial_data_values",
633 OOMPH_EXCEPTION_LOCATION);
640 for (
unsigned t=0;
t<=NSTEPS;
t++)
643 data_pt->
set_value(
t,j,initial_value_fct[j](time_local));
654 double U = initial_value_fct[j](time_);
658 double U0 = initial_value_fct[j](time_);
663 double Udot = initial_veloc_fct[j](time_);
668 double Udotdot = initial_accel_fct[j](time_);
675 matrix(0,0)=
Weight(2,NSTEPS+1);
676 matrix(0,1)=
Weight(2,NSTEPS+2);
677 matrix(1,0)=
Weight(1,NSTEPS+1);
678 matrix(1,1)=
Weight(1,NSTEPS+2);
702 template<
unsigned NSTEPS>
704 Node*
const & node_pt,
715 if(initial_value_fct.size() != initial_veloc_fct.size() ||
716 initial_value_fct.size() != initial_accel_fct.size())
718 throw OomphLibError(
"The Vectors of fcts for values, velocities and acceleration must be the same size",
719 "Newmark<NSTEPS>::assign_initial_data_values",
720 OOMPH_EXCEPTION_LOCATION);
725 unsigned n_fcts = initial_value_fct.size();
730 unsigned n_value = node_pt->
nvalue();
733 std::stringstream message;
734 message <<
"There are more nodal values than initial value fcts.\n";
735 message <<
"Only the first " << n_fcts <<
" nodal values will be set\n";
737 OOMPH_CURRENT_FUNCTION,
738 OOMPH_EXCEPTION_LOCATION);
743 unsigned n_dim=node_pt->
ndim();
745 for (
unsigned i=0;
i<n_dim;
i++) x[
i]=node_pt->
x(
i);
748 for(
unsigned j=0;j<n_fcts;j++)
750 if (initial_value_fct[j]==0)
755 std::stringstream message;
756 message <<
"Ignoring value " << j <<
" in assignment of ic.\n";
758 OOMPH_CURRENT_FUNCTION,
759 OOMPH_EXCEPTION_LOCATION);
766 for (
unsigned t=0;
t<=NSTEPS;
t++)
769 node_pt->
set_value(
t,j,initial_value_fct[j](time_local,x));
780 double U = initial_value_fct[j](time_,x);
784 double U0 = initial_value_fct[j](time_,x);
789 double Udot = initial_veloc_fct[j](time_,x);
794 double Udotdot = initial_accel_fct[j](time_,x);
801 matrix(0,0)=
Weight(2,NSTEPS+1);
802 matrix(0,1)=
Weight(2,NSTEPS+2);
803 matrix(1,0)=
Weight(1,NSTEPS+1);
804 matrix(1,1)=
Weight(1,NSTEPS+2);
846 template<
unsigned NSTEPS>
848 Data*
const &data_pt)
851 unsigned n_value = data_pt->
nvalue();
854 for(
unsigned j=0;j<n_value;j++)
882 std::ostringstream error_message_stream;
883 error_message_stream <<
"t_deriv " << t_deriv
884 <<
" is not possible with a Newmark scheme " 888 error_message_stream.str(),
889 OOMPH_CURRENT_FUNCTION,
890 OOMPH_EXCEPTION_LOCATION);
906 template<
unsigned NSTEPS>
910 unsigned n_value = data_pt->
nvalue();
913 for(
unsigned j=0;j<n_value;j++)
921 double U = data_pt->
value(1,j);
924 double U0 = data_pt->
value(0,j);
927 double Udot = data_pt->
value(NSTEPS+1,j);
930 double Udotdot = data_pt->
value(NSTEPS+2,j);
937 matrix(0,0)=
Weight(2,NSTEPS+1);
938 matrix(0,1)=
Weight(2,NSTEPS+2);
939 matrix(1,0)=
Weight(1,NSTEPS+1);
940 matrix(1,1)=
Weight(1,NSTEPS+2);
969 template<
unsigned NSTEPS>
973 unsigned n_value = data_pt->
nvalue();
982 for(
unsigned j=0;j<n_value;j++)
988 for (
unsigned t=NSTEPS;
t>0;
t--)
1002 template<
unsigned NSTEPS>
1006 unsigned n_dim = node_pt->
ndim();
1011 double veloc[n_position_type][n_dim];
1012 double accel[n_position_type][n_dim];
1018 for(
unsigned i=0;
i<n_dim;
i++)
1020 for(
unsigned k=0;k<n_position_type;k++)
1022 veloc[k][
i] = accel[k][
i] = 0.0;
1024 for(
unsigned t=0;
t<n_tstorage;
t++)
1033 for(
unsigned i=0;
i<n_dim;
i++)
1039 for(
unsigned k=0;k<n_position_type;k++)
1043 for(
unsigned t=NSTEPS;
t>0;
t--)
1048 node_pt->
x_gen(NSTEPS+1,k,
i) = veloc[k][
i];
1049 node_pt->
x_gen(NSTEPS+2,k,
i) = accel[k][
i];
1058 template<
unsigned NSTEPS>
1065 Weight(2,0)= 2.0/(Beta2*dt*dt);
1066 Weight(2,1)=-2.0/(Beta2*dt*dt);
1067 for (
unsigned t=2;
t<=NSTEPS;
t++)
1071 Weight(2,NSTEPS+1)=-2.0/(dt*Beta2);
1072 Weight(2,NSTEPS+2)=(Beta2-1.0)/Beta2;
1077 for (
unsigned t=2;
t<=NSTEPS;
t++)
1082 Weight(1,NSTEPS+2)=dt*(1.0-Beta1)+Beta1*dt*
Weight(2,NSTEPS+2);
1102 template<
unsigned NSTEPS>
1106 unsigned n_value = data_pt->
nvalue();
1113 unsigned n_tstorage = this->
ntstorage();
1116 for(
unsigned i=0;
i<n_value;
i++)
1119 for(
unsigned t=0;
t<n_tstorage;
t++)
1121 veloc[
i] += Newmark_veloc_weight[
t]*data_pt->
value(
t,
i);
1128 for(
unsigned j=0;j<n_value;j++)
1134 for (
unsigned t=NSTEPS;
t>0;
t--)
1138 data_pt->
set_value(NSTEPS+1,j,veloc[j]);
1139 data_pt->
set_value(NSTEPS+2,j,accel[j]);
1148 template<
unsigned NSTEPS>
1152 unsigned n_dim = node_pt->
ndim();
1157 double veloc[n_position_type][n_dim];
1158 double accel[n_position_type][n_dim];
1164 for(
unsigned i=0;
i<n_dim;
i++)
1166 for(
unsigned k=0;k<n_position_type;k++)
1168 veloc[k][
i] = accel[k][
i] = 0.0;
1170 for(
unsigned t=0;
t<n_tstorage;
t++)
1172 veloc[k][
i] += Newmark_veloc_weight[
t]*node_pt->
x_gen(
t,k,
i);
1179 for(
unsigned i=0;
i<n_dim;
i++)
1185 for(
unsigned k=0;k<n_position_type;k++)
1189 for(
unsigned t=NSTEPS;
t>0;
t--)
1194 node_pt->
x_gen(NSTEPS+1,k,
i) = veloc[k][
i];
1195 node_pt->
x_gen(NSTEPS+2,k,
i) = accel[k][
i];
1210 Weight(2,0)= 2.0/(Beta2*dt*dt);
1211 Weight(2,1)=-2.0/(Beta2*dt*dt);
1212 Weight(2,2)=-2.0/(dt*Beta2);
1213 Weight(2,3)=(Beta2-1.0)/Beta2;
1222 set_newmark_veloc_weights(dt);
1233 Weight(2,0)= 2.0/(Beta2*dt*dt);
1234 Weight(2,1)=-2.0/(Beta2*dt*dt);
1236 Weight(2,3)=-2.0/(dt*Beta2);
1237 Weight(2,4)=(Beta2-1.0)/Beta2;
1240 if (Degrade_to_bdf1_for_first_derivs)
1242 this->
Weight(1,0) = 1.0/dt;
1243 this->
Weight(1,1) = -1.0/dt;
1245 for (
unsigned i=2;
i<nweights;
i++)
1253 Weight(1,0) = 1.0/dt + 1.0/(dt + dtprev);
1254 Weight(1,1) = -(dt + dtprev)/(dt*dtprev);
1255 Weight(1,2) = dt/((dt+dtprev)*dtprev);
1261 set_newmark_veloc_weights(dt);
1272 Weight(2,0)= 2.0/(Beta2*dt*dt);
1273 Weight(2,1)=-2.0/(Beta2*dt*dt);
1277 Weight(2,5)=-2.0/(dt*Beta2);
1278 Weight(2,6)=(Beta2-1.0)/Beta2;
1287 "BDF4 currently only works for fixed timesteps \n",
1288 OOMPH_CURRENT_FUNCTION,
1289 OOMPH_EXCEPTION_LOCATION);
1295 if (Degrade_to_bdf1_for_first_derivs)
1297 this->
Weight(1,0) = 1.0/dt;
1298 this->
Weight(1,1) = -1.0/dt;
1300 for (
unsigned i=2;
i<nweights;
i++)
1307 Weight(1,0) = 25.0/12.0/dt;
1308 Weight(1,1) = -48.0/12.0/dt;
1309 Weight(1,2) = 36.0/12.0/dt;
1310 Weight(1,3) = -16.0/12.0/dt;
1311 Weight(1,4) = 3.0/12.0/dt;
1317 set_newmark_veloc_weights(dt);
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
double value(const unsigned &i) const
Return i-th stored value. This function is not virtual so that it can be inlined. This means that if ...
bool Shut_up_in_assign_initial_data_values
Boolean to indicate if the timestepper will output warnings when setting possibly an incorrect number...
unsigned long ncol() const
Return the number of columns of the matrix.
void set_weights()
Set weights.
Class to keep track of discrete/continous time. It is essential to have a single Time object when usi...
void assign_initial_positions_impulsive(Node *const &node_pt)
Initialise the time-history for the values, corresponding to an impulsive start.
virtual ~TimeStepper()
virtual destructor
ExplicitTimeStepper * Explicit_predictor_pt
void set_predictor_weights()
Function to set the predictor weights.
void shift_time_positions(Node *const &node_pt)
This function updates a nodal time history so that we can advance to the next timestep.
void calculate_predicted_positions(Node *const &node_pt)
Function to calculate predicted positions at a node.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
int Predictor_storage_index
The time-index in each Data object where predicted values are stored. -1 if not set.
void assign_initial_data_values(Data *const &data_pt, Vector< InitialConditionFctPt > initial_value_fct, Vector< InitialConditionFctPt > initial_veloc_fct, Vector< InitialConditionFctPt > initial_accel_fct)
Initialise the time-history for the Data values, so that the Newmark representations for current velo...
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
void set_error_weights()
Function to set the error weights.
Newmark scheme for second time deriv. Stored data represents.
void solve(DoubleVector &rhs)
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution)...
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
void assign_initial_values_impulsive(Data *const &data_pt)
Initialise the time-history for the values, corresponding to an impulsive start.
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
bool adaptive_flag() const
Function to indicate whether the scheme is adaptive (false by default)
virtual void set_weights()=0
Function to set the weights for present timestep (don't need to pass present timestep or previous tim...
void set_value(const unsigned &i, const double &value_)
Set the i-th stored data value to specified value. The only reason that we require an explicit set fu...
double & dt(const unsigned &t=0)
unsigned nposition_type() const
Number of coordinate types needed in the mapping between local and global coordinates.
Time * Time_pt
Pointer to discrete time storage scheme.
unsigned ndt() const
Return the number of timesteps stored.
A class that represents a collection of data; each Data object may contain many different individual ...
void set_weights()
Set the weights.
double & x_gen(const unsigned &k, const unsigned &i)
Reference to the generalised position x(k,i).
double temporal_error_in_position(Node *const &node_pt, const unsigned &i)
Compute the error in the position i at a node.
void shift_time_values(Data *const &data_pt)
This function updates the Data's time history so that we can advance to the next timestep.
double & time()
Return the current value of the continuous time.
double temporal_error_in_value(Data *const &data_pt, const unsigned &i)
Compute the error in the value i in a Data structure.
void shift_time_values(Data *const &data_pt)
This function updates the Data's time history so that we can advance to the next timestep.
void assign_initial_data_values_stage1(const unsigned t_deriv, Data *const &data_pt)
First step in a two-stage procedure to assign the history values for the Newmark scheme so that the v...
void assign_initial_data_values_stage2(Data *const &data_pt)
Second step in a two-stage procedure to assign the history values for the Newmark scheme so that the ...
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
Newmark scheme for second time deriv with first derivatives calculated using BDF. ...
virtual bool position_is_a_copy() const
Return whether any position coordinate has been copied (always false)
void calculate_predicted_values(Data *const &data_pt)
Function to calculate predicted data values in a Data object.
void shift_time_positions(Node *const &node_pt)
This function updates a nodal time history so that we can advance to the next timestep.
void time_derivative(const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
Evaluate i-th derivative of all values in Data and return in Vector deriv[].
virtual bool is_a_copy() const
Return a boolean to indicate whether the Data objact contains any copied values. A base Data object c...
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
void set_weights()
Set weights.