-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
571d2dd
ad77c44
2764b4f
d4ca631
0cdbd4a
aae3c1e
0a76006
a60306e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -237,11 +237,15 @@ 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("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" | ||||||
*/ | ||||||
|
||||||
std::string xmlfile = inparams.get<std::string>("IFPACK_XML_FILE"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
... and also at other places throughout this PR. |
||||||
if (xmlfile != "none") ifpacklist.set("IFPACK_XML_FILE", xmlfile); | ||||||
|
||||||
return ifpacklist; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 | ||||||||||
|
||||||||||
//------------------------------------------------------------------------------ | ||||||||||
|
@@ -18,7 +21,6 @@ Core::LinearSolver::IFPACKPreconditioner::IFPACKPreconditioner( | |||||||||
Teuchos::ParameterList& ifpacklist, Teuchos::ParameterList& solverlist) | ||||||||||
: ifpacklist_(ifpacklist), solverlist_(solverlist) | ||||||||||
{ | ||||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
//------------------------------------------------------------------------------ | ||||||||||
|
@@ -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); | ||||||||||
std::string xmlFileName = ifpacklist_.get<std::string>("IFPACK_XML_FILE"); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
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); | ||||||||||
|
||||||||||
auto prectype = ifpack_params.get<std::string>("Preconditioner type"); | ||||||||||
auto overlap = ifpack_params.get<int>("Overlap"); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Const qualifiers?
Suggested change
|
||||||||||
|
||||||||||
// 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; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can read files in a better way (so that relative paths are correctly resolved). See e.g. https://github.com/4C-multiphysics/4C/blob/main/src/inpar/4C_inpar_solver.cpp#L104-L108 |
||
} | ||
|
||
// Iterative solver options | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -61,8 +61,7 @@ AZTOL 1.0E-3 | |||||||||
AZCONV AZ_r0 | ||||||||||
AZITER 1000 | ||||||||||
AZSUB 50 | ||||||||||
IFPACKGFILL 1 | ||||||||||
IFPACKOVERLAP 1 | ||||||||||
IFPACK_XML_FILE xml/ifpack.xml | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This places the xml file into the top level directory of all xml files for solvers/preconditioners. There is an existing folder structure. @maxfirmbach, should we sort it into the folder structure? If yes, where? Into a new directory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dharinib98 @mayrmt We need to figure out a place, not sure where it fits best, in theory we could just create a folder called |
||||||||||
IFPACKCOMBINE Zero | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yet another reason to use yaml for input files :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is also the case with overlap values, not all files use a value of 0. Based on the number of tests that fail, we can think about a solution by maybe adding another xml file for the higher gfill values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can have one or two default xml files in the central xml file collection. If individual tests require a specialized preconditioned, then we can put the xml file just next to the input file. |
||||||||||
------------------------------------------------STRUCT NOX/Printing | ||||||||||
Outer Iteration = Yes | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ SOLVER Belos | |
AZSOLVE GMRES | ||
AZPREC ILU | ||
AZREUSE 0 | ||
IFPACKGFILL 0 | ||
AZCONV AZ_r0 | ||
AZTOL 1.0E-3 | ||
AZITER 200 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.