two_d_parallel_unstructured_adaptive_poisson.cc File Reference
#include <fenv.h>
#include "generic.h"
#include "poisson.h"
#include "meshes/triangle_mesh.h"

Classes

class  PoissonProblem< ELEMENT >
 Micky mouse Poisson problem. More...
 

Namespaces

 TanhSolnForPoisson
 Namespace for exact solution for Poisson equation with "sharp step".
 
 TestArguments
 

Functions

void TanhSolnForPoisson::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector. More...
 
void TanhSolnForPoisson::get_exact_u (const Vector< double > &x, double &u)
 Exact solution as a scalar. More...
 
void TanhSolnForPoisson::get_source (const Vector< double > &x, double &source)
 Source function to make it an exact solution. More...
 
int main (int argc, char *argv[])
 Demonstrate how to solve Poisson problem using parallel. More...
 

Variables

unsigned TestArguments::Domain_configuration = 1
 
double TestArguments::Element_size = 1.0e-2
 
unsigned TestArguments::Max_adapt = 3
 
double TestArguments::Max_permitted_error = 1.0e-3
 
double TestArguments::Min_permitted_error = 1.0e-5
 
double TestArguments::Max_element_size = Element_size
 
double TestArguments::Min_element_size = 1.0e-14
 
unsigned TestArguments::Load_balance = 0
 
std::string TestArguments::Folder_distribution_file =""
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Demonstrate how to solve Poisson problem using parallel.

Trace file to document error and norm of solution

