Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 75c04c4

Browse files
qichenghuaOpenModelica-Hudson
authored andcommitted
muted nonlinear solver nox
1 parent 33db784 commit 75c04c4

File tree

1 file changed

+15
-3
lines changed
  • SimulationRuntime/cpp/Solver/Nox

1 file changed

+15
-3
lines changed

SimulationRuntime/cpp/Solver/Nox/Nox.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void Nox::solve()
9191
double * rhs = new double[_dimSys];
9292
double sum;
9393

94-
94+
Teuchos::RCP<std::ostream> output = Teuchos::rcp(new std::stringstream);
9595

9696
if (_firstCall) initialize();
9797

@@ -111,6 +111,8 @@ void Nox::solve()
111111
_solverParametersPtr->set("Nonlinear Solver", "Line Search Based");
112112

113113
_solverParametersPtr->sublist("Printing").set("Output Precision", 15);
114+
_solverParametersPtr->sublist("Printing").set("Output Stream", output);
115+
_solverParametersPtr->sublist("Printing").set("Error Stream", output);
114116

115117
//_solverParametersPtr->sublist("Direction").set("Method", "Steepest Descent");
116118

@@ -306,6 +308,9 @@ void Nox::solve()
306308
try{
307309
//std::cout << "solving..." << std::endl;
308310
status = _solver->solve();
311+
LOGGER_WRITE_BEGIN("NOX: ",LC_NLS,LL_DEBUG)
312+
LOGGER_WRITE((dynamic_cast<const std::stringstream &>(*output)).str(),LC_NLS,LL_DEBUG);
313+
LOGGER_WRITE_END(LC_NLS,LL_DEBUG)
309314
//std::cout << "done!" << std::endl;
310315
}
311316
catch(const std::exception &ex)
@@ -576,6 +581,8 @@ void Nox::LocaHomotopySolve(int numberofhomotopytries)
576581
//Since we are doing an equilibrium continuation, we set the bifurcation method to "None".
577582
//We use a secant predictor and adaptive step size control with an initial step size of 0.1, maximum of 1.0 and minimum of 0.001.
578583

584+
Teuchos::RCP<std::ostream> output = Teuchos::rcp(new std::stringstream);
585+
579586
// Create parameter list. For detailed calibration, check https://trilinos.org/docs/dev/packages/nox/doc/html/parameters.html
580587
Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(new Teuchos::ParameterList);
581588
// Create LOCA sublist
@@ -617,6 +624,8 @@ void Nox::LocaHomotopySolve(int numberofhomotopytries)
617624

618625
Teuchos::ParameterList& nlPrintParams = nlParams.sublist("Printing");
619626
nlPrintParams.set("Output Precision", 15);
627+
nlPrintParams.set("Output Stream", output);
628+
nlPrintParams.set("Error Stream", output);
620629
//Set the level of output
621630
if (_generateoutput){
622631
nlPrintParams.set("Output Information", NOX::Utils::Details + NOX::Utils::OuterIteration + NOX::Utils::Warning + NOX::Utils::StepperIteration + NOX::Utils::StepperDetails + NOX::Utils::StepperParameters); // Should set
@@ -655,16 +664,19 @@ void Nox::LocaHomotopySolve(int numberofhomotopytries)
655664
try{
656665
// Perform continuation run
657666
LOCA::Abstract::Iterator::IteratorStatus status = stepper.run();
667+
LOGGER_WRITE_BEGIN("LOCA: ",LC_NLS,LL_DEBUG)
668+
LOGGER_WRITE((dynamic_cast<const std::stringstream &>(*output)).str(),LC_NLS,LL_DEBUG);
669+
LOGGER_WRITE_END(LC_NLS,LL_DEBUG)
658670
// Check for convergence
659671
if (status != LOCA::Abstract::Iterator::Finished){
660-
std::cout << "Stepper failed to converge!" << std::endl;
672+
if(_generateoutput) std::cout << "Stepper failed to converge!" << std::endl;
661673
}else{
662674
_iterationStatus=DONE;
663675
}
664676
}
665677
catch(const std::exception &ex)
666678
{
667-
std::cout << std::endl << "sth went wrong during stepper running, with error message" << ex.what() << std::endl;
679+
if(_generateoutput) std::cout << std::endl << "sth went wrong during stepper running, with error message" << ex.what() << std::endl;
668680
//std::cout << add_error_info("building solver with grp, status tests and solverparameters", ex.what(), ex.getErrorID(), time) << std::endl << std::endl;
669681
throw ModelicaSimulationError(ALGLOOP_SOLVER,"solving error");
670682
}

0 commit comments

Comments
 (0)