Skip to content

Commit

Permalink
[NF] Skip empty array variables and equations
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Oct 24, 2018
1 parent a08ef7b commit 8e8393f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Compiler/NFFrontEnd/NFConnector.mo
Expand Up @@ -236,7 +236,9 @@ protected
conns := splitImpl(c, t, face, source, cty, conns);
end for;
else
conns := CONNECTOR(name, ty, face, cty, source) :: conns;
if not Type.isEmptyArray(ty) then
conns := CONNECTOR(name, ty, face, cty, source) :: conns;
end if;
end if;
then
conns;
Expand Down
4 changes: 4 additions & 0 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -97,6 +97,7 @@ import FlatModel = NFFlatModel;
import ElementSource;
import SimplifyModel = NFSimplifyModel;
import Record = NFRecord;
import Variable = NFVariable;
import OperatorOverloading = NFOperatorOverloading;
import EvalConstants = NFEvalConstants;

Expand Down Expand Up @@ -167,6 +168,9 @@ algorithm
// Scalarize array components in the flat model.
if Flags.isSet(Flags.NF_SCALARIZE) then
flat_model := Scalarize.scalarize(flat_model, name);
else
// Remove empty arrays from variables
flat_model.variables := List.filterOnFalse(flat_model.variables, Variable.isEmptyArray);
end if;

// Convert the flat model to a DAE.
Expand Down
5 changes: 5 additions & 0 deletions Compiler/NFFrontEnd/NFVariable.mo
Expand Up @@ -84,5 +84,10 @@ public
variable.attributes.variability <= Variability.STRUCTURAL_PARAMETER;
end isStructural;

function isEmptyArray
input Variable variable;
output Boolean isEmpty = Type.isEmptyArray(variable.ty);
end isEmptyArray;

annotation(__OpenModelica_Interface="frontend");
end NFVariable;

0 comments on commit 8e8393f

Please sign in to comment.