Test mesh distribution in parallel, starting with n_uniform_first uniform refinments before starting the distribution. Then refine and unrefine uniformly as specified. Re-distribute after every uniform refinement if requested by the boolean flag.
298 << std::endl << std::endl
299 <<
"Running with " << n_refine_first <<
" initial serial refinements and \n"
300 <<
"with " << n_refine_once_distributed
301 <<
" subsequent distributed refinements"
302 << std::endl << std::endl;
304 double av_efficiency;
305 double max_efficiency;
306 double min_efficiency;
307 double av_number_halo_nodes;
308 unsigned max_number_halo_nodes;
309 unsigned min_number_halo_nodes;
312 std::ofstream some_file;
332 unsigned n_dof_orig=problem_pt->
ndof();
333 unsigned n_dof=problem_pt->
ndof();
338 clock_t t_start = clock();
339 for (
unsigned i=0;
i<n_refine_first;
i++)
344 clock_t t_end = clock();
350 double t_tot=
double(t_end-t_start)/CLOCKS_PER_SEC;
351 oomph_info <<
"Time for initial adaptation [ndof=" << problem_pt->
ndof()
352 <<
"]: " << t_tot << std::endl;
354 n_dof=problem_pt->
ndof();
357 "%s/two_d_initial_refinement_nrefinement_%i_ndofbefore_%i_ndofafter_%i.dat",
363 some_file << n_refine_first <<
" "
378 std::ifstream input_file;
379 std::ofstream output_file;
382 unsigned n_partition=problem_pt->
mesh_pt()->nelement();
384 sprintf(
filename,
"two_d_mesh_dist_partition.dat");
387 for (
unsigned e=0;
e<n_partition;
e++)
389 getline(input_file,input_string,
'\n');
390 element_partition[
e]=atoi(input_string.c_str());
394 bool report_stats=
false;
395 out_element_partition=problem_pt->distribute(element_partition,
396 doc_info,report_stats);
398 sprintf(
filename,
"out_two_d_mesh_dist_partition.dat");
400 for (
unsigned e=0;
e<n_partition;
e++)
402 output_file << out_element_partition[
e] << std::endl;
407 problem_pt->distribute();
414 problem_pt->
mesh_pt()->get_halo_node_stats(av_number_halo_nodes,
415 max_number_halo_nodes,
416 min_number_halo_nodes);
417 problem_pt->
mesh_pt()->get_efficiency_of_mesh_distribution
418 (av_efficiency,max_efficiency,min_efficiency);
424 double t_tot=
double(t_end-t_start)/CLOCKS_PER_SEC;
425 oomph_info <<
"Time for problem distribution [ndof=" << problem_pt->
ndof()
426 <<
"]: " << t_tot << std::endl;
430 "%s/two_d_initial_distr_np_%i_nrefinement_%i_ndof_%i.dat",
436 some_file << n_proc <<
" "
439 << av_number_halo_nodes <<
" "
440 << max_number_halo_nodes <<
" "
441 << min_number_halo_nodes <<
" "
442 << av_efficiency <<
" "
443 << max_efficiency <<
" "
444 << min_efficiency <<
" "
452 problem_pt->check_halo_schemes(quiet_doc_info);
460 #ifdef OOMPH_HAS_TRILINOS
463 oomph_info <<
"Using the TRILINOS solver" << std::endl;
475 linear_solver_pt->
solver_type()=TrilinosAztecOOSolver::GMRES;
498 for (
unsigned i=0;
i<n_refine_once_distributed;
i++)
501 n_dof_orig=problem_pt->
ndof();
512 problem_pt->
mesh_pt()->get_halo_node_stats(av_number_halo_nodes,
513 max_number_halo_nodes,
514 min_number_halo_nodes);
515 problem_pt->
mesh_pt()->get_efficiency_of_mesh_distribution
516 (av_efficiency,max_efficiency,min_efficiency);
521 double t_tot=
double(t_end-t_start)/CLOCKS_PER_SEC;
522 oomph_info <<
"Time for distributed adaptation [ndof="
523 << problem_pt->
ndof()
524 <<
"]: " << t_tot << std::endl;
527 n_dof=problem_pt->
ndof();
531 if (!redistribute) snippet=
"out";
535 "%s/two_d_distributed_refinement_np_%i_ninitialrefinement_%i_ntotalrefinement_%i_ndof_%i_with%sredistribution.dat",
543 some_file << n_proc <<
" "
547 << av_number_halo_nodes <<
" "
548 << max_number_halo_nodes <<
" "
549 << min_number_halo_nodes <<
" "
550 << av_efficiency <<
" "
551 << max_efficiency <<
" "
552 << min_efficiency <<
" "
566 bool report_stats=
false;
568 problem_pt->prune_halo_elements_and_nodes(doc_info,
571 double t_tot=
double(t_end-t_start)/CLOCKS_PER_SEC;
577 oomph_info <<
"Av., min. max. efficiency before redistribution "
578 << av_efficiency <<
" "
579 << min_efficiency <<
" "
580 << max_efficiency <<
" "
584 "%s/two_d_redistribution_np_%i_ninitialrefinement_%i_ntotalrefinement_%i_ndof_%i.dat",
591 some_file << n_proc <<
" "
594 << av_number_halo_nodes <<
" "
595 << max_number_halo_nodes <<
" "
596 << min_number_halo_nodes <<
" "
597 << av_efficiency <<
" "
598 << max_efficiency <<
" "
599 << min_efficiency <<
" "
606 problem_pt->
mesh_pt()->get_halo_node_stats(av_number_halo_nodes,
607 max_number_halo_nodes,
608 min_number_halo_nodes);
610 get_efficiency_of_mesh_distribution(av_efficiency,
617 oomph_info <<
"Time for redistribution [ndof="
618 << problem_pt->
ndof()
619 <<
"]: " << t_tot << std::endl;
622 some_file << n_proc <<
" "
625 << av_number_halo_nodes <<
" "
626 << max_number_halo_nodes <<
" "
627 << min_number_halo_nodes <<
" "
628 << av_efficiency <<
" "
629 << max_efficiency <<
" "
630 << min_efficiency <<
" "
636 get_efficiency_of_mesh_distribution(av_efficiency,
639 oomph_info <<
"Av., min., max. efficiency after redistribution "
640 << av_efficiency <<
" "
641 << min_efficiency <<
" "
642 << max_efficiency <<
" "
649 problem_pt->check_halo_schemes(quiet_doc_info);
674 n_dof_orig=problem_pt->
ndof();
683 double t_tot=
double(t_end-t_start)/CLOCKS_PER_SEC;
684 oomph_info <<
"Time for distributed unrefinement [ndof="
685 << problem_pt->
ndof()
686 <<
"]: " << t_tot << std::endl;
689 n_dof=problem_pt->
ndof();
693 "%s/two_d_distributed_unrefinement_np_%i_ninitialrefinement_%i_ntotalrefinement_%i_ndof_%i.dat",
697 n_refine_first+n_refine_once_distributed,
700 some_file << n_proc <<
" "
704 << av_number_halo_nodes <<
" "
705 << max_number_halo_nodes <<
" "
706 << min_number_halo_nodes <<
" "
707 << av_efficiency <<
" "
708 << max_efficiency <<
" "
709 << min_efficiency <<
" "
717 problem_pt->check_halo_schemes(quiet_doc_info);
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc:149
void doc_solution(DocInfo &doc_info)
Doc the solution: doc_info contains labels/output directory etc.
Definition: optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc:354
SimpleRefineableRectangularQuadMesh< ELEMENT > * mesh_pt()
Definition: optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc:188
Definition: oomph_utilities.h:499
void disable_doc()
Disable documentation.
Definition: oomph_utilities.h:542
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
Preconditioner *& preconditioner_pt()
Access function to preconditioner.
Definition: iterative_linear_solver.h:95
void disable_doc_time()
Disable documentation of solve times.
Definition: linear_solver.h:116
int my_rank() const
my rank
Definition: communicator.h:176
int nproc() const
number of processors
Definition: communicator.h:157
void refine_uniformly(const Vector< unsigned > &nrefine_for_mesh)
Definition: problem.h:2575
unsigned long ndof() const
Return the number of dofs.
Definition: problem.h:1674
unsigned unrefine_uniformly()
Definition: problem.cc:15831
OomphCommunicator * communicator_pt()
access function to the oomph-lib communicator
Definition: problem.h:1246
LinearSolver *& linear_solver_pt()
Return a pointer to the linear solver object.
Definition: problem.h:1466
void newton_solve()
Use Newton method to solve the problem.
Definition: problem.cc:8783
Definition: trilinos_solver.h:267
unsigned & solver_type()
Access function to Solver_type.
Definition: trilinos_solver.h:442
Definition: trilinos_preconditioners.h:152
string filename
Definition: MergeRestartFiles.py:39
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
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286