two_d_womersley.cc File Reference
#include "generic.h"
#include "womersley.h"
#include "navier_stokes.h"
#include "meshes/rectangular_quadmesh.h"
#include "meshes/quarter_tube_mesh.h"

Classes

class  RectangularWomersleyImpedanceTube< ELEMENT >
 Specific Womersley impedance tube for a rectangular cross-section. More...
 

Namespaces

 GlobalPhysicalParameters
 Namespace for Womersley problem.
 

Functions

double GlobalPhysicalParameters::prescribed_volume_flux (const double &time)
 Prescribed volume flux – must be assigned to Prescribed_volume_flux. More...
 
double GlobalPhysicalParameters::prescribed_pressure_gradient (const double &time)
 Prescribed pressure gradient. More...
 
void run_navier_stokes_outflow ()
 
void run_impedance_tube ()
 Driver code for Womersley problem based on impedance tube. More...
 
void run_prescribed_flux ()
 Normal driver code for Womersley problem with prescribed flux. More...
 
void run_prescribed_pressure_gradient ()
 
int main ()
 Driver code for Womersley problem. More...
 

Variables

double GlobalPhysicalParameters::Prescribed_volume_flux =0.0
 Prescribed volume flux. More...
 
double GlobalPhysicalParameters::Alpha_sq =10.0
 Womersley number. More...
 
double GlobalPhysicalParameters::L_impedance =7.0
 Length of impedance tube. More...
 

Function Documentation

◆ main()

int main ( )

Driver code for Womersley problem.

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

692 {
693 
695 
697 
699 
701 
702 
703 };
void run_impedance_tube()
Driver code for Womersley problem based on impedance tube.
Definition: two_d_womersley.cc:358
void run_prescribed_flux()
Normal driver code for Womersley problem with prescribed flux.
Definition: two_d_womersley.cc:450
void run_prescribed_pressure_gradient()
Definition: two_d_womersley.cc:572
void run_navier_stokes_outflow()
Definition: two_d_womersley.cc:159

References run_impedance_tube(), run_navier_stokes_outflow(), run_prescribed_flux(), and run_prescribed_pressure_gradient().

◆ run_impedance_tube()

void run_impedance_tube ( )

Driver code for Womersley problem based on impedance tube.

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

359  {
360 
361  // Setup labels for output
362  DocInfo doc_info;
363 
364  // Output directory
365  doc_info.set_directory("RESLT_impedance_tube");
366 
367  // Output number
368  doc_info.number()=0;
369 
370  // Open a trace file
371  ofstream trace_file;
372  char filename[100];
373  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
374  trace_file.open(filename);
375 
376  // Choose simulation interval and timestep
377  double t_max=5.0;
378  double dt=0.05;
379 
380  // Build Womersley impedance tube
382  womersley_impedance_tube_pt=
386 
387  // Set initial flux
390 
391  // Set up steady flow in impedance tube. NOTE: In NSt problem this
392  // needs to be called when the outflow from the 3D NSt problem
393  // has been assigned (implicitly by assigning its velocity dofs)
394  womersley_impedance_tube_pt->
397 
398 
399  //Output solution
400  womersley_impedance_tube_pt->womersley_problem_pt()->
401  doc_solution(doc_info,trace_file);
402 
403  //Increment counter for solutions
404  doc_info.number()++;
405 
406  // Find number of steps
407  unsigned nstep = static_cast<unsigned>(round(t_max/dt));
408 
409  // Timestepping loop
410  for (unsigned istep=0;istep<nstep;istep++)
411  {
412  // Shift timesteps. NOTE: In NSt problem this needs to go into
413  // the 3D Problem's actions_before_implicit_time_step().
414  // Note: The volume flux is prescribed by a function pointer
415  // so it updates itself.
416  womersley_impedance_tube_pt->shift_time_values(dt);
417 
418  // Get response
419  double p_in=0.0;
420  double dp_in_dq=0.0;
421  womersley_impedance_tube_pt->get_response(p_in,dp_in_dq);
422 
423  //Output solution
424  womersley_impedance_tube_pt->womersley_problem_pt()->
425  doc_solution(doc_info,trace_file);
426 
427  //Increment counter for solutions
428  doc_info.number()++;
429 
430  }
431 
432  // Close trace file
433  trace_file.close();
434 
435 
436  }
Specific Womersley impedance tube for a rectangular cross-section.
Definition: two_d_womersley.cc:91
Definition: oomph_utilities.h:499
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
WomersleyProblem< ELEMENT, DIM > * womersley_problem_pt()
Access to underlying Womersley problem.
Definition: womersley_elements.h:1302
void get_response(double &p_in, double &dp_in_dq)
Definition: womersley_elements.h:1375
void shift_time_values(const double &dt)
Definition: womersley_elements.h:1311
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 round(const bfloat16 &a)
Definition: BFloat16.h:646
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
double Prescribed_volume_flux
Prescribed volume flux.
Definition: two_d_womersley.cc:66
double prescribed_volume_flux(const double &time)
Prescribed volume flux – must be assigned to Prescribed_volume_flux.
Definition: two_d_womersley.cc:54
double Alpha_sq
Womersley number.
Definition: two_d_womersley.cc:69
double L_impedance
Length of impedance tube.
Definition: two_d_womersley.cc:72
string filename
Definition: MergeRestartFiles.py:39

