mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc File Reference
#include "generic.h"
#include "advection_diffusion.h"
#include "navier_stokes.h"
#include "multi_physics.h"
#include "meshes/rectangular_quadmesh.h"

Classes

class  ConvectionProblem< NST_ELEMENT, AD_ELEMENT >
 

Namespaces

 Global_Physical_Variables
 Global variables.
 

Functions

int main (int argc, char **argv)
 Driver code for 2D Boussinesq convection problem. More...
 

Variables

double Global_Physical_Variables::Inverse_Prandtl =1.0
 1/Prandtl number More...
 
double Global_Physical_Variables::Rayleigh = 1800.0
 Rayleigh number. More...
 
Vector< doubleGlobal_Physical_Variables::Direction_of_gravity (2)
 Gravity vector. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Driver code for 2D Boussinesq convection problem.

442 {
443 
444 #ifdef OOMPH_HAS_MPI
445  MPI_Helpers::init(argc,argv);
446 #endif
447 
448  // Switch off output modifier
450 
451  // Define processor-labeled output file for all on-screen stuff
452  std::ofstream output_stream;
453  char filename[100];
454  sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank());
455  output_stream.open(filename);
456  oomph_info.stream_pt() = &output_stream;
457  OomphLibWarning::set_stream_pt(&output_stream);
458  OomphLibError::set_stream_pt(&output_stream);
459 
460  // Store command line arguments
461  CommandLineArgs::setup(argc,argv);
462 
463  // Set the direction of gravity
466 
467  //Construct our problem
473  >
474  problem;
475 
476  // Apply the boundary condition at time zero
477  problem.set_boundary_conditions(0.0);
478 
479  // Distribute the problem
480  //-----------------------
481 
482 #ifdef OOMPH_HAS_MPI
483 
484  DocInfo mesh_doc_info;
485  mesh_doc_info.number()=0;
486 
487 #ifdef USE_FD_JACOBIAN_NST_IN_MULTI_DOMAIN_BOUSSINESQ
488  mesh_doc_info.set_directory("RESLT_FD");
489 #else
490  mesh_doc_info.set_directory("RESLT");
491 #endif
492 
493  bool report_stats=true;
494 
495  // Are there command-line arguments?
496  if (CommandLineArgs::Argc==1)
497  {
498  // No arguments, so distribute without reference to partition vector
499  problem.distribute(mesh_doc_info,report_stats);
500  }
501  else
502  {
503  // Command line argument(s), so read in partition from file
504  std::ifstream input_file;
505  std::ofstream output_file;
506  char filename[100];
507 
508  // Get partition from file
509  unsigned n_element=problem.mesh_pt()->nelement();
510  Vector<unsigned> element_partition(n_element);
511 
512  // Two possible partitions on two processors - one for "normal"
513  // METIS behaviour, the other gives one mesh to one processor
514  // and the other mesh to the other processor
515  if (atoi(argv[2])==2)
516  {
517  oomph_info << "Using connected partitioning" << std::endl;
518  sprintf(filename,"multi_domain_boussinesq_partition_2.dat");
519  }
520  else
521  {
522  oomph_info << "Giving a mesh to each processor" << std::endl;
523  sprintf(filename,"multi_domain_boussinesq_partition.dat");
524  }
525  input_file.open(filename);
526  oomph_info << "Opened: " << filename << std::endl;
527  if (!input_file.is_open())
528  {
529  oomph_info << "Error opening input file\n";
530  exit(1);
531  }
532  std::string input_string;
533  for (unsigned e=0;e<n_element;e++)
534  {
535  if (getline(input_file,input_string,'\n'))
536  {
537  element_partition[e]=atoi(input_string.c_str());
538  }
539  else
540  {
541  oomph_info << "Reached end of file when reading partitioning file\n";
542  exit(1);
543  }
544  }
545  input_file.close();
546 
547  // Create storage for actually used partitioning
548  Vector<unsigned> used_element_partition;
549  used_element_partition=problem.distribute(element_partition,
550  mesh_doc_info,report_stats);
551 
552  // Write used partition to disk
553  sprintf(filename,"RESLT/partitioning.dat");
554  output_file.open(filename);
555  unsigned n_used=used_element_partition.size();
556  output_file << n_used << std::endl;
557  for (unsigned e=0;e<n_used;e++)
558  {
559  output_file << used_element_partition[e] << std::endl;
560  }
561  output_file.close();
562 
563  }
564 
565 #endif
566 
567  //Perform a single steady Newton solve
568  problem.steady_newton_solve();
569 
570  //Document the solution
571  problem.doc_solution();
572 
573  //Set the timestep
574  double dt = 0.1;
575 
576  //Initialise the value of the timestep and set an impulsive start
577  problem.assign_initial_values_impulsive(dt);
578 
579  //Set the number of timesteps to our default value
580  unsigned n_steps = 200;
581 
582  //If we have a command line argument, perform fewer steps
583  //(used for self-test runs)
584  if(argc > 1) {n_steps = 5;}
585 
586  //Perform n_steps timesteps
587  for(unsigned i=0;i<n_steps;++i)
588  {
589  problem.unsteady_newton_solve(dt);
590  problem.doc_solution();
591  }
592 
593 
594 #ifdef OOMPH_HAS_MPI
595  MPI_Helpers::finalize();
596 #endif
597 
598 
599 } // end of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc:75
Definition: multi_domain_boussinesq_elements.h:1073
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: multi_domain_boussinesq_elements.h:818
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
OutputModifier *& output_modifier_pt()
Access function for the output modifier pointer.
Definition: oomph_definitions.h:476
Definition: advection_diffusion_elements.h:610
Definition: navier_stokes_elements.h:1749
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
Vector< double > Direction_of_gravity(2)
Gravity vector.
string filename
Definition: MergeRestartFiles.py:39
int Argc
Number of arguments + 1.
Definition: oomph_utilities.cc:407
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
OutputModifier default_output_modifier
Single global instatiation of the default output modifier.
Definition: oomph_definitions.cc:325
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References oomph::CommandLineArgs::Argc, oomph::MPI_Helpers::communicator_pt(), oomph::default_output_modifier, oomph::Global_Physical_Variables::Direction_of_gravity, e(), MergeRestartFiles::filename, oomph::MPI_Helpers::finalize(), i, oomph::MPI_Helpers::init(), oomph::DocInfo::number(), oomph::oomph_info, oomph::OomphInfo::output_modifier_pt(), problem, oomph::DocInfo::set_directory(), oomph::OomphLibError::set_stream_pt(), oomph::OomphLibWarning::set_stream_pt(), oomph::CommandLineArgs::setup(), oomph::OomphInfo::stream_pt(), and oomph::Global_string_for_annotation::string().