Skip to content

Commit

Permalink
[98] PrimitiveType modification
Browse files Browse the repository at this point in the history
Rename all use of PrimitiveType unicode '\u2115', '\u211D', '\u213E' by
int, real and bool.
Generated code and LaTeX view are unchanged.

Bug: cea-hpc#98
Signed-off-by: Vincent BLAIN <[email protected]>
  • Loading branch information
vblainobeo committed Oct 12, 2022
1 parent 033d13a commit c4b7812
Show file tree
Hide file tree
Showing 47 changed files with 1,095 additions and 1,083 deletions.
6 changes: 3 additions & 3 deletions plugins/fr.cea.nabla.ir/model/Ir.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IrType" eSuperTypes="#//IrAnnotable"/>
<eClassifiers xsi:type="ecore:EEnum" name="PrimitiveType">
<eLiterals name="Int" value="1" literal=""/>
<eLiterals name="Real" value="2" literal=""/>
<eLiterals name="Bool" value="3" literal=""/>
<eLiterals name="Int" value="1" literal="int"/>
<eLiterals name="Real" value="2" literal="real"/>
<eLiterals name="Bool" value="3" literal="bool"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BaseType" eSuperTypes="#//IrType">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="primitive" lowerBound="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ with Math.*;
with CartesianMesh2D.*;

// Simulation options
stopTime;
maxIterations;

