Skip to content

Commit a0d00d8

Browse files
Jan ŠilarOpenModelica-Hudson
authored andcommitted
PDEModelica Ghost Cells
not finished -- serching for fields in pder to be extended by ghost cells
1 parent c4c02c1 commit a0d00d8

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

Compiler/FrontEnd/Inst.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ algorithm
20952095
(smCompCrefs, smInitialCrefs) = InstStateMachineUtil.getSMStatesInContext(eqs_1, pre);
20962096
//ih = List.fold1(smCompCrefs, InnerOuter.updateSMHierarchy, inPrefix3, ih);
20972097
ih = List.fold(smCompCrefs, InnerOuter.updateSMHierarchy, ih);
2098-
2098+
compelts_2 = InstUtil.addGhostCells(compelts_2, eqs_1);
20992099
(cache,env5,ih,store,dae1,csets,ci_state2,vars,graph,domainFieldsLst) =
21002100
instElementList(cache, env3, ih, store, mods, pre, ci_state1,
21012101
compelts_2, inst_dims, impl, callscope, graph, csets, true);

Compiler/FrontEnd/InstUtil.mo

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8211,6 +8211,65 @@ end propagateModFinal;
82118211
public type DomainFieldOpt = Option<tuple<Absyn.ComponentRef,DAE.ComponentRef>>;
82128212
public type DomainFieldsLst = list<tuple<DAE.ComponentRef,list<Absyn.ComponentRef>>>;
82138213

8214+
public function addGhostCells
8215+
//add ghost cells to fields that are differentiated in pder
8216+
input list<tuple<SCode.Element, DAE.Mod>> inCompelts;
8217+
input list<SCode.Equation> inEqs;
8218+
output list<tuple<SCode.Element, DAE.Mod>> outCompelts;
8219+
protected list<Absyn.Ident> fieldNamesP;
8220+
algorithm
8221+
fieldNamesP := List.fold(inEqs, fieldsInPderEq, {});
8222+
//TODO: implement
8223+
8224+
8225+
outCompelts := inCompelts;
8226+
end addGhostCells;
8227+
8228+
function fieldsInPderEq
8229+
//adds field variable names that are differentiated using pder
8230+
//in given equation to given list if it isn't already there
8231+
input SCode.Equation eq;
8232+
input list<Absyn.Ident> inFieldNames;
8233+
output list<Absyn.Ident> outFieldNames;
8234+
protected list<Absyn.Ident> fieldNames2;
8235+
algorithm
8236+
fieldNames2 := match eq
8237+
local
8238+
list<Absyn.Ident> fieldNames1;
8239+
Absyn.Exp lhs_exp, rhs_exp;
8240+
case SCode.EQUATION(SCode.EQ_PDE(expLeft = lhs_exp, expRight = rhs_exp))
8241+
/*,domain = domainCr as Absyn.CREF_IDENT(), comment = comment, info = info))*/
8242+
algorithm
8243+
(_,fieldNames1) := Absyn.traverseExp(lhs_exp, fieldInPderExp, inFieldNames);
8244+
(_,fieldNames1) := Absyn.traverseExp(rhs_exp, fieldInPderExp, fieldNames1);
8245+
then
8246+
fieldNames1;
8247+
else
8248+
inFieldNames;
8249+
end match;
8250+
outFieldNames := fieldNames2;
8251+
end fieldsInPderEq;
8252+
8253+
function fieldInPderExp
8254+
//if given expression is pder call, than adds the differentiated field name
8255+
//to given list of names if it is not already there
8256+
input Absyn.Exp inExp;
8257+
input list<Absyn.Ident> inFieldNames;
8258+
output Absyn.Exp outExp;
8259+
output list<Absyn.Ident> outFieldNames;
8260+
algorithm
8261+
outFieldNames := match inExp
8262+
local
8263+
Absyn.Ident newFieldName;
8264+
case Absyn.CALL(function_=Absyn.CREF_IDENT(name="pder"),functionArgs=Absyn.FUNCTIONARGS(args={Absyn.CREF(Absyn.CREF_IDENT(name=newFieldName)),_}))
8265+
then
8266+
List.unionElt(newFieldName,inFieldNames);
8267+
else
8268+
inFieldNames;
8269+
end match;
8270+
outExp := inExp;
8271+
end fieldInPderExp;
8272+
82148273
public function elabField
82158274
//For field variables: finds the "domain" modifier,
82168275
//finds domain.N - length of discretized field array

0 commit comments

Comments
 (0)