oomph::Newmark< NSTEPS > Class Template Reference

#include <timesteppers.h>

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

Public Types

typedef double(* InitialConditionFctPt) (const double &t)
 
typedef double(* NodeInitialConditionFctPt) (const double &t, const Vector< double > &x)
 

Public Member Functions

 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)
 
void shift_time_values (Data *const &data_pt)
 
void shift_time_positions (Node *const &node_pt)
 
void set_weights ()
 Set weights. More...
 
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)
 

Protected Attributes

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::Newmark< NSTEPS >

////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// Newmark scheme for second time deriv. 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.

Member Typedef Documentation

◆ InitialConditionFctPt

template<unsigned NSTEPS>
typedef double(* oomph::Newmark< NSTEPS >::InitialConditionFctPt) (const double &t)

Typedef for function that returns the (scalar) initial value at a given value of the continuous time t.

◆ NodeInitialConditionFctPt

template<unsigned NSTEPS>
typedef double(* oomph::Newmark< NSTEPS >::NodeInitialConditionFctPt) (const double &t, const Vector< double > &x)

Typedef for function that returns the (scalar) initial value at a given value of the continuous time t and the spatial coordinate – appropriate for assignement of initial conditions for nodes

Constructor & Destructor Documentation

◆ Newmark() [1/2]

template<unsigned NSTEPS>
oomph::Newmark< NSTEPS >::Newmark ( )
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.

917  : TimeStepper(NSTEPS + 3, 2)
918  {
919  Type = "Newmark";
920 
921  // Standard Newmark parameters
922  Beta1 = 0.5;
923  Beta2 = 0.5;
924  }
double Beta2
Second Newmark parameter (usually 0.5)
Definition: timesteppers.h:1049
double Beta1
First Newmark parameter (usually 0.5)
Definition: timesteppers.h:1046
std::string Type
Definition: timesteppers.h:241
TimeStepper()
Broken empty constructor.
Definition: timesteppers.h:301

References GlobalParameters::Beta1.

◆ Newmark() [2/2]

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

Broken copy constructor.

Member Function Documentation

◆ assign_initial_data_values() [1/2]

template<unsigned NSTEPS>
void oomph::Newmark< NSTEPS >::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 veloc and acceleration are exact.

