OMSimulatorLib The OMSimulator project is a FMI-based co-simulation environment.

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
oms::KinsolSolver Class Reference

`#include <AlgLoop.h>`

## Public Member Functions
| ~KinsolSolver ()
| Destroy the oms::KinsolSolver::KinsolSolver object.
oms_status_enu_t | kinsolSolve (System &syst, DirectedGraph &graph)
| Solve algebraic system with KINSOL.

## Static Public Member Functions
static KinsolSolver * | NewKinsolSolver (const int algLoopNum, const unsigned int size, double relativeTolerance, const bool useDirectionalDerivative)
| Create new oms::KinsolSolver::KinsolSolver object.

## Static Private Member Functions
static int | nlsKinsolJac (N_Vector u, N_Vector fu, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2)
| Jacobian function for KINSOL.
static int | nlsKinsolResiduals (N_Vector u, N_Vector fval, void *user_data)
| Residual function for KINSOL.
static void | sundialsErrorHandlerFunction (int line, const char *func, const char *file, const char *msg, SUNErrCode err_code, void *err_user_data, SUNContext sunctx)
| Error handler function of type SUNErrHandlerFn.

## Private Attributes
double | fnormtol = 0.0
N_Vector | initialGuess = nullptr
N_Vector | uScale = nullptr
N_Vector | fScale = nullptr
N_Vector | fTmp = nullptr
SUNContext | sunctx = nullptr
void * | kinsolMemory = nullptr
void * | user_data = nullptr
int | size = 0
SUNLinearSolver | linSol = nullptr
N_Vector | y = nullptr
SUNMatrix | J = nullptr

## Constructor & Destructor Documentation

## ◆ ~KinsolSolver()

oms::KinsolSolver::~KinsolSolver | ( |  | ) |

Destroy the oms::KinsolSolver::KinsolSolver object.

## Member Function Documentation

## ◆ kinsolSolve()

oms_status_enu_t oms::KinsolSolver::kinsolSolve | ( | System & | syst,
|  | DirectedGraph & | graph
| ) |  |

Solve algebraic system with KINSOL.

Parameters

  syst | Reference to System object
  graph | Reference to graph opbject

Returns
  oms_status_enu_t Return `oms_status_ok` on success, `oms_status_warning` if solving was computed, but solution is not within tolerance and `oms_status_error` if an error occured.

Here is the call graph for this function:

## ◆ NewKinsolSolver()

oms::KinsolSolver * oms::KinsolSolver::NewKinsolSolver | ( | const int | algLoopNum,
|  | const unsigned int | size,
|  | double | relativeTolerance,
|  | const bool | useDirectionalDerivative
| ) |  |
| static

Create new oms::KinsolSolver::KinsolSolver object.

Parameters

  algLoopNum | Number of algebraic loop
  size | Dimension of algebraic loop
  relativeTolerance | Tolerance used for solving the loop

Returns
  oms::KinsolSolver* Retruns pointer to KinsolSolver object

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ nlsKinsolJac()

int oms::KinsolSolver::nlsKinsolJac | ( | N_Vector | u,
|  | N_Vector | fu,
|  | SUNMatrix | J,
|  | void * | user_data,
|  | N_Vector | tmp1,
|  | N_Vector | tmp2
| ) |  |
| static private

Jacobian function for KINSOL.

Parameters

  u | is the current (unscaled) iterate
  fu | is the current value of the vector F(u)
  J | is the output approximate Jacobian matrix, J = ∂F/∂u, of type SUNMatrix
  data | is a pointer to user data, the same as the user data parameter passed to KINSetUserData
  tmp1 | pointer to memory allocated for variables of type N_Vector which can be used by the KINJacFn function as temporary storage or work space
  tmp2 | pointer to memory allocated for variables of type N_Vector which can be used by the KINJacFn function as temporary storage or work space

Returns
  int A function of type KINLsJacFn should return 0 if successful or a non-zero value otherwise

Here is the call graph for this function:

## ◆ nlsKinsolResiduals()

int oms::KinsolSolver::nlsKinsolResiduals | ( | N_Vector | u,
|  | N_Vector | fval,
|  | void * | user_data
| ) |  |
| static private

Residual function for KINSOL.

This function computes F(u) (or G(u) for fixed-point iteration and Anderson acceleration) for a given value of the vector u.

Parameters

  u | is the current value of the variable vector, u
  fval | is the output vector F(u)
  user_data | a is a pointer to user data, the pointer user data passed to KINSetUserData

Returns
  int A KINSysFn function should return 0 if successful, a positive value if a recoverable error occurred (in which case kinsol will attempt to correct), or a negative value if it failed unrecoverably (in which case the solution process is halted and KIN SYSFUNC FAIL is returned).

Here is the call graph for this function:

## ◆ sundialsErrorHandlerFunction()

void oms::KinsolSolver::sundialsErrorHandlerFunction | ( | int | line,
|  | const char * | func_name,
|  | const char * | file,
|  | const char * | msg,
|  | SUNErrCode | err_code,
|  | void * | err_user_data,
|  | SUNContext | sunctx
| ) |  |
| static private

Error handler function of type SUNErrHandlerFn.

Pushed onto the error handler stack of the SUNDIALS context, so it is called for errors reported by KINSOL and by any other SUNDIALS module created with that context.

Parameters

  line | Line number in the SUNDIALS source file where the error occurred.
  func_name | Name of the SUNDIALS function in which the error occurred.
  file | Name of the SUNDIALS source file where the error occurred.
  msg | Error message. Can be NULL, in which case the message belonging to `err_code` is used.
  err_code | Error code. Either a SUNErrCode or a package level code, e.g. one of the KIN_* constants.
  err_user_data | Pointer to user data given to SUNContext_PushErrHandler(), a KINSOL_USER_DATA pointer. Can be NULL.
  sunctx | SUNDIALS context reporting the error. Unused.

## Member Data Documentation

## ◆ fnormtol

double oms::KinsolSolver::fnormtol = 0.0
| private

## ◆ fScale

N_Vector oms::KinsolSolver::fScale = nullptr
| private

## ◆ fTmp

N_Vector oms::KinsolSolver::fTmp = nullptr
| private

## ◆ initialGuess

N_Vector oms::KinsolSolver::initialGuess = nullptr
| private

## ◆ J

SUNMatrix oms::KinsolSolver::J = nullptr
| private

## ◆ kinsolMemory

void* oms::KinsolSolver::kinsolMemory = nullptr
| private

## ◆ linSol

SUNLinearSolver oms::KinsolSolver::linSol = nullptr
| private

## ◆ size

int oms::KinsolSolver::size = 0
| private

## ◆ sunctx

SUNContext oms::KinsolSolver::sunctx = nullptr
| private

## ◆ uScale

N_Vector oms::KinsolSolver::uScale = nullptr
| private

## ◆ user_data

void* oms::KinsolSolver::user_data = nullptr
| private

## ◆ y

N_Vector oms::KinsolSolver::y = nullptr
| private

The documentation for this class was generated from the following files:

- /var/lib/jenkins/ws/OMSimulator_PR-1619/src/OMSimulatorLib/AlgLoop.h
- /var/lib/jenkins/ws/OMSimulator_PR-1619/src/OMSimulatorLib/AlgLoop.cpp