32 #include "navier_stokes.h"
36 #include "meshes/quarter_circle_sector_mesh.h"
44 using namespace oomph;
46 using namespace MathematicalConstants;
84 template<
class ELEMENT>
93 FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt);
118 fluid_mesh_pt()->node_update();
136 unsigned num_nod= fluid_mesh_pt()->nboundary_node(ibound);
137 for (
unsigned inod=0;inod<num_nod;inod++)
139 fluid_mesh_pt()->boundary_node_pt(ibound,inod)->
140 set_auxiliary_node_update_fct_pt(
141 FSI_functions::apply_no_slip_on_moving_wall);
146 dynamic_cast<PseudoBucklingRingElement*
>(Wall_pt)
147 ->set_reference_pressure_pt(fluid_mesh_pt()->element_pt(0)
148 ->internal_data_pt(0));
152 void unsteady_run(
const unsigned &ntsteps,
const bool& restarted,
157 void set_initial_condition();
160 void doc_solution(DocInfo& doc_info);
165 return Fluid_mesh_pt;
169 void dump_it(ofstream& dump_file, DocInfo doc_info);
172 void restart(ifstream& restart_file);
177 void write_trace_file_header();
208 template<
class ELEMENT>
210 FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt) : IC_Fct_pt(IC_fct_pt)
217 add_time_stepper_pt(
new BDF<4>);
224 double eps_buckl=0.1;
225 double ampl_ratio=-0.5;
230 Wall_pt=
new PseudoBucklingRingElement(eps_buckl,ampl_ratio,n_buckl,r_0,T,
236 double xi_hi=2.0*atan(1.0);
239 double fract_mid=0.5;
242 Fluid_mesh_pt=
new AlgebraicRefineableQuarterCircleSectorMesh<ELEMENT>(
243 Wall_pt,xi_lo,fract_mid,xi_hi,time_stepper_pt());
246 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
247 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
268 unsigned nnode=
fluid_mesh_pt()->finite_element_pt(0)->nnode();
274 unsigned nnode_1d=
dynamic_cast<ELEMENT*
>(
277 finite_element_pt(0)->node_pt(nnode_1d-1);
282 dynamic_cast<PseudoBucklingRingElement*
>(
Wall_pt)
284 ->element_pt(0)->internal_data_pt(0));
297 for (
unsigned inod=0;inod<num_nod;inod++)
311 for (
unsigned inod=0;inod<num_nod;inod++)
314 Node* node_pt=
fluid_mesh_pt()->boundary_node_pt(ibound,inod);
318 node_pt->set_auxiliary_node_update_fct_pt(
319 FSI_functions::apply_no_slip_on_moving_wall);
322 for (
unsigned i=0;i<2;i++)
333 for (
unsigned inod=0;inod<num_nod;inod++)
351 for(
unsigned i=0;i<n_element;i++)
354 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(i));
363 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
399 template<
class ELEMENT>
406 dynamic_cast<PseudoBucklingRingElement*
>(Wall_pt)->set_R_0(1.0);
409 double backed_up_time=time_pt()->time();
416 Vector<double> soln(3);
420 unsigned num_nod = fluid_mesh_pt()->nnode();
423 int nprev_steps=time_stepper_pt()->nprev_values();
424 Vector<double> prev_time(nprev_steps+1);
425 for (
int itime=nprev_steps;itime>=0;itime--)
427 prev_time[itime]=time_pt()->time(
unsigned(itime));
432 for (
int itime=nprev_steps;itime>=0;itime--)
434 double time=prev_time[itime];
438 time_pt()->time()=time;
440 cout <<
"setting IC at time =" << time << std::endl;
445 fluid_mesh_pt()->node_update();
448 for (
unsigned jnod=0;jnod<num_nod;jnod++)
452 x[0]=fluid_mesh_pt()->node_pt(jnod)->x(0);
453 x[1]=fluid_mesh_pt()->node_pt(jnod)->x(1);
456 (*IC_Fct_pt)(time,x,soln);
459 for (
unsigned i=0;i<2;i++)
461 fluid_mesh_pt()->node_pt(jnod)->set_value(itime,i,soln[i]);
465 for (
unsigned i=0;i<2;i++)
467 fluid_mesh_pt()->node_pt(jnod)->x(itime,i)=x[i];
473 time_pt()->time()=backed_up_time;
485 template<
class ELEMENT>
489 cout <<
"Doc-ing step " << doc_info.number()
490 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
502 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
505 some_file.open(filename);
506 unsigned nelem=fluid_mesh_pt()->nelement();
507 for (
unsigned ielem=0;ielem<nelem;ielem++)
509 dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
510 full_output(some_file,npts);
517 sprintf(filename,
"%s/Wall%i.dat",doc_info.directory().c_str(),
519 some_file.open(filename);
522 Vector<double > xi_wall(1);
523 Vector<double > r_wall(2);
524 for (
unsigned iplot=0;iplot<nplot;iplot++)
526 xi_wall[0]=0.5*Pi*double(iplot)/double(nplot-1);
527 Wall_pt->position(xi_wall,r_wall);
528 some_file << r_wall[0] <<
" " << r_wall[1] << std::endl;
535 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
537 some_file.open(filename);
538 fluid_mesh_pt()->output_fct(some_file,npts,
539 time_stepper_pt()->time_pt()->time(),
549 Vector<double> xi(1);
550 xi[0]=MathematicalConstants::Pi/2.0;
551 wall_pt()->position(xi,r);
560 double press_int=0.0;
563 nelem=fluid_mesh_pt()->nelement();
565 for (
unsigned ielem=0;ielem<nelem;ielem++)
567 area+=fluid_mesh_pt()->finite_element_pt(ielem)->size();
568 press_int+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))
569 ->pressure_integral();
570 diss+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
572 kin_en+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
577 double global_kin=4.0*kin_en;
582 fluid_mesh_pt()->get_refinement_levels(min_level,max_level);
586 double time=time_pt()->time();
590 Vector<double> x_sarah(2);
591 Vector<double> soln_sarah(3);
592 x_sarah[0]=Sarah_veloc_trace_node_pt->x(0);
593 x_sarah[1]=Sarah_veloc_trace_node_pt->x(1);
597 Trace_file << time_pt()->time()
601 <<
" " <<
static_cast<PseudoBucklingRingElement*
>(Wall_pt)->r_0()
603 <<
" " << press_int/area
605 <<
" " << diss_asympt
606 <<
" " << Veloc_trace_node_pt->x(0)
607 <<
" " << Veloc_trace_node_pt->x(1)
608 <<
" " << Veloc_trace_node_pt->value(0)
609 <<
" " << Veloc_trace_node_pt->value(1)
610 <<
" " << fluid_mesh_pt()->nelement()
614 <<
" " << fluid_mesh_pt()->nrefinement_overruled()
615 <<
" " << fluid_mesh_pt()->max_error()
616 <<
" " << fluid_mesh_pt()->min_error()
617 <<
" " << fluid_mesh_pt()->max_permitted_error()
618 <<
" " << fluid_mesh_pt()->min_permitted_error()
619 <<
" " << fluid_mesh_pt()->max_keep_unrefined()
620 <<
" " << doc_info.number()
621 <<
" " << Sarah_veloc_trace_node_pt->x(0)
622 <<
" " << Sarah_veloc_trace_node_pt->x(1)
623 <<
" " << Sarah_veloc_trace_node_pt->value(0)
624 <<
" " << Sarah_veloc_trace_node_pt->value(1)
627 <<
" " << soln_sarah[0]
628 <<
" " << soln_sarah[1]
630 <<
static_cast<PseudoBucklingRingElement*
>(Wall_pt)->r_0()-1.0
638 Vector<Tree*> all_element_pt;
639 fluid_mesh_pt()->forest_pt()->
640 stick_all_tree_nodes_into_vector(all_element_pt);
643 Mesh* coarse_mesh_pt =
new Mesh();
647 nelem=all_element_pt.size();
648 for (
unsigned ielem=0;ielem<nelem;ielem++)
650 Tree* el_pt=all_element_pt[ielem];
651 if (el_pt->level()==min_level)
653 coarse_mesh_pt->add_element_pt(el_pt->object_pt());
658 sprintf(filename,
"%s/coarse_soln%i.dat",doc_info.directory().c_str(),
660 some_file.open(filename);
661 nelem=coarse_mesh_pt->nelement();
662 for (
unsigned ielem=0;ielem<nelem;ielem++)
664 dynamic_cast<ELEMENT*
>(coarse_mesh_pt->element_pt(ielem))->
665 full_output(some_file,npts);
670 sprintf(filename,
"%s/restart%i.dat",doc_info.directory().c_str(),
672 some_file.open(filename);
673 dump_it(some_file,doc_info);
686 template<
class ELEMENT>
694 Problem::dump(dump_file);
703 template<
class ELEMENT>
713 Problem::read(restart_file);
730 template<
class ELEMENT>
732 const bool& restarted,
738 sprintf(filename,
"%s/trace.dat",doc_info.directory().c_str());
739 Trace_file.open(filename);
755 fluid_mesh_pt()->max_permitted_error()= 0.5e-2;
756 fluid_mesh_pt()->min_permitted_error()= 0.5e-3;
759 fluid_mesh_pt()->min_refinement_level()=2;
762 fluid_mesh_pt()->max_refinement_level()=6;
766 fluid_mesh_pt()->max_keep_unrefined()=20;
770 unsigned min_refinement_level;
771 unsigned max_refinement_level;
772 fluid_mesh_pt()->get_refinement_levels(min_refinement_level,
773 max_refinement_level);
775 cout <<
"\n Initial mesh: min/max refinement levels: "
776 << min_refinement_level <<
" " << max_refinement_level << std::endl << std::endl;
779 fluid_mesh_pt()->doc_adaptivity_targets(cout);
782 write_trace_file_header();
785 doc_solution(doc_info);
789 doc_info.disable_doc();
800 time_pt()->time()-=time_pt()->dt();
809 double dt=time_pt()->dt();
810 unsteady_newton_solve(dt,max_adapt,first,shift);
813 doc_info.enable_doc();
816 doc_solution(doc_info);
823 for(
unsigned t=2;t<=ntsteps;t++)
827 doc_info.disable_doc();
831 unsteady_newton_solve(dt,max_adapt,first);
834 doc_info.enable_doc();
839 doc_solution(doc_info);
855 template<
class ELEMENT>
860 Trace_file <<
"# err_max " << fluid_mesh_pt()->max_permitted_error() << std::endl;
861 Trace_file <<
"# err_min " << fluid_mesh_pt()->min_permitted_error() << std::endl;
865 Trace_file <<
"# dt " << time_stepper_pt()->time_pt()->dt() << std::endl;
866 Trace_file <<
"# initial # elements " << mesh_pt()->nelement() << std::endl;
867 Trace_file <<
"# min_refinement_level "
868 << fluid_mesh_pt()->min_refinement_level() << std::endl;
869 Trace_file <<
"# max_refinement_level "
870 << fluid_mesh_pt()->max_refinement_level() << std::endl;
874 Trace_file <<
"VARIABLES=\"time\",\"V_c_t_r_l\",\"e_k_i_n\"";
875 Trace_file <<
",\"e_k_i_n_(_a_s_y_m_p_t_)\",\"R_0\",\"Area\"" ;
876 Trace_file <<
",\"Average pressure\",\"Total dissipation (quarter domain)\"";
877 Trace_file <<
",\"Asymptotic dissipation (quarter domain)\"";
878 Trace_file <<
",\"x<sub>1</sub><sup>(track)</sup>\"";
879 Trace_file <<
",\"x<sub>2</sub><sup>(track)</sup>\"";
880 Trace_file <<
",\"u<sub>1</sub><sup>(track)</sup>\"";
881 Trace_file <<
",\"u<sub>2</sub><sup>(track)</sup>\"";
882 Trace_file <<
",\"N<sub>element</sub>\"";
883 Trace_file <<
",\"N<sub>dof</sub>\"";
884 Trace_file <<
",\"max. refinement level\"";
885 Trace_file <<
",\"min. refinement level\"";
886 Trace_file <<
",\"# of elements whose refinement was over-ruled\"";
887 Trace_file <<
",\"max. error\"";
888 Trace_file <<
",\"min. error\"";
889 Trace_file <<
",\"max. permitted error\"";
890 Trace_file <<
",\"min. permitted error\"";
891 Trace_file <<
",\"max. permitted # of unrefined elements\"";
892 Trace_file <<
",\"doc number\"";
893 Trace_file <<
",\"x<sub>1</sub><sup>(track2 FE)</sup>\"";
894 Trace_file <<
",\"x<sub>2</sub><sup>(track2 FE)</sup>\"";
895 Trace_file <<
",\"u<sub>1</sub><sup>(track2 FE)</sup>\"";
896 Trace_file <<
",\"u<sub>2</sub><sup>(track2 FE)</sup>\"";
897 Trace_file <<
",\"x<sub>1</sub><sup>(track2 Sarah)</sup>\"";
898 Trace_file <<
",\"x<sub>2</sub><sup>(track2 Sarah)</sup>\"";
899 Trace_file <<
",\"u<sub>1</sub><sup>(track2 Sarah)</sup>\"";
900 Trace_file <<
",\"u<sub>2</sub><sup>(track2 Sarah)</sup>\"";
901 Trace_file <<
",\"R<sub>0</sub>-1\"";
902 Trace_file << std::endl;
923 int main(
int argc,
char* argv[])
927 CommandLineArgs::setup(argc,argv);
930 unsigned nstep_per_period=40;
934 unsigned nstep=nstep_per_period*nperiod;
935 double dt=1.0/double(nstep_per_period);
945 bool restarted=
false;
948 ifstream* restart_file_pt=0;
952 if (CommandLineArgs::Argc!=2)
954 cout <<
"No restart" << std::endl;
958 problem.refine_uniformly();
959 problem.refine_uniformly();
960 problem.refine_uniformly();
974 else if (CommandLineArgs::Argc==2)
979 restart_file_pt=
new ifstream(CommandLineArgs::Argv[1],ios_base::in);
980 if (restart_file_pt!=0)
982 cout <<
"Have opened " << CommandLineArgs::Argv[1] <<
983 " for restart. " << std::endl;
987 std::ostringstream error_stream;
988 error_stream <<
"ERROR while trying to open "
989 << CommandLineArgs::Argv[2]
990 <<
" for restart." << std::endl;
992 throw OomphLibError(error_stream.str(),
993 OOMPH_CURRENT_FUNCTION,
994 OOMPH_EXCEPTION_LOCATION);
997 problem.
restart(*restart_file_pt);
1002 if (CommandLineArgs::Argc==3)
1005 cout <<
"Only doing nstep steps for validation: " << nstep << std::endl;
1015 doc_info.set_directory(
"RESLT");
1025 if (CommandLineArgs::Argc==3)
1036 DocInfo restarted_doc_info;
1039 restarted_doc_info.set_directory(
"RESLT_restarted");
1042 restarted_doc_info.number()=0;
1045 restart_file_pt=
new ifstream(
"RESLT/restart2.dat");
1048 restarted_problem.
restart(*restart_file_pt);
1052 bool restarted=
true;
1053 restarted_problem.
unsteady_run(nstep,restarted,restarted_doc_info);
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
void unsteady_run(const unsigned &ntsteps, const bool &restarted, DocInfo &doc_info)
Run the time integration for ntsteps steps.
void restart(ifstream &restart_file)
Read problem data.
GeomObject * Wall_pt
Pointer to wall.
void actions_after_adapt()
Update the problem specs after adaptation: Set auxiliary update function that applies no slip on all ...
ofstream Trace_file
Trace file.
Node * Sarah_veloc_trace_node_pt
Pointer to node in symmetry plane on coarsest mesh at which velocity is traced.
void actions_after_newton_solve()
Update after solve (empty)
void actions_before_newton_solve()
Update the problem specs before solve (empty)
void doc_solution(DocInfo &doc_info)
Doc the solution.
GeomObject * wall_pt()
Get pointer to wall as geometric object.
void write_trace_file_header()
Write header for trace file.
~OscRingNStProblem()
Destructor (empty)
void actions_before_newton_convergence_check()
Update the problem specs before checking Newton convergence: Update the fluid mesh and re-set velocit...
Mesh * Wall_mesh_pt
Pointer to wall mesh (contains only a single GeneralisedElement)
void set_initial_condition()
Set initial condition (incl previous timesteps) according to specified function.
OscRingNStProblem(const double &dt, FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt)
Constructor: Pass timestep and function pointer to the solution that provides the initial conditions ...
FiniteElement::UnsteadyExactSolutionFctPt IC_Fct_pt
Function pointer to set the intial condition.
AlgebraicRefineableQuarterCircleSectorMesh< ELEMENT > * fluid_mesh_pt()
Access function for the fluid mesh.
Node * Veloc_trace_node_pt
Pointer to node on coarsest mesh on which velocity is traced.
void dump_it(ofstream &dump_file, DocInfo doc_info)
Dump problem data.
AlgebraicRefineableQuarterCircleSectorMesh< ELEMENT > * Fluid_mesh_pt
Pointer to fluid mesh.
Namespace for physical parameters.
double ReSt
Reynolds x Strouhal number.
double Re
Reynolds number.
double Kin_energy_sarah(double t)
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 exact_soln(const double &time, const Vector< double > &x, Vector< double > &soln)
Exact solution: x,y,u,v,p.
double Total_Diss_sarah(double t)
int main(int argc, char *argv[])
///////////////////////////////////////////////////////////////////// ///////////////////////////////...