self_test/mpi/line_visualiser/adaptive_driven_cavity.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.

311 {
312 
313 #ifdef OOMPH_HAS_MPI
314 
315  // Initialise MPI
316  MPI_Helpers::init(argc,argv);
317 
318 #endif
319 
320  // Store command line arguments
321  CommandLineArgs::setup(argc,argv);
322 
323  // Set output directory
324  DocInfo doc_info;
325  doc_info.set_directory("RESLT");
326 
327  // Set max. number of black-box adaptation
328  unsigned max_adapt=3;
329 
330  // Solve problem with Taylor Hood elements
331  //---------------------------------------
332  {
333  //Build problem
335 
336  //Are there command-line arguments?
337  if (CommandLineArgs::Argc==1)
338  {
339 
340 #ifdef OOMPH_HAS_MPI
341 
342  // Provide storage for each element's partition number
343  const unsigned n_element=problem.mesh_pt()->nelement();
344  Vector<unsigned> out_element_partition(n_element);
345 
346  // Distribute the problem
347  bool report_stats=false;
348  out_element_partition=problem.distribute(report_stats);
349 
350  // Write partition to disk
351  std::ofstream output_file;
352  char filename[100];
353  sprintf(filename,"out_adaptive_cavity_1_partition.dat");
354  output_file.open(filename);
355  for (unsigned e=0;e<n_element;e++)
356  {
357  output_file << out_element_partition[e] << std::endl;
358  }
359 
360  // Check halo schemes (optional)
361  problem.check_halo_schemes(doc_info);
362 
363 #endif
364 
365  // Solve the problem with automatic adaptation
366  problem.newton_solve(max_adapt);
367 
368  //Output solution
369  problem.doc_solution(doc_info);
370 
371  }
372  // Validation run - read in partition from file
373  else
374  {
375 
376 #ifdef OOMPH_HAS_MPI
377 
378  // DocInfo object specifies directory in which we document
379  // the distribution
380  DocInfo mesh_doc_info;
381  mesh_doc_info.set_directory("RESLT");
382 
383  // Create storage for pre-determined partitioning
384  const unsigned n_element=problem.mesh_pt()->nelement();
385  Vector<unsigned> element_partition(n_element);
386 
387  // Read in partitioning from disk
388  std::ifstream input_file;
389  char filename[100];
390  sprintf(filename,"adaptive_cavity_1_partition.dat");
391  input_file.open(filename);
392  std::string input_string;
393  for (unsigned e=0;e<n_element;e++)
394  {
395  getline(input_file,input_string,'\n');
396  element_partition[e]=atoi(input_string.c_str());
397  }
398 
399  // Now perform the distribution
400  problem.distribute(element_partition);
401 
402 #endif
403 
404  // solve with adaptation
405  problem.newton_solve(max_adapt);
406 
407  //Output solution
408  problem.doc_solution(doc_info);
409  }
410 
411  } // end of Taylor Hood elements
412 
413 
414  // Solve problem with Crouzeix Raviart elements
415  //--------------------------------------------
416  {
417  // Build problem
419 
420  //Are there command-line arguments?
421  if (CommandLineArgs::Argc==1)
422  {
423 #ifdef OOMPH_HAS_MPI
424  // Distribute the problem
425  problem.distribute();
426 
427  // Check halo schemes (optional)
428  problem.check_halo_schemes(doc_info);
429 #endif
430 
431  // Solve the problem with automatic adaptation
432  problem.newton_solve(max_adapt);
433 
434  // Step number
435  doc_info.number()=1;
436 
437  //Output solution
438  problem.doc_solution(doc_info);
439  } // end of no command-line arguments
440  else // Validation run - read in partition from file
441  {
442 
443 #ifdef OOMPH_HAS_MPI
444 
445  DocInfo mesh_doc_info;
446  mesh_doc_info.set_directory("RESLT");
447  mesh_doc_info.number()=0;
448  std::ifstream input_file;
449  char filename[100];
450 
451  // Get the partition to be used from file
452  const unsigned n_element=problem.mesh_pt()->nelement();
453  Vector<unsigned> element_partition(n_element);
454  sprintf(filename,"adaptive_cavity_2_partition.dat");
455  input_file.open(filename);
456  std::string input_string;
457  for (unsigned e=0;e<n_element;e++)
458  {
459  getline(input_file,input_string,'\n');
460  element_partition[e]=atoi(input_string.c_str());
461  }
462 
463  // Now perform the distribution
464  problem.distribute(element_partition);
465 
466 #endif
467 
468  // Re-solve with adaptation
469  problem.newton_solve(max_adapt);
470 
471  // change doc_info number
472  doc_info.number()=1;
473 
474  //Output solution
475  problem.doc_solution(doc_info);
476  }
477 
478  } // end of Crouzeix Raviart elements
479 
480 
481 // Finalise MPI
482 #ifdef OOMPH_HAS_MPI
483 
484  MPI_Helpers::finalize();
485 
486 #endif
487 
488 } // 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
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
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
int Argc
Number of arguments + 1.
Definition: oomph_utilities.cc:407
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References oomph::CommandLineArgs::Argc, e(), MergeRestartFiles::filename, oomph::DocInfo::number(), problem, oomph::DocInfo::set_directory(), Flag_definition::setup(), and oomph::Global_string_for_annotation::string().