Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added first version of nonlinear solver Nox.
cannot be compilated at the moment, because Trilinos is not part of 3rdParty yet.
- Loading branch information
1 parent
ca147d7
commit 3f1dccb
Showing
12 changed files
with
836 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
/** @defgroup solverNox Solver.Nox | ||
* Nox class wrapper from Trilinos package | ||
* @{ | ||
*/ | ||
#if defined(__vxworks) || defined(__TRICORE__) || defined(RUNTIME_STATIC_LINKING) | ||
#define BOOST_EXTENSION_LOGGER_DECL | ||
#define BOOST_EXTENSION_SOLVER_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL | ||
#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD) | ||
#define BOOST_EXTENSION_LOGGER_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_SOLVER_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#else | ||
error "operating system not supported" | ||
#endif | ||
/** @} */ // end of solverNox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
/** @addtogroup solverNox | ||
* | ||
* @{ | ||
*/ | ||
|
||
|
||
|
||
class Nox : public IAlgLoopSolver | ||
{ | ||
public: | ||
Nox(INonLinearAlgLoop* algLoop, INonLinSolverSettings* settings); | ||
virtual ~Nox(); | ||
|
||
/// (Re-) initialize the solver | ||
virtual void initialize(); | ||
|
||
/// Solution of a (non-)linear system of equations | ||
virtual void solve(); | ||
|
||
/// Returns the status of iteration | ||
virtual ITERATIONSTATUS getIterationStatus(); | ||
virtual void stepCompleted(double time); | ||
virtual void restoreOldValues(); | ||
virtual void restoreNewValues(); | ||
|
||
private: | ||
|
||
void getsolutionandevaluate(NOX::LAPACK::Group grp); | ||
void solverinit(); | ||
void createStatusTests(); | ||
void createSolverParameters(); | ||
|
||
//void check4EventRetry(double* y) | ||
|
||
// Member variables | ||
//--------------------------------------------------------------- | ||
INonLinSolverSettings | ||
*_noxSettings; ///< Settings for the solver | ||
|
||
INonLinearAlgLoop | ||
*_algLoop; ///< Algebraic loop to be solved | ||
|
||
ITERATIONSTATUS | ||
_iterationStatus; ///< Output - Denotes the status of iteration | ||
|
||
long int _dimSys; | ||
|
||
double | ||
*_y, | ||
*_y0, | ||
*_y_old, | ||
*_y_new, | ||
*_yScale; | ||
|
||
NoxLapackInterface *_noxLapackInterface; | ||
|
||
Teuchos::RCP<NOX::LAPACK::Group> _grp; | ||
|
||
//used for status tests | ||
Teuchos::RCP<NOX::StatusTest::NormF> _statusTestNormF; | ||
Teuchos::RCP<NOX::StatusTest::MaxIters> _statusTestMaxIters; | ||
Teuchos::RCP<NOX::StatusTest::Combo> _statusTestsCombo; | ||
|
||
//list of solver parameters | ||
Teuchos::RCP<Teuchos::ParameterList> _solverParametersPtr; | ||
|
||
//solver | ||
Teuchos::RCP<NOX::Solver::Generic> _solver; | ||
|
||
bool _firstCall; | ||
bool _generateoutput; | ||
bool _useScale; | ||
}; | ||
/** @} */ // end of solverNox |
27 changes: 27 additions & 0 deletions
27
SimulationRuntime/cpp/Include/Solver/Nox/NoxLapackInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "NOX_LAPACK_Group.H" | ||
|
||
class NoxLapackInterface : public NOX::LAPACK::Interface { | ||
|
||
public: | ||
|
||
//! Constructor | ||
NoxLapackInterface(INonLinearAlgLoop *algLoop); | ||
|
||
//! Destructor | ||
~NoxLapackInterface(); | ||
|
||
const NOX::LAPACK::Vector& getInitialGuess(); | ||
|
||
bool computeF(NOX::LAPACK::Vector& f, const NOX::LAPACK::Vector &x); | ||
|
||
bool computeJacobian(NOX::LAPACK::Matrix<double>& J, const NOX::LAPACK::Vector & x); | ||
|
||
private: | ||
//! Initial guess | ||
Teuchos::RCP<NOX::LAPACK::Vector> _initialGuess; | ||
INonLinearAlgLoop *_algLoop;///< Algebraic loop to be solved, required to obtain value of f | ||
double _yScale; | ||
int _dimSys; | ||
bool _generateoutput; | ||
bool _useScale; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
/** @addtogroup solverNox | ||
* | ||
* @{ | ||
*/ | ||
#include <Core/Solver/INonLinSolverSettings.h> | ||
|
||
class NoxSettings :public INonLinSolverSettings | ||
{ | ||
public: | ||
NoxSettings(); | ||
/*max. Anzahl an Newtonititerationen pro Schritt (default: 25)*/ | ||
virtual long int getNewtMax(); | ||
virtual void setNewtMax(long int); | ||
/* Relative Toleranz für die Newtoniteration (default: 1e-6)*/ | ||
virtual double getRtol(); | ||
virtual void setRtol(double); | ||
/*Absolute Toleranz für die Newtoniteration (default: 1e-6)*/ | ||
virtual double getAtol(); | ||
virtual void setAtol(double); | ||
/*Dämpfungsfaktor (default: 0.9)*/ | ||
virtual double getDelta(); | ||
virtual void setDelta(double); | ||
virtual void load(string); | ||
|
||
virtual void setContinueOnError(bool); | ||
virtual bool getContinueOnError(); | ||
private: | ||
long int _iNewt_max; ///< max. Anzahl an Newtonititerationen pro Schritt (default: 25) | ||
|
||
double _dRtol; ///< Relative Toleranz für die Newtoniteration (default: 1e-6) | ||
double _dAtol; ///< Absolute Toleranz für die Newtoniteration (default: 1e-6) | ||
double _dDelta; ///< Dämpfungsfaktor (default: 0.9) | ||
bool _continueOnError; | ||
}; | ||
/** @} */ // end of solverNox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 2.8.9) | ||
|
||
project(${NoxName}) | ||
|
||
add_library(${NoxName} Nox.cpp NoxSettings.cpp FactoryExport.cpp NoxLapackInterface.cpp) | ||
|
||
if(NOT BUILD_SHARED_LIBS) | ||
set_target_properties(${NoxName} PROPERTIES COMPILE_DEFINITIONS "RUNTIME_STATIC_LINKING;ENABLE_SUNDIALS_STATIC") | ||
endif(NOT BUILD_SHARED_LIBS) | ||
|
||
add_precompiled_header(${NoxName} Include/Core/Modelica.h) | ||
target_link_libraries(${NoxName} ${ExtensionUtilitiesName} ${Boost_LIBRARIES} ${TRILINOS_LIBRARIES} ) #C:/OpenModelica/OMCompiler/SimulationRuntime/cpp/Solver/KLU/OMCppklu_static.lib | ||
#target_link_libraries(${NoxName} ${ExtensionUtilitiesName} ${Boost_LIBRARIES} ${SUNDIALS_LIBRARIES} ${LAPACK_LIBRARIES} ${kluName}) | ||
|
||
install(TARGETS ${NoxName} DESTINATION ${LIBINSTALLEXT}) | ||
install(FILES | ||
${CMAKE_SOURCE_DIR}/Include/Solver/Nox/Nox.h | ||
${CMAKE_SOURCE_DIR}/Include/Solver/Nox/NoxSettings.h | ||
${CMAKE_SOURCE_DIR}/Include/Solver/Nox/FactoryExport.h | ||
${CMAKE_SOURCE_DIR}/Include/Solver/Nox/NoxLapackInterface.h | ||
DESTINATION include/omc/cpp/Solver/Nox) |
Oops, something went wrong.