MicroModelicaCCompiler  4.5.3
qss_model.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/builders/eq_graph_builder.hpp>
28 #include <deps/sbg_graph/deps_graph.hpp>
29 #include <util/symbol_table.hpp>
30 #include <util/table.hpp>
31 
32 namespace MicroModelica {
33 namespace IR {
34 
35 struct QSSModelDef {
36  std::string simple;
37  std::string generic;
38 };
39 
40 class QSSModelGenerator {
41  public:
42  QSSModelGenerator();
43  ~QSSModelGenerator() = default;
44 
45  void init(SB::Deps::SetVertex vertex);
46  void end();
47  void postProcess(SB::Deps::SetVertex vertex);
48  void visitF(SB::Deps::SetVertex vertex, SB::Deps::VariableDep var_dep);
49  void visitF(SB::Deps::SetVertex vertex, SB::Deps::VariableDep var_dep, SB::Deps::SetVertex gen_vertex);
50  void visitG(SB::Deps::SetVertex v_vertex, SB::Deps::SetVertex g_vertex, SB::Deps::VariableDep var_dep, int index_shift = 0);
51  void visitG(SB::Deps::SetVertex v_vertex, SB::Deps::SetVertex g_vertex, SB::PWLMap use_map, SB::Deps::LMapExp use_map_exp,
52  Expression use_exp, SB::PWLMap def_map, SB::Deps::LMapExp def_map_exp, SB::Set intersection);
53  void initG(SB::Deps::SetVertex vertex, SB::Deps::SetEdge edge);
54  QSSModelDef def();
55 
56  void setup(QSSModelConfig config);
57  QSSModelConfig config() { return _config; }
58 
59  protected:
60  QSSModelDef _qss_model_def;
61  int _tabs;
62  AlgDepsMap _der_deps;
63  AlgDepsMap _alg_deps;
64  bool _post_process_eval;
65  QSSModelConfig _config;
66 };
67 
68 template <typename GraphBuilder>
69 class QSSModel {
70  public:
71  QSSModel();
72  ~QSSModel() = default;
73 
74  void build(EquationTable eqs);
75 
76  std::string simpleDef();
77 
78  std::string genericDef();
79 
80  protected:
81  QSSModelDef _qss_model_def;
82 };
83 
85 
87 
89 
90 } // namespace IR
91 } // namespace MicroModelica
ModelTable< int, Equation >
MicroModelica::IR::QSSModel
Definition: qss_model.hpp:103
compute_deps.hpp
symbol_table.hpp
MicroModelica::IR::ZCModelGen
QSSModel< Deps::SZSBGraphBuilder > ZCModelGen
Definition: qss_model.hpp:120
MicroModelica::IR::AlgDepsMap
std::map< int, AlgDeps > AlgDepsMap
Definition: compute_deps.hpp:138
MicroModelica::IR::OutputModelGen
QSSModel< Deps::SOSBGraphBuilder > OutputModelGen
Definition: qss_model.hpp:122
MicroModelica::IR::QSSModelDef::simple
std::string simple
Definition: qss_model.hpp:87
equation.hpp
MicroModelica::IR::QSSModelDef
Definition: qss_model.hpp:69
MicroModelica::IR::QSSModelGen
QSSModel< Deps::SDSBGraphBuilder > QSSModelGen
Definition: qss_model.hpp:118
MicroModelica
Definition: files.cpp:45
table.hpp