demo_drivers/mpi/distribution/adaptive_driven_cavity/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.

262 {
263 
264 #ifdef OOMPH_HAS_MPI
265 
266  // Initialise MPI
267  MPI_Helpers::init(argc,argv);
268 
269 #endif
270 
271  // Store command line arguments
272  CommandLineArgs::setup(argc,argv);
273 
274  // Set output directory
275  DocInfo doc_info;
276  doc_info.set_directory("RESLT");
277 
278  // Set max. number of black-box adaptation
279  unsigned max_adapt=3;
280 
281  // Solve problem with Taylor Hood elements
282  //---------------------------------------
283  {
284  //Build problem
286 
287  //Are there command-line arguments?
288  if (CommandLineArgs::Argc==1)
289  {
290 
291 #ifdef OOMPH_HAS_MPI
292 
293  // Provide storage for each element's partition number
294  const unsigned n_element=problem.mesh_pt()->nelement();
295  Vector<unsigned> out_element_partition(n_element);
296 
297  // Distribute the problem
298  bool report_stats=true;
299  out_element_partition=problem.distribute(report_stats);
300 
301  // Write partition to disk
302  std::ofstream output_file;
303  char filename[100];
304  sprintf(filename,"out_adaptive_cavity_1_partition.dat");
305  output_file.open(filename);
306  for (unsigned e=0;e<n_element;e++)
307  {
308  output_file << out_element_partition[e] << std::endl;
309  }
310 
311  // Check halo schemes (optional)
312  problem.check_halo_schemes(doc_info);
313 
314 #endif
315 
316  // Solve the problem with automatic adaptation
317  problem.newton_solve(max_adapt);
318 
319  //Output solution
320  problem.doc_solution(doc_info);
321 
322  }
323  // Validation run - read in partition from file
324  else
325  {
326 
327 #ifdef OOMPH_HAS_MPI
328 
329  // DocInfo object specifies directory in which we document
330  // the distribution
331  DocInfo mesh_doc_info;
332  mesh_doc_info.set_directory("RESLT_TH_MESH");
333 
334  // Create storage for pre-determined partitioning
335  const unsigned n_element=problem.mesh_pt()->nelement();
336  Vector<unsigned> element_partition(n_element);
337 
338  // Read in partitioning from disk
339  std::ifstream input_file;
340  char filename[100];
341  sprintf(filename,"adaptive_cavity_1_partition.dat");
342  input_file.open(filename);
343  std::string input_string;
344  for (unsigned e=0;e<n_element;e++)
345  {
346  getline(input_file,input_string,'\n');
347  element_partition[e]=atoi(input_string.c_str());
348  }
349 
350  // Now perform the distribution and document it
351  bool report_stats=true;
352  problem.distribute(element_partition,mesh_doc_info,report_stats);
353 
354 #endif
355 
356  // solve with adaptation
357  problem.newton_solve(max_adapt);
358 
359  //Output solution
360  problem.doc_solution(doc_info);
361 
362 #ifdef OOMPH_HAS_MPI
363 
364  mesh_doc_info.number()=1;
365  problem.mesh_pt()->doc_mesh_distribution(mesh_doc_info);
366 #endif
367  }
368 
369  } // end of Taylor Hood elements
370 
371 
372  // Solve problem with Crouzeix Raviart elements
373  //--------------------------------------------
374  {
375  // Build problem
377 
378  //Are there command-line arguments?
379  if (CommandLineArgs::Argc==1)
380  {
381 #ifdef OOMPH_HAS_MPI
382  // Distribute the problem
383  problem.distribute();
384 
385  // Check halo schemes (optional)
386  problem.check_halo_schemes(doc_info);
387 #endif
388 
389  // Solve the problem with automatic adaptation
390  problem.newton_solve(max_adapt);
391 
392  // Step number
393  doc_info.number()=1;
394 
395  //Output solution
396  problem.doc_solution(doc_info);
397  } // end of no command-line arguments
398  else // Validation run - read in partition from file
399  {
400 
401 #ifdef OOMPH_HAS_MPI
402 
403  DocInfo mesh_doc_info;
404  mesh_doc_info.set_directory("RESLT_CR_MESH");
405  mesh_doc_info.number()=0;
406  std::ifstream input_file;
407  char filename[100];
408 
409  // Get the partition to be used from file
410  const unsigned n_element=problem.mesh_pt()->nelement();
411  Vector<unsigned> element_partition(n_element);
412  sprintf(filename,"adaptive_cavity_2_partition.dat");
413  input_file.open(filename);
414  std::string input_string;
415  for (unsigned e=0;e<n_element;e++)
416  {
417  getline(input_file,input_string,'\n');
418  element_partition[e]=atoi(input_string.c_str());
419  }
420 
421  // Now perform the distribution
422  bool report_stats=true;
423  problem.distribute(element_partition,mesh_doc_info,report_stats);
424 
425 #endif
426 
427  // Re-solve with adaptation
428  problem.newton_solve(max_adapt);
429 
430  // change doc_info number
431  doc_info.number()=1;
432 
433  //Output solution
434  problem.doc_solution(doc_info);
435 
436 #ifdef OOMPH_HAS_MPI
437  mesh_doc_info.number()=1;
438  problem.mesh_pt()->doc_mesh_distribution(mesh_doc_info);
439 #endif
440  }
441 
442  } // end of Crouzeix Raviart elements
443 
444 
445 // Finalise MPI
446 #ifdef OOMPH_HAS_MPI
447 
448  MPI_Helpers::finalize();
449 
450 #endif
451 
452 } // 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().