OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBEvaluation.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of OpenModelica. | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), | ||
| 5 | * c/o Linköpings universitet, Department of Computer and Information Science, | ||
| 6 | * SE-58183 Linköping, Sweden. | ||
| 7 | * | ||
| 8 | * All rights reserved. | ||
| 9 | * | ||
| 10 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR | ||
| 11 | * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. | ||
| 12 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
| 13 | * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL | ||
| 14 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 15 | * | ||
| 16 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) | ||
| 17 | * Public License (OSMC-PL) are obtained from OSMC, either from the above | ||
| 18 | * address, from the URLs: | ||
| 19 | * http://www.openmodelica.org or | ||
| 20 | * https://github.com/OpenModelica/ or | ||
| 21 | * http://www.ida.liu.se/projects/OpenModelica, | ||
| 22 | * and in the OpenModelica distribution. | ||
| 23 | * | ||
| 24 | * GNU AGPL version 3 is obtained from: | ||
| 25 | * https://www.gnu.org/licenses/licenses.html#GPL | ||
| 26 | * | ||
| 27 | * This program is distributed WITHOUT ANY WARRANTY; without | ||
| 28 | * even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 29 | * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
| 30 | * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
| 31 | * | ||
| 32 | * See the full OSMC Public License conditions for more details. | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | encapsulated package NBEvaluation | ||
| 37 | "file: NBEvaluation.mo | ||
| 38 | package: NBEvaluation | ||
| 39 | description: This file contains the functions to create and analyze the | ||
| 40 | evaluation dependency graph. | ||
| 41 | This graph is used for the different evaluation stages. | ||
| 42 | " | ||
| 43 | |||
| 44 | public | ||
| 45 | import BackendDAE = NBackendDAE; | ||
| 46 | import Module = NBModule; | ||
| 47 | import Partition = NBPartition.Partition; | ||
| 48 | import StrongComponent = NBStrongComponent; | ||
| 49 | |||
| 50 | protected | ||
| 51 | // Old Backend imports | ||
| 52 | import OldBackendDAE = BackendDAE; | ||
| 53 | |||
| 54 | public | ||
| 55 | uniontype Stages | ||
| 56 | record STAGES | ||
| 57 | Boolean dynamicEval; | ||
| 58 | Boolean algebraicEval; | ||
| 59 | Boolean zerocrossEval; | ||
| 60 | Boolean discreteEval; | ||
| 61 | end STAGES; | ||
| 62 | |||
| 63 | function convert | ||
| 64 | input Stages stages; | ||
| 65 | output OldBackendDAE.EvaluationStages oldEvalStages; | ||
| 66 | algorithm | ||
| 67 | 12003 | oldEvalStages := OldBackendDAE.EVALUATION_STAGES( | |
| 68 | dynamicEval = stages.dynamicEval, | ||
| 69 | algebraicEval = stages.algebraicEval, | ||
| 70 | zerocrossEval = stages.zerocrossEval, | ||
| 71 | discreteEval = stages.discreteEval); | ||
| 72 | end convert; | ||
| 73 | end Stages; | ||
| 74 | |||
| 75 | constant Stages DEFAULT_STAGES = STAGES(true, true, false, true); | ||
| 76 | |||
| 77 | function removeDummies | ||
| 78 | "removes the dummy components in a partition | ||
| 79 | Note: will be expanded into removeConstantComponents()" | ||
| 80 | input output BackendDAE bdae; | ||
| 81 | algorithm | ||
| 82 | bdae := match bdae | ||
| 83 | case BackendDAE.MAIN() algorithm | ||
| 84 |
4/4✓ Branch 0 taken 327 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 188 times.
|
703 | bdae.ode := list(removeDummyComponents(p) for p in bdae.ode); |
| 85 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
|
188 | bdae.algebraic := list(removeDummyComponents(p) for p in bdae.algebraic); |
| 86 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
|
188 | bdae.ode_event := list(removeDummyComponents(p) for p in bdae.ode_event); |
| 87 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
|
376 | bdae.alg_event := list(removeDummyComponents(p) for p in bdae.alg_event); |
| 88 | then bdae; | ||
| 89 | else bdae; | ||
| 90 | end match; | ||
| 91 | end removeDummies; | ||
| 92 | |||
| 93 | function removeDummyComponents | ||
| 94 | input output Partition part; | ||
| 95 | algorithm | ||
| 96 | 654 | part.strongComponents := Util.applyOption(part.strongComponents, function Array.filter(fun = StrongComponent.isDummy)); | |
| 97 | end removeDummyComponents; | ||
| 98 | |||
| 99 | annotation(__OpenModelica_Interface="nbackend"); | ||
| 100 | end NBEvaluation; | ||
| 101 |