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

Commit

Permalink
PDEModelica - ghost cells hopefully finished
Browse files Browse the repository at this point in the history
addGhostCell() call moved before addComponentsToEnv() call.
Fixed some other bugs in ghost cell handling.
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Mar 10, 2017
1 parent 52646f2 commit 3461537
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Compiler/FrontEnd/Inst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,8 @@ algorithm
(compelts_1, eqs_1, initeqs_1, alg_1, initalg_1) =
InstUtil.extractConstantPlusDepsTpl(compelts_1, instSingleCref, {}, className, eqs_1, initeqs_1, alg_1, initalg_1);

compelts_1 = InstUtil.addGhostCells(compelts_1, eqs_1);

//(csets, env2, ih) = InstUtil.addConnectionCrefsFromEqs(csets, eqs_1, pre, env2, ih);

//// fprintln(Flags.INST_TRACE, "Emods to InstUtil.addComponentsToEnv: " + Mod.printModStr(emods));
Expand All @@ -2095,7 +2097,7 @@ algorithm
(smCompCrefs, smInitialCrefs) = InstStateMachineUtil.getSMStatesInContext(eqs_1, pre);
//ih = List.fold1(smCompCrefs, InnerOuter.updateSMHierarchy, inPrefix3, ih);
ih = List.fold(smCompCrefs, InnerOuter.updateSMHierarchy, ih);
compelts_2 = InstUtil.addGhostCells(compelts_2, eqs_1);

(cache,env5,ih,store,dae1,csets,ci_state2,vars,graph,domainFieldsLst) =
instElementList(cache, env3, ih, store, mods, pre, ci_state1,
compelts_2, inst_dims, impl, callscope, graph, csets, true);
Expand All @@ -2112,7 +2114,9 @@ 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
14 changes: 6 additions & 8 deletions Compiler/FrontEnd/InstUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8230,23 +8230,21 @@ function fieldsInPderEq
input SCode.Equation eq;
input list<Absyn.Ident> inFieldNames;
output list<Absyn.Ident> outFieldNames;
protected list<Absyn.Ident> fieldNames2;
algorithm
fieldNames2 := match eq
outFieldNames := match eq
local
list<Absyn.Ident> fieldNames1;
Absyn.Exp lhs_exp, rhs_exp;
case SCode.EQUATION(SCode.EQ_PDE(expLeft = lhs_exp, expRight = rhs_exp))
/*,domain = domainCr as Absyn.CREF_IDENT(), comment = comment, info = info))*/
algorithm
(_,fieldNames1) := Absyn.traverseExp(lhs_exp, fieldInPderExp, inFieldNames);
(_,fieldNames1) := Absyn.traverseExp(rhs_exp, fieldInPderExp, fieldNames1);
(_,fieldNames1) := Absyn.traverseExpTopDown(lhs_exp, fieldInPderExp, inFieldNames);
(_,fieldNames1) := Absyn.traverseExpTopDown(rhs_exp, fieldInPderExp, fieldNames1);
then
fieldNames1;
listAppend(inFieldNames,fieldNames1);
else
inFieldNames;
end match;
outFieldNames := fieldNames2;
end fieldsInPderEq;

function fieldInPderExp
Expand All @@ -8270,7 +8268,7 @@ algorithm
end fieldInPderExp;

function addGhostCells2
//if name os given variable is in the given array
//if name of given variable is in the given array
//adds ghost cells for it
input tuple<SCode.Element, DAE.Mod> inCompelt;
input list<Absyn.Ident> fieldNamesP;
Expand Down Expand Up @@ -8901,7 +8899,7 @@ algorithm
leftVar = (if i == 1 then
Absyn.CREF(Absyn.CREF_IDENT(stringAppend(name,".ghostL"), subscripts))
else
Absyn.CREF(Absyn.CREF_IDENT(name, Absyn.SUBSCRIPT(Absyn.INTEGER(i+1))::subscripts))
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))
Expand Down

0 comments on commit 3461537

Please sign in to comment.