32 #include "navier_stokes.h"
35 #include "meshes/quarter_circle_sector_mesh.h"
39 using namespace oomph;
55 const double& period, Time* time_pt) :
56 GeomObject(1,2),
A(a),
A_hat(a_hat),
T(period), Time_pt(time_pt) {}
63 void position(
const Vector<double>& xi, Vector<double>& r)
const
66 double time=Time_pt->time();
69 double axis=
A+
A_hat*cos(2.0*MathematicalConstants::Pi*time/
T);
70 r[0] = axis*cos(xi[0]);
71 r[1] = (1.0/axis)*sin(xi[0]);
77 void position(
const unsigned& t,
const Vector<double>& xi,
78 Vector<double>& r)
const
81 double time=Time_pt->time(t);
84 double axis=
A+
A_hat*cos(2.0*MathematicalConstants::Pi*time/
T);
85 r[0] = axis*cos(xi[0]);
86 r[1] = (1.0/axis)*sin(xi[0]);
135 void get_exact_u(
const double& t,
const Vector<double>& x, Vector<double>& u)
137 using namespace MathematicalConstants;
143 double a=
A+
A_hat*cos(2.0*Pi*t/
T);
144 double adot=-2.0*
A_hat*Pi*sin(2.0*Pi*t/
T)/
T;
152 u[2]=(2.0*
A_hat*Pi*Pi*
Re*(x[0]*x[0]*St*cos(2.0*Pi*t/
T)*
A +
154 x[0]*x[0]*
A_hat*cos(2.0*Pi*t/
T)*cos(2.0*Pi*t/
T) -
155 x[1]*x[1]*St*cos(2.0*Pi*t/
T)*
A -
157 x[1]*x[1]*
A_hat*cos(2.0*Pi*t/
T)*cos(2.0*Pi*t/
T) ))
177 template<
class ELEMENT,
class TIMESTEPPER>
202 RefineableNavierStokesEquations<2>::
203 unpin_all_pressure_dofs(mesh_pt()->element_pt());
206 RefineableNavierStokesEquations<2>::
207 pin_redundant_nodal_pressures(mesh_pt()->element_pt());
210 fix_pressure(0,0,0.0);
219 mesh_pt()->node_update();
224 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
225 for (
unsigned inod=0;inod<num_nod;inod++)
228 Node* node_pt=mesh_pt()->boundary_node_pt(ibound,inod);
231 FSI_functions::apply_no_slip_on_moving_wall(node_pt);
239 void doc_solution(DocInfo& doc_info);
242 void unsteady_run(DocInfo& doc_info);
245 void set_initial_condition();
251 const double &pvalue)
254 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(e))->
255 fix_pressure(pdof,pvalue);
268 template<
class ELEMENT,
class TIMESTEPPER>
273 add_time_stepper_pt(
new TIMESTEPPER);
291 Wall_pt=
new MyEllipse(a,a_hat,period,Problem::time_pt());
296 double xi_hi=MathematicalConstants::Pi/2.0;
301 double fract_mid=0.5;
302 Problem::mesh_pt() =
new RefineableQuarterCircleSectorMesh<ELEMENT>(
303 Wall_pt,xi_lo,fract_mid,xi_hi,time_stepper_pt());
317 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
318 for (
unsigned inod=0;inod<num_nod;inod++)
322 for (
unsigned i=0;i<2;i++)
324 mesh_pt()->boundary_node_pt(ibound,inod)->pin(i);
332 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
333 for (
unsigned inod=0;inod<num_nod;inod++)
337 mesh_pt()->boundary_node_pt(ibound,inod)->pin(1);
345 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
346 for (
unsigned inod=0;inod<num_nod;inod++)
350 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
360 unsigned n_element = mesh_pt()->nelement();
364 for(
unsigned i=0;i<n_element;i++)
367 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
375 RefineableNavierStokesEquations<2>::
376 pin_redundant_nodal_pressures(mesh_pt()->element_pt());
379 fix_pressure(0,0,0.0);
382 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
391 template<
class ELEMENT,
class TIMESTEPPER>
395 double backed_up_time=time_pt()->time();
402 Vector<double> soln(3);
406 unsigned num_nod = mesh_pt()->nnode();
409 int nprev_steps=time_stepper_pt()->nprev_values();
410 Vector<double> prev_time(nprev_steps+1);
411 for (
int itime=nprev_steps;itime>=0;itime--)
413 prev_time[itime]=time_pt()->time(
unsigned(itime));
418 for (
int itime=nprev_steps;itime>=0;itime--)
420 double time=prev_time[itime];
424 time_pt()->time()=time;
426 cout <<
"setting IC at time =" << time << std::endl;
431 mesh_pt()->node_update();
434 for (
unsigned jnod=0;jnod<num_nod;jnod++)
437 x[0]=mesh_pt()->node_pt(jnod)->x(0);
438 x[1]=mesh_pt()->node_pt(jnod)->x(1);
444 mesh_pt()->node_pt(jnod)->set_value(itime,0,soln[0]);
445 mesh_pt()->node_pt(jnod)->set_value(itime,1,soln[1]);
448 for (
unsigned i=0;i<2;i++)
450 mesh_pt()->node_pt(jnod)->x(itime,i)=x[i];
456 time_pt()->time()=backed_up_time;
465 template<
class ELEMENT,
class TIMESTEPPER>
477 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
479 some_file.open(filename);
480 mesh_pt()->output(some_file,npts);
481 some_file <<
"TEXT X=2.5,Y=93.6,F=HELV,HU=POINT,C=BLUE,H=26,T=\"time = "
482 << time_pt()->time() <<
"\"";
483 some_file <<
"GEOMETRY X=2.5,Y=98,T=LINE,C=BLUE,LT=0.4" << std::endl;
484 some_file <<
"1" << std::endl;
485 some_file <<
"2" << std::endl;
486 some_file <<
" 0 0" << std::endl;
487 some_file << time_pt()->time()*20.0 <<
" 0" << std::endl;
491 some_file <<
"ZONE I=2,J=2" << std::endl;
492 some_file <<
"0.0 0.0 -0.65 -0.65 -200.0" << std::endl;
493 some_file <<
"1.15 0.0 -0.65 -0.65 -200.0" << std::endl;
494 some_file <<
"0.0 1.15 -0.65 -0.65 -200.0" << std::endl;
495 some_file <<
"1.15 1.15 -0.65 -0.65 -200.0" << std::endl;
496 some_file <<
"ZONE I=2,J=2" << std::endl;
497 some_file <<
"0.0 0.0 0.65 0.65 300.0" << std::endl;
498 some_file <<
"1.15 0.0 0.65 0.65 300.0" << std::endl;
499 some_file <<
"0.0 1.15 0.65 0.65 300.0" << std::endl;
500 some_file <<
"1.15 1.15 0.65 0.65 300.0" << std::endl;
506 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
508 some_file.open(filename);
509 mesh_pt()->output_fct(some_file,npts,time_pt()->time(),
516 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
518 some_file.open(filename);
519 mesh_pt()->compute_error(some_file,
528 cout <<
"error: " << error << std::endl;
529 cout <<
"norm : " << norm << std::endl << std::endl;
534 sprintf(filename,
"%s/Wall%i.dat",doc_info.directory().c_str(),
536 some_file.open(filename);
539 for (
unsigned iplot=0;iplot<nplot;iplot++)
541 Vector<double> xi_wall(1), r_wall(2);
542 xi_wall[0]=0.5*MathematicalConstants::Pi*double(iplot)/double(nplot-1);
543 Wall_pt->position(xi_wall,r_wall);
544 some_file << r_wall[0] <<
" " << r_wall[1] << std::endl;
557 template<
class ELEMENT,
class TIMESTEPPER>
571 set_initial_condition();
577 unsigned nstep = unsigned(t_max/dt);
581 if (CommandLineArgs::Argc>1)
585 cout <<
"validation run" << std::endl;
597 doc_solution(doc_info);
600 for (
unsigned istep=0;istep<nstep;istep++)
602 cout <<
"TIMESTEP " << istep << std::endl;
603 cout <<
"Time is now " << time_pt()->time() << std::endl;
606 unsteady_newton_solve(dt);
609 doc_solution(doc_info);
624 int main(
int argc,
char* argv[])
628 CommandLineArgs::setup(argc,argv);
635 doc_info.set_directory(
"RESLT_CR");
648 doc_info.set_directory(
"RESLT_TH");
double A_hat
Amplitude of variation in x-half axis.
MyEllipse(const double &a, const double &a_hat, const double &period, Time *time_pt)
Constructor: Pass initial x-half axis, amplitude of x-variation, period of oscillation and pointer to...
void position(const Vector< double > &xi, Vector< double > &r) const
Current position vector to material point at Lagrangian coordinate xi.
void position(const unsigned &t, const Vector< double > &xi, Vector< double > &r) const
Parametrised position on object: r(xi). Evaluated at previous time level. t=0: current time; t>0: pre...
double T
Period of oscillation.
Time * Time_pt
Pointer to time object.
virtual ~MyEllipse()
Destructor: Empty.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
void actions_before_newton_solve()
Update problem specs before solve (empty)
void actions_after_newton_solve()
Update the problem specs after solve (empty)
~OscEllipseProblem()
Destructor (empty)
void actions_after_adapt()
Actions after adaptation, pin relevant pressures.
void actions_before_implicit_timestep()
Update the problem specs before next timestep.
GeomObject * Wall_pt
Pointer to GeomObject that specifies the domain bondary.
void actions_after_implicit_timestep()
Update the problem specs after timestep (empty)
void fix_pressure(const unsigned &e, const unsigned &pdof, const double &pvalue)
Fix pressure in element e at pressure dof pdof and set to pvalue.
void actions_before_adapt()
Actions before adapt (empty)
OscEllipseProblem()
Constructor.
void unsteady_run(DocInfo &doc_info)
Timestepping loop.
void set_initial_condition()
Set initial condition.
void doc_solution(DocInfo &doc_info)
Doc the solution.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
double ReSt
Womersley = Reynolds times Strouhal.
double A_hat
x-Half axis amplitude
double T
Period of oscillations.
double A
x-Half axis length
double Re
Reynolds number.
void get_exact_u(const double &t, const Vector< double > &x, Vector< double > &u)
Exact solution of the problem as a vector containing u,v,p.
int main(int argc, char *argv[])
/////////////////////////////////////////////////////////////////////