36 #include "navier_stokes.h" 40 #include "meshes/quarter_circle_sector_mesh.h" 48 using namespace oomph;
88 template<
class ELEMENT>
97 FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt);
122 fluid_mesh_pt()->node_update();
140 unsigned num_nod= fluid_mesh_pt()->nboundary_node(ibound);
141 for (
unsigned inod=0;inod<num_nod;inod++)
143 fluid_mesh_pt()->boundary_node_pt(ibound,inod)->
144 set_auxiliary_node_update_fct_pt(
145 FSI_functions::apply_no_slip_on_moving_wall);
150 dynamic_cast<PseudoBucklingRingElement*
>(Wall_pt)
151 ->set_reference_pressure_pt(fluid_mesh_pt()->element_pt(0)
152 ->internal_data_pt(0));
156 void unsteady_run(
const unsigned &ntsteps,
const bool& restarted,
161 void set_initial_condition();
164 void doc_solution(DocInfo& doc_info);
169 return Fluid_mesh_pt;
173 void dump_it(ofstream& dump_file, DocInfo doc_info);
176 void restart(ifstream& restart_file);
181 void write_trace_file_header();
212 template<
class ELEMENT>
214 FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt) : IC_Fct_pt(IC_fct_pt)
221 add_time_stepper_pt(
new BDF<4>);
228 double eps_buckl=0.1;
229 double ampl_ratio=-0.5;
234 Wall_pt=
new PseudoBucklingRingElement(eps_buckl,ampl_ratio,n_buckl,r_0,T,
240 double xi_hi=2.0*atan(1.0);
243 double fract_mid=0.5;
246 Fluid_mesh_pt=
new AlgebraicRefineableQuarterCircleSectorMesh<ELEMENT>(
247 Wall_pt,xi_lo,fract_mid,xi_hi,time_stepper_pt());
250 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
251 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
261 Wall_mesh_pt->add_element_pt(dynamic_cast<GeneralisedElement*>(Wall_pt));
272 unsigned nnode=
fluid_mesh_pt()->finite_element_pt(0)->nnode();
278 unsigned nnode_1d=
dynamic_cast<ELEMENT*
>(
281 finite_element_pt(0)->node_pt(nnode_1d-1);
286 dynamic_cast<PseudoBucklingRingElement*
>(
Wall_pt)
288 ->element_pt(0)->internal_data_pt(0));
301 for (
unsigned inod=0;inod<num_nod;inod++)
315 for (
unsigned inod=0;inod<num_nod;inod++)
318 Node* node_pt=
fluid_mesh_pt()->boundary_node_pt(ibound,inod);
322 node_pt->set_auxiliary_node_update_fct_pt(
323 FSI_functions::apply_no_slip_on_moving_wall);
326 for (
unsigned i=0;i<2;i++)
337 for (
unsigned inod=0;inod<num_nod;inod++)
355 for(
unsigned i=0;i<n_element;i++)
358 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(i));
367 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
403 template<
class ELEMENT>
410 dynamic_cast<PseudoBucklingRingElement*
>(
Wall_pt)->set_R_0(1.0);
413 double backed_up_time=time_pt()->time();
420 Vector<double> soln(3);
427 int nprev_steps=time_stepper_pt()->nprev_values();
428 Vector<double> prev_time(nprev_steps+1);
429 for (
int itime=nprev_steps;itime>=0;itime--)
431 prev_time[itime]=time_pt()->time(
unsigned(itime));
436 for (
int itime=nprev_steps;itime>=0;itime--)
438 double time=prev_time[itime];
442 time_pt()->time()=time;
444 cout <<
"setting IC at time =" << time << std::endl;
452 for (
unsigned jnod=0;jnod<num_nod;jnod++)
460 (*IC_Fct_pt)(time,x,soln);
463 for (
unsigned i=0;i<2;i++)
469 for (
unsigned i=0;i<2;i++)
477 time_pt()->time()=backed_up_time;
489 template<
class ELEMENT>
493 cout <<
"Doc-ing step " << doc_info.number()
494 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
506 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
509 some_file.open(filename);
511 for (
unsigned ielem=0;ielem<nelem;ielem++)
514 full_output(some_file,npts);
521 sprintf(filename,
"%s/Wall%i.dat",doc_info.directory().c_str(),
523 some_file.open(filename);
526 Vector<double > xi_wall(1);
527 Vector<double > r_wall(2);
528 for (
unsigned iplot=0;iplot<nplot;iplot++)
530 xi_wall[0]=0.5*Pi*double(iplot)/double(nplot-1);
531 Wall_pt->position(xi_wall,r_wall);
532 some_file << r_wall[0] <<
" " << r_wall[1] << std::endl;
539 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
541 some_file.open(filename);
543 time_stepper_pt()->time_pt()->time(),
553 Vector<double> xi(1);
554 xi[0]=MathematicalConstants::Pi/2.0;
564 double press_int=0.0;
569 for (
unsigned ielem=0;ielem<nelem;ielem++)
572 press_int+=
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(ielem))
573 ->pressure_integral();
574 diss+=
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(ielem))->
576 kin_en+=
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(ielem))->
581 double global_kin=4.0*kin_en;
590 double time=time_pt()->time();
594 Vector<double> x_sarah(2);
595 Vector<double> soln_sarah(3);
605 <<
" " <<
static_cast<PseudoBucklingRingElement*
>(
Wall_pt)->r_0()
607 <<
" " << press_int/area
609 <<
" " << diss_asympt
624 <<
" " << doc_info.number()
631 <<
" " << soln_sarah[0]
632 <<
" " << soln_sarah[1]
634 <<
static_cast<PseudoBucklingRingElement*
>(
Wall_pt)->r_0()-1.0
642 Vector<Tree*> all_element_pt;
644 stick_all_tree_nodes_into_vector(all_element_pt);
647 Mesh* coarse_mesh_pt =
new Mesh();
651 nelem=all_element_pt.size();
652 for (
unsigned ielem=0;ielem<nelem;ielem++)
654 Tree* el_pt=all_element_pt[ielem];
655 if (el_pt->level()==min_level)
657 coarse_mesh_pt->add_element_pt(el_pt->object_pt());
662 sprintf(filename,
"%s/coarse_soln%i.dat",doc_info.directory().c_str(),
664 some_file.open(filename);
665 nelem=coarse_mesh_pt->nelement();
666 for (
unsigned ielem=0;ielem<nelem;ielem++)
668 dynamic_cast<ELEMENT*
>(coarse_mesh_pt->element_pt(ielem))->
669 full_output(some_file,npts);
674 sprintf(filename,
"%s/restart%i.dat",doc_info.directory().c_str(),
676 some_file.open(filename);
690 template<
class ELEMENT>
698 Problem::dump(dump_file);
707 template<
class ELEMENT>
717 Problem::read(restart_file);
734 template<
class ELEMENT>
736 const bool& restarted,
742 sprintf(filename,
"%s/trace.dat",doc_info.directory().c_str());
774 unsigned min_refinement_level;
775 unsigned max_refinement_level;
777 max_refinement_level);
779 cout <<
"\n Initial mesh: min/max refinement levels: " 780 << min_refinement_level <<
" " << max_refinement_level << std::endl << std::endl;
793 doc_info.disable_doc();
804 time_pt()->time()-=time_pt()->dt();
813 double dt=time_pt()->dt();
814 unsteady_newton_solve(dt,max_adapt,first,shift);
817 doc_info.enable_doc();
827 for(
unsigned t=2;t<=ntsteps;t++)
831 doc_info.disable_doc();
835 unsteady_newton_solve(dt,max_adapt,first);
838 doc_info.enable_doc();
859 template<
class ELEMENT>
869 Trace_file <<
"# dt " << time_stepper_pt()->time_pt()->dt() << std::endl;
870 Trace_file <<
"# initial # elements " << mesh_pt()->nelement() << std::endl;
878 Trace_file <<
"VARIABLES=\"time\",\"V_c_t_r_l\",\"e_k_i_n\"";
879 Trace_file <<
",\"e_k_i_n_(_a_s_y_m_p_t_)\",\"R_0\",\"Area\"" ;
880 Trace_file <<
",\"Average pressure\",\"Total dissipation (quarter domain)\"";
881 Trace_file <<
",\"Asymptotic dissipation (quarter domain)\"";
882 Trace_file <<
",\"x<sub>1</sub><sup>(track)</sup>\"";
883 Trace_file <<
",\"x<sub>2</sub><sup>(track)</sup>\"";
884 Trace_file <<
",\"u<sub>1</sub><sup>(track)</sup>\"";
885 Trace_file <<
",\"u<sub>2</sub><sup>(track)</sup>\"";
890 Trace_file <<
",\"# of elements whose refinement was over-ruled\"";
895 Trace_file <<
",\"max. permitted # of unrefined elements\"";
897 Trace_file <<
",\"x<sub>1</sub><sup>(track2 FE)</sup>\"";
898 Trace_file <<
",\"x<sub>2</sub><sup>(track2 FE)</sup>\"";
899 Trace_file <<
",\"u<sub>1</sub><sup>(track2 FE)</sup>\"";
900 Trace_file <<
",\"u<sub>2</sub><sup>(track2 FE)</sup>\"";
901 Trace_file <<
",\"x<sub>1</sub><sup>(track2 Sarah)</sup>\"";
902 Trace_file <<
",\"x<sub>2</sub><sup>(track2 Sarah)</sup>\"";
903 Trace_file <<
",\"u<sub>1</sub><sup>(track2 Sarah)</sup>\"";
904 Trace_file <<
",\"u<sub>2</sub><sup>(track2 Sarah)</sup>\"";
927 int main(
int argc,
char* argv[])
931 CommandLineArgs::setup(argc,argv);
934 unsigned nstep_per_period=40;
938 unsigned nstep=nstep_per_period*nperiod;
939 double dt=1.0/double(nstep_per_period);
949 bool restarted=
false;
952 ifstream* restart_file_pt=0;
956 if (CommandLineArgs::Argc!=2)
958 cout <<
"No restart" << std::endl;
962 problem.refine_uniformly();
963 problem.refine_uniformly();
964 problem.refine_uniformly();
978 else if (CommandLineArgs::Argc==2)
983 restart_file_pt=
new ifstream(CommandLineArgs::Argv[1],ios_base::in);
984 if (restart_file_pt!=0)
986 cout <<
"Have opened " << CommandLineArgs::Argv[1] <<
987 " for restart. " << std::endl;
991 std::ostringstream error_stream;
992 error_stream <<
"ERROR while trying to open " 993 << CommandLineArgs::Argv[2]
994 <<
" for restart." << std::endl;
996 throw OomphLibError(error_stream.str(),
997 OOMPH_CURRENT_FUNCTION,
998 OOMPH_EXCEPTION_LOCATION);
1001 problem.
restart(*restart_file_pt);
1006 if (CommandLineArgs::Argc==3)
1009 cout <<
"Only doing nstep steps for validation: " << nstep << std::endl;
1019 doc_info.set_directory(
"RESLT");
1029 if (CommandLineArgs::Argc==3)
1040 DocInfo restarted_doc_info;
1043 restarted_doc_info.set_directory(
"RESLT_restarted");
1046 restarted_doc_info.number()=0;
1049 restart_file_pt=
new ifstream(
"RESLT/restart2.dat");
1052 restarted_problem.
restart(*restart_file_pt);
1056 bool restarted=
true;
1057 restarted_problem.
unsteady_run(nstep,restarted,restarted_doc_info);
OscRingNStProblem(const double &dt, FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt)
Constructor: Pass timestep and function pointer to the solution that provides the initial conditions ...
void actions_after_newton_solve()
Update after solve (empty)
void doc_solution(DocInfo &doc_info)
Doc the solution.
AlgebraicRefineableQuarterCircleSectorMesh< ELEMENT > * fluid_mesh_pt()
Access function for the fluid mesh.
FiniteElement::UnsteadyExactSolutionFctPt IC_Fct_pt
Function pointer to set the intial condition.
Node * Sarah_veloc_trace_node_pt
Pointer to node in symmetry plane on coarsest mesh at which velocity is traced.
void unsteady_run(const unsigned &ntsteps, const bool &restarted, DocInfo &doc_info)
Run the time integration for ntsteps steps.
void dump_it(ofstream &dump_file, DocInfo doc_info)
Dump problem data.
double ReSt
Reynolds x Strouhal number.
void set_initial_condition()
Set initial condition (incl previous timesteps) according to specified function.
void actions_before_newton_solve()
Update the problem specs before solve (empty)
double Re
Reynolds number.
void full_exact_soln(const double &time, const Vector< double > &x, Vector< double > &soln)
Full exact solution: x,y,u,v,p,du/dt,dv/dt,diss.
void restart(ifstream &restart_file)
Read problem data.
void actions_after_adapt()
Update the problem specs after adaptation: Set auxiliary update function that applies no slip on all ...
GeomObject * Wall_pt
Pointer to wall.
int main(int argc, char *argv[])
Namespace for physical parameters.
ofstream Trace_file
Trace file.
~OscRingNStProblem()
Destructor (empty)
AlgebraicRefineableQuarterCircleSectorMesh< ELEMENT > * Fluid_mesh_pt
Pointer to fluid mesh.
double Total_Diss_sarah(double t)
GeomObject * wall_pt()
Get pointer to wall as geometric object.
void write_trace_file_header()
Write header for trace file.
Mesh * Wall_mesh_pt
Pointer to wall mesh (contains only a single GeneralisedElement)
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: Update the fluid mesh and re-set velocit...
void exact_soln(const double &time, const Vector< double > &x, Vector< double > &soln)
Exact solution: x,y,u,v,p.
double Kin_energy_sarah(double t)