574  {
575  // Set weights
576  set_weights();
577 
578 #ifdef PARANOID
579  // Check if the 3 vectors of functions have the same size
580  if (initial_value_fct.size() != initial_veloc_fct.size() ||
581  initial_value_fct.size() != initial_accel_fct.size())
582  {
583  throw OomphLibError("The Vectors of fcts for values, velocities and "
584  "acceleration must be the same size",
587  }
588 #endif
589 
590  // The number of functions in each vector (they should be the same)
591  unsigned n_fcts = initial_value_fct.size();
592 
593 #ifdef PARANOID
594 
595  // If there are more data values at the node than functions, issue a warning
596  unsigned n_value = data_pt->nvalue();
597  if (n_value > n_fcts && !Shut_up_in_assign_initial_data_values)
598  {
599  std::stringstream message;
600  message << "There are more data values than initial value fcts.\n";
601  message << "Only the first " << n_fcts << " data values will be set\n";
602  OomphLibWarning(
604  }
605 #endif
606 
607  // Loop over elements of the function vectors
608  for (unsigned j = 0; j < n_fcts; j++)
609  {
610  if (initial_value_fct[j] == 0)
611  {
612 #ifdef PARANOID
614  {
615  std::stringstream message;
616  message << "Ignoring value " << j << " in assignment of ic.\n";
617  OomphLibWarning(message.str(),
618  "Newmark<NSTEPS>::assign_initial_data_values",
620  }
621 #endif
622  }
623  else
624  {
625  // Value itself at current and previous times
626  for (unsigned t = 0; t <= NSTEPS; t++)
627  {
628  double time_local = Time_pt->time(t);
629  data_pt->set_value(t, j, initial_value_fct[j](time_local));
630  }
631 
632  // Now, rather than assigning the values for veloc and accel
633  // in the Newmark scheme directly, we solve a linear system
634  // to determine the values required to make the Newmark
635  // representations of the veloc and accel at the current (!)
636  // time are exact.
637 
638  // Initial time: The value itself
639  double time_ = Time_pt->time();
640  double U = initial_value_fct[j](time_);
641 
642  // Value itself at previous time
643  time_ = Time_pt->time(1);
644  double U0 = initial_value_fct[j](time_);
645 
646  // Veloc (time deriv) at present time -- this is what the
647  // Newmark scheme should return!
648  time_ = Time_pt->time(0);
649  double Udot = initial_veloc_fct[j](time_);
650 
651  // Acccel (2nd time deriv) at present time -- this is what the
652  // Newmark scheme should return!
653  time_ = Time_pt->time(0);
654  double Udotdot = initial_accel_fct[j](time_);
655 
656  Vector<double> vect(2);
657  vect[0] = Udotdot - Weight(2, 0) * U - Weight(2, 1) * U0;
658  vect[1] = Udot - Weight(1, 0) * U - Weight(1, 1) * U0;
659 
660  DenseDoubleMatrix matrix(2, 2);
661  matrix(0, 0) = Weight(2, NSTEPS + 1);
662  matrix(0, 1) = Weight(2, NSTEPS + 2);
663  matrix(1, 0) = Weight(1, NSTEPS + 1);
664  matrix(1, 1) = Weight(1, NSTEPS + 2);
665 
666  matrix.solve(vect);
667 
668  // Discrete veloc (time deriv) at previous time , to be entered into the
669  // Newmark scheme so that its prediction for the *current* veloc
670  // and accel is correct.
671  data_pt->set_value(NSTEPS + 1, j, vect[0]);
672 
673  // Discrete veloc (2nd time deriv) at previous time, to be entered into
674  // the Newmark scheme so that its prediction for the *current* veloc
675  // and accel is correct.
676  data_pt->set_value(NSTEPS + 2, j, vect[1]);
677  }
678  }
679  }
void set_weights()
Set weights.
Definition: timesteppers.cc:1039
DenseMatrix< double > Weight
Storage for the weights associated with the timestepper.
Definition: timesteppers.h:237
bool Shut_up_in_assign_initial_data_values
Definition: timesteppers.h:256
Time * Time_pt
Pointer to discrete time storage scheme.
Definition: timesteppers.h:234
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
double U0
Constant/initial temperature.
Definition: circular_boulder_melt.cc:99
double U
Swimming speed.
Definition: two_d_variable_diff_adapt.cc:53
t
Definition: plotPSD.py:36
#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 j, matrix(), oomph::Data::nvalue(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Data::set_value(), plotPSD::t, Flag_definition::Time_pt, RachelsAdvectionDiffusion::U, ExactSolution::U0, and ProblemParameters::Weight.

◆ assign_initial_data_values() [2/2]

template<unsigned NSTEPS>
void oomph::Newmark< NSTEPS >::assign_initial_data_values ( Node *const &  node_pt,
Vector< NodeInitialConditionFctPt initial_value_fct,
Vector< NodeInitialConditionFctPt initial_veloc_fct,
Vector< NodeInitialConditionFctPt initial_accel_fct 
)

Initialise the time-history for the nodal values, so that the Newmark representations for current veloc and acceleration are exact.

Initialise the time-history for the Data values, so that the Newmark representations for current veloc and acceleration are exact.

693  {
694  // Set weights
695  set_weights();
696 
697 
698 #ifdef PARANOID
699  // Check if the 3 vectors of functions have the same size
700  if (initial_value_fct.size() != initial_veloc_fct.size() ||
701  initial_value_fct.size() != initial_accel_fct.size())
702  {
703  throw OomphLibError("The Vectors of fcts for values, velocities and "
704  "acceleration must be the same size",
705  "Newmark<NSTEPS>::assign_initial_data_values",
707  }
708 #endif
709 
710  // The number of functions in each vector (they should be the same)
711  unsigned n_fcts = initial_value_fct.size();
712 
713 #ifdef PARANOID
714 
715  // If there are more data values at the node than functions, issue a warning
716  unsigned n_value = node_pt->nvalue();
717  if (n_value > n_fcts && !Shut_up_in_assign_initial_data_values)
718  {
719  std::stringstream message;
720  message << "There are more nodal values than initial value fcts.\n";
721  message << "Only the first " << n_fcts << " nodal values will be set\n";
722  OomphLibWarning(
724  }
725 #endif
726 
727  // Get current nodal coordinates
728  unsigned n_dim = node_pt->ndim();
729  Vector<double> x(n_dim);
730  for (unsigned i = 0; i < n_dim; i++) x[i] = node_pt->x(i);
731 
732  // Loop over values
733  for (unsigned j = 0; j < n_fcts; j++)
734  {
735  if (initial_value_fct[j] == 0)
736  {
737 #ifdef PARANOID
739  {
740  std::stringstream message;
741  message << "Ignoring value " << j << " in assignment of ic.\n";
742  OomphLibWarning(
744  }
745 #endif
746  }
747  else
748  {
749  // Value itself at current and previous times
750  for (unsigned t = 0; t <= NSTEPS; t++)
751  {
752  double time_local = Time_pt->time(t);
753  node_pt->set_value(t, j, initial_value_fct[j](time_local, x));
754  }
755 
756  // Now, rather than assigning the values for veloc and accel
757  // in the Newmark scheme directly, we solve a linear system
758  // to determine the values required to make the Newmark
759  // representations of the veloc and accel at the current (!)
760  // time are exact.
761 
762  // Initial time: The value itself
763  double time_ = Time_pt->time();
764  double U = initial_value_fct[j](time_, x);
765 
766  // Value itself at previous time
767  time_ = Time_pt->time(1);
768  double U0 = initial_value_fct[j](time_, x);
769 
770  // Veloc (time deriv) at present time -- this is what the
771  // Newmark scheme should return!
772  time_ = Time_pt->time(0);
773  double Udot = initial_veloc_fct[j](time_, x);
774 
775  // Acccel (2nd time deriv) at present time -- this is what the
776  // Newmark scheme should return!
777  time_ = Time_pt->time(0);
778  double Udotdot = initial_accel_fct[j](time_, x);
779 
780  Vector<double> vect(2);
781  vect[0] = Udotdot - Weight(2, 0) * U - Weight(2, 1) * U0;
782  vect[1] = Udot - Weight(1, 0) * U - Weight(1, 1) * U0;
783 
784  DenseDoubleMatrix matrix(2, 2);
785  matrix(0, 0) = Weight(2, NSTEPS + 1);
786  matrix(0, 1) = Weight(2, NSTEPS + 2);
787  matrix(1, 0) = Weight(1, NSTEPS + 1);
788  matrix(1, 1) = Weight(1, NSTEPS + 2);
789 
790  matrix.solve(vect);
791 
792  // Discrete veloc (time deriv) at previous time , to be entered into the
793  // Newmark scheme so that its prediction for the *current* veloc
794  // and accel is correct.
795  node_pt->set_value(NSTEPS + 1, j, vect[0]);
796 
797  // Discrete veloc (2nd time deriv) at previous time, to be entered into
798  // the Newmark scheme so that its prediction for the *current* veloc
799  // and accel is correct.
800  node_pt->set_value(NSTEPS + 2, j, vect[1]);
801  }
802  }
803  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
list x
Definition: plotDoE.py:28

References i, j, matrix(), oomph::Node::ndim(), oomph::Data::nvalue(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Data::set_value(), plotPSD::t, Flag_definition::Time_pt, RachelsAdvectionDiffusion::U, ExactSolution::U0, ProblemParameters::Weight, plotDoE::x, and oomph::Node::x().

◆ assign_initial_data_values_stage1()

template<unsigned NSTEPS>
void oomph::Newmark< NSTEPS >::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 veloc and accel that are computed by the scheme are correct at the current time.

Call this function for t_deriv=0,1,2,3. When calling with

  • t_deriv=0 : data_pt(0,*) should contain the values at the previous timestep
  • t_deriv=1 : data_pt(0,*) should contain the current values; they get stored (temporarily) in data_pt(1,*).
  • t_deriv=2 : data_pt(0,*) should contain the current velocities (first time derivs); they get stored (temporarily) in data_pt(NSTEPS+1,*).
  • t_deriv=3 : data_pt(0,*) should contain the current accelerations (second time derivs); they get stored (temporarily) in data_pt(NSTEPS+2,*).

Follow this by calls to

void assign_initial_data_values_stage2(Data *const &data_pt)
Definition: timesteppers.cc:889
833  {
834  // Find number of values stored
835  unsigned n_value = data_pt->nvalue();
836 
837  // Loop over values
838  for (unsigned j = 0; j < n_value; j++)
839  {
840  // Which deriv are we dealing with?
841  switch (t_deriv)
842  {
843  // 0-th deriv: the value itself at present time
844  case 0:
845 
846  data_pt->set_value(1, j, data_pt->value(j));
847  break;
848 
849  // 1st deriv: the veloc at present time
850  case 1:
851 
852  data_pt->set_value(NSTEPS + 1, j, data_pt->value(j));
853  break;
854 
855  // 2nd deriv: the accel at present time
856  case 2:
857 
858  data_pt->set_value(NSTEPS + 2, j, data_pt->value(j));
859  break;
860 
861 
862  // None other are possible!
863  default:
864 
865  std::ostringstream error_message_stream;
866  error_message_stream << "t_deriv " << t_deriv
867  << " is not possible with a Newmark scheme "
868  << std::endl;
869 
870  throw OomphLibError(error_message_stream.str(),
873  }
874  }
875  }

References j, oomph::Data::nvalue(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Data::set_value(), and oomph::Data::value().

◆ assign_initial_data_values_stage2()

template<unsigned NSTEPS>
void oomph::Newmark< NSTEPS >::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 veloc and accel that are computed by the scheme are correct at the current time.

This assigns appropriate values for the "previous velocities and accelerations" so that their current values, which were defined in assign_initial_data_values_stage1(...), are represented exactly by the Newmark scheme.

890  {
891  // Find number of values stored
892  unsigned n_value = data_pt->nvalue();
893 
894  // Loop over values
895  for (unsigned j = 0; j < n_value; j++)
896  {
897  // Rather than assigning the previous veloc and accel
898  // directly, solve linear system to determine their values
899  // so that the Newmark representations are exact.
900 
901  // The exact value at present time (stored in stage 1)
902  double U = data_pt->value(1, j);
903 
904  // Exact value at previous time
905  double U0 = data_pt->value(0, j);
906 
907  // Veloc (1st time deriv) at present time (stored in stage 1)
908  double Udot = data_pt->value(NSTEPS + 1, j);
909 
910  // Acccel (2nd time deriv) at present time (stored in stage 1)
911  double Udotdot = data_pt->value(NSTEPS + 2, j);
912 
913  Vector<double> vect(2);
914  vect[0] = Udotdot - Weight(2, 0) * U - Weight(2, 1) * U0;
915  vect[1] = Udot - Weight(1, 0) * U - Weight(1, 1) * U0;
916 
917  DenseDoubleMatrix matrix(2, 2);
918  matrix(0, 0) = Weight(2, NSTEPS + 1);
919  matrix(0, 1) = Weight(2, NSTEPS + 2);
920  matrix(1, 0) = Weight(1, NSTEPS + 1);
921  matrix(1, 1) = Weight(1, NSTEPS + 2);
922 
923  matrix.solve(vect);
924 
925 
926  // Now assign the discrete coefficients
927  // so that the Newmark scheme returns the correct
928  // results for the present values, and 1st and 2nd derivatives:
929 
930  // Value at present time
931  data_pt->set_value(0, j, U);
932 
933  // Value at previous time
934  data_pt->set_value(1, j, U0);
935 
936  // Veloc (time deriv) at previous time
937  data_pt->set_value(NSTEPS + 1, j, vect[0]);
938 
939  // Acccel (2nd time deriv) at previous time
940  data_pt->set_value(NSTEPS + 2, j, vect[1]);
941  }
942  }

References j, matrix(), oomph::Data::nvalue(), oomph::Data::set_value(), RachelsAdvectionDiffusion::U, ExactSolution::U0, oomph::Data::value(), and ProblemParameters::Weight.

◆ assign_initial_positions_impulsive()

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

Initialise the time-history for the values, corresponding to an impulsive start.

Implements oomph::TimeStepper.

533  {
534  // Find the number of coordinates
535  unsigned n_dim = node_pt->ndim();
536  // Find the number of position types
537  unsigned n_position_type = node_pt->nposition_type();
538 
539  // Loop over values
540  for (unsigned i = 0; i < n_dim; i++)
541  {
542  // If not a copy
543  if (node_pt->position_is_a_copy(i) == false)
544  {
545  // Loop over the position types
546  for (unsigned k = 0; k < n_position_type; k++)
547  {
548  // Set previous value to the initial value, if not a copy
549  for (unsigned t = 1; t <= NSTEPS; t++)
550  {
551  node_pt->x_gen(t, k, i) = node_pt->x_gen(k, i);
552  }
553 
554  // Initial velocity and initial acceleration are zero
555  node_pt->x_gen(NSTEPS + 1, k, i) = 0.0;
556  node_pt->x_gen(NSTEPS + 2, k, i) = 0.0;
557  }
558  }
559  }
560  }
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().

◆ assign_initial_values_impulsive()

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

Initialise the time-history for the values, corresponding to an impulsive start.

////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// Initialise the time-history for the values, corresponding to an impulsive start.

Implements oomph::TimeStepper.

504  {
505  // Find number of values stored in Data object
506  unsigned n_value = data_pt->nvalue();
507 
508  // Loop over values
509  for (unsigned j = 0; j < n_value; j++)
510  {
511  // Set previous values to the initial value, if not a copy
512  if (data_pt->is_a_copy(j) == false)
513  {
514  for (unsigned t = 1; t <= NSTEPS; t++)
515  {
516  data_pt->set_value(t, j, data_pt->value(j));
517  }
518  }
519 
520  // Initial velocity and initial acceleration are zero
521  data_pt->set_value(NSTEPS + 1, j, 0.0);
522  data_pt->set_value(NSTEPS + 2, j, 0.0);
523  }
524  }

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

◆ ndt()

template<unsigned NSTEPS>
unsigned oomph::Newmark< NSTEPS >::ndt ( ) const
inlinevirtual

Number of timestep increments that need to be stored by the scheme.

Implements oomph::TimeStepper.

1039  {
1040  return NSTEPS;
1041  }

◆ nprev_values()

template<unsigned NSTEPS>
unsigned oomph::Newmark< NSTEPS >::nprev_values ( ) const
inlinevirtual

Number of previous values available.

Implements oomph::TimeStepper.

1033  {
1034  return NSTEPS;
1035  }

◆ operator=()

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

Broken assignment operator.

◆ order()

template<unsigned NSTEPS>
unsigned oomph::Newmark< NSTEPS >::order ( ) const
inlinevirtual

The actual order (accuracy of the scheme)

Reimplemented from oomph::TimeStepper.

935  {
936  std::string error_message =
937  "Can't remember the order of the Newmark scheme";
938  error_message += " -- I think it's 2nd order...\n";
939 
940  OomphLibWarning(
941  error_message, "Newmark::order()", OOMPH_EXCEPTION_LOCATION);
942  return 2;
943  }
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ set_weights()

template<unsigned NSTEPS>
void oomph::Newmark< NSTEPS >::set_weights
virtual

Set weights.

Implements oomph::TimeStepper.

Reimplemented in oomph::NewmarkBDF< NSTEPS >, oomph::NewmarkBDF< NSTEPS >, oomph::NewmarkBDF< NSTEPS >, and oomph::NewmarkBDF< NSTEPS >.

1040  {
1041  double dt = Time_pt->dt(0);
1042 
1043  // Weights for second derivs
1044  Weight(2, 0) = 2.0 / (Beta2 * dt * dt);
1045  Weight(2, 1) = -2.0 / (Beta2 * dt * dt);
1046  for (unsigned t = 2; t <= NSTEPS; t++)
1047  {
1048  Weight(2, t) = 0.0;
1049  }
1050  Weight(2, NSTEPS + 1) = -2.0 / (dt * Beta2);
1051  Weight(2, NSTEPS + 2) = (Beta2 - 1.0) / Beta2;
1052 
1053  // Weights for first derivs.
1054  Weight(1, 0) = Beta1 * dt * Weight(2, 0);
1055  Weight(1, 1) = Beta1 * dt * Weight(2, 1);
1056  for (unsigned t = 2; t <= NSTEPS; t++)
1057  {
1058  Weight(1, t) = 0.0;
1059  }
1060  Weight(1, NSTEPS + 1) = 1.0 + Beta1 * dt * Weight(2, NSTEPS + 1);
1061  Weight(1, NSTEPS + 2) =
1062  dt * (1.0 - Beta1) + Beta1 * dt * Weight(2, NSTEPS + 2);
1063  }
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136

References GlobalParameters::Beta1, plotPSD::t, Flag_definition::Time_pt, and ProblemParameters::Weight.

◆ shift_time_positions()

template<unsigned NSTEPS>
void oomph::Newmark< 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.

Implements oomph::TimeStepper.

Reimplemented in oomph::NewmarkBDF< NSTEPS >.

984  {
985  // Find the number of coordinates
986  unsigned n_dim = node_pt->ndim();
987  // Find the number of position types
988  unsigned n_position_type = node_pt->nposition_type();
989 
990  // Storage for the velocity and acceleration
991  double veloc[n_position_type][n_dim];
992  double accel[n_position_type][n_dim];
993 
994  // Find number of stored time values
995  unsigned n_tstorage = ntstorage();
996 
997  // Loop over the variables
998  for (unsigned i = 0; i < n_dim; i++)
999  {
1000  for (unsigned k = 0; k < n_position_type; k++)
1001  {
1002  veloc[k][i] = accel[k][i] = 0.0;
1003  // Loop over all the history data
1004  for (unsigned t = 0; t < n_tstorage; t++)
1005  {
1006  veloc[k][i] += weight(1, t) * node_pt->x_gen(t, k, i);
1007  accel[k][i] += weight(2, t) * node_pt->x_gen(t, k, i);
1008  }
1009  }
1010  }
1011 
1012  // Loop over the position variables
1013  for (unsigned i = 0; i < n_dim; i++)
1014  {
1015  // If not a copy
1016  if (node_pt->position_is_a_copy(i) == false)
1017  {
1018  // Loop over position types
1019  for (unsigned k = 0; k < n_position_type; k++)
1020  {
1021  // Set previous values/veloc/accel to present values/veloc/accel,
1022  // if not a copy
1023  for (unsigned t = NSTEPS; t > 0; t--)
1024  {
1025  node_pt->x_gen(t, k, i) = node_pt->x_gen(t - 1, k, i);
1026  }
1027 
1028  node_pt->x_gen(NSTEPS + 1, k, i) = veloc[k][i];
1029  node_pt->x_gen(NSTEPS + 2, k, i) = accel[k][i];
1030  }
1031  }
1032  }
1033  }
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

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

◆ shift_time_values()

template<unsigned NSTEPS>
void oomph::Newmark< 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.

Implements oomph::TimeStepper.

Reimplemented in oomph::NewmarkBDF< NSTEPS >.

951  {
952  // Find number of values stored
953  unsigned n_value = data_pt->nvalue();
954 
955  Vector<double> veloc(n_value);
956  time_derivative(1, data_pt, veloc);
957 
958  Vector<double> accel(n_value);
959  time_derivative(2, data_pt, accel);
960 
961  // Loop over values
962  for (unsigned j = 0; j < n_value; j++)
963  {
964  // Set previous values/veloc/accel to present values/veloc/accel,
965  // if not a copy
966  if (data_pt->is_a_copy(j) == false)
967  {
968  for (unsigned t = NSTEPS; t > 0; t--)
969  {
970  data_pt->set_value(t, j, data_pt->value(t - 1, j));
971  }
972  data_pt->set_value(NSTEPS + 1, j, veloc[j]);
973  data_pt->set_value(NSTEPS + 2, j, accel[j]);
974  }
975  }
976  }
void time_derivative(const unsigned &i, Data *const &data_pt, Vector< double > &deriv)
Definition: timesteppers.h:502

Member Data Documentation

◆ Beta1

template<unsigned NSTEPS>
double oomph::Newmark< NSTEPS >::Beta1
protected

First Newmark parameter (usually 0.5)

◆ Beta2

template<unsigned NSTEPS>
double oomph::Newmark< NSTEPS >::Beta2
protected

Second Newmark parameter (usually 0.5)


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