1329 {
1330 
1331  // initialise MPI
1332 #ifdef OOMPH_HAS_MPI
1333  MPI_Helpers::init(argc,argv);
1334 #endif
1335 
1336  // Get the processor rank (we use this to name the trace file)
1337  const unsigned my_rank = MPI_Helpers::communicator_pt()->my_rank();
1338 
1339  // Store command line arguments
1340  CommandLineArgs::setup(argc,argv);
1341 
1342  // Domain configurations: 1 Square domain
1343  // 2 Half circle domain
1344  // 3 Half circle domain with internal boundaries
1345  // 4 Complex domain with holes
1346  // Domain configuration
1347  CommandLineArgs::specify_command_line_flag("--domain_configuration",
1349 
1350  // Element size
1353 
1354  // Sample point container
1357 #ifdef OOMPH_HAS_CGAL
1359 #endif
1360 
1361  // Max adaptations
1364 
1365  // Max. permitted error
1366  CommandLineArgs::specify_command_line_flag("--max_permitted_error",
1368 
1369  // Min. permitted error
1370  CommandLineArgs::specify_command_line_flag("--min_permitted_error",
1372 
1373  // Max. element size
1374  CommandLineArgs::specify_command_line_flag("--max_element_size",
1376 
1377  // Min. element size
1378  CommandLineArgs::specify_command_line_flag("--min_element_size",
1380 
1381  // Do load balance?
1384 
1385  // Max adaptations
1386  CommandLineArgs::specify_command_line_flag("--folder_distribution_file",
1388 
1389  // Parse command line
1391 
1392  // Doc what has actually been specified on the command line
1394 
1395  // Label for output
1396  DocInfo doc_info;
1397 
1398  // Output directory
1399  doc_info.set_directory("RESLT");
1400 
1401  // Do not monitor memory usage
1403 
1404  // Swith timings on
1406 
1407  // Only set one!
1408  unsigned count=0;
1410  {
1411  count++;
1414  }
1416  {
1417  count++;
1420  }
1421 
1422 #ifdef OOMPH_HAS_CGAL
1424  {
1425  count++;
1427  UseCGALSamplePointContainer;
1428  }
1429 #endif
1430 
1431  if (count>1)
1432  {
1433  std::ostringstream error_message;
1434  error_message
1435  << "Can only choose one of --non_ref_bin, --ref_bin or --cgal!";
1436  throw OomphLibError(error_message.str(),
1439  }
1440 
1441 
1442  // Use quadratic elements to solve the problem
1443  //----------------------------------------------
1444 
1445  //Set up the problem
1448 
1449  // Open the trace file (the name of the trace file is different for
1450  // each processor)
1451  char trace_filename[100];
1452  sprintf(trace_filename,"%s/trace_proc%i.dat",
1453  doc_info.directory().c_str(), my_rank);
1454 
1456  ofstream trace_file;
1457  trace_file.open(trace_filename);
1458 
1459  // Doc the initial mesh
1460  problem.doc_solution(doc_info, trace_file);
1461 
1462  //Increment counter for solutions
1463  doc_info.number()++;
1464 
1465  // Once the mesh has been created, suppress the generation of points
1466  // along the boundaries by Triangle during mesh adaptation
1467  problem.mesh_pt()->disable_automatic_creation_of_vertices_on_boundaries();
1468 
1469  // Set the number of bins for area transfer
1470  problem.mesh_pt()->nbin_x_for_area_transfer() = 100; // default values
1471  problem.mesh_pt()->nbin_y_for_area_transfer() = 100; // default values
1472 
1473 #ifdef OOMPH_HAS_MPI
1474  // Store the distribution of the elements
1475  Vector<unsigned> distributed_elements;
1476  // Should we read the distribution from file
1477  if(CommandLineArgs::command_line_flag_has_been_set("--folder_distribution_file"))
1478  {
1479  // Read a custom distribution from file
1480  Vector<unsigned> input_distribution;
1481  problem.read_custom_distribution_from_file(input_distribution);
1482  // Distribute the problem and store the distribution of the elements
1483  distributed_elements = problem.distribute(input_distribution);
1484  }
1485  else
1486  {
1487  // Distribute problem
1488  distributed_elements = problem.distribute();
1489  // Uncomment the next lines if you want to save the distribution to
1490  // file. Create a file with the custom distribution
1491  //problem.save_custom_distribution_to_file(distributed_elements);
1492  }
1493 
1494  // Output the initial distributed mesh
1495  char file_initial_distributed_mesh[100];
1496  // This show us the elements assigned to this processor (remember to
1497  // disable the output of halo elements)
1498  problem.mesh_pt()->disable_output_of_halo_elements();
1499  sprintf(file_initial_distributed_mesh,
1500  "%s/output_initial_distributed_mesh_%i.dat",
1501  doc_info.directory().c_str(), my_rank);
1502 
1503  problem.mesh_pt()->output(file_initial_distributed_mesh, 2);
1504 #endif // OOMPH_HAS_MPI
1505 
1506  // Solve the problem doing (parallel unstructured) mesh adaptation
1507  problem.newton_solve(TestArguments::Max_adapt);
1508 
1509  // Document the solution
1510  problem.doc_solution(doc_info, trace_file);
1511 
1512  //Increment counter for solutions
1513  doc_info.number()++;
1514 
1515  // Do load balance?
1517  {
1518  // Perform load balance
1519  problem.load_balance();
1520  } // if (load_balance > 0)
1521 
1522  //Output solution (balanced solution)
1523  problem.doc_solution(doc_info, trace_file);
1524 
1525  //Increment counter for solutions
1526  doc_info.number()++;
1527 
1528  // Close the trace file
1529  trace_file.close();
1530 
1531 #ifdef OOMPH_HAS_MPI
1532  MPI_Helpers::finalize();
1533 #endif
1534 
1535  // Return exit successful
1536  return 0;
1537 
1538 }
Micky mouse Poisson problem.
Definition: HypreSolver_test.cc:81
Definition: oomph_utilities.h:499
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
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
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.
Definition: extrude_with_macro_element_representation.cc:224
double Min_permitted_error
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:95
double Min_element_size
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:97
double Max_element_size
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:96
double Element_size
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:92
std::string Folder_distribution_file
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:105
double Max_permitted_error
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:94
unsigned Load_balance
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:99
unsigned Domain_configuration
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:91
unsigned Max_adapt
Definition: two_d_parallel_unstructured_adaptive_poisson.cc:93
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
bool Doc_comprehensive_timings
Definition: oomph_definitions.cc:49
bool Bypass_all_memory_usage_monitoring
Definition: oomph_utilities.cc:1390
unsigned Default_sample_point_container_version
Default sample point container type.
Definition: mesh_as_geometric_object.cc:58
@ UseRefineableBinArray
Definition: sample_point_parameters.h:41
@ UseNonRefineableBinArray
Definition: sample_point_parameters.h:42
#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::MemoryUsage::Bypass_all_memory_usage_monitoring, oomph::CommandLineArgs::command_line_flag_has_been_set(), oomph::MeshAsGeomObject_Helper::Default_sample_point_container_version, oomph::DocInfo::directory(), oomph::Global_timings::Doc_comprehensive_timings, oomph::CommandLineArgs::doc_specified_flags(), TestArguments::Domain_configuration, TestArguments::Element_size, TestArguments::Folder_distribution_file, TanhSolnForPoisson::get_source(), TestArguments::Load_balance, TestArguments::Max_adapt, TestArguments::Max_element_size, TestArguments::Max_permitted_error, TestArguments::Min_element_size, TestArguments::Min_permitted_error, oomph::DocInfo::number(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::CommandLineArgs::parse_and_assign(), problem, oomph::DocInfo::set_directory(), Flag_definition::setup(), oomph::CommandLineArgs::specify_command_line_flag(), oomph::UseNonRefineableBinArray, and oomph::UseRefineableBinArray.