Skip to content

Commit

Permalink
Moving code around.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Šilar authored and OpenModelica-Hudson committed Feb 10, 2016
1 parent 61c812f commit aed8fab
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -8731,6 +8731,9 @@ end propagateModFinal;
//------------------------------
//------ PDE extension: ------
//------------------------------

public type DomainFieldsLst = List<Tuple<DAE.ComponentRef,List<Absyn.ComponentRef>>>;

public function elabField
//For field variables: finds the "domain" modifier,
//finds domain.N - length of discretized field array
Expand Down Expand Up @@ -8777,6 +8780,61 @@ algorithm
end match;
end elabField;

protected function domainSearchFun
"fold function to find domain modifier in modifiers list"
//TODO: simplify this function, perhaps not use fold
input DAE.SubMod subMod;
input Integer inN;
input list<DAE.SubMod> inSubModLst;
input Option<DAE.ComponentRef> inCrOpt;
output Integer outN;
output list<DAE.SubMod> outSubModLst;
output Option<DAE.ComponentRef> outCrOpt;

algorithm
(outSubModLst,outN,outCrOpt) := matchcontinue subMod
local
DAE.Mod mod;
list<DAE.SubMod> subModLst;
Option<DAE.EqMod> eqModOption;
// list<Values.Value> values;
// list<String> names;
list<DAE.Var> varLst;
Integer N;
DAE.ComponentRef cr;
case DAE.NAMEMOD(ident="domain", mod=DAE.MOD(eqModOption=SOME(
DAE.TYPED(
//TODO: check the type of the domain
modifierAsExp=DAE.CREF(cr)
)
)))
equation
DAE.CREF_IDENT(identType = DAE.T_COMPLEX(varLst = varLst)) = cr;
N = List.findSome(varLst,findN);
then (inSubModLst,N,SOME(cr));
case DAE.NAMEMOD(ident="domain")
equation
print("cant find N in the domain");
then
fail();
else (subMod::inSubModLst,inN,inCrOpt);
end matchcontinue;
end domainSearchFun;

protected function findN
"a map function to find N in domain class modifiers"
input DAE.Var inVar;
output Option<Integer> optN;
algorithm
optN := match inVar
local
Integer N;
case DAE.TYPES_VAR(name="N",binding=DAE.Binding.EQBOUND(evaluatedExp=SOME(Values.INTEGER(N))))
then SOME(N);
else NONE();
end match;
end findN;

protected function addEach
"map function that adds each prefix to given modifier"
input DAE.SubMod inSubMod;
Expand All @@ -8797,8 +8855,7 @@ protected function addEach
end match;
end addEach;

//public type List<Tuple<DAE.ComponentRef,List<Absyn.ComponentRef>>> LDomainFields;
public type DomainFieldsLst = List<Tuple<DAE.ComponentRef,List<Absyn.ComponentRef>>>;
//----end elabField and sub funs

public function optAppendField
input DomainFieldsLst inDomFieldsLst;
Expand Down Expand Up @@ -8845,60 +8902,7 @@ algorithm
end matchcontinue;
end optAppendFieldMapFun;

protected function domainSearchFun
"fold function to find domain modifier in modifiers list"
//TODO: simplify this function, perhaps not use fold
input DAE.SubMod subMod;
input Integer inN;
input list<DAE.SubMod> inSubModLst;
input Option<DAE.ComponentRef> inCrOpt;
output Integer outN;
output list<DAE.SubMod> outSubModLst;
output Option<DAE.ComponentRef> outCrOpt;

algorithm
(outSubModLst,outN,outCrOpt) := matchcontinue subMod
local
DAE.Mod mod;
list<DAE.SubMod> subModLst;
Option<DAE.EqMod> eqModOption;
// list<Values.Value> values;
// list<String> names;
list<DAE.Var> varLst;
Integer N;
DAE.ComponentRef cr;
case DAE.NAMEMOD(ident="domain", mod=DAE.MOD(eqModOption=SOME(
DAE.TYPED(
//TODO: check the type of the domain
modifierAsExp=DAE.CREF(cr)
)
)))
equation
DAE.CREF_IDENT(identType = DAE.T_COMPLEX(varLst = varLst)) = cr;
N = List.findSome(varLst,findN);
then (inSubModLst,N,SOME(cr));
case DAE.NAMEMOD(ident="domain")
equation
print("cant find N in the domain");
then
fail();
else (subMod::inSubModLst,inN,inCrOpt);
end matchcontinue;
end domainSearchFun;

protected function findN
"a map function to find N in domain class modifiers"
input DAE.Var inVar;
output Option<Integer> optN;
algorithm
optN := match inVar
local
Integer N;
case DAE.TYPES_VAR(name="N",binding=DAE.Binding.EQBOUND(evaluatedExp=SOME(Values.INTEGER(N))))
then SOME(N);
else NONE();
end match;
end findN;
//----end optAppendField and sub funs

public function discretizePDE
//main discretization function, converts PDE into set of ODEs
Expand Down

0 comments on commit aed8fab

Please sign in to comment.