@@ -43,6 +43,7 @@ void usage()
4343 cout << endl;
4444 cout << " -h, --help Display this information and exit" << endl;
4545 cout << " -o <path>, --output <path> Sets the output path for the generated graph dot file." << endl;
46+ cout << " -t, --tearing Use tearing variables." << endl;
4647 cout << " -v, --version Display version information and exit" << endl;
4748 cout << endl;
4849 cout << " Modelica C Compiler home page: https://github.com/CIFASIS/modelicacc " << endl;
@@ -61,12 +62,16 @@ int main(int argc, char** argv)
6162 int opt;
6263 extern char * optarg;
6364 string output_path = " " ;
65+ bool tearing = false ;
6466
6567 while (true ) {
66- static struct option long_options[] = {
67- {" version" , no_argument, 0 , ' v' }, {" help" , no_argument, 0 , ' h' }, {" output" , required_argument, 0 , ' o' }, {0 , 0 , 0 , 0 }};
68+ static struct option long_options[] = {{" version" , no_argument, 0 , ' v' },
69+ {" help" , no_argument, 0 , ' h' },
70+ {" output" , required_argument, 0 , ' o' },
71+ {" tearing" , no_argument, 0 , ' t' },
72+ {0 , 0 , 0 , 0 }};
6873 int option_index = 0 ;
69- opt = getopt_long (argc, argv, " vho :" , long_options, &option_index);
74+ opt = getopt_long (argc, argv, " vhot :" , long_options, &option_index);
7075 if (opt == EOF ) {
7176 break ;
7277 }
@@ -80,6 +85,9 @@ int main(int argc, char** argv)
8085 case ' o' :
8186 output_path = optarg;
8287 break ;
88+ case ' t' :
89+ tearing = true ;
90+ break ;
8391 case ' ?' :
8492 usage ();
8593 exit (-1 );
@@ -121,9 +129,13 @@ int main(int argc, char** argv)
121129 Modelica::AST ::ClassList classes = stored_def.classes ();
122130 const Modelica::Causalize::CausalModel& causal_model = result.vertical_sort ();
123131 EquationList causalized;
124- for (const Modelica::Causalize::CausalEquations& l : causal_model) {
132+ Modelica::Causalize::TearingVariables tearing_vars;
133+ if (tearing) {
134+ tearing_vars = result.tearing ();
135+ }
136+ for (const Modelica::Causalize::CausalEquations& s : causal_model) {
125137 EquationList res =
126- EquationSolver::Solve (l .equations (), l .variables (), mmo_class.syms_ref (), mmo_class.variables_ref (), classes, result. tearing () );
138+ EquationSolver::Solve (s .equations (), s .variables (), mmo_class.syms_ref (), mmo_class.variables_ref (), classes, tearing_vars );
127139 causalized.insert (causalized.end (), res.begin (), res.end ());
128140 }
129141
0 commit comments