MicroModelicaCCompiler  4.5.3
qss_model_deps.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  This file is part of QSS Solver.
4 
5  QSS Solver is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  QSS Solver is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QSS Solver. If not, see <http://www.gnu.org/licenses/>.
17 
18  ******************************************************************************/
19 
20 #pragma once
21 
22 #include <string>
23 #include <map>
24 
25 #include <ir/compute_deps.hpp>
26 #include <ir/equation.hpp>
27 #include <deps/sbg_graph/deps_graph.hpp>
28 #include <util/symbol_table.hpp>
29 #include <util/table.hpp>
30 
31 namespace MicroModelica {
32 namespace IR {
33 
34 struct QSSModelDepsDef {
35  std::string simple;
36  std::string generic;
37 };
38 
39 struct DepCode {
40  vector<std::string> begin;
41  vector<std::string> end;
42  vector<std::string> code;
43  vector<std::string> alg_code;
44  bool scalar;
45 };
46 
47 class QSSModelDepsGenerator {
48  public:
49  QSSModelDepsGenerator();
50  ~QSSModelDepsGenerator() = default;
51 
52  void init(SB::Deps::SetVertex vertex);
53  void end();
54  void postProcess(SB::Deps::SetVertex vertex);
55  void visitF(SB::Deps::SetVertex vertex, SB::Deps::VariableDep var_dep);
56  void visitF(SB::Deps::SetVertex vertex, SB::Deps::VariableDep var_dep, SB::Deps::SetVertex gen_vertex);
57  void visitG(SB::Deps::SetVertex v_vertex, SB::Deps::SetVertex g_vertex, SB::Deps::VariableDep var_dep, int index_shift = 0);
58  void visitG(SB::Deps::SetVertex v_vertex, SB::Deps::SetVertex g_vertex, SB::PWLMap use_map, SB::Deps::LMapExp use_map_exp,
59  Expression use_exp, SB::PWLMap def_map, SB::Deps::LMapExp def_map_exp, SB::Set intersection);
60  void initG(SB::Deps::SetVertex vertex, SB::Deps::SetEdge edge);
61  QSSModelDepsDef def();
62 
63  void setup(QSSModelConfig _config);
64  QSSModelConfig config();
65 
66  protected:
67  void addCode(DepCode dep_code, std::stringstream& code);
68 
69  QSSModelDepsDef _qss_model_deps_def;
70  int _tabs;
71  AlgDepsMap _der_deps;
72  AlgDepsMap _alg_deps;
73  DepsMap _deps;
74  bool _post_process_eval;
75  QSSModelConfig _config;
76 };
77 
78 class QSSModelDeps {
79  public:
80  QSSModelDeps();
81  ~QSSModelDeps() = default;
82 
83  void build(EquationTable eqs);
84 
85  std::string simpleDef();
86 
87  std::string genericDef();
88 
89  protected:
90  QSSModelDepsDef _qss_model_deps_def;
91 };
92 
93 } // namespace IR
94 } // namespace MicroModelica
ModelTable< int, Equation >
MicroModelica::IR::DepsMap
std::map< std::string, DepsData > DepsMap
Definition: compute_deps.hpp:159
compute_deps.hpp
symbol_table.hpp
MicroModelica::IR::AlgDepsMap
std::map< int, AlgDeps > AlgDepsMap
Definition: compute_deps.hpp:138
equation.hpp
MicroModelica::IR::QSSModelDeps
Definition: qss_model_deps.hpp:112
MicroModelica::IR::QSSModelDepsDef::simple
std::string simple
Definition: qss_model_deps.hpp:86
MicroModelica
Definition: files.cpp:45
MicroModelica::IR::QSSModelDepsDef
Definition: qss_model_deps.hpp:68
table.hpp
MicroModelica::IR::QSSModelConfig
Definition: compute_deps.hpp:62