OMCompiler/SimulationRuntime/cpp/Core/Solver/AlgLoopSolverDefaultImplementation.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | /** @addtogroup coreSolver | ||
| 29 | * | ||
| 30 | * @{ | ||
| 31 | */ | ||
| 32 | #include <Core/ModelicaDefine.h> | ||
| 33 | #include <Core/Modelica.h> | ||
| 34 | #include <Core/Solver/FactoryExport.h> | ||
| 35 | #include <Core/Solver/AlgLoopSolverDefaultImplementation.h> | ||
| 36 | |||
| 37 | |||
| 38 | 121 | AlgLoopSolverDefaultImplementation::AlgLoopSolverDefaultImplementation() | |
| 39 | 121 | :_dimZeroFunc(-1) | |
| 40 | 121 | , _dimSys(-1) | |
| 41 | 121 | ,_algloopVars(NULL) | |
| 42 | 121 | ,_conditions0(NULL) | |
| 43 | 121 | ,_conditions1(NULL) | |
| 44 | { | ||
| 45 | |||
| 46 | 121 | } | |
| 47 | |||
| 48 | 121 | AlgLoopSolverDefaultImplementation::~AlgLoopSolverDefaultImplementation() | |
| 49 | { | ||
| 50 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
121 | if(_algloopVars) |
| 51 | 121 | delete [] _algloopVars; | |
| 52 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
121 | if(_conditions0) |
| 53 | 121 | delete [] _conditions0; | |
| 54 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
121 | if(_conditions1) |
| 55 | 121 | delete [] _conditions1; | |
| 56 | 121 | } | |
| 57 | 24773211 | bool* AlgLoopSolverDefaultImplementation::getConditionsWorkArray() | |
| 58 | { | ||
| 59 |
1/2✓ Branch 0 taken 24773211 times.
✗ Branch 1 not taken.
|
24773211 | if(_conditions0) |
| 60 | 24773211 | return _conditions0; | |
| 61 | else | ||
| 62 | ✗ | throw ModelicaSimulationError(ALGLOOP_SOLVER, "algloop working arrays are not initialized"); | |
| 63 | } | ||
| 64 | 24773211 | bool* AlgLoopSolverDefaultImplementation::getConditions2WorkArray() | |
| 65 | { | ||
| 66 |
1/2✓ Branch 0 taken 24773211 times.
✗ Branch 1 not taken.
|
24773211 | if(_conditions1) |
| 67 | 24773211 | return _conditions1; | |
| 68 | else | ||
| 69 | ✗ | throw ModelicaSimulationError(ALGLOOP_SOLVER, "algloop working arrays are not initialized"); | |
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | 24773211 | double* AlgLoopSolverDefaultImplementation::getVariableWorkArray() | |
| 74 | { | ||
| 75 |
1/2✓ Branch 0 taken 24773211 times.
✗ Branch 1 not taken.
|
24773211 | if(_algloopVars) |
| 76 | 24773211 | return _algloopVars; | |
| 77 | else | ||
| 78 | ✗ | throw ModelicaSimulationError(ALGLOOP_SOLVER, "algloop working arrays are not initialized"); | |
| 79 | } | ||
| 80 | |||
| 81 | 121 | void AlgLoopSolverDefaultImplementation::initialize(int dimZeroFunc,int dimSys) | |
| 82 | { | ||
| 83 | 121 | _dimZeroFunc = dimZeroFunc; | |
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
|
121 | if(_conditions0) |
| 85 | ✗ | delete [] _conditions0; | |
| 86 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
|
121 | if(_conditions1) |
| 87 | ✗ | delete [] _conditions1; | |
| 88 | 121 | _conditions0 = new bool[_dimZeroFunc]; | |
| 89 | 121 | _conditions1 = new bool[_dimZeroFunc]; | |
| 90 | 121 | _dimSys=dimSys; | |
| 91 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
|
121 | if(_algloopVars) |
| 92 | ✗ | delete [] _algloopVars; | |
| 93 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
121 | _algloopVars = new double[_dimSys]; |
| 94 | 121 | memset(_algloopVars, 0, _dimSys*sizeof(double)); | |
| 95 | 121 | } | |
| 96 | /** @} */ // end of coreSolver | ||
| 97 |