mpi/distribution/hp_adaptive_driven_cavity/hp_adaptive_driven_cavity.cc File Reference

Classes

class  SimpleRefineableRectangularQuadMesh< ELEMENT >
 
class  PRefineableDrivenCavityProblem< 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.

301 {
302 
303 #ifdef OOMPH_HAS_MPI
304 
305  // Initialise MPI
306  MPI_Helpers::init(argc,argv);
307 
308 #endif
309 
310  // Store command line arguments
311  CommandLineArgs::setup(argc,argv);
312 
313  // Set output directory
314  DocInfo doc_info;
315  doc_info.set_directory("RESLT");
316 
317 
318 
319  // Solve problem with hp-refineable Crouzeix Raviart elements
320  //-----------------------------------------------------------
321  // Build problem
323  //Are there command-line arguments?
324  if(CommandLineArgs::Argc==1)
325  {
326 
327 #ifdef OOMPH_HAS_MPI
328 
329  // Provide storage for each element's partition number
330  const unsigned n_element=problem.mesh_pt()->nelement();
331  Vector<unsigned> out_element_partition(n_element);
332 
333  // Distribute the problem
334  bool report_stats=true;
335  out_element_partition=problem.distribute(report_stats);
336 
337  // Write partition to disk
338  std::ofstream output_file;
339  char filename[100];
340  sprintf(filename,"out_hp_adaptive_cavity_partition.dat");
341  output_file.open(filename);
342  for (unsigned e=0;e<n_element;e++)
343  {
344  output_file << out_element_partition[e] << std::endl;
345  }
346 
347  // Check halo schemes (optional)
348  problem.check_halo_schemes(doc_info);
349 
350 #endif
351 
352  oomph_info << "\n\n\nProblem self-test ";
353  if (problem.self_test()==0)
354  {
355  oomph_info << "passed: Problem can be solved." << std::endl;
356  }
357  else
358  {
359  throw OomphLibError("Self test failed",
362  }
363 
364  problem.p_adapt();
365  problem.newton_solve();
366  doc_info.number()=1;
367  problem.doc_solution(doc_info);
368 
369  problem.p_adapt();
370  problem.newton_solve();
371  doc_info.number()=3;
372  problem.doc_solution(doc_info);
373 
374  problem.adapt();
375  problem.newton_solve();
376  doc_info.number()=4;
377  problem.doc_solution(doc_info);
378 
379  problem.p_adapt();
380  problem.newton_solve();
381  doc_info.number()=5;
382  problem.doc_solution(doc_info);
383 
384  problem.adapt();
385  problem.newton_solve();
386  doc_info.number()=6;
387  problem.doc_solution(doc_info);
388 
389  problem.p_adapt();
390  problem.newton_solve();
391  doc_info.number()=7;
392  problem.doc_solution(doc_info);
393 
394  problem.adapt();
395  problem.newton_solve();
396  doc_info.number()=8;
397  problem.doc_solution(doc_info);
398 
399  } // end of no command-line arguments
400  else // Validation run - read in partition from file
401  {
402 
403 #ifdef OOMPH_HAS_MPI
404 
405  DocInfo mesh_doc_info;
406  mesh_doc_info.set_directory("RESLT_MESH");
407  mesh_doc_info.number()=0;
408  std::ifstream input_file;
409  char filename[100];
410 
411  // Get the partition to be used from file
412  const unsigned n_element=problem.mesh_pt()->nelement();
413  Vector<unsigned> element_partition(n_element);
414  sprintf(filename,"hp_adaptive_cavity_partition.dat");
415  input_file.open(filename);
416  std::string input_string;
417  for (unsigned e=0;e<n_element;e++)
418  {
419  getline(input_file,input_string,'\n');
420  element_partition[e]=atoi(input_string.c_str());
421  }
422 
423  // Now perform the distribution
424  bool report_stats=true;
425  problem.distribute(element_partition,mesh_doc_info,report_stats);
426 
427 #endif
428 
429  problem.p_adapt();
430  problem.newton_solve();
431  doc_info.number()=1;
432  problem.doc_solution(doc_info);
433 
434  problem.p_adapt();
435  problem.newton_solve();
436  doc_info.number()=3;
437  problem.doc_solution(doc_info);
438 
439  problem.adapt();
440  problem.newton_solve();
441  doc_info.number()=4;
442  problem.doc_solution(doc_info);
443 
444  problem.p_adapt();
445  problem.newton_solve();
446  doc_info.number()=5;
447  problem.doc_solution(doc_info);
448 
449  problem.adapt();
450  problem.newton_solve();
451  doc_info.number()=6;
452  problem.doc_solution(doc_info);
453 
454  } // end of validation run
455 
456  // Count hanging nodes
457  //cout << "Hanging nodes:" << endl;
458  unsigned num_hang=0;
459  for (unsigned n=0; n<problem.mesh_pt()->nnode(); n++)
460  {
461  if (problem.mesh_pt()->node_pt(n)->is_hanging())
462  {
463  /*
464  cout << " node " << n << " is hanging... at ("
465  << problem.mesh_pt()->node_pt(n)->x(0) << ", "
466  << problem.mesh_pt()->node_pt(n)->x(1) << ")" << endl;
467  HangInfo* hang_pt = problem.mesh_pt()->node_pt(n)->hanging_pt();
468  cout << " Nmaster = " << hang_pt->nmaster() << endl;
469  double totweight = 0.0;
470  for (unsigned nm=0; nm<hang_pt->nmaster(); nm++)
471  {
472  cout << " master node: x = (" << hang_pt->master_node_pt(nm)->x(0)
473  << ", " << hang_pt->master_node_pt(nm)->x(1) << ") w = "
474  << hang_pt->master_weight(nm) << endl;
475  totweight += hang_pt->master_weight(nm);
476  }
477  cout << " Total weights = " << totweight << endl;
478  */
479  num_hang++;
480  }
481  }
482  oomph_info << "There were "<<num_hang<<" hanging nodes." << endl;
483 
484  // Step number
485  doc_info.number()=0;
486 
487  //Output solution
488  problem.doc_solution(doc_info);
489 
490 
491 // Finalise MPI
492 #ifdef OOMPH_HAS_MPI
493 
494  MPI_Helpers::finalize();
495 
496 #endif
497 
498 } // end_of_main
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: mpi/distribution/hanging_node_reconciliation/hp_adaptive_driven_cavity.cc:98
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: oomph_definitions.h:222
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
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

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