Skip to content

Commit

Permalink
Merged branches/FFrontEnd into trunk/
Browse files Browse the repository at this point in the history
Main changes:
- changed the environment to support both non-destructive and destructive updates
- Env.Cache -> FCore.Cache, Env.Env -> FCore.Graph
- FCore.Graph is not a list of Frames anymore is a stucture where the previous list is saved in component "scope"
- all Frames in the new FCore.Graph are FCore.Ref pointing to FCore.Node having different FCore.Data depending on what they are 
- all FCore.Nodes have children (FCore.CAvlTree) which maps names to FCore.Ref (which is Array<FCore.Node>, size 1)
- FGraph.openScope pushes an already existing FCore.Ref (or a new one) on the scope list
- for all components having modifications the last class in the type path is renamed to include the 
  prefix, see FGraph.createVersionScope (this is done because we need unique names for redeclared functions,
  records, etc and we need a unique type scope for that)
  Example: A.B.C c -> A.B.C$c c

Bug fixes:
- calling function via component (multibody MSL 3.2.1 patch not needed anymore, will remove it in a next commit)
- #2837 array equations wrongly handled in RemoveSimpleEquations (used in ThermoPower and PowerSystems libraries, etc)
  #2784, #2727, #2739 (missing modifiers combined with redeclare and unique function generation for redeclared functions)
  #2835 - handle overconstrained connectors extending basic types (used in PowerSystems library)
- do not loose modifications on derived classes handled by InstExtends
- some error messages about missing components in Fluid library are gone
- for components of size 0 do not check if they are assigned before use in functions (residue in equalityConstraint)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22496 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 30, 2014
1 parent 2a3e9eb commit 0705075
Show file tree
Hide file tree
Showing 70 changed files with 12,092 additions and 6,079 deletions.
6 changes: 3 additions & 3 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -39,7 +39,7 @@ encapsulated package BackendDAE

public import Absyn;
public import DAE;
public import Env;
public import FCore;
public import SCode;
public import Values;
public import HashTable3;
Expand Down Expand Up @@ -115,8 +115,8 @@ uniontype Shared "Data shared for all equation-systems"
EquationArray removedEqs "these are equations that cannot solve for a variable. for example assertions, external function calls, algorithm sections without effect";
list< .DAE.Constraint> constraints "constraints (Optimica extension)";
list< .DAE.ClassAttributes> classAttrs "class attributes (Optimica extension)";
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
.DAE.FunctionTree functionTree "functions for Backend";
EventInfo eventInfo "eventInfo";
ExternalObjectClasses extObjClasses "classes of external objects, contains constructor & destructor";
Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -41,7 +41,7 @@ encapsulated package BackendDAECreate
public import Absyn;
public import BackendDAE;
public import DAE;
public import Env;
public import FCore;

protected import BackendDAEUtil;
protected import BackendDump;
Expand Down Expand Up @@ -85,11 +85,11 @@ public function lower "This function translates a DAE, which is the result from
O(1) for finding a variable. The equations are put in an expandable
array. Where adding a new equation can be done in O(1) time if space
is available.
inputs: lst: DAE.DAElist, inCache: Env.Cache, inEnv: Env.Env
inputs: lst: DAE.DAElist, inCache: FCore.Cache, inEnv: FCore.Graph
outputs: BackendDAE.BackendDAE"
input DAE.DAElist lst;
input Env.Cache inCache;
input Env.Env inEnv;
input FCore.Cache inCache;
input FCore.Graph inEnv;
input BackendDAE.ExtraInfo inExtraInfo;
output BackendDAE.BackendDAE outBackendDAE;
protected
Expand All @@ -110,7 +110,7 @@ protected
algorithm
// reset dumped file sequence number
System.tmpTickResetIndex(0, Global.backendDAE_fileSequence);
functionTree := Env.getFunctionTree(inCache);
functionTree := FCore.getFunctionTree(inCache);
(DAE.DAE(elems), functionTree, timeEvents) := processBuiltinExpressions(lst, functionTree);
vars := BackendVariable.emptyVars();
knvars := BackendVariable.emptyVars();
Expand Down
174 changes: 89 additions & 85 deletions Compiler/BackEnd/BackendDAEOptimize.mo

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -51,7 +51,7 @@ public import Absyn;
public import BackendDAE;
public import BackendDAEFunc;
public import DAE;
public import Env;
public import FCore;
public import Util;

