35 #include "meshes/one_d_lagrangian_mesh.h"    39 using namespace oomph;
    74 template<
class ELEMENT, 
class TIMESTEPPER>
    87    return dynamic_cast<OneDLagrangianMesh<ELEMENT>*
>(Problem::mesh_pt());
    97  void doc_solution(DocInfo& doc_info);
   130 template<
class ELEMENT,
class TIMESTEPPER>
   132 (
const unsigned& N, 
const double& L) 
   137  add_time_stepper_pt(
new TIMESTEPPER());
   140  Undef_geom_pt=
new Ellipse(1.0,1.0); 
   143  Problem::mesh_pt() = 
new OneDLagrangianMesh<ELEMENT>(
   144   N,L,Undef_geom_pt,Problem::time_stepper_pt()); 
   151  mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1); 
   153  mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,0);
   158  mesh_pt()->boundary_node_pt(ibound,0)->pin_position(0); 
   160  mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,1); 
   166  S_displ_control.resize(1);
   172  unsigned Nelement = mesh_pt()->nelement();
   175  for(
unsigned i=0;i<Nelement;i++)
   178    ELEMENT *elem_pt = 
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
   181    elem_pt->undeformed_beam_pt() = Undef_geom_pt;
   188  Displ_control_elem_pt=
dynamic_cast<ELEMENT*
>(
   189   mesh_pt()->element_pt(Nelement-1));
   193  S_displ_control[0]=1.0;
   196  cout << 
"# of dofs " << assign_eqn_numbers() << std::endl;
   199  double eps_buckl=1.0e-2;
   200  double HoR=
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(0))->h();
   203  GeomObject* ic_geom_object_pt=
   204   new PseudoBucklingRing(eps_buckl,HoR,n_buckl,imode,
   205                          Problem::time_stepper_pt()); 
   208  IC_pt = 
new SolidInitialCondition(ic_geom_object_pt);
   216 template<
class ELEMENT, 
class TIMESTEPPER>
   221  cout << 
"Doc-ing step " <<  doc_info.number()
   222       << 
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
   226  unsigned Nelem=mesh_pt()->nelement();
   230  for (
unsigned ielem=0;ielem<Nelem;ielem++)
   232    dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->get_energy(pot,kin);
   239  Vector<double> xi_ctrl(1);
   240  Vector<double> posn_ctrl(2);
   243  xi_ctrl[0]=Displ_control_elem_pt->interpolated_xi(S_displ_control,0);
   246  IC_pt->geom_object_pt()->position(xi_ctrl,posn_ctrl);
   249  Trace_file << time_pt()->time()  << 
" "    250             << Displ_control_elem_pt->interpolated_x(S_displ_control,1) 
   251             << 
" " << global_pot  << 
" " << global_kin
   252             << 
" " << global_pot + global_kin 
   253             << 
