33 #include "navier_stokes.h"
36 #include "axisym_navier_stokes.h"
39 #include "meshes/rectangular_quadmesh.h"
43 using namespace oomph;
70 template <
class ELEMENT,
class TIMESTEPPER>
79 const double& l_r,
const double& l_z);
85 void set_initial_condition();
88 void set_boundary_conditions();
91 void doc_solution(DocInfo &doc_info);
94 void unsteady_run(
const double& t_max,
const double& dt,
95 const string dir_name);
98 RefineableRectangularQuadMesh<ELEMENT>*
mesh_pt()
100 return dynamic_cast<RefineableRectangularQuadMesh<ELEMENT>*
>
101 (Problem::mesh_pt());
118 RefineableAxisymmetricNavierStokesEquations::
119 unpin_all_pressure_dofs(mesh_pt()->element_pt());
122 RefineableAxisymmetricNavierStokesEquations::
123 pin_redundant_nodal_pressures(mesh_pt()->element_pt());
126 fix_pressure(0,0,0.0);
132 const unsigned& pdof,
133 const double& pvalue)
136 dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(e))->
137 fix_pressure(pdof,pvalue);
147 template <
class ELEMENT,
class TIMESTEPPER>
150 const double& l_r,
const double& l_z)
154 add_time_stepper_pt(
new TIMESTEPPER);
157 Problem::mesh_pt() =
new RefineableRectangularQuadMesh<ELEMENT>
158 (n_r,n_z,l_r,l_z,time_stepper_pt());
161 mesh_pt()->spatial_error_estimator_pt() =
new Z2ErrorEstimator;
164 mesh_pt()->max_refinement_level() = 4;
167 mesh_pt()->max_permitted_error() = 1.0e-2;
168 mesh_pt()->min_permitted_error() = 1.0e-3;
178 const unsigned n_boundary = mesh_pt()->nboundary();
181 for(
unsigned b=0;b<n_boundary;b++)
184 const unsigned n_node = mesh_pt()->nboundary_node(b);
187 for(
unsigned n=0;n<n_node;n++)
190 mesh_pt()->boundary_node_pt(b,n)->pin(0);
193 if(b!=3) { mesh_pt()->boundary_node_pt(b,n)->pin(1); }
196 mesh_pt()->boundary_node_pt(b,n)->pin(2);
206 const unsigned n_element = mesh_pt()->nelement();
209 for(
unsigned e=0;e<n_element;e++)
212 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(e));
221 el_pt->disable_ALE();
226 RefineableAxisymmetricNavierStokesEquations::
227 pin_redundant_nodal_pressures(mesh_pt()->element_pt());
230 fix_pressure(0,0,0.0);
233 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
243 template <
class ELEMENT,
class TIMESTEPPER>
247 const unsigned n_node = mesh_pt()->nnode();
250 for(
unsigned n=0;n<n_node;n++)
253 for(
unsigned i=0;i<3;i++)
256 mesh_pt()->node_pt(n)->set_value(i,0.0);
262 assign_initial_values_impulsive();
273 template <
class ELEMENT,
class TIMESTEPPER>
277 const unsigned n_boundary = mesh_pt()->nboundary();
280 for(
unsigned b=0;b<n_boundary;b++)
283 const unsigned n_node = mesh_pt()->nboundary_node(b);
286 for(
unsigned n=0;n<n_node;n++)
292 const double r_pos = mesh_pt()->boundary_node_pt(b,n)->x(0);
295 mesh_pt()->boundary_node_pt(b,n)->set_value(0,0,0.0);
296 mesh_pt()->boundary_node_pt(b,n)->set_value(0,1,0.0);
297 mesh_pt()->boundary_node_pt(b,n)->set_value(0,2,r_pos);
305 mesh_pt()->boundary_node_pt(b,n)->set_value(0,0,0.0);
306 mesh_pt()->boundary_node_pt(b,n)->set_value(0,2,0.0);
318 template <
class ELEMENT,
class TIMESTEPPER>
324 cout <<
"Time is now " << time_pt()->time() << std::endl;
330 const unsigned npts = 5;
333 sprintf(filename,
"%s/soln%i.dat",
334 doc_info.directory().c_str(),doc_info.number());
335 some_file.open(filename);
338 mesh_pt()->output(some_file,npts);
350 template <
class ELEMENT,
class TIMESTEPPER>
352 unsteady_run(
const double& t_max,
const double& dt,
const string dir_name)
359 doc_info.set_directory(dir_name);
368 set_initial_condition();
371 unsigned max_adapt = 4;
374 for(
unsigned i=0;i<2;i++) { refine_uniformly(); }
377 const unsigned n_timestep = unsigned(t_max/dt);
380 doc_solution(doc_info);
386 bool first_timestep =
true;
389 Z2ErrorEstimator* error_pt =
dynamic_cast<Z2ErrorEstimator*
>
390 (mesh_pt()->spatial_error_estimator_pt());
391 error_pt->reference_flux_norm() = 0.01;
394 for(
unsigned t=1;t<=n_timestep;t++)
397 cout <<
"\nTimestep " << t <<
" of " << n_timestep << std::endl;
400 unsteady_newton_solve(dt,max_adapt,first_timestep);
403 first_timestep =
false;
409 doc_solution(doc_info);
427 int main(
int argc,
char* argv[])
430 CommandLineArgs::setup(argc,argv);
436 const double dt = 0.01;
439 if(CommandLineArgs::Argc>1) { t_max = 0.02; }
442 const unsigned n_r = 2;
445 const unsigned n_z = 2;
448 const double l_r = 1.0;
451 const double l_z = 1.4;
457 cout <<
"Doing RefineableAxisymmetricQTaylorHoodElement" << std::endl;
461 <RefineableAxisymmetricQTaylorHoodElement, BDF<2> >
462 problem(n_r,n_z,l_r,l_z);
465 problem.unsteady_run(t_max,dt,
"RESLT_TH");
472 cout <<
"Doing RefineableAxisymmetricQCrouzeixRaviartElement" << std::endl;
476 <RefineableAxisymmetricQCrouzeixRaviartElement, BDF<2> >
477 problem(n_r,n_z,l_r,l_z);
480 problem.unsteady_run(t_max,dt,
"RESLT_CR");
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
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 doc_solution(DocInfo &doc_info)
Document the solution.
void actions_after_newton_solve()
No actions required after solve step.
void set_boundary_conditions()
Set boundary conditions.
RotatingCylinderProblem(const unsigned &n_r, const unsigned &n_z, const double &l_r, const double &l_z)
Constructor: Pass the number of elements and the lengths of the domain in the radial (r) and axial (z...
RefineableRectangularQuadMesh< ELEMENT > * mesh_pt()
Access function for the specific mesh.
~RotatingCylinderProblem()
Destructor (empty)
void set_initial_condition()
Set initial conditions.
void actions_after_adapt()
After adaptation: Pin pressure again (the previously pinned value might have disappeared) and pin red...
void unsteady_run(const double &t_max, const double &dt, const string dir_name)
Do unsteady run up to maximum time t_max with given timestep dt.
void actions_before_newton_solve()
Update the problem specs before solve. Reset velocity boundary conditions just to be on the safe side...
Namespace for physical parameters.
double ReSt
Womersley number.
double Re
Reynolds number.
int main(int argc, char *argv[])
/////////////////////////////////////////////////////////////////////// /////////////////////////////...