Skip to content

Commit

Permalink
MueLu ML translation: Translate Hiptmair
Browse files Browse the repository at this point in the history
  • Loading branch information
cgcgcg committed Nov 10, 2021
1 parent 030b9e8 commit 03e62f1
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
66 changes: 66 additions & 0 deletions packages/muelu/src/Interface/MueLu_ML2MueLuParameterTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ namespace MueLu {
else my_name = "\"smoother: " + PreOrPost + " type\"";
mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"RELAXATION\"/>" << std::endl;

} else if ( valuestr == "hiptmair" ) {
std::string my_name;
if ( PreOrPost == "both" ) my_name = "\"" + pname + "\"";
else my_name = "\"smoother: " + PreOrPost + " type\"";
mueluss << "<Parameter name=" << my_name << " type=\"string\" value=\"HIPTMAIR\"/>" << std::endl;

} else if ( valuestr == "ifpack" ) {
std::string my_name = "\"" + pname + "\"";
if ( paramList.isParameter("smoother: ifpack type") ) {
Expand Down Expand Up @@ -180,6 +186,66 @@ namespace MueLu {
else { mueluss << "<Parameter name=\"eigen-analysis: type\" type=\"string\" value=\"cg\"/>" << std::endl; }
}

if ( valuestr == "hiptmair" ) {
std::string subSmootherType = "Chebyshev";
if (paramList.isParameter("subsmoother: type"))
subSmootherType = paramList.get<std::string>("subsmoother: type");
std::string subSmootherIfpackType;
if (subSmootherType == "Chebyshev")
subSmootherIfpackType = "CHEBYSHEV";
else if (subSmootherType == "Jacobi" || subSmootherType == "Gauss-Seidel" || subSmootherType == "symmetric Gauss-Seidel") {
if (subSmootherType == "symmetric Gauss-Seidel") subSmootherType = "Symmetric Gauss-Seidel"; // FIXME
subSmootherIfpackType = "RELAXATION";
} else
TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::MLParameterListTranslator: unknown smoother type. '" << subSmootherType << "' not supported by MueLu.");

mueluss << "<Parameter name=\"hiptmair: smoother 1\" type=\"string\" value=\"" << subSmootherIfpackType << "\"/>" << std::endl;
mueluss << "<Parameter name=\"hiptmair: smoother 2\" type=\"string\" value=\"" << subSmootherIfpackType << "\"/>" << std::endl;

mueluss << "<ParameterList name=\"hiptmair: smoother list 1\">" << std::endl;
if (subSmootherType == "Chebyshev") {
if (paramList.isParameter("subsmoother: edge sweeps")) {
mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>("subsmoother: edge sweeps") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: edge sweeps", false);
}
if (paramList.isParameter("subsmoother: Chebyshev alpha")) {
mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>("subsmoother: Chebyshev alpha") << "\"/>" << std::endl;
}
} else {
if (paramList.isParameter("subsmoother: edge sweeps")) {
mueluss << "<Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"" << paramList.get<int>("subsmoother: edge sweeps") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: edge sweeps", false);
}
if (paramList.isParameter("subsmoother: SGS damping factor")) {
mueluss << "<Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"" << paramList.get<double>("subsmoother: SGS damping factor") << "\"/>" << std::endl;
}
}
mueluss << "</ParameterList>" << std::endl;

mueluss << "<ParameterList name=\"hiptmair: smoother list 2\">" << std::endl;
if (subSmootherType == "Chebyshev") {
if (paramList.isParameter("subsmoother: node sweeps")) {
mueluss << "<Parameter name=\"chebyshev: degree\" type=\"int\" value=\"" << paramList.get<int>("subsmoother: node sweeps") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: node sweeps", false);
}
if (paramList.isParameter("subsmoother: Chebyshev alpha")) {
mueluss << "<Parameter name=\"chebyshev: ratio eigenvalue\" type=\"double\" value=\"" << paramList.get<double>("subsmoother: Chebyshev alpha") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: Chebyshev alpha", false);
}
} else {
if (paramList.isParameter("subsmoother: node sweeps")) {
mueluss << "<Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"" << paramList.get<int>("subsmoother: node sweeps") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: node sweeps", false);
}
if (paramList.isParameter("subsmoother: SGS damping factor")) {
mueluss << "<Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"" << paramList.get<double>("subsmoother: SGS damping factor") << "\"/>" << std::endl;
adaptingParamList.remove("subsmoother: SGS damping factor", false);
}
}
mueluss << "</ParameterList>" << std::endl;

}

// parameters for ILU based preconditioners
if ( valuestr == "ifpack") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,43 @@ namespace MueLu {
}


smooProto = rcp( new TrilinosSmoother(ifpackType, smootherParamList, 0) );
smooProto->SetFactory("A", AFact);

} else if (type == "Hiptmair") {
ifpackType = "HIPTMAIR";
std::string subSmootherType = "Chebyshev";
if (paramList.isParameter("subsmoother: type"))
subSmootherType = paramList.get<std::string>("subsmoother: type");
std::string subSmootherIfpackType;
if (subSmootherType == "Chebyshev")
subSmootherIfpackType = "CHEBYSHEV";
else if (subSmootherType == "Jacobi" || subSmootherType == "Gauss-Seidel" || subSmootherType == "symmetric Gauss-Seidel") {
if (subSmootherType == "symmetric Gauss-Seidel") subSmootherType = "Symmetric Gauss-Seidel"; // FIXME
subSmootherIfpackType = "RELAXATION";
} else
TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter: unknown smoother type. '" << subSmootherType << "' not supported by MueLu.");

smootherParamList.set("hiptmair: smoother type 1", subSmootherIfpackType);
smootherParamList.set("hiptmair: smoother type 2", subSmootherIfpackType);

auto smoother1ParamList = smootherParamList.sublist("hiptmair: smoother list 1");
auto smoother2ParamList = smootherParamList.sublist("hiptmair: smoother list 2");

if (subSmootherType == "Chebyshev") {
MUELU_COPY_PARAM(paramList, "subsmoother: edge sweeps", int, 2, smoother1ParamList, "chebyshev: degree");
MUELU_COPY_PARAM(paramList, "subsmoother: node sweeps", int, 2, smoother2ParamList, "chebyshev: degree");

MUELU_COPY_PARAM(paramList, "subsmoother: Chebyshev", double, 20, smoother1ParamList, "chebyshev: ratio eigenvalue");
MUELU_COPY_PARAM(paramList, "subsmoother: Chebyshev", double, 20, smoother2ParamList, "chebyshev: ratio eigenvalue");
} else {
MUELU_COPY_PARAM(paramList, "subsmoother: edge sweeps", int, 2, smoother1ParamList, "relaxation: sweeps");
MUELU_COPY_PARAM(paramList, "subsmoother: node sweeps", int, 2, smoother2ParamList, "relaxation: sweeps");

MUELU_COPY_PARAM(paramList, "subsmoother: SGS damping factor", double, 0.8, smoother2ParamList, "relaxation: damping factor");
}


smooProto = rcp( new TrilinosSmoother(ifpackType, smootherParamList, 0) );
smooProto->SetFactory("A", AFact);

Expand Down

0 comments on commit 03e62f1

Please sign in to comment.