References GlobalPhysicalParameters::Alpha_sq, oomph::DocInfo::directory(), MergeRestartFiles::filename, oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::get_response(), GlobalPhysicalParameters::L_impedance, oomph::DocInfo::number(), GlobalPhysicalParameters::prescribed_volume_flux(), GlobalPhysicalParameters::Prescribed_volume_flux, Eigen::bfloat16_impl::round(), oomph::DocInfo::set_directory(), Flag_definition::setup(), oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::shift_time_values(), and oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::womersley_problem_pt().

Referenced by main().

◆ run_navier_stokes_outflow()

void run_navier_stokes_outflow ( )

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// Driver code for Womersley problem driven by outflow from Navier-Stokes mesh

160  {
161 
162  // Setup labels for output
163  DocInfo doc_info;
164 
165  // Output directory
166  doc_info.set_directory("RESLT_navier_stokes");
167 
168  // Output number
169  doc_info.number()=0;
170 
171  // Open a trace file
172  ofstream trace_file;
173  char filename[100];
174  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
175  trace_file.open(filename);
176 
177 
178  // Create Navier-Stokes mesh
179 
180  // Create geometric objects: Elliptical tube with half axes = radius = 1.0
181  double radius=1.0;
182  GeomObject* Wall_pt=new EllipticalTube(radius,radius);
183 
184  // Boundaries on object
185  Vector<double> xi_lo(2);
186  xi_lo[0]=0.0;
187  xi_lo[1]=0.0;
188  Vector<double> xi_hi(2);
189  xi_hi[0]=7.0;
190  xi_hi[1]=2.0*atan(1.0);
191 
192  // # of layers
193  unsigned nlayer=6;
194 
195  //Radial divider is located half-way along the circumference
196  double frac_mid=0.5;
197 
198  // Build volume mesh
201  Wall_pt,xi_lo,frac_mid,xi_hi,nlayer);
202 
203  n_st_mesh_pt->refine_uniformly();
204  n_st_mesh_pt->refine_uniformly();
205 
206 
207  // Apply boundary conditons: Pin axial velocity on wall (boundary 3)
208  unsigned bound=3;
209  unsigned num_nod=n_st_mesh_pt->nboundary_node(bound);
210  for (unsigned inod=0;inod<num_nod;inod++)
211  {
212  n_st_mesh_pt->boundary_node_pt(bound,inod)->pin(2);
213  }
214 
215 
216  // Create outflow mesh
217  Mesh* Outflow_traction_mesh_pt=new Mesh;
218 
219  // Populate it...
220  unsigned b=n_st_mesh_pt->nboundary()-1;
221  {
222  // Loop over all elements on these boundaries
223  unsigned n_bound_el=n_st_mesh_pt->nboundary_element(b);
224  for (unsigned e=0;e<n_bound_el;e++)
225  {
226  // Get pointer to bulk element
227  RefineableQTaylorHoodElement<3>* bulk_elem_pt =
228  dynamic_cast<RefineableQTaylorHoodElement<3>*>(
229  n_st_mesh_pt->boundary_element_pt(b,e));
230 
231  //What is the index of the face of element e along boundary b
232  int face_index = n_st_mesh_pt->face_index_at_boundary(b,e);
233 
234  // Build the corresponding prescribed traction element
237  traction_element_pt
240  QWomersleyElement<2,3>,2>(bulk_elem_pt,face_index);
241 
242  //Add the prescribed traction element to the mesh
243  Outflow_traction_mesh_pt->add_element_pt(traction_element_pt);
244 
245  }
246  }
247 
248 
249  // Choose simulation interval and timestep
250  double t_max=5.0;
251  double dt=0.05;
252 
253  // Build Womersley impedance tube
254  unsigned fixed_coordinate=2;
255  unsigned w_index=2;
257  womersley_impedance_tube_pt=
260  Outflow_traction_mesh_pt,
261  fixed_coordinate,
262  w_index);
263 
264  // Set up steady flow in impedance tube, imposing the same
265  // flow rate that "comes out of" the 3D tube.
266  double q_initial=womersley_impedance_tube_pt->
267  total_volume_flux_into_impedance_tube();
268  womersley_impedance_tube_pt->
270 
271 
272  //Output Womersley solution
273  womersley_impedance_tube_pt->womersley_problem_pt()->
274  doc_solution(doc_info,trace_file, xi_hi[0]);
275 
276 
277 // // Output Navier Stokes "solution"
278 // ofstream some_file;
279 
280 // // Number of plot points
281 // unsigned npts;
282 // npts=5;
283 
284 // sprintf(filename,"%s/navier_stokes_soln%i.dat",
285 // doc_info.directory().c_str(),
286 // doc_info.number());
287 // some_file.open(filename);
288 // n_st_mesh_pt->output(some_file,npts);
289 // some_file.close();
290 
291  //Increment counter for solutions
292  doc_info.number()++;
293 
294  // Find number of steps
295  unsigned nstep = static_cast<unsigned>(round(t_max/dt));
296 
297  // Timestepping loop
298  for (unsigned istep=0;istep<nstep;istep++)
299  {
300  // Shift timesteps. NOTE: In NSt problem this needs to go into
301  // the 3D Problem's actions_before_implicit_time_step()
302  womersley_impedance_tube_pt->shift_time_values(dt);
303 
304 
305  // Crank up flow rate in 3D tube
306  unsigned nnod= n_st_mesh_pt->nnode();
307  for (unsigned j=0;j<nnod;j++)
308  {
309  Node* nod_pt=n_st_mesh_pt->node_pt(j);
310  double x=nod_pt->x(0);
311  double y=nod_pt->x(1);
312  double time=womersley_impedance_tube_pt->womersley_problem_pt()->
313  time_pt()->time();
314  nod_pt->set_value(2,(1.0-x*x-y*y)*
315  sin(2.0*MathematicalConstants::Pi*time));
316  }
317 
318 
319  // Get response
320  double p_in=0.0;
321  double dp_in_dq=0.0;
322  womersley_impedance_tube_pt->get_response(p_in,dp_in_dq);
323 
324  //Output Womersley solution
325  womersley_impedance_tube_pt->womersley_problem_pt()->
326  doc_solution(doc_info,trace_file,xi_hi[0]);
327 
328 // // Output Navier Stokes "solution"
329 // sprintf(filename,"%s/navier_stokes_soln%i.dat",
330 // doc_info.directory().c_str(),
331 // doc_info.number());
332 // some_file.open(filename);
333 // n_st_mesh_pt->output(some_file,npts);
334 // some_file.close();
335 
336  //Increment counter for solutions
337  doc_info.number()++;
338 
339  }
340 
341  // Close trace file
342  trace_file.close();
343 
344 
345  }
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar * b
Definition: benchVecAdd.cpp:17
void pin(const unsigned &i)
Pin the i-th stored variable.
Definition: nodes.h:385
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
Definition: geom_objects.h:1131
Definition: geom_objects.h:101
Definition: mesh.h:67
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
Definition: mesh.h:833
int face_index_at_boundary(const unsigned &b, const unsigned &e) const
Definition: mesh.h:896
unsigned nboundary_element(const unsigned &b) const
Return number of finite elements that are adjacent to boundary b.
Definition: mesh.h:878
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
FiniteElement * boundary_element_pt(const unsigned &b, const unsigned &e) const
Return pointer to e-th finite element on boundary b.
Definition: mesh.h:840
unsigned long nnode() const
Return number of nodes in the mesh.
Definition: mesh.h:596
void add_element_pt(GeneralisedElement *const &element_pt)
Add a (pointer to) an element to the mesh.
Definition: mesh.h:617
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:436
Node *& boundary_node_pt(const unsigned &b, const unsigned &n)
Return pointer to node n on boundary b.
Definition: mesh.h:493
Definition: womersley_elements.h:1979
Definition: nodes.h:906
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
Definition: womersley_elements.h:632
Definition: refineable_navier_stokes_elements.h:652
Definition: quarter_tube_mesh.template.h:162
void refine_uniformly(DocInfo &doc_info)
Refine mesh uniformly and doc process.
Definition: refineable_mesh.cc:1772
Definition: womersley_elements.h:1828
Scalar * y
Definition: level1_cplx_impl.h:128
double Pi
Definition: two_d_biharmonic.cc:235
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 atan(const bfloat16 &a)
Definition: BFloat16.h:636
radius
Definition: UniformPSDSelfTest.py:15
list x
Definition: plotDoE.py:28
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::Mesh::add_element_pt(), GlobalPhysicalParameters::Alpha_sq, Eigen::bfloat16_impl::atan(), b, oomph::Mesh::boundary_element_pt(), oomph::Mesh::boundary_node_pt(), oomph::DocInfo::directory(), e(), oomph::Mesh::face_index_at_boundary(), MergeRestartFiles::filename, oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::get_response(), j, GlobalPhysicalParameters::L_impedance, oomph::Mesh::nboundary(), oomph::Mesh::nboundary_element(), oomph::Mesh::nboundary_node(), oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::DocInfo::number(), BiharmonicTestFunctions2::Pi, oomph::Data::pin(), UniformPSDSelfTest::radius, oomph::TreeBasedRefineableMeshBase::refine_uniformly(), Eigen::bfloat16_impl::round(), oomph::DocInfo::set_directory(), oomph::Data::set_value(), Flag_definition::setup(), oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::shift_time_values(), sin(), oomph::WomersleyImpedanceTubeBase< ELEMENT, DIM >::womersley_problem_pt(), plotDoE::x, oomph::Node::x(), and y.

