Skip to content

Commit 9e033a1

Browse files
Jan ŠilarOpenModelica-Hudson
authored andcommitted
PDEModelica bugfix and minor changes
- Added other than EQ_EQUALS and EQ_PDE cases to discretizePDE() function. - _ghostL/R renamed to $ghostL/R
1 parent 02e5c4a commit 9e033a1

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Compiler/FrontEnd/Inst.mo

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,9 +2115,6 @@ algorithm
21152115
if intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PDEMODELICA) then
21162116
eqs_1 = List.fold1(eqs_1, InstUtil.discretizePDE, domainFieldsLst, {});
21172117
end if;
2118-
if className == "ghostTest" then
2119-
print("GhostTest");
2120-
end if;
21212118
//Instantiate equations (see function "instEquation")
21222119
(cache,env5,ih,dae2,csets2,ci_state3,graph) =
21232120
instList(cache, env5, ih, pre, csets1, ci_state2, InstSection.instEquation, eqs_1, impl, InstTypes.alwaysUnroll, graph);

Compiler/FrontEnd/InstUtil.mo

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8317,12 +8317,12 @@ algorithm
83178317
//remove domain from the subModLst:
83188318
subModLst = List.filterOnFalse(subModLst,isSubModDomainOrStart);
83198319

8320-
ghostL = (SCode.COMPONENT(stringAppend(name,"_ghostL"), prefixes,
8320+
ghostL = (SCode.COMPONENT(stringAppend(name,"$ghostL"), prefixes,
83218321
SCode.ATTR(arrayDims,connectorType,parallelism,
83228322
variability, direction, Absyn.NONFIELD()), typeSpec,
83238323
SCode.MOD(finalPrefix, eachPrefix,subModLst,binding,info2),
83248324
comment, condition, info),daeMod);
8325-
ghostR = (SCode.COMPONENT(stringAppend(name,"_ghostR"), prefixes,
8325+
ghostR = (SCode.COMPONENT(stringAppend(name,"$ghostR"), prefixes,
83268326
SCode.ATTR(arrayDims,connectorType,parallelism,
83278327
variability, direction, Absyn.NONFIELD()), typeSpec,
83288328
SCode.MOD(finalPrefix, eachPrefix,subModLst,binding,info2),
@@ -8535,9 +8535,6 @@ public function discretizePDE
85358535
output List<SCode.Equation> outDiscretizedEQs;
85368536
protected List<SCode.Equation> newDiscretizedEQs;
85378537
algorithm
8538-
newDiscretizedEQs := {inEQ};
8539-
//TODO: fix:
8540-
85418538
newDiscretizedEQs := match inEQ
85428539
local
85438540
Absyn.Exp lhs_exp, rhs_exp;
@@ -8549,9 +8546,6 @@ algorithm
85498546
Absyn.Ident name;
85508547
list<Absyn.Subscript> subscripts;
85518548

8552-
//Normal equation withhout domain specified, no field variables present:
8553-
case SCode.EQUATION(SCode.EQ_EQUALS())
8554-
then {inEQ};
85558549
//PDE with domain specified, allow for field variables:
85568550
case SCode.EQUATION(SCode.EQ_PDE(expLeft = lhs_exp, expRight = rhs_exp,
85578551
domain = domainCr as Absyn.CREF_IDENT(), comment = comment, info = info))
@@ -8591,6 +8585,14 @@ algorithm
85918585
(rhs_exp, _) = Absyn.traverseExp(rhs_exp, extrapFieldTraverseFun, N);
85928586
then
85938587
{newEQFun(N, lhs_exp, rhs_exp, domainCr1, N, true, fieldLst, comment, info)};
8588+
//Unhandled pde
8589+
case SCode.EQUATION(SCode.EQ_PDE())
8590+
equation
8591+
print("Unhandled type of EQ_PDE in discretizePDE\n");
8592+
fail();
8593+
then {};
8594+
//Other than EQ_PDE:
8595+
else {inEQ};
85948596
end match;
85958597

85968598
outDiscretizedEQs := listAppend(inDiscretizedEQs, newDiscretizedEQs);
@@ -8858,9 +8860,9 @@ algorithm
88588860
equation
88598861
true = List.isMemberOnTrue(fieldCr,fieldLst,Absyn.crefEqual);
88608862
exp = (if isBC and i == 1 then
8861-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts)) //left BC
8863+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts)) //left BC
88628864
elseif isBC and i == N then
8863-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts)) //right BC
8865+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts)) //right BC
88648866
else
88658867
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i))::subscripts)) //no BC
88668868
);
@@ -8875,12 +8877,12 @@ algorithm
88758877
end if;
88768878
//skip = true
88778879
leftVar = (if i == 1 then
8878-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts))
8880+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts))
88798881
else
88808882
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i-1))::subscripts))
88818883
);
88828884
rightVar = (if i == N then
8883-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts))
8885+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts))
88848886
else
88858887
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i+1))::subscripts))
88868888
);
@@ -8903,13 +8905,13 @@ algorithm
89038905
end if;
89048906
//skip = true
89058907
leftVar = (if i == 1 then
8906-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostL"), subscripts))
8908+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostL"), subscripts))
89078909
else
89088910
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i-1))::subscripts))
89098911
);
89108912
actualVar = Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i))::subscripts));
89118913
rightVar = (if i == N then
8912-
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"_ghostR"), subscripts))
8914+
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,"$ghostR"), subscripts))
89138915
else
89148916
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i+1))::subscripts))
89158917
);

0 commit comments

Comments
 (0)