protected import Algorithm;
Expand Down Expand Up @@ -450,13 +450,13 @@ protected
BackendDAE.Variables emptyvars;
EquationArray emptyEqns;
BackendDAE.Variables emptyAliasVars;
Env.Cache cache;
FCore.Cache cache;
DAE.FunctionTree funcTree;
algorithm
emptyvars := BackendVariable.emptyVars();
emptyEqns := BackendEquation.emptyEqns();
emptyAliasVars := BackendVariable.emptyVars();
cache := Env.emptyCache();
cache := FCore.emptyCache();
funcTree := DAEUtil.avlTreeNew();
outBDAE := BackendDAE.DAE({BackendDAE.EQSYSTEM(emptyvars,
emptyEqns,
Expand Down Expand Up @@ -549,23 +549,23 @@ algorithm
EquationArray remeqns,inieqns,remeqns1,inieqns1;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcTree;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
BackendDAEType btp;
BackendDAE.SymbolicJacobians symjacs;
BackendDAE.ExtraInfo ei;

case (BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei))
case (BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei))
equation
knvars1 = BackendVariable.copyVariables(knvars);
_ = BackendVariable.copyVariables(exobj);
inieqns1 = BackendEquation.copyEquationArray(inieqns);
remeqns1 = BackendEquation.copyEquationArray(remeqns);
then
BackendDAE.SHARED(knvars1,exobj,av,inieqns1,remeqns1,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei);
BackendDAE.SHARED(knvars1,exobj,av,inieqns1,remeqns1,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei);
end match;
end copyBackendDAEShared;

Expand Down Expand Up @@ -603,20 +603,20 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcTree;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
BackendDAEType btp;
BackendDAE.SymbolicJacobians symjacs;
BackendDAE.ExtraInfo ei;

case (_,_,_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei))
case (_,_,_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei))
equation
symjacs = {(SOME(inSymJac),inSparsePattern,inSparseColoring), (NONE(),({},{},({},{})),{}),(NONE(),({},{},({},{})),{}),(NONE(),({},{},({},{})),{})};
then
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei);
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei);

end match;
end addBackendDAESharedJacobian;
Expand All @@ -634,18 +634,18 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcTree;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
BackendDAEType btp;
BackendDAE.SymbolicJacobians symjacs;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,_,ei))
case (_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,_,ei))
then
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,inSymJac,ei);
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,inSymJac,ei);

end match;
end addBackendDAESharedJacobians;
Expand All @@ -665,8 +665,8 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcTree;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
Expand All @@ -675,12 +675,12 @@ algorithm
Option<BackendDAE.SymbolicJacobian> symJac;
BackendDAE.ExtraInfo ei;

case (_, _, _, BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei))
case (_, _, _, BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei))
equation
((symJac,_,_)) = listGet(symjacs, inIndex);
symjacs = List.set(symjacs, inIndex, ((symJac, inSparsePattern, inSparseColoring)));
then
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei);
BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei);

end match;
end addBackendDAESharedJacobianSparsePattern;
Expand All @@ -698,8 +698,8 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcTree;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
Expand All @@ -708,8 +708,8 @@ algorithm
EqSystems eqs;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.DAE(eqs=eqs,shared=BackendDAE.SHARED(_,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei)))
then BackendDAE.DAE(eqs,BackendDAE.SHARED(inKnVars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,funcTree,einfo,eoc,btp,symjacs,ei));
case (_,BackendDAE.DAE(eqs=eqs,shared=BackendDAE.SHARED(_,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei)))
then BackendDAE.DAE(eqs,BackendDAE.SHARED(inKnVars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcTree,einfo,eoc,btp,symjacs,ei));

