Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.2% 16 / 0 / 19
Functions: 100.0% 3 / 0 / 3
Branches: 47.4% 9 / 0 / 19

OMCompiler/SimulationRuntime/cpp/Core/SimController/Initialization.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 coreSimcontroller
29 *
30 * @{
31 */
32
33 #include <Core/ModelicaDefine.h>
34 #include <Core/Modelica.h>
35 #include <Core/SimController/Initialization.h>
36
37 40 Initialization::Initialization(shared_ptr<ISystemInitialization> system_initialization, shared_ptr<ISolver> solver)
38 : _system(system_initialization)
39 , _solver(solver)
40 {
41 40 }
42
43
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 Initialization::~Initialization(void)
44 {
45 40 }
46
47 40 void Initialization::initializeSystem()
48 {
49 40 shared_ptr<IContinuous> continous_system = dynamic_pointer_cast<IContinuous>(_system);
50 40 shared_ptr<IEvent> event_system = dynamic_pointer_cast<IEvent>(_system);
51 40 shared_ptr<IMixedSystem> mixed_system = dynamic_pointer_cast<IMixedSystem>(_system);
52
1/1
✓ Branch 1 taken 40 times.
40 int dim = event_system->getDimZeroFunc();
53 bool* conditions0 = new bool[dim];
54 bool* conditions1 = new bool[dim];
55
56
1/1
✓ Branch 1 taken 40 times.
40 _system->setInitial(true);
57 //Initialization of continous equations and bounded parameters
58
59
1/1
✓ Branch 1 taken 40 times.
40 _system->initialize();
60
1/1
✓ Branch 1 taken 40 times.
40 _solver->stateSelection();
61 /*deactivated initialization loop*/
62 //bool restart = true;
63 //int iter = 0;
64 //bool cond_restart = true;
65 //while((restart /*|| cond_restart*/) && !(iter++ > 15))
66 //{
67 // event_system->getConditions(conditions0);
68 // _system->initEquations(); // vxworksupdate
69 // restart = event_system->checkForDiscreteEvents();
70 // event_system->getConditions(conditions1);
71 // //Deactivated: event_system->saveDiscreteVars();
72 // event_system->saveAll();
73
74 // cond_restart = !std::equal (conditions1, conditions1+dim, conditions0);
75 //}
76
77
1/1
✓ Branch 1 taken 40 times.
40 event_system->saveAll();
78
1/1
✓ Branch 1 taken 40 times.
40 _system->setInitial(false);
79
80
2/3
✓ Branch 1 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
40 if( _solver->stateSelection())
81 {
82 ✗ _system->initEquations();
83 ✗ continous_system->stepCompleted(0.0);
84
85
86 /* report a warning about strange start values */
87 ✗ if(_solver->stateSelection())
88 cout << "Cannot initialize the dynamic state selection in an unique way." << std::endl;
89 }
90 delete[] conditions0;
91 delete[] conditions1;
92 40 }
93 /** @} */ // end of coreSimcontroller
94