Referenced by main().

◆ run_prescribed_flux()

void run_prescribed_flux ( )

Normal driver code for Womersley problem with prescribed flux.

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

451 {
452 
453  // Create timestepper
454  TimeStepper* time_stepper_pt=new BDF<2>;
455 
456  // Setup mesh
457 
458  // Number of elements in x and y directions
459  unsigned nx=5;
460  unsigned ny=5;
461 
462  // Lengths in x and y directions
463  double lx=1.0;
464  double ly=1.0;
465 
466  // Build mesh
467  Mesh* my_mesh_pt =
469  time_stepper_pt);
470 
471 
472  // Set the boundary conditions for this problem:
473 
474  // All nodes are free by default -- just pin the ones that have
475  // Dirichlet conditions here.
476  unsigned n_bound = my_mesh_pt->nboundary();
477  for(unsigned b=0;b<n_bound;b++)
478  {
479  unsigned n_node = my_mesh_pt->nboundary_node(b);
480  for (unsigned n=0;n<n_node;n++)
481  {
482  my_mesh_pt->boundary_node_pt(b,n)->pin(0);
483  }
484  } // end of set boundary conditions
485 
486 
487 
488  // Build problem with specifically created mesh (BCs applied and
489  // timestepper)
493  time_stepper_pt,my_mesh_pt);
494 
495  // Setup labels for output
496  DocInfo doc_info;
497 
498  // Output directory
499  doc_info.set_directory("RESLT_prescribed_volume_flux");
500 
501  // Output number
502  doc_info.number()=0;
503 
504  // Open a trace file
505  ofstream trace_file;
506  char filename[100];
507  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
508  trace_file.open(filename);
509 
510  // Choose simulation interval and timestep
511  double t_max=5.0;
512  double dt=0.05;
513 
514  // Initialise timestep -- also sets the weights for all timesteppers
515  // in the problem.
516  problem.initialise_dt(dt);
517 
518  // Assign current flux
521 
522  // Do steady solve and impulsive start from it
523  problem.steady_newton_solve();
524 
525  //Output initial condition
526  problem.doc_solution(doc_info,trace_file);
527 
528  //Increment counter for solutions
529  doc_info.number()++;
530 
531  // Reuse Jacobian during time-dependent run
532  problem.enable_jacobian_reuse();
533 
534  // Find number of steps
535  unsigned nstep = static_cast<unsigned>(round(t_max/dt));
536 
537  // Timestepping loop
538  for (unsigned istep=0;istep<nstep;istep++)
539  {
540  // Assign flux at next timestep
543  problem.time_pt()->time()+dt);
544 
545  // Take timestep
546  problem.unsteady_newton_solve(dt);
547 
548  //Output solution
549  problem.doc_solution(doc_info,trace_file);
550 
551  //Increment counter for solutions
552  doc_info.number()++;
553 
554  }
555 
556  // Close trace file
557  trace_file.close();
558 
559 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: rectangular_quadmesh.template.h:59
Definition: timesteppers.h:231
Womersley problem.
Definition: womersley_elements.h:743
const double ly
Definition: ConstraintElementsUnitTest.cpp:34
const double lx
Definition: ConstraintElementsUnitTest.cpp:33
const unsigned nx
Definition: ConstraintElementsUnitTest.cpp:30
const unsigned ny
Definition: ConstraintElementsUnitTest.cpp:31
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References GlobalPhysicalParameters::Alpha_sq, b, oomph::Mesh::boundary_node_pt(), oomph::DocInfo::directory(), MergeRestartFiles::filename, Mesh_Parameters::lx, Mesh_Parameters::ly, n, oomph::Mesh::nboundary(), oomph::Mesh::nboundary_node(), oomph::DocInfo::number(), Mesh_Parameters::nx, Mesh_Parameters::ny, oomph::Data::pin(), GlobalPhysicalParameters::prescribed_volume_flux(), GlobalPhysicalParameters::Prescribed_volume_flux, problem, Eigen::bfloat16_impl::round(), and oomph::DocInfo::set_directory().