let u0 = 1.0;
let [2] vectOne = [2](1.0);
let δt = 0.001;
t;
[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
u{cells}; // Temperature
V{cells}; // Volume of cells
D{cells}; // Cell centered conductivity
faceLength{faces}, faceConductivity{faces};
α{cells, cells};
real stopTime;
int maxIterations;

let real u0 = 1.0;
let real[2] vectOne = real[2](1.0);
let real δt = 0.001;
real t;
real[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
real u{cells}; // Temperature
real V{cells}; // Volume of cells
real D{cells}; // Cell centered conductivity
real faceLength{faces}, faceConductivity{faces};
real α{cells, cells};

iterate n while (t^{n+1} < stopTime && n+1 < maxIterations);

Expand All @@ -48,9 +48,9 @@ ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈ce

// Assembling of the diffusion matrix
ComputeAlphaCoeff: ∀c∈cells(), {
let αDiag = 0.0;
let real αDiag = 0.0;
∀d∈neighbourCells(c), ∀f∈commonFace(c,d), {
let αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
let real αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
α{c, d} = αExtraDiag;
αDiag = αDiag + αExtraDiag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,50 @@ with Math.*;
with CartesianMesh2D.*;

// Only for 2D vectors
def perp: [2] → [2], (a) → return [ a[1], -a[0] ];
def perp: real[2] → real[2], (a) → return [ a[1], -a[0] ];

def trace: l | [l,l] → , (a) → {
let result = 0.0;
def trace: l | real[l,l] → real, (a) → {
let real result = 0.0;
∀ ia ∈ [0;l[, result = result + a[ia, ia];
return result;
}

def tensProduct: l | [l] × [l] → [l,l], (a, b) → {
[l,l] result;
def tensProduct: l | real[l] × real[l] → real[l,l], (a, b) → {
real[l,l] result;
∀ ia ∈ [0;l[,
∀ ib ∈ [0;l[,
result[ia,ib] = a[ia]*b[ib];
return result;
}

// Only for 2x2 matrices
def inverse: [2,2] → [2,2], (a) → {
let alpha = 1.0 / det(a);
def inverse: real[2,2] → real[2,2], (a) → {
let real alpha = 1.0 / det(a);
return [[ a[1,1] * alpha, -a[0,1] * alpha ],
[-a[1,0] * alpha, a[0,0] * alpha ]];
}

// Simulation options
stopTime;
maxIterations;

let γ = 1.4;
let xInterface = 0.5;
let δtCfl = 0.4;
let ρIniZg = 1.0;
let ρIniZd = 0.125;
let pIniZg = 1.0;
let pIniZd = 0.1;
t, δt;
[2] X{nodes}, b{nodes}, bt{nodes};
[2,2] Ar{nodes}, Mt{nodes};
[2] ur{nodes};
c{cells}, m{cells}, p{cells}, ρ{cells}, e{cells}, E{cells}, V{cells};
δtj{cells};
[2] uj{cells};
l{cells, nodesOfCell};
[2] Cjr_ic{cells, nodesOfCell}, C{cells, nodesOfCell}, F{cells, nodesOfCell};
[2,2] Ajr{cells, nodesOfCell};
real stopTime;
int maxIterations;

let real γ = 1.4;
let real xInterface = 0.5;
let real δtCfl = 0.4;
let real ρIniZg = 1.0;
let real ρIniZd = 0.125;
let real pIniZg = 1.0;
let real pIniZd = 0.1;
real t, δt;
real[2] X{nodes}, b{nodes}, bt{nodes};
real[2,2] Ar{nodes}, Mt{nodes};
real[2] ur{nodes};
real c{cells}, m{cells}, p{cells}, ρ{cells}, e{cells}, E{cells}, V{cells};
real δtj{cells};
real[2] uj{cells};
real l{cells, nodesOfCell};
real[2] Cjr_ic{cells, nodesOfCell}, C{cells, nodesOfCell}, F{cells, nodesOfCell};
real[2,2] Ajr{cells, nodesOfCell};

iterate n while (t^{n+1} < stopTime && n+1 < maxIterations);

Expand All @@ -68,16 +68,16 @@ IniCjrIc: ∀j∈cells(), ∀r∈nodesOfCell(j),
Cjr_ic{j,r} = 0.5 * perp(X^{n=0}{r+1} - X^{n=0}{r-1});

Initialize: ∀j∈cells(), {
ρ_ic, p_ic;
let [2] center = 0.25 * ∑{r∈nodesOfCell(j)}(X^{n=0}{r});
real ρ_ic, p_ic;
let real[2] center = 0.25 * ∑{r∈nodesOfCell(j)}(X^{n=0}{r});
if (center[0] < xInterface) {
ρ_ic = ρIniZg;
p_ic = pIniZg;
} else {
ρ_ic = ρIniZd;
p_ic = pIniZd;
}
let V_ic = 0.5 * ∑{r∈nodesOfCell(j)}(dot(Cjr_ic{j,r}, X^{n=0}{r}));
let real V_ic = 0.5 * ∑{r∈nodesOfCell(j)}(dot(Cjr_ic{j,r}, X^{n=0}{r}));
m{j} = ρ_ic * V_ic; // m is a constant
p{j} = p_ic;
ρ{j} = ρ_ic;
Expand Down Expand Up @@ -111,20 +111,20 @@ ComputeMt: ∀r∈nodes("InnerNodes"), Mt{r} = Ar{r};
ComputeBt: ∀r∈nodes("InnerNodes"), bt{r} = b{r};

ComputeBoundaryConditions: {
let [2,2] I = [ [1.0, 0.0], [0.0, 1.0] ];
let real[2,2] I = [ [1.0, 0.0], [0.0, 1.0] ];

// Y boundary conditions (must be done before X)
∀r∈nodes("TopNodes"), {
let [2] N = [0.0, 1.0];
let [2,2] NxN = tensProduct(N,N);
let [2,2] IcP = I - NxN;
let real[2] N = [0.0, 1.0];
let real[2,2] NxN = tensProduct(N,N);
let real[2,2] IcP = I - NxN;
bt{r} = matVectProduct(IcP, b{r});
Mt{r} = IcP * (Ar{r} * IcP) + NxN*trace(Ar{r});
}
∀r∈nodes("BottomNodes"), {
let [2] N = [0.0, -1.0];
let [2,2] NxN = tensProduct(N,N);
let [2,2] IcP = I - NxN;
let real[2] N = [0.0, -1.0];
let real[2,2] NxN = tensProduct(N,N);
let real[2,2] IcP = I - NxN;
bt{r} = matVectProduct(IcP, b{r});
Mt{r} = IcP * (Ar{r} * IcP) + NxN*trace(Ar{r});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ with Math.*;
with CartesianMesh2D.*;

// Simulation options
stopTime;
maxIterations;
real stopTime;
int maxIterations;

let PI = 3.1415926;
let α = 1.0;
let δt = 0.001;
t;
[2] X{nodes}, center{cells};
u{cells}, V{cells}, f{cells}, outgoingFlux{cells}, surface{faces};
let real PI = 3.1415926;
let real α = 1.0;
let real δt = 0.001;
real t;
real[2] X{nodes}, center{cells};
real u{cells}, V{cells}, f{cells}, outgoingFlux{cells}, surface{faces};

iterate n while (t^{n+1} < stopTime && n+1 < maxIterations);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ with LinearAlgebra.*;
with CartesianMesh2D.*;

// Simulation options
stopTime;
maxIterations;

let u0 = 1.0;
let [2] vectOne = [2](1.0);
let δt = 0.001;
t;
[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
u{cells}; // Temperature
V{cells}; // Volume of cells
D{cells}; // Cell centered conductivity
faceLength{faces}, faceConductivity{faces};
α{cells, cells};
real stopTime;
int maxIterations;

let real u0 = 1.0;
let real[2] vectOne = real[2](1.0);
let real δt = 0.001;
real t;
real[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
real u{cells}; // Temperature
real V{cells}; // Volume of cells
real D{cells}; // Cell centered conductivity
real faceLength{faces}, faceConductivity{faces};
real α{cells, cells};

iterate n while (t^{n+1} < stopTime && n+1 < maxIterations);

Expand All @@ -49,9 +49,9 @@ ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈ce

// Assembling of the diffusion matrix
ComputeAlphaCoeff: ∀c∈cells(), {
let αDiag = 0.0;
let real αDiag = 0.0;
∀d∈neighbourCells(c), ∀f∈commonFace(c,d), {
let αExtraDiag = - δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
let real αExtraDiag = - δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
α{c, d} = αExtraDiag;
αDiag = αDiag + αExtraDiag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ module IterativeHeatEquation;
with Math.*;
with CartesianMesh2D.*;

def check: , (a) → if (a) return true; else exit "Assertion failed";
def check: boolbool, (a) → if (a) return true; else exit "Assertion failed";

// Simulation options
stopTime;
maxIterations;
real stopTime;
int maxIterations;

let u0 = 1.0;
let [2] vectOne = [2](1.0);
let maxIterationsK = 1000;
let ε = 1.0e-8;
let δt = 0.001;
t;
[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
u{cells}; // Temperature
V{cells}; // Volume of cells
D{cells}; // Cell centered conductivity
faceLength{faces}, faceConductivity{faces};
α{cells, cells};
residual;
let real u0 = 1.0;
let real[2] vectOne = real[2](1.0);
let int maxIterationsK = 1000;
let real ε = 1.0e-8;
let real δt = 0.001;
real t;
real[2] X{nodes}, Xc{cells}; // Position of nodes and cells center of gravity
real u{cells}; // Temperature
real V{cells}; // Volume of cells
real D{cells}; // Cell centered conductivity
real faceLength{faces}, faceConductivity{faces};
real α{cells, cells};
real residual;

iterate n while (t^{n+1} < stopTime && n+1 < maxIterations),
k while (residual > ε && check(k+1 < maxIterationsK));
Expand All @@ -54,9 +54,9 @@ ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈ce

// Assembling of the diffusion matrix
ComputeAlphaCoeff: ∀c∈cells(), {
let αDiag = 0.0;
let real αDiag = 0.0;
∀d∈neighbourCells(c), ∀f∈commonFace(c,d), {
let αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
let real αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d});
α{c, d} = αExtraDiag;
αDiag = αDiag + αExtraDiag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ class NewNablaProjectWizard extends Wizard implements INewWizard

with CartesianMesh2D.*;

let maxIter = 200;
let maxTime = 1.0;
let int maxIter = 200;
let real maxTime = 1.0;

t, δt;
[2] X{nodes};
e{nodes};
real t, δt;
real[2] X{nodes};
real e{nodes};

iterate n while (n+1 < maxIter && t^{n+1} < maxTime);
'''
Expand All @@ -270,7 +270,7 @@ class NewNablaProjectWizard extends Wizard implements INewWizard
'''
extension «extensionName»;

def myMatVectProduct: x, y | [x,y] × [y] → [x];
def myMatVectProduct: x, y | real[x,y] × real[y] → real[x];
'''
private def getManifestContent()
Expand Down
6 changes: 3 additions & 3 deletions plugins/fr.cea.nabla/model/generated/Nabla.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@
eType="#//Expression" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="PrimitiveType">
<eLiterals name="Int" literal=""/>
<eLiterals name="Real" value="1" literal=""/>
<eLiterals name="Bool" value="2" literal=""/>
<eLiterals name="Int" literal="int"/>
<eLiterals name="Real" value="1" literal="real"/>
<eLiterals name="Bool" value="2" literal="bool"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BaseType">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="primitive" eType="#//PrimitiveType"/>
Expand Down
12 changes: 6 additions & 6 deletions plugins/fr.cea.nabla/nablalib/Assert.n
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
*******************************************************************************/
extension Assert;

def assertEquals: × , (expected, actual) →
def assertEquals: int × intbool, (expected, actual) →
{
let ret = (expected == actual);
let bool ret = (expected == actual);
if (!ret) exit "** Assertion failed";
return ret;
}

def assertEquals: × , (expected, actual) →
def assertEquals: real × realbool, (expected, actual) →
{
let ret = (expected == actual);
let bool ret = (expected == actual);
if (!ret) exit "** Assertion failed";
return ret;
}

def assertEquals: x | [x] × [x] → , (expected, actual) →
def assertEquals: x | int[x] × int[x] → bool, (expected, actual) →
{
∀i∈[0;x[,
if (expected[i] != actual[i])
exit "** Assertion failed";
return true;
}

def assertEquals: x | [x] × [x] → , (expected, actual) →
def assertEquals: x | real[x] × real[x] → bool, (expected, actual) →
{
∀i∈[0;x[,
if (expected[i] != actual[i])
Expand Down
Loading

0 comments on commit c4b7812

Please sign in to comment.