39 #include "meshes/one_d_lagrangian_mesh.h" 43 using namespace oomph;
65 const Vector<double> &x,
66 const Vector<double>& N,
69 for(
unsigned i=0;i<2;i++)
71 load[i] = -Pcos*cos(2.0*xi[0])*N[i];
80 double H=Alpha*1.0/20.0;
101 template<
class ELEMENT,
class TIMESTEPPER>
113 return dynamic_cast<OneDLagrangianMesh<ELEMENT>*
>(Problem::mesh_pt());
123 void set_initial_conditions();
126 void doc_solution(DocInfo& doc_info);
133 void dump_it(ofstream& dump_file);
137 void restart(ifstream& restart_file);
160 template<
class ELEMENT,
class TIMESTEPPER>
162 (
const unsigned& n_element) :
163 Validation_run_flag(0),
169 add_time_stepper_pt(
new TIMESTEPPER());
172 GeomObject* undef_geom_pt=
new Ellipse(1.0,1.0);
175 double length = MathematicalConstants::Pi/2.0;
178 Problem::mesh_pt() =
new OneDLagrangianMesh<ELEMENT>(
179 n_element,length,undef_geom_pt,Problem::time_stepper_pt());
186 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1);
188 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,0);
193 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(0);
195 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,1);
201 for(
unsigned i=0;i<n_element;i++)
204 ELEMENT *elem_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
216 elem_pt->undeformed_beam_pt() = undef_geom_pt;
220 cout <<
"# of dofs " << assign_eqn_numbers() << std::endl;
230 template<
class ELEMENT,
class TIMESTEPPER>
235 cout <<
"Doc-ing step " << doc_info.number()
236 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
240 unsigned n_elem=mesh_pt()->nelement();
244 for (
unsigned ielem=0;ielem<n_elem;ielem++)
246 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->get_energy(pot,kin);
253 FiniteElement* trace_elem_pt=mesh_pt()->finite_element_pt(n_elem-1);
256 Vector<double> s_trace(1);
260 Trace_file << time_pt()->time() <<
" " 261 << trace_elem_pt->interpolated_x(s_trace,1)
262 <<
" " << global_pot <<
" " << global_kin
263 <<
" " << global_pot + global_kin
273 sprintf(filename,
"%s/ring%i.dat",doc_info.directory().c_str(),
275 some_file.open(filename);
276 mesh_pt()->output(some_file,npts);
279 some_file <<
"TEXT X=2.5,Y=93.6,F=HELV,HU=POINT,C=BLUE,H=26,T=\"time = " 280 << time_pt()->time() <<
"\"";
284 some_file <<
"GEOMETRY X=2.5,Y=98,T=LINE,C=BLUE,LT=0.4" << std::endl;
285 some_file <<
"1" << std::endl;
286 some_file <<
"2" << std::endl;
287 some_file <<
" 0 0" << std::endl;
288 some_file << time_pt()->time()*20.0 <<
" 0" << std::endl;
293 unsigned nsteps=time_stepper_pt()->nprev_values();
294 for (
unsigned t=0;t<=nsteps;t++)
296 sprintf(filename,
"%s/ring%i-%i.dat",doc_info.directory().c_str(),
297 doc_info.number(),t);
298 some_file.open(filename);
299 unsigned n_elem=mesh_pt()->nelement();
300 for (
unsigned ielem=0;ielem<n_elem;ielem++)
302 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->
303 output(t,some_file,npts);
310 sprintf(filename,
"%s/ring_restart%i.dat",doc_info.directory().c_str(),
312 some_file.open(filename);
328 template<
class ELEMENT,
class TIMESTEPPER>
337 dump_file << Validation_run_flag
338 <<
" # Validation run flag" << std::endl;
341 Problem::dump(dump_file);
350 template<
class ELEMENT,
class TIMESTEPPER>
357 getline(restart_file,input_string,
'#');
359 restart_file.ignore(80,
'\n');
364 getline(restart_file,input_string,
'#');
366 restart_file.ignore(80,
'\n');
369 unsigned(atof(input_string.c_str()));
372 Problem::read(restart_file);
383 template<
class ELEMENT,
class TIMESTEPPER>
395 assign_initial_values_impulsive(dt);
401 ifstream* restart_file_pt=
402 new ifstream(CommandLineArgs::Argv[2],ios_base::in);
403 if (restart_file_pt!=0)
405 cout <<
"Have opened " << CommandLineArgs::Argv[2] <<
406 " for restart. " << std::endl;
410 std::ostringstream error_stream;
411 error_stream <<
"ERROR while trying to open " 412 << CommandLineArgs::Argv[2]
413 <<
" for restart." << std::endl;
415 throw OomphLibError(error_stream.str(),
416 OOMPH_CURRENT_FUNCTION,
417 OOMPH_EXCEPTION_LOCATION);
421 restart(*restart_file_pt);
432 template<
class ELEMENT,
class TIMESTEPPER>
439 if (CommandLineArgs::Argc<2)
441 cout <<
"No command line arguments -- using defaults." 444 else if (CommandLineArgs::Argc==2)
447 Validation_run_flag=atoi(CommandLineArgs::Argv[1]);
449 else if (CommandLineArgs::Argc==3)
452 Validation_run_flag=atoi(CommandLineArgs::Argv[1]);
460 std::string error_message =
461 "Wrong number of command line arguments. Specify two or fewer.\n";
462 error_message +=
"Arg1: Validation_run_flag [0/1] for [false/true]\n";
463 error_message +=
"Arg2: Name of restart_file (optional)\n";
464 error_message +=
"No arguments specified --> default run\n";
466 throw OomphLibError(error_message,
467 OOMPH_CURRENT_FUNCTION,
468 OOMPH_EXCEPTION_LOCATION);
476 doc_info.set_directory(
"RESLT");
483 sprintf(filename,
"%s/trace_ring.dat",doc_info.directory().c_str());
484 Trace_file.open(filename);
486 Trace_file <<
"VARIABLES=\"time\",\"R<sub>ctrl</sub>\",\"E<sub>pot</sub>\"";
487 Trace_file <<
",\"E<sub>kin</sub>\",\"E<sub>kin</sub>+E<sub>pot</sub>\"" 499 if (Validation_run_flag==1) {nstep=10;}
502 set_initial_conditions();
505 double dt=time_pt()->dt();
508 doc_solution(doc_info);
515 if (Restart_flag&&(time_pt()->time()>10.0)&&(time_pt()->time()<100.0))
521 for(
unsigned i=1;i<=nstep;i++)
531 unsteady_newton_solve(dt);
535 doc_solution(doc_info);
538 if ((time_pt()->time()>10.0)&&(time_pt()->time()<100.0))
553 int main(
int argc,
char* argv[])
557 CommandLineArgs::setup(argc,argv);
double Lambda_sq
Square of timescale ratio (i.e. non-dimensional density) – 1.0 for default value of scaling factor...
double Pcos
Perturbation pressure.
void set_initial_conditions()
Setup initial conditions.
void unsteady_run()
Do unsteady run.
unsigned Validation_run_flag
Flag for validation run: Default: 0 = no validation run.
double T_kick
Duration of transient load.
void press_load(const Vector< double > &xi, const Vector< double > &x, const Vector< double > &N, Vector< double > &load)
Load function: Perturbation pressure to force non-axisymmetric deformation.
int main(int argc, char *argv[])
Driver for oscillating ring problem.
void doc_solution(DocInfo &doc_info)
Doc solution.
OneDLagrangianMesh< ELEMENT > * mesh_pt()
Access function for the specific mesh.
void actions_before_newton_solve()
Update function is empty.
void dump_it(ofstream &dump_file)
Dump problem-specific parameter values, then dump generic problem data.
bool Restart_flag
Restart flag specified via command line?
Namespace for physical parameters.
double H
Wall thickness – 1/20 for default value of scaling factor.
void restart(ifstream &restart_file)
Read problem-specific parameter values, then recover generic problem data.
void actions_after_newton_solve()
Update function is empty.
double Alpha
Scaling factor for wall thickness (to be used in an exercise)
ElasticRingProblem(const unsigned &N, const double &L)
Constructor: Number of elements, length of domain, flag for setting Newmark IC directly or consistent...