Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ifpack move parameters and options to xml file #400

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,8 @@ Teuchos::ParameterList translate_four_c_to_ifpack(const Teuchos::ParameterList&
{
Teuchos::ParameterList ifpacklist;

ifpacklist.set("fact: level-of-fill", inparams.get<int>("IFPACKGFILL"));
ifpacklist.set("partitioner: overlap", inparams.get<int>("IFPACKOVERLAP"));
ifpacklist.set("schwarz: combine mode",
inparams.get<std::string>("IFPACKCOMBINE")); // can be "Zero", "Add", "Insert"
ifpacklist.set("schwarz: reordering type", "rcm"); // "rcm" or "metis" or "amd"
const std::string xmlfile = inparams.get<std::string>("IFPACK_XML_FILE");
if (xmlfile != "none") ifpacklist.set("IFPACK_XML_FILE", xmlfile);

return ifpacklist;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

#include "4C_linear_solver_preconditioner_ifpack.hpp"

#include "4C_comm_utils.hpp"
#include "4C_linalg_blocksparsematrix.hpp"
#include "4C_utils_exceptions.hpp"

#include <Teuchos_XMLParameterListHelpers.hpp>

FOUR_C_NAMESPACE_OPEN

//------------------------------------------------------------------------------
Expand All @@ -18,7 +21,6 @@ Core::LinearSolver::IFPACKPreconditioner::IFPACKPreconditioner(
Teuchos::ParameterList& ifpacklist, Teuchos::ParameterList& solverlist)
: ifpacklist_(ifpacklist), solverlist_(solverlist)
{
return;
}

//------------------------------------------------------------------------------
Expand All @@ -44,24 +46,30 @@ void Core::LinearSolver::IFPACKPreconditioner::setup(bool create, Epetra_Operato

pmatrix_ = std::make_shared<Epetra_CrsMatrix>(*A_crs);

// get the type of ifpack preconditioner from solver parameter list
std::string prectype = solverlist_.get("Preconditioner Type", "ILU");
const int overlap = ifpacklist_.get("IFPACKOVERLAP", 0);
const std::string xmlFileName = ifpacklist_.get<std::string>("IFPACK_XML_FILE");
if (xmlFileName == "none") FOUR_C_THROW("IFPACK_XML_FILE parameter not set!");

Teuchos::ParameterList ifpack_params;

auto comm = Core::Communication::to_teuchos_comm<int>(
Core::Communication::unpack_epetra_comm(pmatrix_->Comm()));

Teuchos::updateParametersFromXmlFileAndBroadcast(
xmlFileName, Teuchos::Ptr(&ifpack_params), *comm);

const std::string prectype = ifpack_params.get<std::string>("Preconditioner type");
const int overlap = ifpack_params.get<int>("Overlap");

// create the preconditioner
Ifpack Factory;
prec_ =
std::shared_ptr<Ifpack_Preconditioner>(Factory.Create(prectype, pmatrix_.get(), overlap));

if (!prec_)
FOUR_C_THROW("Creation of IFPACK preconditioner of type '%s' failed.", prectype.c_str());

// setup
prec_->SetParameters(ifpacklist_);
prec_->SetParameters(ifpack_params);
prec_->Initialize();
prec_->Compute();

return;
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/inpar/4C_inpar_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,8 @@ namespace Inpar::SOLVER

// Ifpack options
{
Core::Utils::int_parameter("IFPACKOVERLAP", 0,
"The amount of overlap used for the ifpack \"ilu\" preconditioner.", list);

Core::Utils::int_parameter("IFPACKGFILL", 0,
"The amount of fill allowed for an internal \"ilu\" preconditioner.", list);

std::vector<std::string> ifpack_combine_valid_input = {"Add", "Insert", "Zero"};
Core::Utils::string_parameter("IFPACKCOMBINE", "Add",
"Combine mode for Ifpack Additive Schwarz", list, ifpack_combine_valid_input);
Core::Utils::string_parameter(
"IFPACK_XML_FILE", "none", "xml file defining any IFPACK options", list);
}

// Iterative solver options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ AZTOL 1.0E-3
AZCONV AZ_r0
AZITER 1000
AZSUB 50
IFPACKGFILL 1
IFPACKOVERLAP 1
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
IFPACKCOMBINE Zero
------------------------------------------------STRUCT NOX/Printing
Outer Iteration = Yes
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/constr2D_MPC_angle.dat
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ PROBLEMTYPE Structure
RESTART 0
--------------------------------------------------------------------SOLVER 1
AZCONV AZ_r0
IFPACKGFILL 0
AZITER 1000
AZOUTPUT 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZPREC ILU
AZREUSE 0
AZSOLVE GMRES
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/constr2D_MPC_dist.dat
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ THETA 0.5
--------------------------------------------------------------------SOLVER 1
NAME Structure_Solver
AZCONV AZ_r0
IFPACKGFILL 0
AZITER 1000
AZOUTPUT 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZPREC ILU
AZREUSE 0
AZSOLVE GMRES
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/constr3D_NormComp_STI.dat
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ GENAVG TrLike
THETA 0.5
--------------------------------------------------------------------SOLVER 1
AZCONV AZ_r0
IFPACKGFILL 0
AZITER 1000
AZOUTPUT 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZPREC ILU
AZREUSE 0
AZSOLVE GMRES
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/contact3D_blocked_system_ilu_precon.dat
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ NAME Contact_Solver
SOLVER Belos
SOLVER_XML_FILE xml/linear_solver/iterative_gmres_template.xml
AZPREC ILU
IFPACKGFILL 4
IFPACKOVERLAP 1
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZREUSE 5
----------------------------------------------------------MATERIALS
MAT 1 MAT_ElastHyper NUMMAT 1 MATIDS 10 DENS 1.0e-6
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/elch_RCE_rotsymm_pbc.dat
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ AZOUTPUT 20
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZTOL 1.0E-10
AZCONV AZ_r0
AZITER 100
AZSUB 40
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_fluid DYNVISCOSITY 1.0 DENSITY 1.0
MAT 2 MAT_ion DIFFUSIVITY 0.00072 VALENCE 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 20
IFPACKGFILL 0
AZTOL 1.0E-10
AZCONV AZ_r0
AZITER 500
AZSUB 200
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_ion DIFFUSIVITY 0.0006666666666 VALENCE +0.0
MAT 2 MAT_ion DIFFUSIVITY 0.0005 VALENCE +1.0 DENSIFICATION 0.0 ELIM_DIFFUSIVITY 0.001 ELIM_VALENCE -1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 20
IFPACKGFILL 0
AZTOL 1.0E-10
AZCONV AZ_r0
AZITER 500
AZSUB 200
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_elchmat NUMDOF 2 NUMSCAL 1 NUMPHASE 1 PHASEIDS 2
MAT 2 MAT_elchphase EPSILON 1.0 TORTUOSITY 1.0 NUMMAT 1 MATIDS 3
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/elch_gaussian_hill_pbc_genalpha.dat
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 20
IFPACKGFILL 0
AZTOL 1.0E-10
AZCONV AZ_r0
AZITER 500
AZSUB 200
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_ion DIFFUSIVITY 0.0006666666666 VALENCE +0.0
MAT 2 MAT_ion DIFFUSIVITY 0.0005 VALENCE +1.0 DENSIFICATION 0.0 ELIM_DIFFUSIVITY 0.001 ELIM_VALENCE -1.0
Expand Down
6 changes: 2 additions & 4 deletions tests/input_files/elch_natconv_enc_pde_elim.dat
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZTOL 1.0E-10
AZITER 1000
AZSUB 25
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZCONV AZ_r0
--------------------------------------------------------------------SOLVER 2
NAME Fluid_Solver
Expand All @@ -109,12 +108,11 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZTOL 1.0E-10
AZCONV AZ_r0
AZITER 1000
AZSUB 25
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_fluid DYNVISCOSITY 1e-2 DENSITY 1.0
MAT 2 MAT_ion DIFFUSIVITY 5e-6 VALENCE 1.0 DENSIFICATION 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZTOL 1.0E-10
AZITER 1000
AZSUB 25
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZCONV AZ_r0
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_matlist LOCAL No NUMMAT 2 MATIDS 2 3
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f2_drivencavity32x32_Re1000_stat.dat
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZTOL 1.0E-7
AZITER 1000
AZSUB 25
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
//AZCONV AZ_r0
----------------------------------------------DESIGN POINT DIRICH CONDITIONS
// DOBJECT FLAG FLAG FLAG FLAG FLAG FLAG VAL VAL VAL VAL VAL VAL CURVE CURVE CURVE CURVE CURVE CURVE
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f2_kimmoin25x25_oseen_instat.dat
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ AZOUTPUT 50
AZSOLVE GMRES
AZPREC ILU
AZREUSE 1
IFPACKGFILL 3
AZTOL 1.0E-14
AZCONV AZ_r0
AZITER 1000
AZSUB 1000
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
-------------------------------------------------------------------MATERIALS
MAT 1 MAT_fluid DYNVISCOSITY 0.0001 DENSITY 1.0 GAMMA 1.0
----------------------------------------------------------------------FUNCT1 // adapt the rhs function
Expand Down
1 change: 0 additions & 1 deletion tests/input_files/f3_bel_tet4_drt_afg_cons.dat
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ SOLVER Belos
AZSOLVE BiCGSTAB
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZCONV AZ_r0
AZTOL 1.0E-12
AZITER 2500
Expand Down
1 change: 0 additions & 1 deletion tests/input_files/f3_bel_tet4_drt_afgenalpha.dat
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ SOLVER Belos
AZSOLVE BiCGSTAB
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZCONV AZ_r0
AZTOL 1.0E-12
AZITER 2500
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_4x4x4_hdg_lagrange.dat
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ TOL_PRES_INC 1e-04
SOLVER Belos
AZSOLVE GMRES
AZPREC ILU
IFPACKOVERLAP 0
IFPACKGFILL 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
IFPACKCOMBINE Add
AZSUB 100
AZCONV AZ_r0
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_4x4x4_hdg_legendre.dat
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ TOL_PRES_INC 1e-04
SOLVER Belos
AZSOLVE GMRES
AZPREC ILU
IFPACKOVERLAP 0
IFPACKGFILL 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
IFPACKCOMBINE Add
AZSUB 100
AZCONV AZ_r0
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_8x8_meshtying_ale.dat
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZTOL 1.0E-9
AZCONV AZ_r0
AZITER 1000
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_8x8_meshtying_ale_euler.dat
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZTOL 1.0E-9
AZCONV AZ_r0
AZITER 1000
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_8x8_meshtying_bmat_merged.dat
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZTOL 1.0E-9
AZCONV AZ_r0
AZITER 1000
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_8x8_meshtying_smat.dat
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZTOL 1.0E-9
AZCONV AZ_r0
AZITER 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ AZOUTPUT 0
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
IFPACKOVERLAP 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
AZTOL 1.0E-9
AZCONV AZ_r0
AZITER 1000
Expand Down
3 changes: 1 addition & 2 deletions tests/input_files/f3_beltrami_sphere_hdg_legendre.dat
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ TOL_PRES_INC 1e-04
SOLVER Belos
AZSOLVE GMRES
AZPREC ILU
IFPACKOVERLAP 0
IFPACKGFILL 0
IFPACK_XML_FILE xml/preconditioner/ifpack.xml
IFPACKCOMBINE Add
AZSUB 100
AZCONV AZ_r0
Expand Down
1 change: 0 additions & 1 deletion tests/input_files/f3_beltrami_tet10_hdg.dat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ SOLVER Belos
AZSOLVE GMRES
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZCONV AZ_r0
AZTOL 1.0E-3
AZITER 200
Expand Down
1 change: 0 additions & 1 deletion tests/input_files/f3_beltrami_tet4_drt.dat
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ SOLVER Belos
AZSOLVE BiCGSTAB
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZCONV AZ_r0
AZTOL 1.0E-12
AZITER 2500
Expand Down
1 change: 0 additions & 1 deletion tests/input_files/f3_beltrami_tet4_hdg.dat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ SOLVER Belos
AZSOLVE BiCGSTAB
AZPREC ILU
AZREUSE 0
IFPACKGFILL 0
AZCONV AZ_r0
AZTOL 1.0E-4
AZITER 2500
Expand Down
Loading
Loading