jeffery_hamel.cc File Reference
#include <algorithm>
#include "generic.h"
#include "polar_navier_stokes.h"
#include "meshes/rectangular_quadmesh.h"
#include "./refineable_r_mesh.h"
#include "./streamfunction_include.h"
#include "./jh_includes.h"

Classes

class  PolarNSProblem< ELEMENT >
 Driven cavity problem in rectangular domain. More...
 

Namespaces

 Global_Physical_Variables
 Global variables.
 

Functions

void Global_Physical_Variables::traction_function (const double &time, const Vector< double > &x, Vector< double > &traction)
 Unused (but assigned) function to specify tractions. More...
 
int main ()
 

Variables

double Global_Physical_Variables::R_l =0.01
 
double Global_Physical_Variables::R_r =1.
 
int Global_Physical_Variables::xmesh =30
 
int Global_Physical_Variables::ymesh =15
 
double Global_Physical_Variables::Rstep_prestart =30.0
 
double Global_Physical_Variables::Rmax_prestart =94.
 
double Global_Physical_Variables::Rstep =0.1
 
double Global_Physical_Variables::Rmax =100.
 
double Global_Physical_Variables::epsilon =0.1
 
bool Global_Physical_Variables::inlet_traction =false
 
double Global_Physical_Variables::eta_inlet =1.0
 
bool Global_Physical_Variables::outlet_traction =true
 
double Global_Physical_Variables::eta_outlet =0.0
 
bool Global_Physical_Variables::pinv =true
 
bool Global_Physical_Variables::stokes =false
 
bool Global_Physical_Variables::log_mesh =true
 
bool Global_Physical_Variables::new_outlet_region =true
 
int Global_Physical_Variables::uniform = 0
 
int Global_Physical_Variables::adaptive = 0
 

Function Documentation

◆ main()

int main ( )

Driver for PolarNS test problem – test drive with two different types of element.