" " << posn_ctrl[1]
   264  sprintf(filename,
"%s/ring%i.dat",doc_info.directory().c_str(),
   266  some_file.open(filename);
   267  mesh_pt()->output(some_file,npts);
   271  unsigned nsteps=time_stepper_pt()->nprev_values();
   272  for (
unsigned t=0;t<=nsteps;t++)
   274    sprintf(filename,
"%s/ring%i-%i.dat",doc_info.directory().c_str(),
   275            doc_info.number(),t);
   276    some_file.open(filename);
   277    unsigned Nelem=mesh_pt()->nelement();
   278    for (
unsigned ielem=0;ielem<Nelem;ielem++)
   280      dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->
   281       output(t,some_file,npts);
   287  sprintf(filename,
"%s/ic_ring%i.dat",doc_info.directory().c_str(),
   289  some_file.open(filename);
   291  unsigned nplot=1+(npts-1)*mesh_pt()->nelement();
   292  Vector<double> xi(1);
   293  Vector<double> posn(2);
   294  Vector<double> veloc(2);
   295  Vector<double> accel(2);
   297  for (
unsigned iplot=0;iplot<nplot;iplot++)
   299    xi[0]=Length/double(nplot-1)*double(iplot);
   301    IC_pt->geom_object_pt()->position(xi,posn);
   302    IC_pt->geom_object_pt()->dposition_dt(xi,1,veloc);
   303    IC_pt->geom_object_pt()->dposition_dt(xi,2,accel);
   305    some_file << posn[0] << 
" " << posn[1] << 
" "   307              << veloc[0] << 
" " << veloc[1] << 
" "   308              << accel[0] << 
" " << accel[1] << 
" "   309              << sqrt(pow(posn[0],2)+pow(posn[1],2)) << 
" "   310              << sqrt(pow(veloc[0],2)+pow(veloc[1],2)) << 
" "   311              << sqrt(pow(accel[0],2)+pow(accel[1],2)) << 
" "   323 template<
class ELEMENT,
class TIMESTEPPER>
   331  doc_info.set_directory(
"RESLT");
   338  sprintf(filename,
"%s/trace_ring.dat",doc_info.directory().c_str());
   339  Trace_file.open(filename);
   341  Trace_file <<  
"VARIABLES=\"time\",\"R<sub>ctrl</sub>\",\"E<sub>pot</sub>\"";
   342  Trace_file << 
",\"E<sub>kin</sub>\",\"E<sub>kin</sub>+E<sub>pot</sub>\"";
   343  Trace_file << 
",\"<sub>exact</sub>R<sub>ctrl</sub>\""    354  double timestep_ratio=1.0;
   358  unsigned ndt=time_stepper_pt()->time_pt()->ndt();
   361  Vector<double> dt_prev(ndt);
   363  for (
unsigned i=1;i<ndt;i++)
   365    dt_prev[i]=dt_prev[i-1]/timestep_ratio;
   369  time_pt()->initialise_dt(dt_prev);
   373  time_pt()->time()=time0;
   381    SolidMesh::Solid_IC_problem.
   382     set_newmark_initial_condition_consistently(
   383      this,mesh_pt(),static_cast<TIMESTEPPER*>(time_stepper_pt()),IC_pt,dt);
   387    SolidMesh::Solid_IC_problem.
   388     set_newmark_initial_condition_directly(
   389      this,mesh_pt(),static_cast<TIMESTEPPER*>(time_stepper_pt()),IC_pt,dt);
   393  doc_solution(doc_info);
   396  for(
unsigned i=1;i<=nstep;i++)
   399    unsteady_newton_solve(dt); 
   403    doc_solution(doc_info);
   406    if (time_pt()->time()<100.0) {dt=timestep_ratio*dt;}
   416 int main(
int argc, 
char* argv[])
   420  CommandLineArgs::setup(argc,argv);
   427    if (atoi(argv[1])==1) 
   430      cout << 
"Setting Newmark IC consistently" << std::endl;
   435      cout << 
"Setting Newmark IC directly" << std::endl;
   438    cout << 
"Not enough command line arguments specified -- using defaults."    443    cout << 
"Three command line arguments specified:" << std::endl;
   446    if (atoi(argv[1])==1) 
   449      cout << 
"Setting Newmark IC consistently" << std::endl;
   454      cout << 
"Setting Newmark IC directly" << std::endl;
   463    std::string error_message =
   464     "Wrong number of command line arguments. Specify one or three.\n";
   465    error_message += 
"Arg1: Long_run_flag [0/1]\n";
   466    error_message += 
"Arg2: Impulsive_start_flag [0/1]\n";
   467    error_message += 
"Arg3: Restart_flag [restart_file] (optional)\n";
   469    throw OomphLibError(error_message,
   470                        OOMPH_CURRENT_FUNCTION,
   471                        OOMPH_EXCEPTION_LOCATION);
   473  cout << 
"Setting Newmark IC consistently: "   475  cout << 
"Long run flag: "    477  cout << 
"Fixed timestep flag: "    481  double L = MathematicalConstants::Pi/2.0;
 SolidInitialCondition * IC_pt
Pointer to object that specifies the initial condition. 
 
double Length
Length of domain (in terms of the Lagrangian coordinates) 
 
unsigned Fixed_timestep_flag
Flag for fixed timestep: Default = fixed timestep. 
 
void unsteady_run()
Do unsteady run. 
 
int main(int argc, char *argv[])
Driver for ring that performs small-amplitude oscillations. 
 
ELEMENT * Displ_control_elem_pt
In which element are we applying displacement control? (here only used for doc of radius) ...
 
GeomObject * Undef_geom_pt
Pointer to geometric object that represents the undeformed shape. 
 
void doc_solution(DocInfo &doc_info)
Doc solution. 
 
OneDLagrangianMesh< ELEMENT > * mesh_pt()
Access function for the mesh. 
 
void actions_before_newton_solve()
Update function is empty. 
 
Vector< double > S_displ_control
At what local coordinate are we applying displacement control? 
 
Namespace for physical parameters. 
 
void actions_after_newton_solve()
Update function is empty. 
 
unsigned Long_run_flag
Flag for long/short run: Default = perform long run. 
 
ofstream Trace_file
Trace file for recording control data. 
 
bool Consistent_newmark_ic
Boolean flag to decide if to set IC for Newmark directly or consistently : No Default. 
 
ElasticRingProblem(const unsigned &N, const double &L)
Constructor: Number of elements, length of domain, flag for setting Newmark IC directly or consistent...