Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 67.5% 27 / 0 / 40
Functions: 55.6% 5 / 0 / 9
Branches: 30.8% 8 / 0 / 26

OMCompiler/SimulationRuntime/cpp/Core/System/NonLinearAlgLoopDefaultImplementation.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 coreSystem
29 *
30 * @{
31 */
32 #include <Core/ModelicaDefine.h>
33 #include <Core/Modelica.h>
34 #include <Core/System/FactoryExport.h>
35 #include <Core/System/NonLinearAlgLoopDefaultImplementation.h>
36
37 /*bool BOOST_EXTENSION_EXPORT_DECL mycompare ( mytuple lhs, mytuple rhs)
38 {
39 return lhs.ele1 < rhs.ele1;
40 }*/
41
42 52 NonLinearAlgLoopDefaultImplementation::NonLinearAlgLoopDefaultImplementation()
43 52 : _dimAEq (0)
44 52 ,_res(NULL)
45 52 ,_AData(NULL)
46 52 ,_Ax(NULL)
47 52 ,_x0(NULL)
48 52 , _firstcall(true)
49 {
50 52 }
51
52 52 NonLinearAlgLoopDefaultImplementation::~NonLinearAlgLoopDefaultImplementation()
53 {
54
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(_res)
55 52 delete [] _res;
56
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (_x0)
57 52 delete [] _x0;
58 52 }
59
60 /// Provide number (dimension) of variables according to data type
61 104 int NonLinearAlgLoopDefaultImplementation::getDimReal() const
62 {
63 104 return _dimAEq;
64 }
65
66 ✗ int NonLinearAlgLoopDefaultImplementation::getDimZeroFunc() const
67 {
68 ✗ return _dimZeroFunc;
69 }
70
71 /// (Re-) initialize the system of equations
72 52 void NonLinearAlgLoopDefaultImplementation::initialize()
73 {
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( _dimAEq == 0 )
75 ✗ throw ModelicaSimulationError(ALGLOOP_EQ_SYSTEM,"AlgLoop::initialize(): No constraint defined.");
76
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(_res)
78 ✗ delete [] _res;
79
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 _res = new double[_dimAEq];
80
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 memset(_res,0,_dimAEq*sizeof(double));
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(_x0)
82 ✗ delete [] _x0;
83
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 _x0 = new double[_dimAEq];
84 52 };
85
86 //in algloop default verschieben
87 2662721 void NonLinearAlgLoopDefaultImplementation::getRHS(double* res) const
88 {
89 2662721 memcpy(res, _res, sizeof(double) * _dimAEq);
90 2662721 }
91
92 ✗ bool NonLinearAlgLoopDefaultImplementation::getUseSparseFormat(){
93 ✗ return _useSparseFormat;
94 }
95
96 ✗ void NonLinearAlgLoopDefaultImplementation::setUseSparseFormat(bool value){
97 ✗ _useSparseFormat = value;
98 ✗ }
99
100 ✗ void NonLinearAlgLoopDefaultImplementation::getRealStartValues(double* vars) const
101 {
102
103 ✗ memcpy(vars, _x0, sizeof(double) * _dimAEq);
104 ✗ }
105
106
107 //void NonLinearAlgLoopDefaultImplementation::getSparseAdata(double* data, int nonzeros)
108 //{
109 // memcpy(data, _AData, sizeof(double) * nonzeros);
110 //}
111 /** @} */ // end of coreSystem
112