Referenced by main().

◆ run_prescribed_pressure_gradient()

void run_prescribed_pressure_gradient ( )

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// Normal driver code for Womersley problem with prescribed pressure gradient

573 {
574 
575  // Create timestepper
576  TimeStepper* time_stepper_pt=new BDF<2>;
577 
578  // Setup mesh
579 
580  // Number of elements in x and y directions
581  unsigned nx=5;
582  unsigned ny=5;
583 
584  // Lengths in x and y directions
585  double lx=1.0;
586  double ly=1.0;
587 
588  // Build mesh
589  Mesh* my_mesh_pt =
591  time_stepper_pt);
592 
593 
594  // Set the boundary conditions for this problem:
595 
596  // All nodes are free by default -- just pin the ones that have
597  // Dirichlet conditions here.
598  unsigned n_bound = my_mesh_pt->nboundary();
599  for(unsigned b=0;b<n_bound;b++)
600  {
601  unsigned n_node = my_mesh_pt->nboundary_node(b);
602  for (unsigned n=0;n<n_node;n++)
603  {
604  my_mesh_pt->boundary_node_pt(b,n)->pin(0);
605  }
606  } // end of set boundary conditions
607 
608 
609 
610  // Build problem with specifically created mesh (BCs applied and
611  // timestepper)
615  time_stepper_pt,my_mesh_pt);
616 
617  // Setup labels for output
618  DocInfo doc_info;
619 
620  // Output directory
621  doc_info.set_directory("RESLT_prescribed_pressure_gradient");
622 
623  // Output number
624  doc_info.number()=0;
625 
626  // Open a trace file
627  ofstream trace_file;
628  char filename[100];
629  sprintf(filename,"%s/trace.dat",doc_info.directory().c_str());
630  trace_file.open(filename);
631 
632  // Choose simulation interval and timestep
633  double t_max=5.0;
634  double dt=0.05;
635 
636  // Initialise timestep -- also sets the weights for all timesteppers
637  // in the problem.
638  problem.initialise_dt(dt);
639 
640  // Assign initial pressure gradient
641  problem.pressure_gradient_data_pt()->set_value(
642  0,
644 
645 
646  // Do steady solve and impulsive start from it
647  problem.steady_newton_solve();
648 
649  //Output initial condition
650  problem.doc_solution(doc_info,trace_file);
651 
652  //Increment counter for solutions
653  doc_info.number()++;
654 
655  // Reuse Jacobian during time-dependent run
656  problem.enable_jacobian_reuse();
657 
658  // Find number of steps
659  unsigned nstep = static_cast<unsigned>(round(t_max/dt));
660 
661  // Timestepping loop
662  for (unsigned istep=0;istep<nstep;istep++)
663  {
664  // Take timestep
665  problem.unsteady_newton_solve(dt);
666 
667  //Output solution
668  problem.doc_solution(doc_info,trace_file);
669 
670  //Increment counter for solutions
671  doc_info.number()++;
672 
673  }
674 
675  // Close trace file
676  trace_file.close();
677 
678 }
double prescribed_pressure_gradient(const double &time)
Prescribed pressure gradient.
Definition: two_d_womersley.cc:60

References GlobalPhysicalParameters::Alpha_sq, b, oomph::Mesh::boundary_node_pt(), oomph::DocInfo::directory(), MergeRestartFiles::filename, Mesh_Parameters::lx, Mesh_Parameters::ly, n, oomph::Mesh::nboundary(), oomph::Mesh::nboundary_node(), oomph::DocInfo::number(), Mesh_Parameters::nx, Mesh_Parameters::ny, oomph::Data::pin(), GlobalPhysicalParameters::prescribed_pressure_gradient(), problem, Eigen::bfloat16_impl::round(), and oomph::DocInfo::set_directory().

Referenced by main().