Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
PDEModelica bugfix and minor changes
Browse files Browse the repository at this point in the history
- Added other than EQ_EQUALS and EQ_PDE cases to discretizePDE() function.
- _ghostL/R renamed to $ghostL/R
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Mar 10, 2017
1 parent 02e5c4a commit 9e033a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Compiler/FrontEnd/Inst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2115,9 +2115,6 @@ algorithm
if intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PDEMODELICA) then
eqs_1 = List.fold1(eqs_1, InstUtil.discretizePDE, domainFieldsLst, {});
end if;
if className == "ghostTest" then
print("GhostTest");
end if;
//Instantiate equations (see function "instEquation")
(cache,env5,ih,dae2,csets2,ci_state3,graph) =
instList(cache, env5, ih, pre, csets1, ci_state2, InstSection.instEquation, eqs_1, impl, InstTypes.alwaysUnroll, graph);
Expand Down
30 changes: 16 additions & 14 deletions Compiler/FrontEnd/InstUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8317,12 +8317,12 @@ algorithm
//remove domain from the subModLst:
subModLst = List.filterOnFalse(subModLst,isSubModDomainOrStart);

ghostL = (SCode.COMPONENT(stringAppend(name,"_ghostL"), prefixes,
ghostL = (SCode.COMPONENT(stringAppend(name,"$ghostL"), prefixes,
SCode.ATTR(arrayDims,connectorType,parallelism,
variability, direction, Absyn.NONFIELD()), typeSpec,
SCode.MOD(finalPrefix, eachPrefix,subModLst,binding,info2),
comment, condition, info),daeMod);
ghostR = (SCode.COMPONENT(stringAppend(name,"_ghostR"), prefixes,
ghostR = (SCode.COMPONENT(stringAppend(name,"$ghostR"), prefixes,
SCode.ATTR(arrayDims,connectorType,parallelism,
variability, direction, Absyn.NONFIELD()), typeSpec,
SCode.MOD(finalPrefix, eachPrefix,subModLst,binding,info2),
Expand Down Expand Up @@ -8535,9 +8535,6 @@ public function discretizePDE
output List<SCode.Equation> outDiscretizedEQs;
protected List<SCode.Equation> newDiscretizedEQs;
algorithm
newDiscretizedEQs := {inEQ};
//TODO: fix:

newDiscretizedEQs := match inEQ
local
Absyn.Exp lhs_exp, rhs_exp;
Expand All @@ -8549,9 +8546,6 @@ algorithm
Absyn.Ident name;
list<Absyn.Subscript> subscripts;

//Normal equation withhout domain specified, no field variables present:
case SCode.EQUATION(SCode.EQ_EQUALS())
then {inEQ};
//PDE with domain specified, allow for field variables:
case SCode.EQUATION(SCode.EQ_PDE(expLeft = lhs_exp, expRight = rhs_exp,
domain = domainCr as Absyn.CREF_IDENT(), comment = comment, info = info))
Expand Down Expand Up @@ -8591,6 +8585,14 @@ algorithm
(rhs_exp, _) = Absyn.traverseExp(rhs_exp, extrapFieldTraverseFun, N);
then
{newEQFun(N, lhs_exp, rhs_exp, domainCr1, N, true, fieldLst, comment, info)};
//Unhandled pde
case SCode.EQUATION(SCode.EQ_PDE())
equation
print("Unhandled type of EQ_PDE in discretizePDE\n");
fail();
then {};
//Other than EQ_PDE:
else {inEQ};
end match;

outDiscretizedEQs := listAppend(inDiscretizedEQs, newDiscretizedEQs);
Expand Down Expand Up @@ -8858,9 +8860,9 @@ algorithm
equation
true = List.isMemberOnTrue(fieldCr,fieldLst,Absyn.crefEqual);
exp = (if isBC and i == 1 then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts)) //left BC
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts)) //left BC
elseif isBC and i == N then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts)) //right BC
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts)) //right BC
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i))::subscripts)) //no BC
);
Expand All @@ -8875,12 +8877,12 @@ algorithm
end if;
//skip = true
leftVar = (if i == 1 then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts))
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts))
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i-1))::subscripts))
);
rightVar = (if i == N then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts))
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts))
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i+1))::subscripts))
);
Expand All @@ -8903,13 +8905,13 @@ algorithm
end if;
//skip = true
leftVar = (if i == 1 then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts))
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts))
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i-1))::subscripts))
);
actualVar = Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i))::subscripts));
rightVar = (if i == N then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts))
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts))
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i+1))::subscripts))
);
Expand Down

0 comments on commit 9e033a1

Please sign in to comment.