end match;
end addBackendDAEKnVars;
Expand All @@ -727,17 +727,17 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
BackendDAEType btp;
BackendDAE.SymbolicJacobians symjacs;
EqSystems eqs;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.DAE(eqs=eqs,shared=BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,_,einfo,eoc,btp,symjacs,ei)))
then BackendDAE.DAE(eqs,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,inFunctionTree,einfo,eoc,btp,symjacs,ei));
case (_,BackendDAE.DAE(eqs=eqs,shared=BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,_,einfo,eoc,btp,symjacs,ei)))
then BackendDAE.DAE(eqs,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,inFunctionTree,einfo,eoc,btp,symjacs,ei));

end match;
end addBackendDAEFunctionTree;
Expand All @@ -756,17 +756,17 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
BackendDAE.EventInfo einfo;
ExternalObjectClasses eoc;
BackendDAEType btp;
BackendDAE.SymbolicJacobians symjacs;
EqSystems eqs;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,_,einfo,eoc,btp,symjacs,ei))
then BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,env,inFunctionTree,einfo,eoc,btp,symjacs,ei);
case (_,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,_,einfo,eoc,btp,symjacs,ei))
then BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,clsAttrs,cache,graph,inFunctionTree,einfo,eoc,btp,symjacs,ei);

end match;
end addFunctionTree;
Expand Down Expand Up @@ -1098,8 +1098,8 @@ end calculateVarSizes;

public function numberOfZeroCrossings "author: lochel"
input BackendDAE.BackendDAE inBackendDAE;
output Integer outNumZeroCrossings "number of ordinary zerocrossings";
output Integer outNumTimeEvents "number of zerocrossings that are time events";
output Integer outNumZeroCrossings "number of ordinary zerocrossings" ;
output Integer outNumTimeEvents "number of zerocrossings that are time events" ;
output Integer outNumRelations;
output Integer outNumMathEventFunctions;
protected
Expand Down Expand Up @@ -1182,8 +1182,8 @@ algorithm
EquationArray seqns,ie;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcs;
BackendDAE.EventInfo wc;
ExternalObjectClasses extObjCls;
Expand All @@ -1194,27 +1194,27 @@ algorithm

case (BackendDAE.DAE(eqs,BackendDAE.SHARED(knownVars = knvars,externalObjects=extVars,aliasVars = av,
initialEqs = ie,removedEqs = seqns, constraints = constrs,classAttrs = clsAttrs,
cache=cache,env=env, functionTree = funcs, eventInfo = wc, extObjClasses=extObjCls,
cache=cache,graph=graph, functionTree = funcs, eventInfo = wc, extObjClasses=extObjCls,
backendDAEType=btp, symjacs=symjacs, info=ei)))
equation
knvarlst = BackendVariable.varList(knvars);
(varlst1,varlst2) = List.splitOnTrue(knvarlst,BackendVariable.isParam);
paramvars = BackendVariable.listVar(varlst1);
knvarlst = List.map3(varlst1, calculateValue, cache, env, paramvars);
knvarlst = List.map3(varlst1, calculateValue, cache, graph, paramvars);
knvars = BackendVariable.listVar(listAppend(knvarlst,varlst2));
then
BackendDAE.DAE(eqs,BackendDAE.SHARED(knvars,extVars,av,ie,seqns,constrs,clsAttrs,cache,env,funcs,wc,extObjCls,btp,symjacs,ei));
BackendDAE.DAE(eqs,BackendDAE.SHARED(knvars,extVars,av,ie,seqns,constrs,clsAttrs,cache,graph,funcs,wc,extObjCls,btp,symjacs,ei));
end match;
end calculateValues;

