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
Refactoring non-linear solvers #9065
Refactoring non-linear solvers #9065
Conversation
- KINSOL finished
- Newton finished
@bernhardbachmann KINSOL and Newton are already refactored. We can try to merge the current state into a copy of https://github.com/bernhardbachmann/OpenModelica/tree/01-ESDIRK_integrator and see if this is working for your gbode solver. If that is working I'll finish this for the other non-linear solvers and we can merge this into the master. |
- Some clean-up in KINSOL solver
Merging is not straight forward. |
716f148 broke some tests. Now I need to figure out why. |
The gbode development branch has been renamed to 01-GBODE_development. Please use this for merging your NLS changes |
Future me hates me...
- Fixed some memory leaks - Improved some util function interfaces
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.
LGTM, except some small typos.
OMCompiler/SimulationRuntime/c/simulation/solver/kinsolSolver.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/kinsolSolver.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Outdated
Show resolved
Hide resolved
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
Outdated
Show resolved
Hide resolved
c78c7b9
to
a9bb217
Compare
Purpose
Make
solveNLS
more generic, so it can work for any given nonlinear systems, not only for those saved indata->simulationInfo->nonlinearSystemData[sysNumber]
.Progress
NONLINEAR_SYSTEM_DATA* nonlinsys
Changes
Unified user data structs for all non-linear solvers:
Contains pointer to
nlsData
that contains this user data. Used to hide omc internal data from 3rdParty function calls.userData will be passed to residual and Jacobian functions.
Use
initNlsUserData
andfreeNlsUserData
for memory management.Simplify NLS functions interface
int allocateNewtonData(int size, void** voiddata)
-->DATA_NEWTON* allocateNewtonData(int size, NLS_USERDATA* userData)
int nlsKinsolFree(void **solverData)
-->void freeNewtonData(DATA_NEWTON* newtonData)
int solveNLS(DATA *data, threadData_t *threadData, int sysNumber)
-->modelica_boolean solveNLS(DATA *data, threadData_t *threadData, NONLINEAR_SYSTEM_DATA* nonlinsys)
int _omc_newton(int(*f)(int*, double*, double*, void*, int), DATA_NEWTON* solverData, void* userdata);
-->int _omc_newton(genericResidualFunc f, DATA_NEWTON* solverData, void* userData);
void printNonLinearSystemSolvingStatistics(DATA *data, int sysNumber, int logLevel)
-->void printNonLinearSystemSolvingStatistics(NONLINEAR_SYSTEM_DATA* nonlinsys, enum LOG_STREAM stream)
Other
currentNonlinearSystemIndex
fromNONLINEAR_SYSTEM_DATA
.TRUE
andFALSE
to openmodelcia_types.h, next to definition of typemodelica_boolean
.genericResidualFunc
function pointer.