34 #include "navier_stokes.h" 39 #include "meshes/quarter_circle_sector_mesh.h" 40 #include "meshes/one_d_lagrangian_mesh.h" 44 using namespace oomph;
93 cout <<
"\n\n======================================================" <<std::endl;
94 cout <<
"\nSetting parameters. \n\n";
95 cout <<
"Prescribed: Square of Womersley number: Alpha_sq = " 96 << Alpha_sq << std::endl;
97 cout <<
" Density ratio: Density_ratio = " 98 << Density_ratio << std::endl;
99 cout <<
" Wall thickness: H = " 101 cout <<
" Poisson ratio: Nu = " 103 cout <<
" Pressure perturbation: Pcos = " 104 << Pcos << std::endl;
108 cout <<
"\nDependent: Stress ratio: Q = " 112 cout <<
" Timescale ratio: Lambda_sq = " 113 << Lambda_sq << std::endl;
116 cout <<
" Reynolds number: Re = " 120 cout <<
" Womersley number: ReSt = " 121 << ReSt << std::endl;
122 cout <<
"\n======================================================\n\n" 129 void pcos_load(
const Vector<double>& xi,
const Vector<double> &x,
130 const Vector<double>&
N, Vector<double>& load)
132 for(
unsigned i=0;i<2;i++)
133 {load[i] = (Pext - Pcos*cos(2.0*xi[0]))*N[i];}
150 typedef AlgebraicElement<RefineableQCrouzeixRaviartElement<2> >
FLUID_ELEMENT;
160 const double& eps_ampl,
const double& pcos_initial,
161 const double& pcos_duration,
const unsigned& i_case);
175 Fluid_mesh_pt->node_update();
192 unsigned n_node = Fluid_mesh_pt->nboundary_node(1);
193 for (
unsigned n=0;n<n_node;n++)
195 Fluid_mesh_pt->boundary_node_pt(1,n)->set_auxiliary_node_update_fct_pt(
196 FSI_functions::apply_no_slip_on_moving_wall);
208 FSI_functions::setup_fluid_load_info_for_solid_elements<FLUID_ELEMENT,2>
209 (
this,1,Fluid_mesh_pt,Wall_mesh_pt);
215 void doc_solution(
const unsigned& i, DocInfo& doc_info, ofstream& trace_file,
216 const unsigned& i_case);
219 void dynamic_run(
const unsigned& i_case);
224 void set_initial_condition();
227 void set_wall_initial_condition();
230 void set_fluid_initial_condition();
233 SOLID_ELEMENT* Doc_displacement_elem_pt;
236 OneDLagrangianMesh<SOLID_ELEMENT> *Wall_mesh_pt;
239 AlgebraicRefineableQuarterCircleSectorMesh<FLUID_ELEMENT> *Fluid_mesh_pt;
242 GeomObject* Undef_geom_pt;
245 Newmark<2>* Wall_time_stepper_pt;
248 BDF<2>* Fluid_time_stepper_pt;
251 Node* Veloc_trace_node_pt;
260 double Pcos_duration;
272 cout <<
"Setting wall ic" << std::endl;
273 set_wall_initial_condition();
275 cout <<
"Setting fluid ic" << std::endl;
276 set_fluid_initial_condition();
294 Fluid_mesh_pt->node_update();
300 unsigned n_node = Fluid_mesh_pt->nnode();
303 for(
unsigned n=0;n<n_node;n++)
307 for(
unsigned i=0;i<2;i++)
309 Fluid_mesh_pt->node_pt(n)->set_value(i,0.0);
314 Fluid_mesh_pt->assign_initial_values_impulsive();
328 GeomObject* ic_geom_object_pt=
330 Wall_time_stepper_pt);
333 static_cast<PseudoBucklingRing*
>(ic_geom_object_pt)->set_T(1.0);
339 static_cast<PseudoBucklingRing*
>(ic_geom_object_pt)->set_R_0(1.00);
342 SolidInitialCondition* IC_pt =
new SolidInitialCondition(ic_geom_object_pt);
346 SolidMesh::Solid_IC_problem.set_static_initial_condition(
347 this,Wall_mesh_pt,IC_pt,time);
358 DocInfo& doc_info, ofstream& trace_file,
const unsigned& i_case)
367 doc_info.enable_doc();
368 cout <<
"Full doc step " << doc_info.number()
369 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
374 doc_info.disable_doc();
375 cout <<
"Only trace for time " 376 << time_stepper_pt()->time_pt()->time() << std::endl;
381 if (doc_info.is_doc_enabled())
384 ofstream some_file;
char filename[100];
387 sprintf(filename,
"%s/soln%i_%i.dat",doc_info.directory().c_str(),
388 i_case,doc_info.number());
390 some_file.open(filename);
392 Fluid_mesh_pt->output(some_file,5);
399 Vector<double> s(1,1.0);
401 trace_file << time_pt()->time()
403 <<
" " << Doc_displacement_elem_pt->interpolated_x(s,1)
404 <<
" " << Veloc_trace_node_pt->x(0)
405 <<
" " << Veloc_trace_node_pt->x(1)
406 <<
" " << Veloc_trace_node_pt->value(0)
407 <<
" " << Veloc_trace_node_pt->value(1)
408 <<
" " << Fluid_mesh_pt->nelement()
410 <<
" " << Fluid_mesh_pt->nrefinement_overruled()
411 <<
" " << Fluid_mesh_pt->max_error()
412 <<
" " << Fluid_mesh_pt->min_error()
413 <<
" " << Fluid_mesh_pt->max_permitted_error()
414 <<
" " << Fluid_mesh_pt->min_permitted_error()
415 <<
" " << Fluid_mesh_pt->max_keep_unrefined();
419 if (doc_info.is_doc_enabled())
420 {trace_file <<
" " <<doc_info.number() <<
" ";}
421 else {trace_file <<
" " <<-1 <<
" ";}
424 trace_file << std::endl;
427 if (doc_info.is_doc_enabled()) {doc_info.number()++;}
436 const double& eps_ampl,
437 const double& pcos_initial,
438 const double& pcos_duration,
439 const unsigned& i_case) :
440 Eps_ampl(eps_ampl), Pcos_initial(pcos_initial),
441 Pcos_duration(pcos_duration)
465 double L = 2.0*atan(1.0);
498 double fract_mid=0.5;
502 MeshAsGeomObject *wall_mesh_as_geometric_object_pt
506 Fluid_mesh_pt =
new AlgebraicRefineableQuarterCircleSectorMesh<FLUID_ELEMENT >
507 (wall_mesh_as_geometric_object_pt,
511 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
512 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
519 Vector<unsigned> elements_to_be_refined;
520 elements_to_be_refined.push_back(2);
521 Fluid_mesh_pt->refine_selected_elements(elements_to_be_refined);
522 Fluid_mesh_pt->refine_selected_elements(elements_to_be_refined);
531 for (
unsigned n=0;n<n_node;n++)
543 for (
unsigned n=0;n<n_node;n++)
549 node_pt->set_auxiliary_node_update_fct_pt(
550 FSI_functions::apply_no_slip_on_moving_wall);
553 for(
unsigned i=0;i<2;i++) {node_pt->pin(i);}
560 for (
unsigned n=0;n<n_node;n++)
593 for(
unsigned e=0;e<n_element;e++)
608 el_pt->evaluate_shape_derivs_by_direct_fd();
609 if (!done) std::cout <<
"\n\n [CR residuals] Direct FD" << std::endl;
612 else if ( (i_case==1) || (i_case==2) )
615 bool i_know_what_i_am_doing=
true;
616 el_pt->evaluate_shape_derivs_by_chain_rule(i_know_what_i_am_doing);
619 el_pt->enable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
620 if (!done) std::cout <<
"\n\n [CR residuals] Chain rule and FD" 625 el_pt->disable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
626 if (!done) std::cout <<
"\n\n [CR residuals] Chain rule and analytic" 631 else if ( (i_case==3) || (i_case==4) )
635 bool i_know_what_i_am_doing=
true;
636 el_pt->evaluate_shape_derivs_by_fastest_method(i_know_what_i_am_doing);
639 el_pt->enable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
640 if (!done) std::cout <<
"\n\n [CR residuals] Fastest and FD" 645 el_pt->disable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
646 if (!done) std::cout <<
"\n\n [CR residuals] Fastest and analytic" 657 for(
unsigned e=0;e<n_wall_element;e++)
691 FSI_functions::setup_fluid_load_info_for_solid_elements<FLUID_ELEMENT,2>
695 cout <<
"# of dofs " << assign_eqn_numbers() << std::endl;
712 doc_info.set_directory(
"RESLT");
718 ofstream trace_file(
"RESLT/trace_ring.dat");
721 trace_file <<
"VARIABLES=\"time\",\"V_c_t_r_l\"";
722 trace_file <<
",\"x<sub>1</sub><sup>(track)</sup>\"";
723 trace_file <<
",\"x<sub>2</sub><sup>(track)</sup>\"";
724 trace_file <<
",\"u<sub>1</sub><sup>(track)</sup>\"";
725 trace_file <<
",\"u<sub>2</sub><sup>(track)</sup>\"";
726 trace_file <<
",\"N<sub>element</sub>\"";
727 trace_file <<
",\"N<sub>dof</sub>\"";
728 trace_file <<
",\"# of under-refined elements\"";
729 trace_file <<
",\"max. error\"";
730 trace_file <<
",\"min. error\"";
731 trace_file <<
",\"max. permitted error\"";
732 trace_file <<
",\"min. permitted error\"";
733 trace_file <<
",\"max. permitted # of unrefined elements\"";
734 trace_file <<
",\"doc number\"";
735 trace_file << std::endl;
745 if (CommandLineArgs::Argc>1)
748 cout <<
"Only doing nstep steps for validation: " << nstep << std::endl;
836 for(
unsigned i=1;i<=nstep;i++)
839 doc_info.disable_doc();
842 unsigned max_adapt=1;
843 unsteady_newton_solve(dt,max_adapt,first);
862 int main(
int argc,
char* argv[])
866 CommandLineArgs::setup(argc,argv);
872 double pcos_initial=1.0e-6;
875 double pcos_duration=0.3;
883 for (
unsigned i_case=0;i_case<5;i_case++)
885 std::cout <<
"[CR residuals] " << std::endl;
886 std::cout <<
"[CR residuals]==================================================" 888 std::cout <<
"[CR residuals] " << std::endl;
891 FSIRingProblem problem(nelem,eps_ampl,pcos_initial,pcos_duration,i_case);
void doc_solution(const unsigned &i, DocInfo &doc_info, ofstream &trace_file)
Doc solution: Pass number of timestep, i (we append to tracefile after every timestep but do a full d...
double Density_ratio
Density ratio of the solid and the fluid.
void set_params()
Set the parameters that are used in the code as a function of the Womersley number, the density ratio and H.
double Lambda_sq
Timescale ratio (non-dimensation density)
double Pcos
Perturbation pressure.
AlgebraicRefineableQuarterCircleSectorMesh< FLUID_ELEMENT > * Fluid_mesh_pt
Pointer to fluid mesh.
void set_fluid_initial_condition()
Setup initial condition for fluid.
double Pcos_initial
Initial pcos.
void dynamic_run()
Do dynamic run.
double ReSt
Reynolds x Strouhal number.
void set_initial_condition()
Setup initial condition for both domains.
double Pcos_duration
Duration of initial pcos.
double Pext
External Pressure.
double Re
Reynolds number.
BDF< 2 > * Fluid_time_stepper_pt
Pointer to fluid timestepper.
Namespace for physical parameters.
double H
Nondimensional thickness of the beam.
GeomObject * Undef_geom_pt
Pointer to geometric object that represents the undeformed wall shape.
SOLID_ELEMENT * Doc_displacement_elem_pt
Element used for documenting displacement.
Newmark< 2 > * Wall_time_stepper_pt
Pointer to wall timestepper.
FSIHermiteBeamElement SOLID_ELEMENT
Typedef to specify the solid element used.
void actions_after_adapt()
Update the problem specs after adaptation:
double Alpha_sq
Square of Womersly number (a frequency parameter)
int main(int argc, char *argv[])
Driver for fsi ring test problem.
void actions_after_newton_solve()
Update after solve (empty)
FSIRingProblem(const unsigned &nelement_wall, const double &eps_ampl, const double &pcos_initial, const double &pcos_duration)
void pcos_load(const Vector< double > &xi, const Vector< double > &x, const Vector< double > &N, Vector< double > &load)
void set_wall_initial_condition()
Setup initial condition for wall.
AlgebraicElement< RefineableQCrouzeixRaviartElement< 2 > > FLUID_ELEMENT
There are very few element types that will work for this problem. Rather than passing the element typ...
OneDLagrangianMesh< SOLID_ELEMENT > * Wall_mesh_pt
Pointer to wall mesh.
void actions_before_newton_solve()
Update before solve (empty)
Node * Veloc_trace_node_pt
Pointer to node on coarsest mesh on which velocity is traced.
void actions_before_newton_convergence_check()
Update the problem specs before checking Newton convergence.