Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 17 / 0 / 17
Functions: 100.0% 3 / 0 / 3
Branches: 75.0% 3 / 0 / 4

OMCompiler/SimulationRuntime/c/util/context.c
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 #include "context.h"
29 #include "../simulation_data.h"
30
31 const char *EVAL_CONTEXT_STRING[CONTEXT_MAX] = {
32 "UNKNOWN",
33 "ODE evaluation",
34 "algebraic evaluation",
35 "event search",
36 "jacobian evaluation",
37 "symbolica jacobian evaluation"
38 };
39
40 /**
41 * @brief Set current context in simulation info object
42 *
43 * @param data Pointer to data struct.
44 * @param currentTime Current simulation time.
45 * @param currentContext Evaluation context.
46 */
47 39 void setContext(DATA* data, double currentTime, EVAL_CONTEXT currentContext) {
48 39 data->simulationInfo->currentContextOld = data->simulationInfo->currentContext;
49 39 data->simulationInfo->currentContext = currentContext;
50 39 infoStreamPrint(OMC_LOG_SOLVER_CONTEXT, 0, "+++ Set context %s +++ at time %f", EVAL_CONTEXT_STRING[currentContext], currentTime);
51
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 25 times.
39 if (currentContext == CONTEXT_JACOBIAN ||
52 currentContext == CONTEXT_SYM_JACOBIAN)
53 {
54 14 data->simulationInfo->currentJacobianEval = 0;
55 }
56 39 }
57
58 /**
59 * @brief Restores previous context in simulation info object.
60 *
61 * @param data Pointer to data struct.
62 */
63 39 void unsetContext(DATA* data) {
64 39 infoStreamPrint(OMC_LOG_SOLVER_CONTEXT, 0, "--- Unset context %s ---", EVAL_CONTEXT_STRING[data->simulationInfo->currentContext]);
65 39 data->simulationInfo->currentContext = data->simulationInfo->currentContextOld;
66 39 }
67
68 /**
69 * @brief Increase currentJacobianEval in (symbolic) Jacobian context.
70 *
71 * @param data Pointer to data struct.
72 */
73 14 void increaseJacContext(DATA* data) {
74 14 EVAL_CONTEXT currentContext = data->simulationInfo->currentContext;
75
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (currentContext == CONTEXT_JACOBIAN ||
76 currentContext == CONTEXT_SYM_JACOBIAN)
77 {
78 14 data->simulationInfo->currentJacobianEval++;
79 14 infoStreamPrint(OMC_LOG_SOLVER_CONTEXT, 0, "+++ Increase Jacobian column context %s +++ to %d", EVAL_CONTEXT_STRING[currentContext], data->simulationInfo->currentJacobianEval);
80 }
81 14 }
82