three_d_fp.cc File Reference
#include <fenv.h>
#include "generic.h"
#include "navier_stokes.h"
#include "meshes/simple_cubic_mesh.h"
#include "meshes/simple_cubic_tet_mesh.h"

Classes

class  FpTestProblem
 Test problem for Fp/PCD preconditioner. More...
 

Namespaces

 Global_Variables
 Namespace for physical parameters.
 

Enumerations

enum  { Global_Variables::Driven_cavity , Global_Variables::Through_flow }
 Enumeration for the problem ids. More...
 

Functions

void Global_Variables::prescribed_traction (const double &t, const Vector< double > &x, const Vector< double > &n, Vector< double > &traction)
 Traction at the outflow boundary. More...
 
int main (int argc, char **argv)
 Driver for Fp preconditioner. More...
 

Variables

Vector< doubleGlobal_Variables::Linear_solver_time
 Storage for linear solver times during Newton steps. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Driver for Fp preconditioner.

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

689 {
690 
691 
692 #ifdef OOMPH_HAS_MPI
693  MPI_Helpers::init(argc,argv);
694 #endif
695 
696 
697  //Label for output
698  DocInfo doc_info;
699 
700  //Set output directory
701  doc_info.set_directory("RESLT");
702 
703  //Doc number of gmres iterations
704  ofstream out_file;
705 
706  // Set flags
707  bool use_hypre_for_pressure=true;
708  bool use_block_diagonal_for_momentum=false;
709  bool use_hypre_for_momentum_diagonals=false;
710 
711  //Loop over problems: Driven cavity and step
712  for (unsigned problem_id=0;problem_id<2;problem_id++)
713  {
714 
715  if (problem_id==0)
716  {
717  out_file.open("three_d_iter_driven_cavity.dat");
718  }
719  else
720  {
721  out_file.open("three_d_iter_through_flow.dat");
722  }
723 
724  out_file
725  << "VARIABLES=\"nel_1d\","
726  << "\"ndof\","
727  << "\"Re\","
728  << "\" Newton iteration\","
729  << "\"GMRES iterations\","
730  << "\"Linear solver time\","
731  << "\"doc number\""
732  << std::endl;
733 
734  std::string header1;
735  std::string header2;
736 
737 
738  // Loop over preconditioners: iprec=0: LSC
739  // iprec=1: Fp
740  bool use_lsc=true;
741  //bool use_robin=true;
742  for (unsigned iprec=0;iprec<2;iprec++)
743  {
744 
745  // Loop over three cases (tets, non-refineable/refineable bricks)
746  for (unsigned icase=0;icase<=2;icase++)
747  {
748  bool use_tets=false;
749  bool use_adaptivity=false;
750 
751  switch(icase)
752  {
753 
754  case 0:
755 
756  header1=" Tets";
757  use_tets=true;
758  use_adaptivity=false;
759  break;
760 
761  case 1:
762 
763  header1=" Bricks";
764  use_tets=false;
765  use_adaptivity=false;
766  break;
767 
768  case 2:
769 
770  header1=" Refineable Bricks";
771  use_tets=false;
772  use_adaptivity=true;
773  break;
774 
775  default:
776  break;
777  }
778 
779  oomph_info << "Doing it with " << header1 << std::endl;
780 
781  // Set preconditioner
782  if (iprec==0)
783  {
784  use_lsc=true;
785  header2=", LSC";
786  }
787  else if (iprec==1)
788  {
789  use_lsc=false;
790  //use_robin=true;
791  header2=", Fp";
792  }
793 
794  oomph_info << "Doing it with " << header2 << " preconditioner\n";
795 
796  // Write tecplot header
797  string header="ZONE T=\""+header1+header2+"\"\n";
798  out_file << header;
799 
800  // Number of elements in x/y directions (reduced for validaton)
801  unsigned max_nel_1d=4;
802  if (argc>1) max_nel_1d=2;
803  for (unsigned nel_1d = 2; nel_1d <= max_nel_1d; nel_1d*=2)
804  {
805 
806  // Build the problem
808  nel_1d,use_tets,use_adaptivity,use_lsc,
809  use_hypre_for_pressure,use_block_diagonal_for_momentum,
810  use_hypre_for_momentum_diagonals,problem_id);
811 
812 
813 
814  // Refine a few times
815  if (use_adaptivity)
816  {
817  // Note: This manually chosen refinement pattern introduces
818  // doubly hanging nodes on boundary and in the interior
819  Vector<unsigned> elements_to_be_refined;
820  unsigned nel=problem.bulk_mesh_pt()->nelement();
821  unsigned e=0;
822  while (e<nel)
823  {
824  elements_to_be_refined.push_back(e);
825  e+=7;
826  }
827  problem.refine_selected_elements(0,elements_to_be_refined);
828  elements_to_be_refined.clear();
829  elements_to_be_refined.push_back(1);
830  problem.refine_selected_elements(0,elements_to_be_refined);
831  elements_to_be_refined.clear();
832  elements_to_be_refined.push_back(4);
833  problem.refine_selected_elements(0,elements_to_be_refined);
834  }
835  // Attach traction elements now with the problem in its
836  // most refined state
837  if (use_tets)
838  {
839  problem.create_traction_elements<TTaylorHoodElement<3> >();
840  }
841  else
842  {
843  if (use_adaptivity)
844  {
845  problem.create_refineable_traction_elements
847  }
848  else
849  {
850  problem.create_traction_elements<QTaylorHoodElement<3> >();
851  }
852  }
853 
854 
855 
856  // Loop over Reynolds numbers (limited during validation)
857  double start_re = 0.0;
858  if (argc>1) start_re=50;
859  double end_re = 50.0;
860  for (double re = start_re; re <= end_re; re+=50.0)
861  {
862 
863  // Set Reynolds
865 
866  // Solve the problem
867  problem.newton_solve();
868 
869  // Doc solution
870  problem.doc_solution(doc_info);
871  doc_info.number()++;
872 
873  // Doc iteration counts for each Newton iteration
874  unsigned ndof = problem.ndof();
875  unsigned iter = Global_Variables::Iterations.size();
876 
877  // Doc for all Newton iterations or only the last one?
878  unsigned j_lo=0;
879  //j_lo=iter-1;
880  for (unsigned j = j_lo; j < iter; j++)
881  {
882  out_file
883  << nel_1d << " "
884  << ndof << " "
885  << re << " "
886  << j << " "
889  << doc_info.number()-1 << " "
890  << std::endl;
891  }
892 
893  }
894  }
895  }
896  }
897 
898  out_file.close();
899 
900  }
901 
902 
903 #ifdef OOMPH_HAS_MPI
904  MPI_Helpers::finalize();
905 #endif
906 
907 
908 } // end_of_main
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Test problem for Fp/PCD preconditioner.
Definition: three_d_fp.cc:114
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: navier_stokes_elements.h:2308
Definition: refineable_navier_stokes_elements.h:652
Definition: Tnavier_stokes_elements.h:741
Vector< unsigned > Iterations
Storage for number of iterations during Newton steps.
Definition: two_d_tilted_square.cc:111
Vector< double > Linear_solver_time
Storage for linear solver times during Newton steps.
Definition: three_d_fp.cc:86
double Re
Reynolds number.
Definition: two_d_tilted_square.cc:80
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References e(), Global_Variables::Iterations, j, Global_Variables::Linear_solver_time, oomph::DocInfo::number(), oomph::oomph_info, problem, Global_Variables::Re, oomph::DocInfo::set_directory(), and oomph::Global_string_for_annotation::string().