771 {
772  // Set up doc info
773  // ---------------
774  DocInfo doc_info;
775  doc_info.set_directory("RESLT");
776  doc_info.number()=0;
777  // And again for eigenmode
778  DocInfo eigenmode;
779  eigenmode.set_directory("RESLT");
780  eigenmode.number() = 100;
781  // ---------------
782 
783  using namespace Global_Physical_Variables;
784  Vector<double> shear_stress(2,0.0);
785 
786  // Build the problem
788  //PolarNSProblem<RefineablePolarTaylorHoodElement > problem;
789 
790  cout << endl << "# xmesh: " << xmesh << " ymesh: " << ymesh << endl;
791 
792  //Increace the Reynolds number in large increments
794  {
795  cout << endl << "Prestart solving for Re: " << Re << endl << endl;
796 
797  problem.newton_solve();
798  problem.doc_solution(doc_info);
799  doc_info.number()+=1;
800  //problem.output_streamfunction(doc_info,false);
801  }
802 
803  exit(1);
804 
805  //Always start from same Reynolds number
807 
808  problem.newton_solve();
809  problem.doc_solution(doc_info);
810  doc_info.number()+=1;
811 
812  bool sym=true;
813 
814  //Storage for eigenvalues and eigenvectors
815  Vector<complex<double> > eigenvalues;
816  Vector<DoubleVector> eigenvectors;
817  //Desired number eigenvalues
818  unsigned n_eval=6;
819  //Set shift
820  static_cast<ARPACK*>( problem.eigen_solver_pt() ) -> set_shift( 0.4 );
821 
822  //Solve the eigenproblem
823  cout << "facking" << endl;
824  problem.solve_eigenproblem(n_eval,eigenvalues,eigenvectors);
825  for(unsigned k=0;k<n_eval;k++) cout << "eigenvalue: " << eigenvalues[k] << endl;
826  cout << "arpack" << endl;
827  //Activate pitchfork tracking
828  DoubleVector eigenvector(eigenvectors[0]);
829 
830  //Compute symmetry vector
831  DoubleVector symmetry;
832  double norm = 1.e-2;
833  problem.get_symmetry(symmetry,norm);
834 
835  ofstream out("scrap_up.dat");
836  out << "# Output { Re, Alpha, Int du_dphi(-1), Int du_dphi(1), Delta_Shear_Stress, Jacobian sign }" << endl;
837  out << "# Radius ratio: " << R_l << " xmesh: " << xmesh << " ymesh " << ymesh << endl;
838  out << "# Alpha = " << Alpha << endl;
839  out << "# New outlet region: " << new_outlet_region << endl;
840  out << "# Inlet traction: " << inlet_traction << " Outlet traction: " << outlet_traction << endl;
841  out << "# eta_inlet (Homotopy parameter): " << eta_inlet << " eta_outlet: " << eta_outlet << endl;
842  out << "# Pin v at inlet: " << pinv << endl;
843  out << "# Using symmetry for pitchfork solve: " << sym << endl << endl;
844 
845  //Activate pitchfork tracking
846  if(sym)
847  {
848  cout << endl << "Using symmetry vector from get_symmetry routine. Re = " << Re << endl << endl;
849  problem.activate_pitchfork_tracking(&Global_Physical_Variables::Re,symmetry);
850  }
851  else
852  {
853  cout << endl << "Using eigenvector for pitchfork detection. Re = " << Re << endl << endl;
854  problem.activate_pitchfork_tracking(&Global_Physical_Variables::Re,eigenvector);
855  }
856 
857  //Find an intitial pitchfork
858  problem.newton_solve();
859 
860  //Check on slack parameter
861  unsigned long n_dof = problem.ndof();cout << "ndof: " << n_dof << endl;
862  DoubleVector soln;
863  problem.get_dofs(soln);
864  unsigned long half=(n_dof/2)-1;
865  cout << "According to dofs Re is: " << problem.dof(half)
866  << " and slack parameter is: " << problem.dof(n_dof-1) << endl;
867 
868  double slack=problem.dof(n_dof-1);
869 
870  problem.deactivate_bifurcation_tracking();
871 
872  doc_info.number()=10;
873  problem.doc_solution(doc_info);
874  problem.get_shear_stress(shear_stress);
875  cout << "Shear stress is: Lower = " << shear_stress[0] << " Upper = " << shear_stress[1]
876  << " Delta = " << (shear_stress[0]+shear_stress[1]) << endl;
877 
878  cout << endl << "Pitchfork detected at Re = " << Re << " and Alpha = " << Alpha << endl;
879  cout << "========================================================" << endl;
880 
881  out << Re << " " << Alpha << " " << shear_stress[0] << " " << shear_stress[1] << " "
882  << (shear_stress[0]+shear_stress[1]) << " " << 0 << " " << slack << endl;
883 
884 
885  cout << "========================================================" << endl;
886  cout << endl << "Computing eigenvalue at pitchfork. Re = " << Re << endl << endl;
887  //Solve the eigenproblem
888  problem.solve_eigenproblem(n_eval,eigenvalues,eigenvectors);
889  for(unsigned k=0;k<n_eval;k++) cout << "eigenvalue: " << eigenvalues[k] << endl;
890 
891  // OUTPUT THE EIGENMODE
892  eigenmode.number()=100;
893  problem.store_current_dof_values();
894  problem.pin_boundaries_to_zero();
895  problem.assign_eigenvector_to_dofs( eigenvectors[0] );
896  problem.doc_solution( eigenmode );
897  problem.restore_dof_values();
898 
899  //Store solution at bifurcation
900  n_dof = problem.ndof(); cout << "ndof: " << n_dof << endl;
901  DoubleVector soln_at_bifurcation;
902  problem.get_dofs(soln_at_bifurcation);
903  DoubleVector critical_eigenvector(eigenvectors[0]);
904 
905  // part one ---------------------------------------------------------------------------------------
906 
907  double multiplier=-5.0;
908  int sign=0;
909 
910  cout << endl << "Adding eigenvector[0] with multiplier " << multiplier << " to degrees of freedom" << endl;
911  for(unsigned long d=0;d<n_dof;d++)
912  {
913  problem.dof(d)=soln_at_bifurcation[d]+multiplier*critical_eigenvector[d];
914  }
915 
916  //Now we increace/decreace the Reynolds number slightly and compute a solution
917  Re+=epsilon;
918  cout << "Adjusting Reynolds number by " << epsilon << " to Re: " << Re
919  << " and newton solving" << endl << endl;
920  problem.newton_solve();
921  problem.get_shear_stress(shear_stress);
922  sign=problem.get_Jacobian_sign();
923  cout << "Shear stress is: Lower = " << shear_stress[0] << " Upper = " << shear_stress[1]
924  << " Delta = " << (shear_stress[0]+shear_stress[1]) << endl;
925 
926  out << Re << " " << Alpha << " " << shear_stress[0] << " " << shear_stress[1] << " " << (shear_stress[0]+shear_stress[1]) << " " << sign << endl;
927 
928  //Now we step in Re and try to continue the bifurcated state
929  double ds=Rstep;
930  Re-=ds*0.9;
931 
932  ds=problem.arc_length_step_solve( &Re, ds );
933  cout << endl << "Re: " << Re << endl;
934  problem.get_shear_stress(shear_stress);
935  sign=problem.get_Jacobian_sign();
936  cout << "Shear stress is: Lower = " << shear_stress[0] << " Upper = " << shear_stress[1]
937  << " Delta = " << (shear_stress[0]+shear_stress[1]) << endl;
938  if(inlet_traction && outlet_traction) cout << " pext: " << problem.get_pext() << endl;
939  out << Re << " " << Alpha << " " << shear_stress[0] << " " << shear_stress[1] << " " << (shear_stress[0]+shear_stress[1]) << " " << sign << endl;
940 
941  for(;Re<Rmax;)
942  {
943  problem.arc_length_step_solve( &Re, ds );
944  cout << endl << "Re: " << Re << endl;
945  problem.get_shear_stress(shear_stress);
946  sign=problem.get_Jacobian_sign();
947  cout << "Shear stress is: Lower = " << shear_stress[0] << " Upper = " << shear_stress[1]
948  << " Delta = " << (shear_stress[0]+shear_stress[1]) << endl;
949  if(inlet_traction && outlet_traction) cout << " pext: " << problem.get_pext() << endl;
950  out << Re << " " << Alpha << " " << shear_stress[0] << " " << shear_stress[1] << " " << (shear_stress[0]+shear_stress[1]) << " " << sign << endl;
951  }
952 
953  //Compute the picture at Re=Rmax/Re=Rmin
954  Re=Rmax;
955  cout << endl << "Computing picture at Re: " << Re << endl << endl;
956  problem.newton_solve(2);
957  doc_info.number()=20;
958  problem.doc_solution(doc_info);
959  problem.output_streamfunction(doc_info,false);
960  doc_info.number()+=1;
961  problem.get_shear_stress(shear_stress);
962  sign=problem.get_Jacobian_sign();
963  out << Re << " " << Alpha << " " << shear_stress[0] << " " << shear_stress[1] << " " << (shear_stress[0]+shear_stress[1]) << " " << sign << endl;
964 
965  out.close();
966 
967 } // end_of_main
Driven cavity problem in rectangular domain.
Definition: jeffery_hamel.cc:132
Class for the ARPACK eigensolver.
Definition: eigen_solver.h:104
Definition: oomph_utilities.h:499
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
Definition: double_vector.h:58
char char char int int * k
Definition: level2_impl.h:374
Global variables.
Definition: TwenteMeshGluing.cpp:60
int ymesh
Definition: jeffery_hamel.cc:62
double multiplier(const Vector< double > &xi)
Definition: disk_oscillation.cc:63
bool pinv
Definition: jeffery_hamel.cc:86
double Rmax_prestart
Definition: jeffery_hamel.cc:71
double epsilon
Definition: jeffery_hamel.cc:76
bool new_outlet_region
Definition: jeffery_hamel.cc:93
double Rstep
Definition: jeffery_hamel.cc:72
bool outlet_traction
Definition: jeffery_hamel.cc:82
int xmesh
Definition: jeffery_hamel.cc:61
double Rstep_prestart
Definition: jeffery_hamel.cc:70
double R_l
Definition: jeffery_hamel.cc:57
double eta_inlet
Definition: jeffery_hamel.cc:80
double Alpha
Scaling factor for wall thickness (to be used in an exercise)
Definition: unsteady_ring.cc:73
bool inlet_traction
Definition: jeffery_hamel.cc:79
double Re
Reynolds number.
Definition: fibre.cc:55
double eta_outlet
Definition: jeffery_hamel.cc:83
double Rmax
Definition: jeffery_hamel.cc:73
T sign(T x)
Definition: cxx11_tensor_builtins_sycl.cpp:172
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213
std::ofstream out("Result.txt")

References TanhSolnForAdvectionDiffusion::Alpha, Global_Physical_Variables::epsilon, Global_Physical_Variables::eta_inlet, Global_Physical_Variables::eta_outlet, Global_Physical_Variables::inlet_traction, k, Global_Physical_Variables::multiplier(), Global_Physical_Variables::new_outlet_region, oomph::DocInfo::number(), out(), Global_Physical_Variables::outlet_traction, Global_Physical_Variables::pinv, problem, Global_Physical_Variables::R_l, GlobalPhysicalVariables::Re, Global_Physical_Variables::Re, Global_Physical_Variables::Rmax, Global_Physical_Variables::Rmax_prestart, Global_Physical_Variables::Rstep, Global_Physical_Variables::Rstep_prestart, oomph::DocInfo::set_directory(), SYCL::sign(), Global_Physical_Variables::xmesh, and Global_Physical_Variables::ymesh.