35 #include "meshes/one_d_lagrangian_mesh.h"
39 using namespace oomph;
61 const Vector<double> &x,
62 const Vector<double>& N,
65 for(
unsigned i=0;i<2;i++)
67 load[i] = -
Pcos*cos(2.0*xi[0])*N[i];
97 template<
class ELEMENT,
class TIMESTEPPER>
109 return dynamic_cast<OneDLagrangianMesh<ELEMENT>*
>(Problem::mesh_pt());
119 void set_initial_conditions();
129 void dump_it(ofstream& dump_file);
133 void restart(ifstream& restart_file);
156 template<
class ELEMENT,
class TIMESTEPPER>
158 (
const unsigned& n_element) :
159 Validation_run_flag(0),
165 add_time_stepper_pt(
new TIMESTEPPER());
168 GeomObject* undef_geom_pt=
new Ellipse(1.0,1.0);
171 double length = MathematicalConstants::Pi/2.0;
174 Problem::mesh_pt() =
new OneDLagrangianMesh<ELEMENT>(
175 n_element,length,undef_geom_pt,Problem::time_stepper_pt());
182 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1);
184 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,0);
189 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(0);
191 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,1);
197 for(
unsigned i=0;i<n_element;i++)
200 ELEMENT *elem_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
212 elem_pt->undeformed_beam_pt() = undef_geom_pt;
216 cout <<
"# of dofs " << assign_eqn_numbers() << std::endl;
226 template<
class ELEMENT,
class TIMESTEPPER>
231 cout <<
"Doc-ing step " << doc_info.number()
232 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
236 unsigned n_elem=mesh_pt()->nelement();
240 for (
unsigned ielem=0;ielem<n_elem;ielem++)
242 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->get_energy(pot,kin);
249 FiniteElement* trace_elem_pt=mesh_pt()->finite_element_pt(n_elem-1);
252 Vector<double> s_trace(1);
256 Trace_file << time_pt()->time() <<
" "
257 << trace_elem_pt->interpolated_x(s_trace,1)
258 <<
" " << global_pot <<
" " << global_kin
259 <<
" " << global_pot + global_kin
269 sprintf(filename,
"%s/ring%i.dat",doc_info.directory().c_str(),
271 some_file.open(filename);
272 mesh_pt()->output(some_file,npts);
275 some_file <<
"TEXT X=2.5,Y=93.6,F=HELV,HU=POINT,C=BLUE,H=26,T=\"time = "
276 << time_pt()->time() <<
"\"";
280 some_file <<
"GEOMETRY X=2.5,Y=98,T=LINE,C=BLUE,LT=0.4" << std::endl;
281 some_file <<
"1" << std::endl;
282 some_file <<
"2" << std::endl;
283 some_file <<
" 0 0" << std::endl;
284 some_file << time_pt()->time()*20.0 <<
" 0" << std::endl;
289 unsigned nsteps=time_stepper_pt()->nprev_values();
290 for (
unsigned t=0;t<=nsteps;t++)
292 sprintf(filename,
"%s/ring%i-%i.dat",doc_info.directory().c_str(),
293 doc_info.number(),t);
294 some_file.open(filename);
295 unsigned n_elem=mesh_pt()->nelement();
296 for (
unsigned ielem=0;ielem<n_elem;ielem++)
298 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->
299 output(t,some_file,npts);
306 sprintf(filename,
"%s/ring_restart%i.dat",doc_info.directory().c_str(),
308 some_file.open(filename);
324 template<
class ELEMENT,
class TIMESTEPPER>
333 dump_file << Validation_run_flag
334 <<
" # Validation run flag" << std::endl;
337 Problem::dump(dump_file);
346 template<
class ELEMENT,
class TIMESTEPPER>
353 getline(restart_file,input_string,
'#');
355 restart_file.ignore(80,
'\n');
360 getline(restart_file,input_string,
'#');
362 restart_file.ignore(80,
'\n');
365 unsigned(atof(input_string.c_str()));
368 Problem::read(restart_file);
379 template<
class ELEMENT,
class TIMESTEPPER>
391 assign_initial_values_impulsive(dt);
397 ifstream* restart_file_pt=
398 new ifstream(CommandLineArgs::Argv[2],ios_base::in);
399 if (restart_file_pt!=0)
401 cout <<
"Have opened " << CommandLineArgs::Argv[2] <<
402 " for restart. " << std::endl;
406 std::ostringstream error_stream;
407 error_stream <<
"ERROR while trying to open "
408 << CommandLineArgs::Argv[2]
409 <<
" for restart." << std::endl;
411 throw OomphLibError(error_stream.str(),
412 OOMPH_CURRENT_FUNCTION,
413 OOMPH_EXCEPTION_LOCATION);
417 restart(*restart_file_pt);
428 template<
class ELEMENT,
class TIMESTEPPER>
435 if (CommandLineArgs::Argc<2)
437 cout <<
"No command line arguments -- using defaults."
440 else if (CommandLineArgs::Argc==2)
443 Validation_run_flag=atoi(CommandLineArgs::Argv[1]);
445 else if (CommandLineArgs::Argc==3)
448 Validation_run_flag=atoi(CommandLineArgs::Argv[1]);
456 std::string error_message =
457 "Wrong number of command line arguments. Specify two or fewer.\n";
458 error_message +=
"Arg1: Validation_run_flag [0/1] for [false/true]\n";
459 error_message +=
"Arg2: Name of restart_file (optional)\n";
460 error_message +=
"No arguments specified --> default run\n";
462 throw OomphLibError(error_message,
463 OOMPH_CURRENT_FUNCTION,
464 OOMPH_EXCEPTION_LOCATION);
472 doc_info.set_directory(
"RESLT");
479 sprintf(filename,
"%s/trace_ring.dat",doc_info.directory().c_str());
480 Trace_file.open(filename);
482 Trace_file <<
"VARIABLES=\"time\",\"R<sub>ctrl</sub>\",\"E<sub>pot</sub>\"";
483 Trace_file <<
",\"E<sub>kin</sub>\",\"E<sub>kin</sub>+E<sub>pot</sub>\""
495 if (Validation_run_flag==1) {nstep=10;}
498 set_initial_conditions();
501 double dt=time_pt()->dt();
504 doc_solution(doc_info);
511 if (Restart_flag&&(time_pt()->time()>10.0)&&(time_pt()->time()<100.0))
517 for(
unsigned i=1;i<=nstep;i++)
527 unsteady_newton_solve(dt);
531 doc_solution(doc_info);
534 if ((time_pt()->time()>10.0)&&(time_pt()->time()<100.0))
549 int main(
int argc,
char* argv[])
553 CommandLineArgs::setup(argc,argv);
////////////////////////////////////////////////////////////////// //////////////////////////////////...
void restart(ifstream &restart_file)
Read problem-specific parameter values, then recover generic problem data.
unsigned Validation_run_flag
Flag for validation run: Default: 0 = no validation run.
ElasticRingProblem(const unsigned &N, const double &L)
Constructor: Number of elements, length of domain, flag for setting Newmark IC directly or consistent...
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?
OneDLagrangianMesh< ELEMENT > * mesh_pt()
Access function for the specific mesh.
void doc_solution(DocInfo &doc_info)
Doc solution.
void actions_before_newton_solve()
Update function is empty.
void actions_after_newton_solve()
Update function is empty.
void set_initial_conditions()
Setup initial conditions.
void unsteady_run()
Do unsteady run.
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
double Lambda_sq
Square of timescale ratio (i.e. non-dimensional density) – 1.0 for default value of scaling factor.
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.
double T_kick
Duration of transient load.
double Alpha
Scaling factor for wall thickness (to be used in an exercise)
double Pcos
Perturbation pressure.
double H
Wall thickness – 1/20 for default value of scaling factor.
int main(int argc, char *argv[])
Driver for oscillating ring problem.