30 #include "navier_stokes.h"
35 #include "meshes/quarter_circle_sector_mesh.h"
36 #include "meshes/one_d_lagrangian_mesh.h"
40 using namespace oomph;
89 cout <<
"\n\n======================================================" <<std::endl;
90 cout <<
"\nSetting parameters. \n\n";
91 cout <<
"Prescribed: Square of Womersley number: Alpha_sq = "
93 cout <<
" Density ratio: Density_ratio = "
95 cout <<
" Wall thickness: H = "
97 cout <<
" Poisson ratio: Nu = "
99 cout <<
" Pressure perturbation: Pcos = "
100 <<
Pcos << std::endl;
104 cout <<
"\nDependent: Stress ratio: Q = "
108 cout <<
" Timescale ratio: Lambda_sq = "
112 cout <<
" Reynolds number: Re = "
116 cout <<
" Womersley number: ReSt = "
117 <<
ReSt << std::endl;
118 cout <<
"\n======================================================\n\n"
125 void pcos_load(
const Vector<double>& xi,
const Vector<double> &x,
126 const Vector<double>&
N, Vector<double>& load)
128 for(
unsigned i=0;i<2;i++)
129 {load[i] = (
Pext -
Pcos*cos(2.0*xi[0]))*
N[i];}
146 typedef AlgebraicElement<RefineableQCrouzeixRaviartElement<2> >
FLUID_ELEMENT;
156 const double& eps_ampl,
const double& pcos_initial,
157 const double& pcos_duration,
const unsigned& i_case);
171 Fluid_mesh_pt->node_update();
188 unsigned n_node = Fluid_mesh_pt->nboundary_node(1);
189 for (
unsigned n=0;n<n_node;n++)
191 Fluid_mesh_pt->boundary_node_pt(1,n)->set_auxiliary_node_update_fct_pt(
192 FSI_functions::apply_no_slip_on_moving_wall);
204 FSI_functions::setup_fluid_load_info_for_solid_elements<FLUID_ELEMENT,2>
205 (
this,1,Fluid_mesh_pt,Wall_mesh_pt);
211 void doc_solution(
const unsigned& i, DocInfo& doc_info, ofstream& trace_file,
212 const unsigned& i_case);
215 void dynamic_run(
const unsigned& i_case);
232 OneDLagrangianMesh<SOLID_ELEMENT> *Wall_mesh_pt;
235 AlgebraicRefineableQuarterCircleSectorMesh<FLUID_ELEMENT> *Fluid_mesh_pt;
238 GeomObject* Undef_geom_pt;
241 Newmark<2>* Wall_time_stepper_pt;
244 BDF<2>* Fluid_time_stepper_pt;
247 Node* Veloc_trace_node_pt;
256 double Pcos_duration;
268 cout <<
"Setting wall ic" << std::endl;
269 set_wall_initial_condition();
271 cout <<
"Setting fluid ic" << std::endl;
272 set_fluid_initial_condition();
290 Fluid_mesh_pt->node_update();
296 unsigned n_node = Fluid_mesh_pt->nnode();
299 for(
unsigned n=0;n<n_node;n++)
303 for(
unsigned i=0;i<2;i++)
305 Fluid_mesh_pt->node_pt(n)->set_value(i,0.0);
310 Fluid_mesh_pt->assign_initial_values_impulsive();
324 GeomObject* ic_geom_object_pt=
326 Wall_time_stepper_pt);
329 static_cast<PseudoBucklingRing*
>(ic_geom_object_pt)->set_T(1.0);
335 static_cast<PseudoBucklingRing*
>(ic_geom_object_pt)->set_R_0(1.00);
338 SolidInitialCondition* IC_pt =
new SolidInitialCondition(ic_geom_object_pt);
342 SolidMesh::Solid_IC_problem.set_static_initial_condition(
343 this,Wall_mesh_pt,IC_pt,time);
354 DocInfo& doc_info, ofstream& trace_file,
const unsigned& i_case)
363 doc_info.enable_doc();
364 cout <<
"Full doc step " << doc_info.number()
365 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
370 doc_info.disable_doc();
371 cout <<
"Only trace for time "
372 << time_stepper_pt()->time_pt()->time() << std::endl;
377 if (doc_info.is_doc_enabled())
380 ofstream some_file;
char filename[100];
383 sprintf(filename,
"%s/soln%i_%i.dat",doc_info.directory().c_str(),
384 i_case,doc_info.number());
386 some_file.open(filename);
388 Fluid_mesh_pt->output(some_file,5);
395 Vector<double> s(1,1.0);
397 trace_file << time_pt()->time()
399 <<
" " << Doc_displacement_elem_pt->interpolated_x(s,1)
400 <<
" " << Veloc_trace_node_pt->x(0)
401 <<
" " << Veloc_trace_node_pt->x(1)
402 <<
" " << Veloc_trace_node_pt->value(0)
403 <<
" " << Veloc_trace_node_pt->value(1)
404 <<
" " << Fluid_mesh_pt->nelement()
406 <<
" " << Fluid_mesh_pt->nrefinement_overruled()
407 <<
" " << Fluid_mesh_pt->max_error()
408 <<
" " << Fluid_mesh_pt->min_error()
409 <<
" " << Fluid_mesh_pt->max_permitted_error()
410 <<
" " << Fluid_mesh_pt->min_permitted_error()
411 <<
" " << Fluid_mesh_pt->max_keep_unrefined();
415 if (doc_info.is_doc_enabled())
416 {trace_file <<
" " <<doc_info.number() <<
" ";}
417 else {trace_file <<
" " <<-1 <<
" ";}
420 trace_file << std::endl;
423 if (doc_info.is_doc_enabled()) {doc_info.number()++;}
432 const double& eps_ampl,
433 const double& pcos_initial,
434 const double& pcos_duration,
435 const unsigned& i_case) :
436 Eps_ampl(eps_ampl), Pcos_initial(pcos_initial),
437 Pcos_duration(pcos_duration)
461 double L = 2.0*atan(1.0);
494 double fract_mid=0.5;
498 MeshAsGeomObject *wall_mesh_as_geometric_object_pt
502 Fluid_mesh_pt =
new AlgebraicRefineableQuarterCircleSectorMesh<FLUID_ELEMENT >
503 (wall_mesh_as_geometric_object_pt,
507 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
508 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
515 Vector<unsigned> elements_to_be_refined;
516 elements_to_be_refined.push_back(2);
517 Fluid_mesh_pt->refine_selected_elements(elements_to_be_refined);
518 Fluid_mesh_pt->refine_selected_elements(elements_to_be_refined);
527 for (
unsigned n=0;n<n_node;n++)
539 for (
unsigned n=0;n<n_node;n++)
545 node_pt->set_auxiliary_node_update_fct_pt(
546 FSI_functions::apply_no_slip_on_moving_wall);
549 for(
unsigned i=0;i<2;i++) {node_pt->pin(i);}
556 for (
unsigned n=0;n<n_node;n++)
589 for(
unsigned e=0;e<n_element;e++)
604 el_pt->evaluate_shape_derivs_by_direct_fd();
605 if (!done) std::cout <<
"\n\n [CR residuals] Direct FD" << std::endl;
608 else if ( (i_case==1) || (i_case==2) )
611 bool i_know_what_i_am_doing=
true;
612 el_pt->evaluate_shape_derivs_by_chain_rule(i_know_what_i_am_doing);
615 el_pt->enable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
616 if (!done) std::cout <<
"\n\n [CR residuals] Chain rule and FD"
621 el_pt->disable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
622 if (!done) std::cout <<
"\n\n [CR residuals] Chain rule and analytic"
627 else if ( (i_case==3) || (i_case==4) )
631 bool i_know_what_i_am_doing=
true;
632 el_pt->evaluate_shape_derivs_by_fastest_method(i_know_what_i_am_doing);
635 el_pt->enable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
636 if (!done) std::cout <<
"\n\n [CR residuals] Fastest and FD"
641 el_pt->disable_always_evaluate_dresidual_dnodal_coordinates_by_fd();
642 if (!done) std::cout <<
"\n\n [CR residuals] Fastest and analytic"
653 for(
unsigned e=0;e<n_wall_element;e++)
687 FSI_functions::setup_fluid_load_info_for_solid_elements<FLUID_ELEMENT,2>
691 cout <<
"# of dofs " << assign_eqn_numbers() << std::endl;
708 doc_info.set_directory(
"RESLT");
714 ofstream trace_file(
"RESLT/trace_ring.dat");
717 trace_file <<
"VARIABLES=\"time\",\"V_c_t_r_l\"";
718 trace_file <<
",\"x<sub>1</sub><sup>(track)</sup>\"";
719 trace_file <<
",\"x<sub>2</sub><sup>(track)</sup>\"";
720 trace_file <<
",\"u<sub>1</sub><sup>(track)</sup>\"";
721 trace_file <<
",\"u<sub>2</sub><sup>(track)</sup>\"";
722 trace_file <<
",\"N<sub>element</sub>\"";
723 trace_file <<
",\"N<sub>dof</sub>\"";
724 trace_file <<
",\"# of under-refined elements\"";
725 trace_file <<
",\"max. error\"";
726 trace_file <<
",\"min. error\"";
727 trace_file <<
",\"max. permitted error\"";
728 trace_file <<
",\"min. permitted error\"";
729 trace_file <<
",\"max. permitted # of unrefined elements\"";
730 trace_file <<
",\"doc number\"";
731 trace_file << std::endl;
741 if (CommandLineArgs::Argc>1)
744 cout <<
"Only doing nstep steps for validation: " << nstep << std::endl;
832 for(
unsigned i=1;i<=nstep;i++)
835 doc_info.disable_doc();
838 unsigned max_adapt=1;
839 unsteady_newton_solve(dt,max_adapt,first);
858 int main(
int argc,
char* argv[])
862 CommandLineArgs::setup(argc,argv);
868 double pcos_initial=1.0e-6;
871 double pcos_duration=0.3;
879 for (
unsigned i_case=0;i_case<5;i_case++)
881 std::cout <<
"[CR residuals] " << std::endl;
882 std::cout <<
"[CR residuals]=================================================="
884 std::cout <<
"[CR residuals] " << std::endl;
887 FSIRingProblem problem(nelem,eps_ampl,pcos_initial,pcos_duration,i_case);
FSI Ring problem: a fluid-structure interaction problem in which a viscous fluid bounded by an initia...
double Pcos_initial
Initial pcos.
OneDLagrangianMesh< SOLID_ELEMENT > * Wall_mesh_pt
Pointer to wall mesh.
GeomObject * Undef_geom_pt
Pointer to geometric object that represents the undeformed wall shape.
AlgebraicElement< RefineableQCrouzeixRaviartElement< 2 > > FLUID_ELEMENT
There are very few element types that will work for this problem. Rather than passing the element typ...
Node * Veloc_trace_node_pt
Pointer to node on coarsest mesh on which velocity is traced.
void set_initial_condition()
Setup initial condition for both domains.
AlgebraicRefineableQuarterCircleSectorMesh< FLUID_ELEMENT > * Fluid_mesh_pt
Pointer to fluid mesh.
void set_wall_initial_condition()
Setup initial condition for wall.
void actions_after_newton_solve()
Update after solve (empty)
Newmark< 2 > * Wall_time_stepper_pt
Pointer to wall timestepper.
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...
BDF< 2 > * Fluid_time_stepper_pt
Pointer to fluid timestepper.
SOLID_ELEMENT * Doc_displacement_elem_pt
Element used for documenting displacement.
FSIRingProblem(const unsigned &nelement_wall, const double &eps_ampl, const double &pcos_initial, const double &pcos_duration)
Constructor: Number of elements in wall mesh, amplitude of the initial wall deformation,...
double Pcos_duration
Duration of initial pcos.
FSIHermiteBeamElement SOLID_ELEMENT
Typedef to specify the solid element used.
void actions_before_newton_solve()
Update before solve (empty)
void dynamic_run()
Do dynamic run.
void set_fluid_initial_condition()
Setup initial condition for fluid.
void actions_after_adapt()
Update the problem specs after adaptation:
void actions_before_newton_convergence_check()
Update the problem specs before checking Newton convergence.
int main(int argc, char *argv[])
Driver for fsi ring test problem.
Namespace for physical parameters.
double Pext
External Pressure.
double Alpha_sq
Square of Womersly number (a frequency parameter)
double ReSt
Reynolds x Strouhal number.
void set_params()
Set the parameters that are used in the code as a function of the Womersley number,...
double Lambda_sq
Timescale ratio (non-dimensation density)
void pcos_load(const Vector< double > &xi, const Vector< double > &x, const Vector< double > &N, Vector< double > &load)
Non-FSI load function, a constant external pressure plus a (small) sinusoidal perturbation of wavenum...
double Pcos
Perturbation pressure.
double Re
Reynolds number.
double Density_ratio
Density ratio of the solid and the fluid.
double H
Nondimensional thickness of the beam.