5#include <kernel/util/simple_arg_parser.hpp>
6#include <kernel/solver/adp_solver_base.hpp>
8#if defined(FEAT_HAVE_TRILINOS) || defined(DOXYGEN)
11# error FROSch without MPI does not make sense.
50 class FROSchParameterList
80 enum PartitionApproach {
137 explicit FROSchParameterList(
const Dist::Comm& comm_,
const int dim_,
const FROSchParameterList::ProblemType problem_,
const int nlevels_ = 1,
const std::string& name_ =
"FEAT-FROSch Parameterlist");
159 explicit FROSchParameterList(
const Dist::Comm& comm_,
const int dim_,
const std::string& xml_file_,
const std::string& name_ =
"Parameter List");
160 ~FROSchParameterList();
162 void read_from_xml_str(
const std::string &xml_str_);
163 void read_from_xml_file(
const std::string &xml_file_);
169 void* get_core()
const;
175 int get_dpe_velo()
const;
176 int get_dpe_pres()
const;
177 int get_nlevels()
const;
178 bool get_use_timer()
const;
179 bool get_print()
const;
181 void set_dim(
const int dim);
182 void set_nlevels(
const int nlevels);
183 void set_problem_type(
const ProblemType problem_);
184 void set_use_timer(
const bool use_timer_);
185 void set_print(
const bool print_);
187 void set_precond(
const Preconditioner precond_);
188 void set_coarse_solver(
const DirectSolver solver_);
190 void set_gsteps(
const int gsteps_);
191 void set_gsteps(
const std::vector<int>& gsteps_);
193 void set_overlaps(
const int overlap_);
194 void set_overlaps(
const std::vector<int>& overlaps_);
196 void set_combine_overlap(
const CombineOverlap combine_mode_);
197 void set_combine_overlap(
const std::vector<CombineOverlap>& combine_mode_);
199 void set_combine_lvl(
const CombineLevel combine_mode_);
200 void set_combine_lvl(
const std::vector<CombineLevel>& combine_lvl_);
202 void set_solvers(
const DirectSolver solver_ao_,
const DirectSolver solver_ext_);
203 void set_solvers(
const std::vector<DirectSolver>& solvers_ao_,
const std::vector<DirectSolver>& solvers_ext_);
204 void set_solvers_ao(
const DirectSolver solver_);
205 void set_solvers_ao(
const std::vector<DirectSolver>& solvers_);
206 void set_solvers_ext(
const DirectSolver solver_);
207 void set_solvers_ext(
const std::vector<DirectSolver>& solvers_);
209 void set_paritioner(
const std::vector<int>& subregions_,
const PartitionType parti_type_,
const PartitionApproach parti_approach_,
const double parti_imbl_);
210 void set_paritioner(
const std::vector<int>& subregions_,
const std::vector<PartitionType>& parti_types_,
const std::vector<PartitionApproach>& parti_approach_,
const std::vector<double>& parti_imbl_);
212 void set_subregions(
const std::vector<int>& subregions_);
214 void set_parti_types(
const PartitionType parti_type_);
215 void set_parti_types(
const std::vector<PartitionType>& parti_types_);
217 void set_parti_approach(
const PartitionApproach parti_approach_);
218 void set_parti_approach(
const std::vector<PartitionApproach>& parti_approach_);
220 void set_parti_imbl(
const double parti_imbl_);
221 void set_parti_imbl(
const std::vector<double>& parti_imbl_);
223 void set_excludes(
const bool velo_pres_,
const bool pres_velo_);
224 void set_excludes(
const std::vector<bool>& velo_pres_,
const std::vector<bool>& pres_velo_);
225 void set_excludes_velo_pres(
const bool velo_pres_);
226 void set_excludes_velo_pres(
const std::vector<bool>& velo_pres_);
227 void set_excludes_pres_velo(
const bool pres_velo_);
228 void set_excludes_pres_velo(
const std::vector<bool>& pres_velo_);
230 void set_ipous(
const IPOU ipou_velo_,
const IPOU ipou_pres_);
231 void set_ipous(
const std::vector<IPOU>& ipous_velo_,
const std::vector<IPOU>& ipous_pres_);
232 void set_ipous_velo(
const IPOU ipou_);
233 void set_ipous_velo(
const std::vector<IPOU>& ipous_);
234 void set_ipous_pres(
const IPOU ipou_);
235 void set_ipous_pres(
const std::vector<IPOU>& ipous_);
237 void set_cspace(
const bool cspace_velo_,
const bool cspace_pres_);
238 void set_cspace(
const std::vector<bool>& cspace_velo_,
const std::vector<bool>& cspace_pres_);
239 void set_cspace_velo(
const bool cspace_);
240 void set_cspace_velo(
const std::vector<bool>& cspace_);
241 void set_cspace_pres(
const bool cspace_);
242 void set_cspace_pres(
const std::vector<bool>& cspace_);
244 void set_reuse_sf(
const bool rsf_ao_,
const bool rsf_cm_);
245 void set_reuse_sf(
const std::vector<bool> &rsf_ao_,
const std::vector<bool> &rsf_cm_);
246 void set_reuse_sf_ao(
const bool rsf_ao_);
247 void set_reuse_sf_ao(
const std::vector<bool> &rsf_ao_);
248 void set_reuse_sf_cm(
const bool rsf_cm_);
249 void set_reuse_sf_cm(
const std::vector<bool> &rsf_cm_);
251 void set_reuse_coarse(
const bool reuse_cm_,
const bool reuse_cb_);
252 void set_reuse_coarse(
const std::vector<bool> &reuse_cm_,
const std::vector<bool> &reuse_cb_);
253 void set_reuse_coarse_matrix(
const bool reuse_cm_);
254 void set_reuse_coarse_matrix(
const std::vector<bool> &reuse_cm_);
255 void set_reuse_coarse_basis(
const bool reuse_cb_);
256 void set_reuse_coarse_basis(
const std::vector<bool> &reuse_cb_);
258 void set_phi_dropping_threshold(
const double phi_dt_);
259 void set_phi_dropping_threshold(
const std::vector<double> &phi_dt_);
261 void set_verbose(
const bool verbose_);
263 bool parse_args(SimpleArgParser& args);
271 const Dist::Comm& _comm;
288 ProblemType _problem;
289 Preconditioner _preconditioner;
290 DirectSolver _solver_coarse;
292 std::vector<int> _gsteps;
294 std::vector<int> _overlaps;
295 std::vector<DirectSolver> _solvers_ao;
296 std::vector<DirectSolver> _solvers_ext;
299 std::vector<int> _subregions;
300 std::vector<PartitionType> _partition_types;
301 std::vector<PartitionApproach> _partition_approach;
302 std::vector<double> _partition_imbl_tol;
309 std::vector<bool> _exclude_pres_velo;
310 std::vector<bool> _exclude_velo_pres;
314 std::vector<bool> _cspace_velo;
315 std::vector<bool> _cspace_pres;
317 std::vector<IPOU> _ipous_velo;
318 std::vector<IPOU> _ipous_pres;
321 std::vector<CombineOverlap> _combine_ov;
324 std::vector<CombineLevel> _combine_lvl;
327 std::vector<bool> _ao_rsf;
329 std::vector<bool> _cm_rsf;
332 std::vector<bool> _cm_r;
334 std::vector<bool> _cb_r;
338 std::vector<double> _phi_dt;
350 void init_defaults();
354 inline void add_supported_fpl_args(SimpleArgParser& args)
356 args.support(
"frosch-plist",
"<XML file>\n"
357 "The frosch parameter list as a Trilinos parameter list.\n"
358 "__ATTENTION:__ If this option is given, then all the other options are ignored.\n"
359 "May contain the following types: XML file path."
361 args.support(
"frosch-print-list",
"<bool>\n"
362 "The Trilinos parameter list is print after the construction.\n"
363 "May contain the following types: true, false."
365 args.support(
"frosch-verbose",
"<bool>\n"
366 "The Trilinos/FROSch verbose. Print output of FROSch.\n"
367 "May contain the following types: true, false."
369 args.support(
"frosch-use-timer",
"<bool>\n"
370 "Use the Trilinos timers for FROSch solver\n"
371 "May contain the following types: true, false."
373 args.support(
"frosch-nlevels",
"<int>\n"
374 "Specifies the (additional) number of levels.\n"
375 "__ATTENTION:__ The used number of levels are one more, since the coarsest level is not counted.\n"
376 " Therefore, two-level overlapping Schwarz has nlevels == 1.\n"
377 "May contain the following types: int > 0"
379 args.support(
"frosch-dim",
"<int>\n"
380 "Specifies the (spatial) dimension.\n"
381 "May contain the following types: int > 0"
383 args.support(
"frosch-overlap",
"<int | int...>\n"
384 "Specifies which number of overlaps are used.\n"
385 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
386 "May contain the following types: int > 0\n"
389 args.support(
"frosch-subreg",
"<int | int...>\n"
390 "Specifies number of subregions for multi-level approach.\n"
391 "Number of arguments has same as the value of the argument: frosch-nlevels (int).\n"
392 "The last entry has to be one.\n"
393 "May contain the following types: int > 0"
395 args.support(
"frosch-gstep",
"<int | int...>\n"
396 "Specifies number of gathering steps for the coarse problem.\n"
397 "Number of arguments has same as the value of the argument: frosch-nlevels (int).\n"
398 "May contain the following types: int > 0"
400 args.support(
"frosch-parti-type",
"<types | types...>\n"
401 "Specifies the paritioner for multi-level approach.\n"
402 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
403 "May contain the following types: block, parmetis, phg, zoltan, scotch, ptscotch"
405 args.support(
"frosch-parti-approach",
"<types | types...>\n"
406 "Specifies the paritioner approach for multi-level approach.\n"
407 "Only used when parmetis partitioning is used\n."
408 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
409 "May contain the following types: partition, repartition."
411 args.support(
"frosch-parti-imbl",
"<double | double...>\n"
412 "Specifies the paritioner imblance for multi-level approach.\n"
413 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
414 "May contain the following types: double > 1."
416 args.support(
"frosch-ipou-pres",
"<types | types...>\n"
417 "Specifies the interface partition of unity for the pressure space.\n"
418 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
419 "May contain the following types: gdsw, gdswstar, rgdsw."
421 args.support(
"frosch-ipou-velo",
"<types | types...>\n"
422 "Specifies the interface partition of unity for the velocity space.\n"
423 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
424 "May contain the following types: gdsw, gdswstar, rgdsw."
426 args.support(
"frosch-solver-ao",
"<types | types...>\n"
427 "Specifies the overlapping direct solver.\n"
428 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
429 "May contain the following types: klu, mumps, umfpack."
431 args.support(
"frosch-solver-ext",
"<types | types...>\n"
432 "Specifies the extension direct solver.\n"
433 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
434 "May contain the following types: klu, mumps, umfpack."
436 args.support(
"frosch-solver-coarse",
"<types>\n"
437 "Specifies the coarse direct solver.\n"
438 "May contain the following types: klu, mumps, umfpack."
440 args.support(
"frosch-precond-type",
"<types>\n"
441 "Specifies FROSch preconditioner type.\n"
442 "May contain the following types: onelevel, twolevel, twolevelblock."
444 args.support(
"frosch-cspace-pres",
"<bool | bool...>\n"
445 "Specifies the use of the pressure for the coarse space (monolithic only).\n"
446 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
447 "May contain the following types: true, false."
449 args.support(
"frosch-cspace-velo",
"<bool | bool...>\n"
450 "Specifies the use of the velocity for the coarse space (monolithic only).\n"
451 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
452 "May contain the following types: true, false."
454 args.support(
"frosch-exclude-velo-pres",
"<bool | bool...>\n"
455 "Exclude the velocity-pressure coupling in coarse space (monolithic only).\n"
456 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
457 "May contain the following types: true, false."
459 args.support(
"frosch-exclude-pres-velo",
"<bool | bool...>\n"
460 "Exclude the pressure-velocity coupling in coarse space (monolithic only).\n"
461 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
462 "May contain the following types: true, false."
464 args.support(
"frosch-combine-overlap",
"<types | types...>\n"
465 "Combine mode of the overlap.\n"
466 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
467 "May contain the following types: full, restricted, averaging."
469 args.support(
"frosch-combine-lvl",
"<types | types...>\n"
470 "Combine mode of the different levels.\n"
471 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
472 "May contain the following types: additive, multiplicative"
474 args.support(
"frosch-reuse-sf-ao",
"<bool | bool...>\n"
475 "Reuse the symbolic factorization of the algebraic overlapping operator.\n"
476 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
477 "May contain the following types: true, false"
479 args.support(
"frosch-reuse-sf-cm",
"<bool | bool...>\n"
480 "Reuse the symbolic factorization of the coarse matrix.\n"
481 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
482 "May contain the following types: true, false"
484 args.support(
"frosch-reuse-coarse-matrix",
"<bool | bool...>\n"
485 "Reuse the complete coarse matrix.\n"
486 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
487 "May contain the following types: true, false"
489 args.support(
"frosch-reuse-coarse-basis",
"<bool | bool...>\n"
490 "Reuse the coarse basis functions.\n"
491 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
492 "May contain the following types: true, false"
494 args.support(
"frosch-phi-dropping-threshold",
"<double | double...>\n"
495 "Dropping threshold for the coarse matrix.\n"
496 "Number of arguments has be one or same as the value of the argument: frosch-nlevels (int).\n"
497 "May contain the following types: double > 0."
501 inline std::shared_ptr<FROSchParameterList> init_params_two_level_pressure_poisson(
const Dist::Comm& comm_,
504 const FROSchParameterList::IPOU ipou_pres_ = FROSchParameterList::GDSW,
505 const FROSchParameterList::DirectSolver solver_ao_ = FROSchParameterList::KLU,
506 const FROSchParameterList::DirectSolver solver_ext_ = FROSchParameterList::KLU,
507 const FROSchParameterList::DirectSolver solver_coarse_ = FROSchParameterList::KLU,
508 const FROSchParameterList::Preconditioner precond_ = FROSchParameterList::TWOLEVELBLOCK,
509 const FROSchParameterList::CombineOverlap mode_ = FROSchParameterList::RESTRICTED,
510 const bool use_timer_ =
false,
511 const bool print_list_ =
false)
513 std::shared_ptr<FROSchParameterList> params = std::make_shared<FROSchParameterList>(comm_, dim_, FROSchParameterList::PRESSUREPOISSON);
514 params->set_overlaps(overlap_);
516 params->set_ipous(FROSchParameterList::GDSW, ipou_pres_);
517 params->set_solvers(solver_ao_, solver_ext_);
518 params->set_coarse_solver(solver_coarse_);
519 params->set_precond(precond_);
520 params->set_combine_overlap(mode_);
521 params->set_use_timer(use_timer_);
522 params->set_print(print_list_);
524 params->set_cspace(
true,
true);
526 params->set_excludes(
false,
false);
527 params->set_paritioner(std::vector<int>(1, 1),
528 Solver::Trilinos::FROSchParameterList::PARMETIS,
529 Solver::Trilinos::FROSchParameterList::REPARTITION,
534 inline std::shared_ptr<FROSchParameterList> init_params_three_level_pressure_poisson(
const Dist::Comm& comm_,
538 const FROSchParameterList::PartitionType parti_type_ = FROSchParameterList::PARMETIS,
539 const FROSchParameterList::PartitionApproach parti_approach_ = FROSchParameterList::REPARTITION,
540 const double parti_imbl_ = 1.1,
541 const FROSchParameterList::IPOU ipou_pres_ = FROSchParameterList::GDSW,
542 const FROSchParameterList::DirectSolver solver_ao_ = FROSchParameterList::KLU,
543 const FROSchParameterList::DirectSolver solver_ext_ = FROSchParameterList::KLU,
544 const FROSchParameterList::DirectSolver solver_coarse_ = FROSchParameterList::KLU,
545 const FROSchParameterList::Preconditioner precond_ = FROSchParameterList::TWOLEVELBLOCK,
546 const FROSchParameterList::CombineOverlap mode_ = FROSchParameterList::RESTRICTED,
547 const bool use_timer_ =
false,
548 const bool print_list_ =
false)
550 std::shared_ptr<FROSchParameterList> params = std::make_shared<FROSchParameterList>(comm_, dim_, FROSchParameterList::PRESSUREPOISSON, 2);
551 params->set_overlaps(overlap_);
552 params->set_paritioner(std::vector<int>({nsubreg_, 1}), parti_type_, parti_approach_, parti_imbl_);
554 params->set_ipous(FROSchParameterList::GDSW, ipou_pres_);
555 params->set_solvers(solver_ao_, solver_ext_);
556 params->set_coarse_solver(solver_coarse_);
557 params->set_precond(precond_);
558 params->set_combine_overlap(mode_);
559 params->set_use_timer(use_timer_);
560 params->set_print(print_list_);
562 params->set_cspace(
true,
true);
564 params->set_excludes(
false,
false);
568 inline std::shared_ptr<FROSchParameterList> init_params_two_level_monolithic(
const Dist::Comm& comm_,
571 const FROSchParameterList::IPOU ipou_velo_ = FROSchParameterList::GDSW,
572 const FROSchParameterList::IPOU ipou_pres_ = FROSchParameterList::GDSW,
573 const FROSchParameterList::DirectSolver solver_ao_ = FROSchParameterList::KLU,
574 const FROSchParameterList::DirectSolver solver_ext_ = FROSchParameterList::KLU,
575 const FROSchParameterList::DirectSolver solver_coarse_ = FROSchParameterList::KLU,
576 const bool excl_velo_pres_ =
false,
577 const bool excl_pres_velo_ =
false,
578 const FROSchParameterList::CombineOverlap mode_ = FROSchParameterList::RESTRICTED,
579 const bool use_timer_ =
false,
580 const bool print_list_ =
false)
582 std::shared_ptr<FROSchParameterList> params = std::make_shared<FROSchParameterList>(comm_, dim_, FROSchParameterList::PRESSUREPOISSON);
583 params->set_overlaps(overlap_);
584 params->set_ipous(ipou_velo_, ipou_pres_);
585 params->set_solvers(solver_ao_, solver_ext_);
586 params->set_coarse_solver(solver_coarse_);
587 params->set_excludes(excl_velo_pres_, excl_pres_velo_);
588 params->set_combine_overlap(mode_);
589 params->set_use_timer(use_timer_);
590 params->set_print(print_list_);
592 params->set_precond(FROSchParameterList::TWOLEVELBLOCK);
593 params->set_cspace(
true,
true);
594 params->set_paritioner(std::vector<int>(1, 1),
595 Solver::Trilinos::FROSchParameterList::PARMETIS,
596 Solver::Trilinos::FROSchParameterList::REPARTITION,
601 inline std::shared_ptr<FROSchParameterList> init_params_three_level_monolithic(
const Dist::Comm& comm_,
605 const FROSchParameterList::PartitionType parti_type_ = FROSchParameterList::PARMETIS,
606 const FROSchParameterList::PartitionApproach parti_approach_ = FROSchParameterList::REPARTITION,
607 const double parti_imbl_ = 1.1,
608 const FROSchParameterList::IPOU ipou_velo_ = FROSchParameterList::GDSW,
609 const FROSchParameterList::IPOU ipou_pres_ = FROSchParameterList::GDSW,
610 const FROSchParameterList::DirectSolver solver_ao_ = FROSchParameterList::KLU,
611 const FROSchParameterList::DirectSolver solver_ext_ = FROSchParameterList::KLU,
612 const FROSchParameterList::DirectSolver solver_coarse_ = FROSchParameterList::KLU,
613 const bool excl_velo_pres_ =
false,
614 const bool excl_pres_velo_ =
false,
615 const FROSchParameterList::CombineOverlap mode_ = FROSchParameterList::RESTRICTED,
616 const bool use_timer_ =
false,
617 const bool print_list_ =
false)
619 std::shared_ptr<FROSchParameterList> params = std::make_shared<FROSchParameterList>(comm_, dim_, FROSchParameterList::PRESSUREPOISSON, 2);
620 params->set_overlaps(overlap_);
621 params->set_paritioner(std::vector<int>({nsubreg_, 1}), parti_type_, parti_approach_, parti_imbl_);
622 params->set_ipous(ipou_velo_, ipou_pres_);
623 params->set_solvers(solver_ao_, solver_ext_);
624 params->set_coarse_solver(solver_coarse_);
625 params->set_excludes(excl_velo_pres_, excl_pres_velo_);
626 params->set_combine_overlap(mode_);
627 params->set_use_timer(use_timer_);
628 params->set_print(print_list_);
630 params->set_precond(FROSchParameterList::TWOLEVELBLOCK);
631 params->set_cspace(
true,
true);
666 void* create_core_scalar(
const void* comm, Index num_global_dofs, Index my_dof_offset,
667 Index num_owned_dofs, Index num_nonzeros,
const FROSchParameterList & params);
670 void* create_core_stokes(
const void* comm, Index num_global_dofs, Index my_dof_offset,
671 Index num_owned_dofs, Index num_nonzeros, Index num_owned_velo_dofs, Index num_owned_pres_dofs,
672 Index first_owned_velo_dof, Index first_owned_pres_dof,
673 Index num_global_velo_dofs, Index num_global_pres_dofs,
674 const Trilinos::FROSchParameterList & params);
676 void destroy_core(
void* core);
678 void set_parameter_list(
void* core,
const FROSchParameterList & params);
680 void init_symbolic(
void* core);
681 void init_numeric(
void* core);
683 std::int64_t* get_row_ptr(
void* core);
684 std::int32_t* get_col_idx(
void* core);
685 double* get_mat_val(
void* core);
686 double* get_vec_def(
void* core);
687 double* get_vec_cor(
void* core);
688 void format_vec_cor(
void* core);
691 void* create_frosch(
void* core);
692 void reinit_frosch(
void *core);
693 void compute_frosch(
void *solver);
694 void destroy_frosch(
void* solver);
695 void solve_frosch(
void* core,
void* solver);
713 template<
typename Matrix_,
typename Filter_,
typename SolverBase_ = Solver::SolverBase<
typename Matrix_::VectorTypeL>>
726 const Trilinos::FROSchParameterList& _params;
728 explicit TpetraSolverBase(
const Matrix_& matrix,
const Filter_& filter,
const Trilinos::FROSchParameterList & params) :
746 this->
_upload_vector(Trilinos::get_vec_def(this->_core), vec_def.local());
755 Trilinos::format_vec_cor(this->_core);
769 this->
_download_vector(vec_cor.local(), Trilinos::get_vec_cor(this->_core));
786 XASSERT(this->_core !=
nullptr);
790 Trilinos::get_row_ptr(this->_core), Trilinos::get_col_idx(this->_core));
792 Trilinos::init_numeric(this->_core);
803 XASSERT(this->_core !=
nullptr);
805 Trilinos::destroy_core(this->_core);
806 this->_core =
nullptr;
821 template<
typename Matrix_,
typename Filter_>
836 explicit FROSchPreconditioner(
const Matrix_& matrix,
const Filter_& filter,
const Trilinos::FROSchParameterList & params) :
843 const Matrix_& matrix,
const Filter_& filter)
852 return "FROSchPreconditioner";
871 this->
_core = Trilinos::create_core_scalar(
881 Trilinos::init_symbolic(this->
_core);
889 if(_solver ==
nullptr)
891 this->_solver = Trilinos::create_frosch(this->
_core);
895 Trilinos::reinit_frosch(this->_solver);
912 Trilinos::destroy_frosch(
_solver);
924 Trilinos::solve_frosch(this->
_core, this->_solver);
946 template<
typename Matrix_,
typename Filter_>
947 inline std::shared_ptr<FROSchPreconditioner<Matrix_, Filter_>>
new_frosch(
948 const Matrix_& matrix,
const Filter_& filter)
950 return std::make_shared<FROSchPreconditioner<Matrix_, Filter_>>(matrix, filter);
971 template<
typename Matrix_,
typename Filter_>
972 inline std::shared_ptr<FROSchPreconditioner<Matrix_, Filter_>>
new_frosch(
974 const Matrix_& matrix,
const Filter_& filter)
976 return std::make_shared<FROSchPreconditioner<Matrix_, Filter_>>(section_name, section, matrix, filter);
994 template<
typename Matrix_,
typename Filter_>
995 inline std::shared_ptr<FROSchPreconditioner<Matrix_, Filter_>>
new_frosch(
996 const Matrix_& matrix,
const Filter_& filter,
const Trilinos::FROSchParameterList & params)
998 return std::make_shared<FROSchPreconditioner<Matrix_, Filter_>>(matrix, filter, params);
1010 template<
typename Matrix_,
typename Filter_>
1024 Index _num_owned_velo_dofs;
1025 Index _num_owned_pres_dofs;
1027 Index _first_owned_velo_dof;
1028 Index _first_owned_pres_dof;
1030 Index _num_global_velo_dofs;
1031 Index _num_global_pres_dofs;
1034 explicit StokesFROSchPreconditioner(
const Matrix_& matrix,
const Filter_& filter,
const Trilinos::FROSchParameterList & params) :
1037 _num_owned_velo_dofs(0),
1038 _num_owned_pres_dofs(0),
1039 _first_owned_velo_dof(0),
1040 _first_owned_pres_dof(0),
1041 _num_global_velo_dofs(0),
1042 _num_global_pres_dofs(0)
1047 const Matrix_& matrix,
const Filter_& filter) :
1057 Trilinos::destroy_frosch(
_solver);
1064 return "StokesFROSchPreconditioner";
1087 this->_deduct_sizes();
1106 this->
_core = Trilinos::create_core_stokes(
1112 this->_num_owned_velo_dofs,
1113 this->_num_owned_pres_dofs,
1114 this->_first_owned_velo_dof,
1115 this->_first_owned_pres_dof,
1116 this->_num_global_velo_dofs,
1117 this->_num_global_pres_dofs,
1122 Trilinos::init_symbolic(this->
_core);
1130 if(_solver ==
nullptr)
1132 this->_solver = Trilinos::create_frosch(this->
_core);
1136 Trilinos::reinit_frosch(this->_solver);
1147 Trilinos::solve_frosch(this->
_core, this->_solver);
1157 void _deduct_sizes()
1163 XASSERTM(vbi.size() == std::size_t(4),
"invalid block information for StokesFROSchPreconditioner");
1166 XASSERTM(vbi[3] ==
"</Tuple>",
"invalid block information for StokesFROSchPreconditioner");
1169 std::regex rext(
"<Tuple gc=\"(\\d+)\" gf=\"(\\d+)\" go=\"(\\d+)\" lc=\"(\\d+)\" lo=\"0\">");
1171 if(!std::regex_match(vbi.at(0), rmt, rext))
1172 throw InternalError(
"invalid Tuple block information for StokesFROSchPreconditioner:\n" + vbi.at(0));
1175 std::regex rexv(
"<Blocked bs=\"(\\d+)\" gc=\"(\\d+)\" gf=\"(\\d+)\" go=\"(\\d+)\" lc=\"(\\d+)\" lo=\"0\"/>");
1177 if(!std::regex_match(vbi.at(1), rmv, rexv))
1178 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner:\n" + vbi.at(1));
1180 if(!
String(rmv[2]).parse(this->_num_global_velo_dofs))
1181 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse global velocity dof count");
1182 if(!
String(rmv[3]).parse(this->_first_owned_velo_dof))
1183 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse first owned global velocity dof");
1184 if(!
String(rmv[5]).parse(this->_num_owned_velo_dofs))
1185 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse local velocity dof count");
1188 std::regex rexp(
"<Scalar gc=\"(\\d+)\" gf=\"(\\d+)\" go=\"(\\d+)\" lc=\"(\\d+)\" lo=\"(\\d+)\"/>");
1190 if(!std::regex_match(vbi.at(2), rmp, rexp))
1191 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner:\n" + vbi.at(2));
1193 if(!
String(rmp[1]).parse(this->_num_global_pres_dofs))
1194 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse global velocity dof count");
1195 if(!
String(rmp[2]).parse(this->_first_owned_pres_dof))
1196 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse first owned global velocity dof");
1197 if(!
String(rmp[4]).parse(this->_num_owned_pres_dofs))
1198 throw InternalError(
"invalid velocity block information for StokesFROSchPreconditioner: failed to parse local velocity dof count");
1232 template<
typename Matrix_,
typename Filter_>
1234 const Matrix_& matrix,
const Filter_& filter,
const Index num_owned_pres_dofs)
1236 return std::make_shared<StokesFROSchPreconditioner<Matrix_, Filter_>>(matrix, filter, num_owned_pres_dofs);
1257 template<
typename Matrix_,
typename Filter_>
1260 const Matrix_& matrix,
const Filter_& filter)
1262 return std::make_shared<StokesFROSchPreconditioner<Matrix_, Filter_>>(section_name, section, matrix, filter);
1280 template<
typename Matrix_,
typename Filter_>
1282 const Matrix_& matrix,
const Filter_& filter,
const Trilinos::FROSchParameterList & params)
1284 return std::make_shared<StokesFROSchPreconditioner<Matrix_, Filter_>>(matrix, filter, params);
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
exception that is thrown if something that is never supposed to happen happens
A class organizing a tree of key-value pairs.
Base-Class for solvers based on Algebraic-DOF-Partitioning.
const Dist::Comm * _get_comm() const
const FilterType & _system_filter
the system filter
void _upload_symbolic(RPT_ *row_ptr, CIT_ *col_idx)
Uploads the ADP matrix structure to the given arrays.
Index _get_num_owned_dofs() const
Index _get_global_dof_offset() const
String _get_adp_block_information() const
void _download_vector(LocalVectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
void _upload_vector(DTV_ *val, const LocalVectorType &vector)
Uploads the ADP vector values to the given array.
MatrixType::VectorTypeL VectorType
the (local) vector type
Index _get_num_global_dofs() const
Index _get_adp_matrix_num_nzes() const
void _upload_numeric(DTV_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Uploads the (filtered) ADP matrix values to the given array.
Trilinos FROSchPreconditioner class template.
virtual void done_numeric() override
Numeric finalization method.
BaseClass::VectorType VectorType
the vector type
FROSchPreconditioner(const String §ion_name, PropertyMap *section, const Matrix_ &matrix, const Filter_ &filter)
void * _solver
the FROSchPreconditioner solver object
virtual String name() const override
Returns a descriptive string.
TpetraSolverBase< Matrix_, Filter_ > BaseClass
our base-class
virtual void init_numeric() override
Numeric Initialization.
virtual void init_symbolic() override
Symbolic Initialization.
virtual void init_symbolic()
Symbolic initialization method.
virtual void init_numeric()
Numeric initialization method.
virtual void done_symbolic()
Symbolic finalization method.
Trilinos StokesFROSchPreconditioner class template.
virtual void init_numeric() override
Numeric Initialization.
void * _solver
the FROSchPreconditioner solver object
virtual void init_symbolic() override
Symbolic Initialization.
virtual String name() const override
Returns a descriptive string.
TpetraSolverBase< Matrix_, Filter_ > BaseClass
our base-class
StokesFROSchPreconditioner(const String §ion_name, PropertyMap *section, const Matrix_ &matrix, const Filter_ &filter)
BaseClass::VectorType VectorType
the vector type
Base-Class for solvers/preconditioners borrowed from Trilinos/FROSch library.
virtual void done_symbolic() override
Symbolic Finalization.
void _download_cor(VectorType &vec_cor)
Downloads the Tpetra correction vector.
ADPSolverBase< Matrix_, Filter_, SolverBase_ > BaseClass
our base-class
void * _core
a pointer to our opaque core wrapper object
void _format_cor()
Format the Tpetra correction vector.
void _upload_def(const VectorType &vec_def)
Uploads the Tpetra defect vector.
virtual void init_numeric() override
Numeric Initialization.
String class implementation.
std::deque< String > split_by_charset(const String &charset) const
Splits the string by a delimiter charset.
Status
Solver status return codes enumeration.
@ success
solving successful (convergence criterion fulfilled)
std::shared_ptr< FROSchPreconditioner< Matrix_, Filter_ > > new_frosch(const Matrix_ &matrix, const Filter_ &filter)
Creates a new FROSchPreconditioner solver object.
std::shared_ptr< FROSchPreconditioner< Matrix_, Filter_ > > new_stokes_frosch(const Matrix_ &matrix, const Filter_ &filter, const Index num_owned_pres_dofs)
Creates a new StokesFROSchPreconditioner solver object.
std::uint64_t Index
Index data type.