31 #include "meshes/one_d_lagrangian_mesh.h"
35 using namespace oomph;
70 template<
class ELEMENT,
class TIMESTEPPER>
83 return dynamic_cast<OneDLagrangianMesh<ELEMENT>*
>(Problem::mesh_pt());
93 void doc_solution(DocInfo& doc_info);
126 template<
class ELEMENT,
class TIMESTEPPER>
128 (
const unsigned& N,
const double& L)
133 add_time_stepper_pt(
new TIMESTEPPER());
139 Problem::mesh_pt() =
new OneDLagrangianMesh<ELEMENT>(
147 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1);
149 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,0);
154 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(0);
156 mesh_pt()->boundary_node_pt(ibound,0)->pin_position(1,1);
168 unsigned Nelement =
mesh_pt()->nelement();
171 for(
unsigned i=0;i<Nelement;i++)
174 ELEMENT *elem_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
185 mesh_pt()->element_pt(Nelement-1));
192 cout <<
"# of dofs " << assign_eqn_numbers() << std::endl;
195 double eps_buckl=1.0e-2;
196 double HoR=
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(0))->h();
199 GeomObject* ic_geom_object_pt=
200 new PseudoBucklingRing(eps_buckl,HoR,n_buckl,imode,
201 Problem::time_stepper_pt());
204 IC_pt =
new SolidInitialCondition(ic_geom_object_pt);
212 template<
class ELEMENT,
class TIMESTEPPER>
217 cout <<
"Doc-ing step " << doc_info.number()
218 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
222 unsigned Nelem=mesh_pt()->nelement();
226 for (
unsigned ielem=0;ielem<Nelem;ielem++)
228 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->get_energy(pot,kin);
235 Vector<double> xi_ctrl(1);
236 Vector<double> posn_ctrl(2);
239 xi_ctrl[0]=Displ_control_elem_pt->interpolated_xi(S_displ_control,0);
242 IC_pt->geom_object_pt()->position(xi_ctrl,posn_ctrl);
245 Trace_file << time_pt()->time() <<
" "
246 << Displ_control_elem_pt->interpolated_x(S_displ_control,1)
247 <<
" " << global_pot <<
" " << global_kin
248 <<
" " << global_pot + global_kin
249 <<
" " << posn_ctrl[1]
260 sprintf(filename,
"%s/ring%i.dat",doc_info.directory().c_str(),
262 some_file.open(filename);
263 mesh_pt()->output(some_file,npts);
267 unsigned nsteps=time_stepper_pt()->nprev_values();
268 for (
unsigned t=0;t<=nsteps;t++)
270 sprintf(filename,
"%s/ring%i-%i.dat",doc_info.directory().c_str(),
271 doc_info.number(),t);
272 some_file.open(filename);
273 unsigned Nelem=mesh_pt()->nelement();
274 for (
unsigned ielem=0;ielem<Nelem;ielem++)
276 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(ielem))->
277 output(t,some_file,npts);
283 sprintf(filename,
"%s/ic_ring%i.dat",doc_info.directory().c_str(),
285 some_file.open(filename);
287 unsigned nplot=1+(npts-1)*mesh_pt()->nelement();
288 Vector<double> xi(1);
289 Vector<double> posn(2);
290 Vector<double> veloc(2);
291 Vector<double> accel(2);
293 for (
unsigned iplot=0;iplot<nplot;iplot++)
295 xi[0]=Length/double(nplot-1)*double(iplot);
297 IC_pt->geom_object_pt()->position(xi,posn);
298 IC_pt->geom_object_pt()->dposition_dt(xi,1,veloc);
299 IC_pt->geom_object_pt()->dposition_dt(xi,2,accel);
301 some_file << posn[0] <<
" " << posn[1] <<
" "
303 << veloc[0] <<
" " << veloc[1] <<
" "
304 << accel[0] <<
" " << accel[1] <<
" "
305 << sqrt(pow(posn[0],2)+pow(posn[1],2)) <<
" "
306 << sqrt(pow(veloc[0],2)+pow(veloc[1],2)) <<
" "
307 << sqrt(pow(accel[0],2)+pow(accel[1],2)) <<
" "
319 template<
class ELEMENT,
class TIMESTEPPER>
327 doc_info.set_directory(
"RESLT");
334 sprintf(filename,
"%s/trace_ring.dat",doc_info.directory().c_str());
335 Trace_file.open(filename);
337 Trace_file <<
"VARIABLES=\"time\",\"R<sub>ctrl</sub>\",\"E<sub>pot</sub>\"";
338 Trace_file <<
",\"E<sub>kin</sub>\",\"E<sub>kin</sub>+E<sub>pot</sub>\"";
339 Trace_file <<
",\"<sub>exact</sub>R<sub>ctrl</sub>\""
350 double timestep_ratio=1.0;
354 unsigned ndt=time_stepper_pt()->time_pt()->ndt();
357 Vector<double> dt_prev(ndt);
359 for (
unsigned i=1;i<ndt;i++)
361 dt_prev[i]=dt_prev[i-1]/timestep_ratio;
365 time_pt()->initialise_dt(dt_prev);
369 time_pt()->time()=time0;
377 SolidMesh::Solid_IC_problem.
378 set_newmark_initial_condition_consistently(
379 this,mesh_pt(),
static_cast<TIMESTEPPER*
>(time_stepper_pt()),IC_pt,dt);
383 SolidMesh::Solid_IC_problem.
384 set_newmark_initial_condition_directly(
385 this,mesh_pt(),
static_cast<TIMESTEPPER*
>(time_stepper_pt()),IC_pt,dt);
389 doc_solution(doc_info);
392 for(
unsigned i=1;i<=nstep;i++)
395 unsteady_newton_solve(dt);
399 doc_solution(doc_info);
402 if (time_pt()->time()<100.0) {dt=timestep_ratio*dt;}
412 int main(
int argc,
char* argv[])
416 CommandLineArgs::setup(argc,argv);
423 if (atoi(argv[1])==1)
426 cout <<
"Setting Newmark IC consistently" << std::endl;
431 cout <<
"Setting Newmark IC directly" << std::endl;
434 cout <<
"Not enough command line arguments specified -- using defaults."
439 cout <<
"Three command line arguments specified:" << std::endl;
442 if (atoi(argv[1])==1)
445 cout <<
"Setting Newmark IC consistently" << std::endl;
450 cout <<
"Setting Newmark IC directly" << std::endl;
459 std::string error_message =
460 "Wrong number of command line arguments. Specify one or three.\n";
461 error_message +=
"Arg1: Long_run_flag [0/1]\n";
462 error_message +=
"Arg2: Impulsive_start_flag [0/1]\n";
463 error_message +=
"Arg3: Restart_flag [restart_file] (optional)\n";
465 throw OomphLibError(error_message,
466 OOMPH_CURRENT_FUNCTION,
467 OOMPH_EXCEPTION_LOCATION);
469 cout <<
"Setting Newmark IC consistently: "
471 cout <<
"Long run flag: "
473 cout <<
"Fixed timestep flag: "
477 double L = MathematicalConstants::Pi/2.0;
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Vector< double > S_displ_control
At what local coordinate are we applying displacement control?
SolidInitialCondition * IC_pt
Pointer to object that specifies the initial condition.
ElasticRingProblem(const unsigned &N, const double &L)
Constructor: Number of elements, length of domain, flag for setting Newmark IC directly or consistent...
double Length
Length of domain (in terms of the Lagrangian coordinates)
OneDLagrangianMesh< ELEMENT > * mesh_pt()
Access function for the mesh.
ofstream Trace_file
Trace file for recording control data.
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.
GeomObject * Undef_geom_pt
Pointer to geometric object that represents the undeformed shape.
ELEMENT * Displ_control_elem_pt
In which element are we applying displacement control? (here only used for doc of radius)
void unsteady_run()
Do unsteady run.
int main(int argc, char *argv[])
Driver for ring that performs small-amplitude oscillations.
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
unsigned Fixed_timestep_flag
Flag for fixed timestep: Default = fixed timestep.
unsigned Long_run_flag
Flag for long/short run: Default = perform long run.
bool Consistent_newmark_ic
Boolean flag to decide if to set IC for Newmark directly or consistently : No Default.