protected function calculateValue
input BackendDAE.Var inVar;
input Env.Cache cache;
input Env.Env env;
input FCore.Cache cache;
input FCore.Graph graph;
input BackendDAE.Variables vars;
output BackendDAE.Var outVar;
algorithm
outVar := matchcontinue(inVar, cache, env, vars)
outVar := matchcontinue(inVar, cache, graph, vars)
local
Var var;
DAE.ComponentRef cr;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ algorithm
// much faster at runtime.
//((e, _)) = Expression.traverseExp(e, replaceCrefsWithValues, (vars, cr_orign));
true = Expression.isConst(e);
(_, v, _) = Ceval.ceval(cache, env, e, false, NONE(), Absyn.NO_MSG(),0);
(_, v, _) = Ceval.ceval(cache, graph, e, false, NONE(), Absyn.NO_MSG(),0);
then
BackendDAE.VAR(cr, vk, vd, prl, ty, SOME(e), SOME(v), dims, src, va, c, ct);
else inVar;
Expand Down Expand Up @@ -2431,8 +2431,8 @@ algorithm
EquationArray remeqns,inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree funcs;
list<BackendDAE.WhenClause> wclst,wclst1;
list<ZeroCrossing> zc, rellst, smplLst;
Expand All @@ -2443,10 +2443,10 @@ algorithm
list<BackendDAE.TimeEvent> timeEvents;
BackendDAE.ExtraInfo ei;

case (_,BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,env,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei))
case (_,BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei))
equation
wclst1 = listAppend(wclst,inWcLst);
then BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,env,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst1,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei);
then BackendDAE.SHARED(knvars,exobj,aliasVars,inieqns,remeqns,constrs,clsAttrs,cache,graph,funcs,BackendDAE.EVENT_INFO(timeEvents,wclst1,zc,smplLst,rellst,numberOfRelations,numberOfMathEventFunctions),eoc,btp,symjacs,ei);

end match;
end whenClauseAddDAE;
Expand Down Expand Up @@ -5831,8 +5831,8 @@ protected
BackendDAE.EquationArray initialEqs,removedEqs;
list<DAE.Constraint> constraints;
list<DAE.ClassAttributes> classAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph graph;
DAE.FunctionTree functionTree;
BackendDAE.EventInfo eventInfo;
BackendDAE.ExternalObjectClasses extObjClasses;
Expand All @@ -5841,9 +5841,9 @@ protected
BackendDAE.ExtraInfo info;
algorithm
BackendDAE.SHARED(knownVars=knownVars,externalObjects=externalObjects,aliasVars=aliasVars,initialEqs=initialEqs,removedEqs=removedEqs,
constraints=constraints,classAttrs=classAttrs,cache=cache,env=env,functionTree=functionTree,eventInfo=eventInfo,extObjClasses=extObjClasses,
constraints=constraints,classAttrs=classAttrs,cache=cache,graph=graph,functionTree=functionTree,eventInfo=eventInfo,extObjClasses=extObjClasses,
backendDAEType=backendDAEType,symjacs=symjacs,info=info) := sharedIn;
sharedOut := BackendDAE.SHARED(knVars,externalObjects,aliasVars,initialEqs,removedEqs, constraints,classAttrs,cache,env,functionTree,eventInfo,extObjClasses,backendDAEType,symjacs,info);
sharedOut := BackendDAE.SHARED(knVars,externalObjects,aliasVars,initialEqs,removedEqs,constraints,classAttrs,cache,graph,functionTree,eventInfo,extObjClasses,backendDAEType,symjacs,info);
end replaceKnownVarsInShared;

protected function adjacencyRowExpEnhanced
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -52,7 +52,7 @@ protected import ClassInf;
protected import ComponentReference;
protected import DAEUtil;
protected import Debug;
protected import Env;
protected import FCore;
protected import Error;
protected import Expression;
protected import ExpressionDump;
Expand Down Expand Up @@ -1191,8 +1191,8 @@ algorithm
BackendDAE.EquationArray remeqns, inieqns;
list<DAE.Constraint> constrs;
list<DAE.ClassAttributes> clsAttrs;
Env.Cache cache;
Env.Env env;
FCore.Cache cache;
FCore.Graph env;
DAE.FunctionTree funcs;
BackendDAE.EventInfo einfo;
BackendDAE.ExternalObjectClasses eoc;
Expand Down

0 comments on commit 0705075

Please sign in to comment.