Skip to content

Commit

Permalink
PDEModelica Ghost Cells
Browse files Browse the repository at this point in the history
not finished -- serching for fields in pder to be extended by ghost cells
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Mar 10, 2017
1 parent c4c02c1 commit a0d00d8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -2095,7 +2095,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 Down
59 changes: 59 additions & 0 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -8211,6 +8211,65 @@ end propagateModFinal;
public type DomainFieldOpt = Option<tuple<Absyn.ComponentRef,DAE.ComponentRef>>;
public type DomainFieldsLst = list<tuple<DAE.ComponentRef,list<Absyn.ComponentRef>>>;

public function addGhostCells
//add ghost cells to fields that are differentiated in pder
input list<tuple<SCode.Element, DAE.Mod>> inCompelts;
input list<SCode.Equation> inEqs;
output list<tuple<SCode.Element, DAE.Mod>> outCompelts;
protected list<Absyn.Ident> fieldNamesP;
algorithm
fieldNamesP := List.fold(inEqs, fieldsInPderEq, {});
//TODO: implement


outCompelts := inCompelts;
end addGhostCells;

function fieldsInPderEq
//adds field variable names that are differentiated using pder
//in given equation to given list if it isn't already there
input SCode.Equation eq;
input list<Absyn.Ident> inFieldNames;
output list<Absyn.Ident> outFieldNames;
protected list<Absyn.Ident> fieldNames2;
algorithm
fieldNames2 := 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);
then
fieldNames1;
else
inFieldNames;
end match;
outFieldNames := fieldNames2;
end fieldsInPderEq;

function fieldInPderExp
//if given expression is pder call, than adds the differentiated field name
//to given list of names if it is not already there
input Absyn.Exp inExp;
input list<Absyn.Ident> inFieldNames;
output Absyn.Exp outExp;
output list<Absyn.Ident> outFieldNames;
algorithm
outFieldNames := match inExp
local
Absyn.Ident newFieldName;
case Absyn.CALL(function_=Absyn.CREF_IDENT(name="pder"),functionArgs=Absyn.FUNCTIONARGS(args={Absyn.CREF(Absyn.CREF_IDENT(name=newFieldName)),_}))
then
List.unionElt(newFieldName,inFieldNames);
else
inFieldNames;
end match;
outExp := inExp;
end fieldInPderExp;

public function elabField
//For field variables: finds the "domain" modifier,
//finds domain.N - length of discretized field array
Expand Down

0 comments on commit a0d00d8

Please sign in to comment.