axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc File Reference

Classes

class  BaseStateProblem< BASE_ELEMENT >
 Base state problem class for Tuckerman counter-rotating lids problem. More...
 
class  PerturbedStateProblem< BASE_ELEMENT, PERTURBED_ELEMENT >
 
class  StabilityProblem< BASE_ELEMENT, PERTURBED_ELEMENT >
 

Namespaces

 GlobalPhysicalVariables
 Namespace for physical parameters.
 

Functions

int main (int argc, char *argv[])
 Driver for Tuckerman counter-rotating lids problem. More...
 

Variables

Vector< doubleGlobalPhysicalVariables::G (3)
 Direction of gravity. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Driver for Tuckerman counter-rotating lids problem.

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

971 {
972  // Number of elements in radial (r) direction
973  const unsigned base_n_r = 4;
974  const unsigned perturbed_n_r = 4;
975 
976  // Number of elements in axial (z) direction
977  const unsigned base_n_z = 4;
978  const unsigned perturbed_n_z = 4;
979 
980  // Determine height of computational domain (this is just the aspect
981  // ratio since we take the cylinder radius to always be one)
982  const double domain_height = GlobalPhysicalVariables::Gamma;
983 
984  // Set direction of gravity (vertically downwards)
986  GlobalPhysicalVariables::G[1] = -1.0;
988 
989  // Set up labels for output
990  DocInfo doc_info;
991 
992  // Determine length of timestep
993  const double dt = 0.01;
994 
995  // Set number of timesteps to perform during a single iteration of the
996  // power method
997  const unsigned nstep = 1;
998 
999  // Cache tolerance for power method convergence
1000  // Note that we are using a very large tolerance for the purposes of
1001  // this demo driver so that it converges in a very small number of steps
1002  const double power_method_tolerance = 1e-4;
1003 
1004  // Set maximum number of iterations of the power method
1005  const unsigned max_iter = 1000;
1006 
1007  // For the purposes of code validation we will solve this problem twice.
1008  // The first time we shall use Taylor-Hood elements and the second time
1009  // Crouzeix-Raviart elements.
1010 
1011  // --------------------------------------------------------------------
1012  // Taylor-Hood elements
1013  // --------------------------------------------------------------------
1014  {
1015  // Build stability problem (this creates base and perturbed state problems)
1018  problem_TH(base_n_r,base_n_z,perturbed_n_r,perturbed_n_z,domain_height);
1019 
1020  // Output directory
1021  doc_info.set_directory("RESLT_TH");
1022 
1023  // Create and initialise trace file
1024  ofstream trace;
1025  char filename[256];
1026  sprintf(filename,"%s/trace.dat",
1027  doc_info.directory().c_str());
1028  trace.open(filename);
1029  trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl;
1030 
1031  // Refine both base and perturbed state problems uniformly
1032  problem_TH.base_state_problem_pt()->refine_uniformly();
1033  problem_TH.perturbed_state_problem_pt()->refine_uniformly();
1034 
1035  // Set up vector of elements to be refined
1036  const unsigned temp_array[22]
1037  = {0,1,4,5,8,9,12,13,15,29,31,45,47,50,51,54,55,58,59,61,62,63};
1038  Vector<unsigned> els_to_refine;
1039  for(unsigned i=0;i<22;i++) { els_to_refine.push_back(temp_array[i]); }
1040 
1041  // Refine selected elements
1042  problem_TH.base_state_problem_pt()->refine_selected_elements(els_to_refine);
1043  problem_TH.perturbed_state_problem_pt()
1044  ->refine_selected_elements(els_to_refine);
1045 
1046  // Initialise timestep for perturbed state problem
1047  // (also sets weights for all timesteppers)
1048  problem_TH.perturbed_state_problem_pt()->initialise_dt(dt);
1049 
1050  // Set initial conditions
1051  problem_TH.set_initial_condition();
1052 
1053  // Set up storage for dominant eigenvector and eigenvalue
1054  DoubleVector eigenvector;
1055  double eigenvalue = 0.0;
1056 
1057  // Get initial guess for eigenvector (these are the initial conditions
1058  // set up in PerturbedStateProblem::set_initial_conditions())
1059  problem_TH.perturbed_state_problem_pt()->get_dofs(eigenvector);
1060 
1061  // Initialise counter for solutions
1062  doc_info.number()=0;
1063 
1064  // Set base state problem's boundary conditions
1065  problem_TH.base_state_problem_pt()->set_boundary_conditions();
1066 
1067  // Perform a steady base flow solve
1068  problem_TH.base_state_problem_pt()->steady_newton_solve();
1069 
1070  // Doc the base flow solution
1071  problem_TH.base_state_problem_pt()->doc_solution(doc_info);
1072 
1073  // Enable Jacobian reuse in the perturbed state problem. Note that this
1074  // can only be done since the problem is linear and the base state is
1075  // steady, and so the Jacobian will be the same at each timestep.
1076  problem_TH.perturbed_state_problem_pt()->enable_jacobian_reuse();
1077 
1078  // Perform power method and store number of iterations
1079  const unsigned n_power_method_iterations =
1080  problem_TH.perform_power_method(dt,nstep,doc_info,power_method_tolerance,
1081  max_iter,eigenvalue,eigenvector);
1082 
1083  cout << "\nDominating eigenvalue is " << eigenvalue << endl;
1084 
1085  // Document in trace file
1086  trace << GlobalPhysicalVariables::Re << " "
1087  << eigenvalue << " "
1088  << n_power_method_iterations << std::endl;
1089  }
1090 
1091 
1092  // --------------------------------------------------------------------
1093  // Crouzeix-Raviart elements
1094  // --------------------------------------------------------------------
1095  {
1096  // Build stability problem (this creates base and perturbed state problems)
1099  problem_CR(base_n_r,base_n_z,perturbed_n_r,perturbed_n_z,domain_height);
1100 
1101  // Output directory
1102  doc_info.set_directory("RESLT_CR");
1103 
1104  // Create and initialise trace file
1105  ofstream trace;
1106  char filename[256];
1107  sprintf(filename,"%s/trace.dat",
1108  doc_info.directory().c_str());
1109  trace.open(filename);
1110  trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl;
1111 
1112  // Refine both base and perturbed state problems uniformly
1113  problem_CR.base_state_problem_pt()->refine_uniformly();
1114  problem_CR.perturbed_state_problem_pt()->refine_uniformly();
1115 
1116  // Set up vector of elements to be refined
1117  const unsigned temp_array[22]
1118  = {0,1,4,5,8,9,12,13,15,29,31,45,47,50,51,54,55,58,59,61,62,63};
1119  Vector<unsigned> els_to_refine;
1120  for(unsigned i=0;i<22;i++) { els_to_refine.push_back(temp_array[i]); }
1121 
1122  // Refine selected elements
1123  problem_CR.base_state_problem_pt()->refine_selected_elements(els_to_refine);
1124  problem_CR.perturbed_state_problem_pt()
1125  ->refine_selected_elements(els_to_refine);
1126 
1127  // Initialise timestep for perturbed state problem
1128  // (also sets weights for all timesteppers)
1129  problem_CR.perturbed_state_problem_pt()->initialise_dt(dt);
1130 
1131  // Set initial conditions
1132  problem_CR.set_initial_condition();
1133 
1134  // Set up storage for dominant eigenvector and eigenvalue
1135  DoubleVector eigenvector;
1136  double eigenvalue = 0.0;
1137 
1138  // Get initial guess for eigenvector (these are the initial conditions
1139  // set up in PerturbedStateProblem::set_initial_conditions())
1140  problem_CR.perturbed_state_problem_pt()->get_dofs(eigenvector);
1141 
1142  // Initialise counter for solutions
1143  doc_info.number()=0;
1144 
1145  // Set base state problem's boundary conditions
1146  problem_CR.base_state_problem_pt()->set_boundary_conditions();
1147 
1148  // Perform a steady base flow solve
1149  problem_CR.base_state_problem_pt()->steady_newton_solve();
1150 
1151  // Doc the base flow solution
1152  problem_CR.base_state_problem_pt()->doc_solution(doc_info);
1153 
1154  // Enable Jacobian reuse in the perturbed state problem. Note that this
1155  // can only be done since the problem is linear and the base state is
1156  // steady, and so the Jacobian will be the same at each timestep.
1157  problem_CR.perturbed_state_problem_pt()->enable_jacobian_reuse();
1158 
1159  // Perform power method and store number of iterations
1160  const unsigned n_power_method_iterations =
1161  problem_CR.perform_power_method(dt,nstep,doc_info,power_method_tolerance,
1162  max_iter,eigenvalue,eigenvector);
1163 
1164  cout << "\nDominating eigenvalue is " << eigenvalue << endl;
1165 
1166  // Document in trace file
1167  trace << GlobalPhysicalVariables::Re << " "
1168  << eigenvalue << " "
1169  << n_power_method_iterations << std::endl;
1170  }
1171 
1172 } // End of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: demo_drivers/axisym_navier_stokes/counter_rotating_disks/multi_domain_linearised_axisym_navier_stokes_elements.h:456
Definition: demo_drivers/axisym_navier_stokes/counter_rotating_disks/multi_domain_linearised_axisym_navier_stokes_elements.h:320
Definition: axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc:702
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
Definition: double_vector.h:58
Definition: refineable_axisym_navier_stokes_elements.h:765
Definition: refineable_axisym_navier_stokes_elements.h:407
double Re
Reynolds number.
Definition: axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc:61
double Gamma
Aspect ratio (cylinder height / cylinder radius)
Definition: axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc:70
Vector< double > G(3)
Direction of gravity.
string filename
Definition: MergeRestartFiles.py:39

References oomph::DocInfo::directory(), e(), MergeRestartFiles::filename, GlobalPhysicalVariables::G, GlobalPhysicalVariables::Gamma, i, oomph::DocInfo::number(), GlobalPhysicalVariables::Re, and oomph::DocInfo::set_directory().