adaptive_driven_cavity_load_balance.cc File Reference
#include "generic.h"
#include "navier_stokes.h"
#include "meshes/rectangular_quadmesh.h"

Classes

class  RefineableDrivenCavityProblem< ELEMENT >
 

Namespaces

 Global_Physical_Variables
 Global variables.
 

Functions

int main (int argc, char **argv)
 Driver for RefineableDrivenCavity test problem. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Driver for RefineableDrivenCavity test problem.

379 {
380 
381 #ifdef OOMPH_HAS_MPI
382  // Initialise MPI
383  MPI_Helpers::init(argc,argv);
384 #endif
385 
386  // Switch off output modifier
388 
389  // Define processor-labeled output file for all on-screen stuff
390  std::ofstream output_stream;
391  char filename[100];
392  sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank());
393  output_stream.open(filename);
394  oomph_info.stream_pt() = &output_stream;
395  OomphLibWarning::set_stream_pt(&output_stream);
396  OomphLibError::set_stream_pt(&output_stream);
397 
398  // Store command line arguments
399  CommandLineArgs::setup(argc,argv);
400 
401  // Use manual distribution of elements rather than metis
403 
404  // Parse command line
406 
407  // Doc what has actually been specified on the command line
409 
410  //Build problem
412 
413  // Tell us what you're doing
414  bool report_stats=true;
415 
416  // Metis or manual distribution?
418  {
419  // Distribute with metis
420  problem.distribute(report_stats);
421  }
422  else
423  {
424  // Make up some pre-determined distribution
425  unsigned n_element=problem.mesh_pt()->nelement();
426  Vector<unsigned> element_partition(n_element);
427  std::string input_string;
428  for (unsigned e=0;e<n_element;e++)
429  {
430  unsigned target_part=0;
431  if ( (e<unsigned(0.25*double(n_element))) ||
432  ( (e>unsigned(0.5*double(n_element))) &&
433  (e<unsigned(0.75*double(n_element))) ) )
434  {
435  target_part=1;
436  }
437  element_partition[e]=target_part;
438  }
439  problem.distribute(element_partition,report_stats);
440 
441  // This is a validation run: use the default partition when load balancing
442  problem.set_default_partition_in_load_balance();
443  }
444 
445  //Output initial mesh
446  problem.doc_solution("Initial mesh");
447 
448  // Solve the problem with automatic adaptation
449  problem.newton_solve(1);
450 
451  //Output solution
452  problem.doc_solution("First adapted solution");
453 
454  // Prune
455  problem.prune_halo_elements_and_nodes(report_stats);
456 
457  //Output solution
458  problem.doc_solution("After first prune");
459 
460  // Solve the problem again with automatic adaptation
461  problem.newton_solve(1);
462 
463  //Output solution
464  problem.doc_solution("Second adapted solution after pruning");
465 
466  // Do load balancing
467  problem.load_balance(report_stats);
468 
469  //Output solution
470  problem.doc_solution("After load balancing");
471 
472  // Prune
473  problem.prune_halo_elements_and_nodes(report_stats);
474 
475  //Output solution
476  problem.doc_solution("After second pruning");
477 
478  // Solve the problem again with automatic adaptation
479  problem.newton_solve(1);
480 
481  //Output solution
482  problem.doc_solution("Third adapted solution after pruning");
483 
484  // Do a uniform refinement
485  problem.refine_uniformly();
486 
487  //Output solution
488  problem.doc_solution("After uniform refinement");
489 
490  // Prune
491  problem.prune_halo_elements_and_nodes(report_stats);
492 
493  //Output solution
494  problem.doc_solution("After third pruning");
495 
496  // Solve the problem again with automatic adaptation
497  problem.newton_solve(1);
498 
499  //Output solution
500  problem.doc_solution("Fourth adapted solution after pruning");
501 
502  // Do load balancing
503  problem.load_balance(report_stats);
504 
505  //Output solution
506  problem.doc_solution("After load balancing");
507 
508  // Solve the problem again with automatic adaptation
509  problem.newton_solve(1);
510 
511  //Output solution
512  problem.doc_solution("Fifth adapted solution after load balancing");
513 
514  oomph_info << "done\n";
515  std::cout << "done\n";
516 
517  // Finalise MPI
518 #ifdef OOMPH_HAS_MPI
519  MPI_Helpers::finalize();
520 #endif
521 
522 
523 } // end_of_main
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: demo_drivers/mpi/distribution/adaptive_driven_cavity/adaptive_driven_cavity.cc:59
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
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
string filename
Definition: MergeRestartFiles.py:39
bool command_line_flag_has_been_set(const std::string &flag)
Definition: oomph_utilities.cc:501
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
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::command_line_flag_has_been_set(), oomph::default_output_modifier, oomph::CommandLineArgs::doc_specified_flags(), e(), MergeRestartFiles::filename, oomph::oomph_info, oomph::OomphInfo::output_modifier_pt(), oomph::CommandLineArgs::parse_and_assign(), problem, Flag_definition::setup(), oomph::CommandLineArgs::specify_command_line_flag(), oomph::OomphInfo::stream_pt(), and oomph::Global_string_for_annotation::string().