Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 77.8% 21 / 0 / 27
Functions: 100.0% 4 / 0 / 4
Branches: 28.8% 34 / 0 / 118

OMCompiler/SimulationRuntime/cpp/Core/System/AlgLoopSolverFactory.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
35 #include <Core/System/AlgLoopSolverFactory.h>
36
37 41 AlgLoopSolverFactory::AlgLoopSolverFactory(IGlobalSettings* global_settings,PATH library_path,PATH modelicasystem_path)
38 : IAlgLoopSolverFactory(), ObjectFactory<BaseFactory>(library_path,modelicasystem_path,library_path)
39 , NonLinSolverPolicy(library_path,modelicasystem_path,library_path)
40 , LinSolverPolicy(library_path,modelicasystem_path,library_path)
41
14/54
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 40 times.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 41 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 41 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 41 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 41 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 41 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 time.
✗ Branch 21 not taken.
✓ Branch 22 taken 40 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 40 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 40 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
525 , _global_settings(global_settings)
42 {
43 41 }
44 /*#endif*/
45
46 82 AlgLoopSolverFactory::~AlgLoopSolverFactory()
47 {
48 82 }
49
50 69 shared_ptr<ILinearAlgLoopSolver> AlgLoopSolverFactory::createLinearAlgLoopSolver(shared_ptr<ILinearAlgLoop> algLoop)
51 {
52 try
53 {
54
1/1
✓ Branch 1 taken 69 times.
69 string linsolver_name = _global_settings->getSelectedLinSolver();
55
2/4
✓ Branch 1 taken 69 times.
✓ Branch 4 taken 69 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
138 shared_ptr<ILinSolverSettings> algsolversetting = createLinSolverSettings(linsolver_name);
56
1/1
✓ Branch 1 taken 69 times.
69 _linalgsolversettings.push_back(algsolversetting);
57
3/11
✓ Branch 2 taken 69 times.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 69 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
276 shared_ptr<ILinearAlgLoopSolver> algsolver = createLinSolver(linsolver_name, algsolversetting, algLoop);
58
1/1
✓ Branch 1 taken 69 times.
69 _linear_algsolvers.push_back(algsolver);
59 69 return algsolver;
60 }
61 ✗ catch(std::exception &arg)
62 {
63 ✗ throw ModelicaSimulationError(MODEL_FACTORY, "Linear AlgLoop solver is not available");
64 ✗ }
65 }
66
67 /// Creates a nonlinear solver according to given system of equations of type algebraic loop
68 52 shared_ptr<INonLinearAlgLoopSolver> AlgLoopSolverFactory::createNonLinearAlgLoopSolver(shared_ptr<INonLinearAlgLoop> algLoop)
69 {
70 try
71 {
72
1/1
✓ Branch 1 taken 52 times.
52 string nonlinsolver_name = _global_settings->getSelectedNonLinSolver();
73
3/5
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 7 taken 52 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
156 shared_ptr<INonLinSolverSettings> algsolversetting = createNonLinSolverSettings(nonlinsolver_name);
74
1/1
✓ Branch 1 taken 52 times.
52 algsolversetting->setGlobalSettings(_global_settings);
75
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 algsolversetting->setContinueOnError(_global_settings->getNonLinearSolverContinueOnError());
76
1/1
✓ Branch 1 taken 52 times.
52 _algsolversettings.push_back(algsolversetting);
77
78
3/11
✓ Branch 2 taken 52 times.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
208 shared_ptr<INonLinearAlgLoopSolver> algsolver= createNonLinSolver(nonlinsolver_name, algsolversetting, algLoop);
79
1/1
✓ Branch 1 taken 52 times.
52 _non_linear_algsolvers.push_back(algsolver);
80 52 return algsolver;
81 }
82 ✗ catch(std::exception &arg)
83 {
84 ✗ throw ModelicaSimulationError(MODEL_FACTORY, "Nonlinear AlgLoop solver is not available");
85 ✗ }
86 }
87
88 /** @} */ // end of coreSystem
89