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

330 {
331 
332 #ifdef OOMPH_HAS_MPI
333 
334  // Initialise MPI
335  MPI_Helpers::init(argc,argv);
336 
337 #endif
338 
339  // Store command line arguments
340  CommandLineArgs::setup(argc,argv);
341 
342  // Set output directory
343  DocInfo doc_info;
344  doc_info.set_directory("RESLT_hp");
345 
346 
347 
348  // Solve problem with hp-refineable Crouzeix Raviart elements
349  //-----------------------------------------------------------
350  // Build problem
352  //Are there command-line arguments?
353  if(CommandLineArgs::Argc==1)
354  {
355 
356 #ifdef OOMPH_HAS_MPI
357 
358  // Provide storage for each element's partition number
359  const unsigned n_element=problem.mesh_pt()->nelement();
360  Vector<unsigned> out_element_partition(n_element);
361 
362  // Distribute the problem
363  bool report_stats=true;
364  out_element_partition=problem.distribute(report_stats);
365 
366  // Write partition to disk
367  std::ofstream output_file;
368  char filename[100];
369  sprintf(filename,"out_hp_adaptive_cavity_partition.dat");
370  output_file.open(filename);
371  for (unsigned e=0;e<n_element;e++)
372  {
373  output_file << out_element_partition[e] << std::endl;
374  }
375 
376  // Check halo schemes (optional)
377  problem.check_halo_schemes(doc_info);
378 
379 #endif
380 
381  oomph_info << "\n\n\nProblem self-test ";
382  if (problem.self_test()==0)
383  {
384  oomph_info << "passed: Problem can be solved." << std::endl;
385  }
386  else
387  {
388  throw OomphLibError("Self test failed",
391  }
392 
393  problem.p_adapt();
394  problem.newton_solve();
395  doc_info.number()=1;
396  problem.doc_solution(doc_info);
397 
398  problem.p_adapt();
399  problem.newton_solve();
400  doc_info.number()=3;
401  problem.doc_solution(doc_info);
402 
403  problem.adapt();
404  problem.newton_solve();
405  doc_info.number()=4;
406  problem.doc_solution(doc_info);
407 
408  problem.p_adapt();
409  problem.newton_solve();
410  doc_info.number()=5;
411  problem.doc_solution(doc_info);
412 
413  problem.adapt();
414  problem.newton_solve();
415  doc_info.number()=6;
416  problem.doc_solution(doc_info);
417 
418  problem.p_adapt();
419  problem.newton_solve();
420  doc_info.number()=7;
421  problem.doc_solution(doc_info);
422 
423  problem.adapt();
424  problem.newton_solve();
425  doc_info.number()=8;
426  problem.doc_solution(doc_info);
427 
428  } // end of no command-line arguments
429  else // Validation run - read in partition from file
430  {
431 
432 #ifdef OOMPH_HAS_MPI
433 
434  DocInfo mesh_doc_info;
435  mesh_doc_info.set_directory("RESLT_hp_MESH");
436  mesh_doc_info.number()=0;
437  std::ifstream input_file;
438  char filename[100];
439 
440  // Get the partition to be used from file
441  const unsigned n_element=problem.mesh_pt()->nelement();
442  Vector<unsigned> element_partition(n_element);
443  sprintf(filename,"hp_adaptive_cavity_partition.dat");
444  input_file.open(filename);
445  std::string input_string;
446  for (unsigned e=0;e<n_element;e++)
447  {
448  getline(input_file,input_string,'\n');
449  element_partition[e]=atoi(input_string.c_str());
450  }
451 
452  // Now perform the distribution
453  bool report_stats=true;
454  problem.distribute(element_partition,mesh_doc_info,report_stats);
455 
456 #endif
457 
458  problem.p_adapt();
459  problem.newton_solve();
460  doc_info.number()=1;
461  problem.doc_solution(doc_info);
462 
463  problem.p_adapt();
464  problem.newton_solve();
465  doc_info.number()=3;
466  problem.doc_solution(doc_info);
467 
468  problem.adapt();
469  problem.newton_solve();
470  doc_info.number()=4;
471  problem.doc_solution(doc_info);
472 
473  problem.p_adapt();
474  problem.newton_solve();
475  doc_info.number()=5;
476  problem.doc_solution(doc_info);
477 
478  problem.adapt();
479  problem.newton_solve();
480  doc_info.number()=6;
481  problem.doc_solution(doc_info);
482 
483 #ifdef OOMPH_HAS_MPI
484  mesh_doc_info.number()=1;
485  problem.mesh_pt()->doc_mesh_distribution(mesh_doc_info);
486 #endif
487 
488  } // end of validation run
489 
490  // Count hanging nodes
491  //cout << "Hanging nodes:" << endl;
492  unsigned num_hang=0;
493  for (unsigned n=0; n<problem.mesh_pt()->nnode(); n++)
494  {
495  if (problem.mesh_pt()->node_pt(n)->is_hanging())
496  {
497  /*
498  cout << " node " << n << " is hanging... at ("
499  << problem.mesh_pt()->node_pt(n)->x(0) << ", "
500  << problem.mesh_pt()->node_pt(n)->x(1) << ")" << endl;
501  HangInfo* hang_pt = problem.mesh_pt()->node_pt(n)->hanging_pt();
502  cout << " Nmaster = " << hang_pt->nmaster() << endl;
503  double totweight = 0.0;
504  for (unsigned nm=0; nm<hang_pt->nmaster(); nm++)
505  {
506  cout << " master node: x = (" << hang_pt->master_node_pt(nm)->x(0)
507  << ", " << hang_pt->master_node_pt(nm)->x(1) << ") w = "
508  << hang_pt->master_weight(nm) << endl;
509  totweight += hang_pt->master_weight(nm);
510  }
511  cout << " Total weights = " << totweight << endl;
512  */
513  num_hang++;
514  }
515  }
516  oomph_info << "There were "<<num_hang<<" hanging nodes." << endl;
517 
518  // Step number
519  doc_info.number()=0;
520 
521  //Output solution
522  problem.doc_solution(doc_info);
523 
524 
525 // Finalise MPI
526 #ifdef OOMPH_HAS_MPI
527 
528  MPI_Helpers::finalize();
529 
530 #endif
531 
532 } // 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().