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

Panzer: add capability for transient optimization with ROL and Tempus #13581

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/nox/src/NOX_Direction_Factory.C
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ buildDirection(const Teuchos::RCP<NOX::GlobalData>& gd,
}
}
else {
std::string msg = "Error - NOX::Direction::Facotry::buildDirection() - Invalid choice for \"Method\" in \"Direction\" sublist!";
std::string msg = "Error - NOX::Direction::Factory::buildDirection() - Invalid choice for \"Method\" in \"Direction\" sublist!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, msg);
}

Expand Down
43 changes: 31 additions & 12 deletions packages/nox/src/NOX_Direction_Newton.C
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "NOX_Solver_LineSearchBased.H"
#include "NOX_Utils.H"
#include "NOX_GlobalData.H"

#include "Teuchos_StandardParameterEntryValidators.hpp"

NOX::Direction::Newton::
Newton(const Teuchos::RCP<NOX::GlobalData>& gd,
Expand All @@ -39,23 +39,42 @@ reset(const Teuchos::RCP<NOX::GlobalData>& gd,

Teuchos::ParameterList& p = params.sublist("Newton");

doRescue = p.get("Rescue Bad Newton Solve", true);
if (!p.sublist("Linear Solver").isParameter("Tolerance"))
// Validate and set defaults
{
Teuchos::ParameterList validParams;
validParams.sublist("Linear Solver").disableRecursiveValidation();
validParams.sublist("Stratimikos Linear Solver").disableRecursiveValidation();
validParams.set<std::string>("Forcing Term Method", "Constant",
"Choice of forcing term used by the linear solver",
Teuchos::rcp(new Teuchos::StringValidator(Teuchos::tuple<std::string>("Constant", "Type 1", "Type 2"))));
validParams.set("Forcing Term Minimum Tolerance", 1.0e-4);
validParams.set("Forcing Term Maximum Tolerance", 0.9);
validParams.set("Forcing Term Initial Tolerance", 0.01);
validParams.set("Forcing Term Alpha", 1.5);
validParams.set("Forcing Term Gamma", 0.9);
validParams.set("Rescue Bad Newton Solve", true);

p.validateParametersAndSetDefaults(validParams);
}

doRescue = p.get<bool>("Rescue Bad Newton Solve");

if (!p.sublist("Linear Solver").isType<double>("Tolerance"))
p.sublist("Linear Solver").get("Tolerance", 1.0e-10);

method = p.get<std::string>("Forcing Term Method");

if ( p.get("Forcing Term Method", "Constant") == "Constant" ) {
if ( method == "Constant" ) {
useAdjustableForcingTerm = false;
eta_k = p.sublist("Linear Solver").get("Tolerance", 1.0e-4);
eta_k = p.sublist("Linear Solver").get<double>("Tolerance");
}
else {
useAdjustableForcingTerm = true;
method = p.get("Forcing Term Method", "Type 1");
eta_min = p.get("Forcing Term Minimum Tolerance", 1.0e-4);
eta_max = p.get("Forcing Term Maximum Tolerance", 0.9);
eta_initial = p.get("Forcing Term Initial Tolerance", 0.01);
alpha = p.get("Forcing Term Alpha", 1.5);
gamma = p.get("Forcing Term Gamma", 0.9);
eta_min = p.get<double>("Forcing Term Minimum Tolerance");
eta_max = p.get<double>("Forcing Term Maximum Tolerance");
eta_initial = p.get<double>("Forcing Term Initial Tolerance");
alpha = p.get<double>("Forcing Term Alpha");
gamma = p.get<double>("Forcing Term Gamma");
eta_k = eta_min;
}

Expand All @@ -76,7 +95,7 @@ bool NOX::Direction::Newton::compute(NOX::Abstract::Vector& dir,
// Reset the linear solver tolerance.
if (useAdjustableForcingTerm) {
resetForcingTerm(soln, solver.getPreviousSolutionGroup(),
solver.getNumIterations(), solver);
solver.getNumIterations(), solver);
}
else {
if (utils->isPrintType(Utils::Details)) {
Expand Down
18 changes: 16 additions & 2 deletions packages/nox/src/NOX_Observer_Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#include "NOX_Utils.H"
#include "NOX_Solver_LineSearchBased.H"

NOX::ObserverPrint::ObserverPrint(const Teuchos::RCP<NOX::Utils>& os) :
os_(os)
NOX::ObserverPrint::ObserverPrint(const Teuchos::RCP<NOX::Utils>& os,
const size_t offset) :
os_(os),
offset_(offset)
{}

void NOX::ObserverPrint::runPreIterate(const NOX::Solver::Generic& solver)
Expand All @@ -24,6 +26,12 @@ void NOX::ObserverPrint::runPreIterate(const NOX::Solver::Generic& solver)
auto& os = os_->out();
auto original_flags = os.flags();

if (offset_ > 0) {
for (size_t i=0; i < offset_; ++i) {
os << " ";
}
}

os.setf(std::ios::left);
os.width(5);
os << "N";
Expand Down Expand Up @@ -69,6 +77,12 @@ void NOX::ObserverPrint::printStep(const NOX::Solver::Generic& solver)
auto original_flags = os.flags();
const int precision = 6;

if (offset_ > 0) {
for (size_t i=0; i < offset_; ++i) {
os << " ";
}
}

os.width(5);
os.setf(std::ios::left);
os << stats.numNonlinearIterations;
Expand Down
4 changes: 3 additions & 1 deletion packages/nox/src/NOX_Observer_Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ namespace NOX {
*/
class ObserverPrint : public NOX::Observer {
public:
ObserverPrint(const Teuchos::RCP<NOX::Utils>& printUtils);
ObserverPrint(const Teuchos::RCP<NOX::Utils>& printUtils,
const size_t offset=0);
// Derived methods
void runPreIterate(const NOX::Solver::Generic& solver);
void runPostIterate(const NOX::Solver::Generic& solver);
private:
void printStep(const NOX::Solver::Generic& solver);
Teuchos::RCP<NOX::Utils> os_;
const size_t offset_;
};
}

Expand Down
Loading
Loading