From e628d64202b1d0c1d3c85e8c9a184e6d244bd3cf Mon Sep 17 00:00:00 2001 From: Vincent BLAIN Date: Thu, 6 Oct 2022 10:48:44 +0200 Subject: [PATCH] [98] Variable modifications Remove possibility to create variables using unicode caracters (greek alphabet, sum, prod and sqrt symbols). Use of LaTeX keywoed instead of unicode for the LaTeX view Generated code and LaTeX view are unchanged or equivalent. Bug: https://github.com/cea-hpc/NabLab/issues/98 Signed-off-by: Vincent BLAIN --- .../NablaIdeContentProposalProvider.xtend | 15 -- .../generator/java/JobContentProvider.xtend | 122 +++++++-------- .../generator/python/JobContentProvider.xtend | 144 +++++++++--------- .../nabla/ir/interpreter/JobInterpreter.xtend | 4 +- .../transformers/IrTransformationUtils.xtend | 1 - .../ir/transformers/ReplaceUtf8Chars.xtend | 86 ----------- .../ExplicitHeatEquation.n | 28 ++-- .../ExplicitHeatEquation.ngen | 2 +- .../NabLabExamples/src/glace2d/Glace2d.n | 58 +++---- .../NabLabExamples/src/glace2d/Glace2d.ngen | 4 +- .../src/heatequation/HeatEquation.n | 18 +-- .../src/heatequation/HeatEquation.ngen | 2 +- .../ImplicitHeatEquation.n | 28 ++-- .../ImplicitHeatEquation.ngen | 2 +- .../IterativeHeatEquation.n | 32 ++-- .../IterativeHeatEquation.ngen | 2 +- .../contentassist/NablaProposalProvider.xtend | 22 +-- .../ui/wizards/NewNablaProjectWizard.xtend | 2 +- plugins/fr.cea.nabla/nablalib/Math.n | 16 +- .../src/fr/cea/nabla/LatexLabelServices.xtend | 95 ++++++++---- .../fr.cea.nabla/src/fr/cea/nabla/Nabla.xtext | 2 - .../generator/NablagenFileGenerator.xtend | 2 +- .../generator/ir/IrItemIndexFactory.xtend | 4 +- .../src-gen/depthinit/DepthInitDefault.json | 2 +- tests/DepthInit/src/depthinit/DepthInit.json | 2 +- tests/DepthInit/src/depthinit/DepthInit.n | 6 +- tests/DepthInit/src/depthinit/DepthInit.ngen | 2 +- .../sauv/gmds/ParallelWhiteheatKmds.cpp | 24 +-- .../sauv/gmds/ParallelWhiteheatKokkos.cpp | 20 +-- .../NabLabDrafts/sauv/gmds/glace2d/Glace2d.cc | 34 ++--- .../NabLabDrafts/sauv/gmds/glace2d/Glace2d.h | 10 +- tests/NabLabDrafts/src/reduction/Reduction.n | 6 +- .../NabLabDrafts/src/reduction/Reduction.ngen | 2 +- tests/NabLabTests/src/hydroremap/Hydro.n | 2 +- .../NabLabTests/src/hydroremap/HydroRemap.arc | 2 +- .../src/hydroremap/HydroRemap.json | 2 +- .../src/hydroremap/HydroRemap.ngen | 2 +- tests/NabLabTests/src/iteration/Iteration.n | 4 +- .../NabLabTests/src/iteration/Iteration.ngen | 2 +- tests/NabLabTests/src/variables/Variables.n | 2 +- .../NabLabTests/src/variables/Variables.ngen | 2 +- .../nabla/tests/IteratorExtensionsTest.xtend | 10 +- .../nabla/tests/NablaScopeProviderTest.xtend | 52 +++---- .../tests/NablagenScopeProviderTest.xtend | 14 +- .../src/fr/cea/nabla/tests/TestUtils.xtend | 4 +- .../AbstractExpressionInterpreterTest.xtend | 14 +- .../AbstractInstructionInterpreterTest.xtend | 2 +- .../AbstractJobInterpreterTest.xtend | 2 +- .../AbstractOptionsInterpreterTest.xtend | 2 +- .../ArgOrVarTypeProviderTest.xtend | 6 +- .../ExpressionTypeProviderTest.xtend | 4 +- .../tests/validation/BasicValidatorTest.xtend | 6 +- .../validation/NablagenValidatorTest.xtend | 14 +- 53 files changed, 426 insertions(+), 521 deletions(-) delete mode 100644 plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/ReplaceUtf8Chars.xtend diff --git a/plugins/fr.cea.nabla.ide/src/fr/cea/nabla/ide/contentassist/NablaIdeContentProposalProvider.xtend b/plugins/fr.cea.nabla.ide/src/fr/cea/nabla/ide/contentassist/NablaIdeContentProposalProvider.xtend index e5171e390..e7a71555e 100644 --- a/plugins/fr.cea.nabla.ide/src/fr/cea/nabla/ide/contentassist/NablaIdeContentProposalProvider.xtend +++ b/plugins/fr.cea.nabla.ide/src/fr/cea/nabla/ide/contentassist/NablaIdeContentProposalProvider.xtend @@ -10,11 +10,9 @@ package fr.cea.nabla.ide.contentassist import com.google.inject.Inject -import fr.cea.nabla.ir.transformers.ReplaceUtf8Chars import fr.cea.nabla.services.NablaGrammarAccess import org.eclipse.xtext.RuleCall import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext -import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry import org.eclipse.xtext.ide.editor.contentassist.IIdeContentProposalAcceptor import org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider @@ -30,23 +28,10 @@ class NablaIdeContentProposalProvider extends IdeContentProposalProvider case simpleVarRule, case connectivityVarRule: { - buildGrecLetterProposals(context, acceptor) } default: super._createProposals(ruleCall, context, acceptor) } } - private def void buildGrecLetterProposals(ContentAssistContext context, IIdeContentProposalAcceptor acceptor) - { - for (p : ReplaceUtf8Chars.UTF8Chars.keySet) - { - val trueEntry = new ContentAssistEntry => [ - prefix = context.prefix - proposal = p - ] - acceptor.accept(trueEntry, proposalPriorities.getDefaultPriority(trueEntry)) - } - } - } diff --git a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/java/JobContentProvider.xtend b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/java/JobContentProvider.xtend index 1147fe4c4..5f30d2815 100644 --- a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/java/JobContentProvider.xtend +++ b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/java/JobContentProvider.xtend @@ -1,28 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2022 CEA - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * Contributors: see AUTHORS file - *******************************************************************************/ -package fr.cea.nabla.ir.generator.java - -import fr.cea.nabla.ir.IrUtils -import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob -import fr.cea.nabla.ir.ir.IrRoot -import fr.cea.nabla.ir.ir.Job - -import static extension fr.cea.nabla.ir.JobCallerExtensions.* -import static extension fr.cea.nabla.ir.generator.Utils.* -import static extension fr.cea.nabla.ir.generator.java.ExpressionContentProvider.* -import static extension fr.cea.nabla.ir.generator.java.InstructionContentProvider.* - +/******************************************************************************* + * Copyright (c) 2022 CEA + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * Contributors: see AUTHORS file + *******************************************************************************/ +package fr.cea.nabla.ir.generator.java + +import fr.cea.nabla.ir.IrUtils +import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob +import fr.cea.nabla.ir.ir.IrRoot +import fr.cea.nabla.ir.ir.Job + +import static extension fr.cea.nabla.ir.JobCallerExtensions.* +import static extension fr.cea.nabla.ir.generator.Utils.* +import static extension fr.cea.nabla.ir.generator.java.ExpressionContentProvider.* +import static extension fr.cea.nabla.ir.generator.java.InstructionContentProvider.* + class JobContentProvider { static def getContent(Job it) - ''' + ''' «comment» protected void «codeName»() { @@ -31,45 +31,45 @@ class JobContentProvider ''' private static def dispatch CharSequence getInnerContent(Job it) - ''' + ''' «instruction.innerContent» ''' - - private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) - ''' - «val itVar = iterationCounter.codeName» - «val irRoot = IrUtils.getContainerOfType(it, IrRoot)» - «val tn = irRoot.currentTimeVariable.codeName» - «val deltat = irRoot.timeStepVariable.codeName» - «val ppInfo = irRoot.postProcessing» - «itVar» = 0; - boolean continueLoop = true; - do - { - «itVar»++; - «IF caller.main» - System.out.printf("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - deltat: %5.5f\n", «itVar», «tn», «deltat»); - «IF ppInfo !== null» - if («ppInfo.periodReference.codeName» >= «ppInfo.lastDumpVariable.codeName» + «ppInfo.periodValue.codeName») - dumpVariables(«itVar»); - «ENDIF» - «ELSE» - System.out.printf("Start iteration «iterationCounter.name»: %5d\n", «itVar»); - «ENDIF» - - «FOR j : calls» - «j.callName»(); // @«j.at» - «ENDFOR» - - // Evaluate loop condition with variables at time n - continueLoop = («whileCondition.content»); - - «instruction.innerContent» - } while (continueLoop); - «IF caller.main» - - System.out.printf("FINAL TIME: %5.5f - deltat: %5.5f\n", «tn», «deltat»); - «IF ppInfo !== null»dumpVariables(«itVar»+1);«ENDIF» - «ENDIF» - ''' + + private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) + ''' + «val itVar = iterationCounter.codeName» + «val irRoot = IrUtils.getContainerOfType(it, IrRoot)» + «val tn = irRoot.currentTimeVariable.codeName» + «val delta_t = irRoot.timeStepVariable.codeName» + «val ppInfo = irRoot.postProcessing» + «itVar» = 0; + boolean continueLoop = true; + do + { + «itVar»++; + «IF caller.main» + System.out.printf("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - delta_t: %5.5f\n", «itVar», «tn», «delta_t»); + «IF ppInfo !== null» + if («ppInfo.periodReference.codeName» >= «ppInfo.lastDumpVariable.codeName» + «ppInfo.periodValue.codeName») + dumpVariables(«itVar»); + «ENDIF» + «ELSE» + System.out.printf("Start iteration «iterationCounter.name»: %5d\n", «itVar»); + «ENDIF» + + «FOR j : calls» + «j.callName»(); // @«j.at» + «ENDFOR» + + // Evaluate loop condition with variables at time n + continueLoop = («whileCondition.content»); + + «instruction.innerContent» + } while (continueLoop); + «IF caller.main» + + System.out.printf("FINAL TIME: %5.5f - delta_t: %5.5f\n", «tn», «delta_t»); + «IF ppInfo !== null»dumpVariables(«itVar»+1);«ENDIF» + «ENDIF» + ''' } \ No newline at end of file diff --git a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/python/JobContentProvider.xtend b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/python/JobContentProvider.xtend index 48fbfe17e..d87b72c89 100644 --- a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/python/JobContentProvider.xtend +++ b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/python/JobContentProvider.xtend @@ -1,83 +1,83 @@ -/******************************************************************************* - * Copyright (c) 2022 CEA - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * Contributors: see AUTHORS file - *******************************************************************************/ -package fr.cea.nabla.ir.generator.python - -import fr.cea.nabla.ir.IrUtils -import fr.cea.nabla.ir.generator.Utils -import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob -import fr.cea.nabla.ir.ir.IrRoot -import fr.cea.nabla.ir.ir.Job -import fr.cea.nabla.ir.ir.Variable - -import static extension fr.cea.nabla.ir.JobCallerExtensions.* -import static extension fr.cea.nabla.ir.generator.python.ExpressionContentProvider.* -import static extension fr.cea.nabla.ir.generator.python.InstructionContentProvider.* - +/******************************************************************************* + * Copyright (c) 2022 CEA + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * Contributors: see AUTHORS file + *******************************************************************************/ +package fr.cea.nabla.ir.generator.python + +import fr.cea.nabla.ir.IrUtils +import fr.cea.nabla.ir.generator.Utils +import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob +import fr.cea.nabla.ir.ir.IrRoot +import fr.cea.nabla.ir.ir.Job +import fr.cea.nabla.ir.ir.Variable + +import static extension fr.cea.nabla.ir.JobCallerExtensions.* +import static extension fr.cea.nabla.ir.generator.python.ExpressionContentProvider.* +import static extension fr.cea.nabla.ir.generator.python.InstructionContentProvider.* + class JobContentProvider { static def getContent(Job it) - ''' - """ - Job «Utils.getCodeName(it)» called @«at» in «Utils.getCodeName(caller)» method. - In variables: «FOR v : inVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» - Out variables: «FOR v : outVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» - """ + ''' + """ + Job «Utils.getCodeName(it)» called @«at» in «Utils.getCodeName(caller)» method. + In variables: «FOR v : inVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» + Out variables: «FOR v : outVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» + """ def _«Utils.getCodeName(it)»(self): «innerContent» ''' private static def dispatch CharSequence getInnerContent(Job it) - ''' + ''' «instruction.innerContent» ''' - - private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) - ''' - «val itVar = Utils.getCodeName(iterationCounter)» - «val irRoot = IrUtils.getContainerOfType(it, IrRoot)» - «val tn = Utils.getCodeName(irRoot.currentTimeVariable)» - «val deltat = Utils.getCodeName(irRoot.timeStepVariable)» - «val ppInfo = irRoot.postProcessing» - self.«itVar» = 0 - «IF irRoot.currentTimeVariable.needDefinition»self.«tn» = 0.0«ENDIF» - «IF irRoot.timeStepVariable.needDefinition»self.«deltat» = 0.0«ENDIF» - continueLoop = True - while continueLoop: - self.«itVar» += 1 - «IF caller.main» - print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - deltat: %5.5f\n" % (self.«itVar», self.«tn», self.«deltat»)) - «IF ppInfo !== null» - if (self.«Utils.getCodeName(ppInfo.periodReference)» >= self.«Utils.getCodeName(ppInfo.lastDumpVariable)» + self.«Utils.getCodeName(ppInfo.periodValue)»): - self.__dumpVariables(self.«itVar») - «ENDIF» - «ELSE» - print("Start iteration «iterationCounter.name»: %5d\n" % (self.«itVar»)) - «ENDIF» - - «FOR j : calls» - «PythonGeneratorUtils.getCallName(j)»() # @«j.at» - «ENDFOR» - - # Evaluate loop condition with variables at time n - continueLoop = («whileCondition.content») - - «instruction.innerContent» - «IF caller.main» - - print("FINAL TIME: %5.5f - deltat: %5.5f\n" % (self.«tn», self.«deltat»)) - «IF ppInfo !== null»self.__dumpVariables(self.«itVar»+1);«ENDIF» - «ENDIF» - ''' - - private static def needDefinition(Variable v) - { - !v.option && v.defaultValue === null - } + + private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) + ''' + «val itVar = Utils.getCodeName(iterationCounter)» + «val irRoot = IrUtils.getContainerOfType(it, IrRoot)» + «val tn = Utils.getCodeName(irRoot.currentTimeVariable)» + «val delta_t = Utils.getCodeName(irRoot.timeStepVariable)» + «val ppInfo = irRoot.postProcessing» + self.«itVar» = 0 + «IF irRoot.currentTimeVariable.needDefinition»self.«tn» = 0.0«ENDIF» + «IF irRoot.timeStepVariable.needDefinition»self.«delta_t» = 0.0«ENDIF» + continueLoop = True + while continueLoop: + self.«itVar» += 1 + «IF caller.main» + print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - delta_t: %5.5f\n" % (self.«itVar», self.«tn», self.«delta_t»)) + «IF ppInfo !== null» + if (self.«Utils.getCodeName(ppInfo.periodReference)» >= self.«Utils.getCodeName(ppInfo.lastDumpVariable)» + self.«Utils.getCodeName(ppInfo.periodValue)»): + self.__dumpVariables(self.«itVar») + «ENDIF» + «ELSE» + print("Start iteration «iterationCounter.name»: %5d\n" % (self.«itVar»)) + «ENDIF» + + «FOR j : calls» + «PythonGeneratorUtils.getCallName(j)»() # @«j.at» + «ENDFOR» + + # Evaluate loop condition with variables at time n + continueLoop = («whileCondition.content») + + «instruction.innerContent» + «IF caller.main» + + print("FINAL TIME: %5.5f - delta_t: %5.5f\n" % (self.«tn», self.«delta_t»)) + «IF ppInfo !== null»self.__dumpVariables(self.«itVar»+1);«ENDIF» + «ENDIF» + ''' + + private static def needDefinition(Variable v) + { + !v.option && v.defaultValue === null + } } \ No newline at end of file diff --git a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/interpreter/JobInterpreter.xtend b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/interpreter/JobInterpreter.xtend index 034c2684a..d46a6f61c 100644 --- a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/interpreter/JobInterpreter.xtend +++ b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/interpreter/JobInterpreter.xtend @@ -56,7 +56,7 @@ class JobInterpreter if (caller.main) { - val log = String.format(Locale::ENGLISH, "START ITERATION %1$s: %2$5d - t: %3$.5f - deltat: %4$.5f", + val log = String.format(Locale::ENGLISH, "START ITERATION %1$s: %2$5d - t: %3$.5f - delta_t: %4$.5f", iterationCounter.name, iteration, context.getReal(context.ir.currentTimeVariable), @@ -96,7 +96,7 @@ class JobInterpreter if (caller.main) { // force a last trace and output at the end - val log = String.format(Locale::ENGLISH, "FINAL TIME: %1$.5f - deltat: %2$.5f", + val log = String.format(Locale::ENGLISH, "FINAL TIME: %1$.5f - delta_t: %2$.5f", context.getReal(context.ir.currentTimeVariable), context.getReal(context.ir.timeStepVariable)) context.logFine(log) diff --git a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/IrTransformationUtils.xtend b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/IrTransformationUtils.xtend index e51c7becc..1752090eb 100644 --- a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/IrTransformationUtils.xtend +++ b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/IrTransformationUtils.xtend @@ -19,7 +19,6 @@ class IrTransformationUtils static def getCommonTransformation(boolean replaceAllReductions) { #[ - new ReplaceUtf8Chars, new ReplaceReductions(replaceAllReductions), new ReplaceAffectations, new CreateArrayOperators, diff --git a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/ReplaceUtf8Chars.xtend b/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/ReplaceUtf8Chars.xtend deleted file mode 100644 index aad5f3f28..000000000 --- a/plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/transformers/ReplaceUtf8Chars.xtend +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 CEA - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * Contributors: see AUTHORS file - *******************************************************************************/ -package fr.cea.nabla.ir.transformers - -import fr.cea.nabla.ir.ir.ArgOrVar -import fr.cea.nabla.ir.ir.DefaultExtensionProvider -import fr.cea.nabla.ir.ir.Function -import fr.cea.nabla.ir.ir.IrRoot -import fr.cea.nabla.ir.ir.ReductionInstruction -import fr.cea.nabla.ir.ir.TimeVariable - -import static extension fr.cea.nabla.ir.IrRootExtensions.* - -class ReplaceUtf8Chars extends IrTransformationStep -{ - public static val UTF8Chars = #{ - '\u03B1' -> 'alpha', - '\u03B2' -> 'beta', - '\u03B3' -> 'gamma', - '\u03B4' -> 'delta', - '\u03B5' -> 'epsilon', - '\u03B6' -> 'zeta', - '\u03B7' -> 'eta', - '\u03B8' -> 'theta', - '\u03B9' -> 'iota', - '\u03BA' -> 'kappa', - '\u03BB' -> 'lambda', - '\u03BC' -> 'mu', - '\u03BD' -> 'nu', - '\u03BE' -> 'xi', - '\u03BF' -> 'omicron', - '\u03C0' -> 'pi', - '\u03C1' -> 'rho', - '\u03C3' -> 'sigma', - '\u03C4' -> 'tau', - '\u03C5' -> 'upsilon', - '\u03C6' -> 'phi', - '\u03C7' -> 'chi', - '\u03C8' -> 'psi', - '\u03C9' -> 'omega', - '\u2126' -> 'bigomega' - } - - override getDescription() - { - "Replace UTF8 characters in function, variable and job names by ASCII characters" - } - - override transform(IrRoot ir, (String)=>void traceNotifier) - { - for (v : ir.eAllContents.filter(ArgOrVar).toIterable) - { - v.name = v.name.noUtf8 - if (v instanceof TimeVariable) - v.originName = v.originName.noUtf8 - } - ir.eAllContents.filter(ReductionInstruction).forEach[x | x.result.name = x.result.name.noUtf8] - ir.eAllContents.filter(Function).forEach[x | x.name = x.name.noUtf8] - ir.jobs.forEach[x | x.name = x.name.noUtf8] - ir.mesh.connectivities.forEach[x | x.name = x.name.noUtf8] - } - - override transform(DefaultExtensionProvider dep, (String)=>void traceNotifier) - { - dep.functions.forEach[x | x.name = x.name.noUtf8] - } - - private def getNoUtf8(String name) - { - var n = name - for (c : UTF8Chars.entrySet) - n = n.replace(c.key, c.value) - - n = n.replace('\u221A', 'sqrt') - n = n.replace('\u2211', 'sum') - n = n.replace('\u220f', 'prod') - return n - } -} diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.n b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.n index 3c8f1be87..82033edcc 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.n +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.n @@ -18,20 +18,20 @@ int maxIterations; let real u0 = 1.0; let real[2] vectOne = real[2](1.0); -let real δt = 0.001; +let real delta_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 alpha{cells, cells}; iterate n while (t^{n+1} < stopTime && n+1 < maxIterations); InitTime: t^{n=0} = 0.0; -InitXc: ∀c∈cells(), Xc{c} = 0.25 * ∑{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms +InitXc: ∀c∈cells(), Xc{c} = 0.25 * sum{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms InitU: ∀c∈cells(), if (norm(Xc{c} - vectOne) < 0.5) @@ -41,21 +41,21 @@ InitU: ∀c∈cells(), InitD: ∀c∈cells(), D{c} = 1.0; -ComputeDeltaTn: δt = Min{c∈cells()}(V{c}/D{c}) * 0.24; -ComputeV: ∀c∈cells(), V{c} = 0.5 * ∑{p∈nodesOfCell(c)}(det(X{p}, X{p+1})); -ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * ∑{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); -ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈cellsOfFace(f)}(D{c1}) / ∑{c2∈cellsOfFace(f)}(D{c2}); +ComputeDeltaTn: delta_t = Min{c∈cells()}(V{c}/D{c}) * 0.24; +ComputeV: ∀c∈cells(), V{c} = 0.5 * sum{p∈nodesOfCell(c)}(det(X{p}, X{p+1})); +ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * sum{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); +ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * prod{c1∈cellsOfFace(f)}(D{c1}) / sum{c2∈cellsOfFace(f)}(D{c2}); // Assembling of the diffusion matrix ComputeAlphaCoeff: ∀c∈cells(), { - let real αDiag = 0.0; + let real alpha_Diag = 0.0; ∀d∈neighbourCells(c), ∀f∈commonFace(c,d), { - let real αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); - α{c, d} = αExtraDiag; - αDiag = αDiag + αExtraDiag; + let real alpha_ExtraDiag = delta_t / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); + alpha{c, d} = alpha_ExtraDiag; + alpha_Diag = alpha_Diag + alpha_ExtraDiag; } - α{c, c} = 1 - αDiag; + alpha{c, c} = 1 - alpha_Diag; } -UpdateU: ∀c∈cells(), u^{n+1}{c} = α{c, c} * u^{n}{c} + ∑{d∈neighbourCells(c)} (α{c, d} * u^{n}{d}); -ComputeTn: t^{n+1} = t^{n} + δt; +UpdateU: ∀c∈cells(), u^{n+1}{c} = alpha{c, c} * u^{n}{c} + sum{d∈neighbourCells(c)} (alpha{c, d} * u^{n}{d}); +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.ngen b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.ngen index a0c57d5c2..64f1250cb 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.ngen +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/explicitheatequation/ExplicitHeatEquation.ngen @@ -13,7 +13,7 @@ MainModule ExplicitHeatEquation explicitHeatEquation { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterations; timeMax = stopTime; } diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.n b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.n index 3b8cd3820..682ca4a51 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.n +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.n @@ -40,19 +40,19 @@ def inverse: real[2,2] → real[2,2], (a) → { real stopTime; int maxIterations; -let real γ = 1.4; +let real gamma = 1.4; let real xInterface = 0.5; -let real δtCfl = 0.4; -let real ρIniZg = 1.0; -let real ρIniZd = 0.125; +let real delta_tCfl = 0.4; +let real rho_IniZg = 1.0; +let real rho_IniZd = 0.125; let real pIniZg = 1.0; let real pIniZd = 0.1; -real t, δt; +real t, delta_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 c{cells}, m{cells}, p{cells}, rho{cells}, e{cells}, E{cells}, V{cells}; +real delta_tj{cells}; real[2] uj{cells}; real l{cells, nodesOfCell}; real[2] Cjr_ic{cells, nodesOfCell}, C{cells, nodesOfCell}, F{cells, nodesOfCell}; @@ -68,20 +68,20 @@ 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(), { - real ρ_ic, p_ic; - let real[2] center = 0.25 * ∑{r∈nodesOfCell(j)}(X^{n=0}{r}); + real rho_ic, p_ic; + let real[2] center = 0.25 * sum{r∈nodesOfCell(j)}(X^{n=0}{r}); if (center[0] < xInterface) { - ρ_ic = ρIniZg; + rho_ic = rho_IniZg; p_ic = pIniZg; } else { - ρ_ic = ρIniZd; + rho_ic = rho_IniZd; p_ic = pIniZd; } - 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 + let real V_ic = 0.5 * sum{r∈nodesOfCell(j)}(dot(Cjr_ic{j,r}, X^{n=0}{r})); + m{j} = rho_ic * V_ic; // m is a constant p{j} = p_ic; - ρ{j} = ρ_ic; - E^{n}{j} = p_ic / ((γ-1.0) * ρ_ic); + rho{j} = rho_ic; + E^{n}{j} = p_ic / ((gamma-1.0) * rho_ic); uj^{n}{j} = [0.0, 0.0]; } @@ -90,23 +90,23 @@ Initialize: ∀j∈cells(), { // ************************************************************* ComputeCjr: ∀j∈cells(), ∀r∈nodesOfCell(j), C{j,r} = 0.5 * perp(X^{n}{r+1} - X^{n}{r-1}); ComputeLjr: ∀j∈cells(), ∀r∈nodesOfCell(j), l{j,r} = norm(C{j,r}); -Computeδtj: ∀j∈cells(), δtj{j} = 2.0 * V{j} / (c{j} * ∑{r∈nodesOfCell(j)}(l{j,r})); +Computedeltatj: ∀j∈cells(), delta_tj{j} = 2.0 * V{j} / (c{j} * sum{r∈nodesOfCell(j)}(l{j,r})); // ************************************************************* -// * Standard EOS rules: m, ρ, c, p, e +// * Standard EOS rules: m, rho, c, p, e // ************************************************************* -ComputeDensity: ∀j∈cells(), ρ{j} = m{j} / V{j}; -ComputeEOSp: ∀j∈cells(), p{j} = (γ-1.0) * ρ{j} * e{j}; +ComputeDensity: ∀j∈cells(), rho{j} = m{j} / V{j}; +ComputeEOSp: ∀j∈cells(), p{j} = (gamma-1.0) * rho{j} * e{j}; ComputeInternalEnergy: ∀j∈cells(), e{j} = E^{n}{j} - 0.5 * dot(uj^{n}{j}, uj^{n}{j}); -ComputeEOSc: ∀j∈cells(), c{j} = √(γ * p{j} / ρ{j}); +ComputeEOSc: ∀j∈cells(), c{j} = sqrt(gamma * p{j} / rho{j}); // ************************************************************* // * Cell-centered Godunov Scheme for Lagragian gas dynamics // ************************************************************* -ComputeAjr: ∀j∈cells(), ∀r∈nodesOfCell(j), Ajr{j,r} = ((ρ{j} * c{j}) / l{j,r}) * tensProduct(C{j,r}, C{j,r}); +ComputeAjr: ∀j∈cells(), ∀r∈nodesOfCell(j), Ajr{j,r} = ((rho{j} * c{j}) / l{j,r}) * tensProduct(C{j,r}, C{j,r}); ComputeFjr: ∀j∈cells(), ∀r∈nodesOfCell(j), F{j,r} = p{j} * C{j,r} + matVectProduct(Ajr{j,r}, (uj^{n}{j}-ur{r})); -ComputeAr: ∀r∈nodes(), Ar{r} = ∑{j∈cellsOfNode(r)}(Ajr{j,r}); -ComputeBr: ∀r∈nodes(), b{r} = ∑{j∈cellsOfNode(r)}(p{j} * C{j,r} + matVectProduct(Ajr{j,r}, uj^{n}{j})); +ComputeAr: ∀r∈nodes(), Ar{r} = sum{j∈cellsOfNode(r)}(Ajr{j,r}); +ComputeBr: ∀r∈nodes(), b{r} = sum{j∈cellsOfNode(r)}(p{j} * C{j,r} + matVectProduct(Ajr{j,r}, uj^{n}{j})); ComputeMt: ∀r∈nodes("InnerNodes"), Mt{r} = Ar{r}; ComputeBt: ∀r∈nodes("InnerNodes"), bt{r} = b{r}; @@ -141,13 +141,13 @@ ComputeBoundaryConditions: { } ComputeU: ∀r∈nodes(), ur{r} = matVectProduct(inverse(Mt{r}), bt{r}); -ComputeV: ∀j∈cells(), V{j} = 0.5 * ∑{r∈nodesOfCell(j)}(dot(C{j,r}, X^{n}{r})); +ComputeV: ∀j∈cells(), V{j} = 0.5 * sum{r∈nodesOfCell(j)}(dot(C{j,r}, X^{n}{r})); // ************************************************************* // * Loop iteration (n) // ************************************************************* -ComputeXn: ∀r∈nodes(), X^{n+1}{r} = X^{n}{r} + δt * ur{r}; -ComputeUn: ∀j∈cells(), uj^{n+1}{j} = uj^{n}{j} - (δt/m{j}) * ∑{r∈nodesOfCell(j)}(F{j,r}); -ComputeEn: ∀j∈cells(), E^{n+1}{j} = E^{n}{j} - (δt / m{j}) * ∑{r∈nodesOfCell(j)}(dot(F{j,r}, ur{r})); -ComputeDt: δt = min((δtCfl * Min{j∈cells()}(δtj{j})), (stopTime-t^{n})); -ComputeTn: t^{n+1} = t^{n} + δt; +ComputeXn: ∀r∈nodes(), X^{n+1}{r} = X^{n}{r} + delta_t * ur{r}; +ComputeUn: ∀j∈cells(), uj^{n+1}{j} = uj^{n}{j} - (delta_t/m{j}) * sum{r∈nodesOfCell(j)}(F{j,r}); +ComputeEn: ∀j∈cells(), E^{n+1}{j} = E^{n}{j} - (delta_t / m{j}) * sum{r∈nodesOfCell(j)}(dot(F{j,r}, ur{r})); +ComputeDt: delta_t = min((delta_tCfl * Min{j∈cells()}(delta_tj{j})), (stopTime-t^{n})); +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.ngen b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.ngen index f91018de4..aa83e9feb 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.ngen +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/glace2d/Glace2d.ngen @@ -13,7 +13,7 @@ MainModule Glace2d glace2d { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterations; timeMax = stopTime; } @@ -21,7 +21,7 @@ MainModule Glace2d glace2d VtkOutput { periodReferenceVariable = glace2d.n; - outputVariables = glace2d.ρ as "Density"; + outputVariables = glace2d.rho as "Density"; } //LevelDB diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.n b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.n index e68a90fcb..42bb3ba19 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.n +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.n @@ -17,8 +17,8 @@ real stopTime; int maxIterations; let real PI = 3.1415926; -let real α = 1.0; -let real δt = 0.001; +let real alpha = 1.0; +let real delta_t = 0.001; real t; real[2] X{nodes}, center{cells}; real u{cells}, V{cells}, f{cells}, outgoingFlux{cells}, surface{faces}; @@ -27,10 +27,10 @@ iterate n while (t^{n+1} < stopTime && n+1 < maxIterations); IniTime: t^{n=0} = 0.0; IniF: ∀j∈cells(), f{j} = 0.0; -IniCenter: ∀j∈cells(), center{j} = 0.25 * ∑{r∈nodesOfCell(j)}(X{r}); // only on parallelograms -IniUn: ∀j∈cells(), u^{n}{j} = cos(2 * PI * α * center{j}[0]); -ComputeV: ∀j∈cells(), V{j} = 0.5 * ∑{r∈nodesOfCell(j)}(det(X{r}, X{r+1})); -ComputeSurface: ∀f∈faces(), surface{f} = 0.5 * ∑{r∈nodesOfFace(f)}(norm(X{r}-X{r+1})); -ComputeOutgoingFlux: ∀j1∈cells(), outgoingFlux{j1} = δt/V{j1} * ∑{j2∈neighbourCells(j1)}(∑{cf∈commonFace(j1,j2)}( (u^{n}{j2}-u^{n}{j1}) / norm(center{j2}-center{j1}) * surface{cf})); -ComputeUn: ∀j∈cells(), u^{n+1}{j} = f{j} * δt + u^{n}{j} + outgoingFlux{j}; -ComputeTn: t^{n+1} = t^{n} + δt; +IniCenter: ∀j∈cells(), center{j} = 0.25 * sum{r∈nodesOfCell(j)}(X{r}); // only on parallelograms +IniUn: ∀j∈cells(), u^{n}{j} = cos(2 * PI * alpha * center{j}[0]); +ComputeV: ∀j∈cells(), V{j} = 0.5 * sum{r∈nodesOfCell(j)}(det(X{r}, X{r+1})); +ComputeSurface: ∀f∈faces(), surface{f} = 0.5 * sum{r∈nodesOfFace(f)}(norm(X{r}-X{r+1})); +ComputeOutgoingFlux: ∀j1∈cells(), outgoingFlux{j1} = delta_t/V{j1} * sum{j2∈neighbourCells(j1)}(sum{cf∈commonFace(j1,j2)}( (u^{n}{j2}-u^{n}{j1}) / norm(center{j2}-center{j1}) * surface{cf})); +ComputeUn: ∀j∈cells(), u^{n+1}{j} = f{j} * delta_t + u^{n}{j} + outgoingFlux{j}; +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.ngen b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.ngen index 02992ad26..6e6746215 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.ngen +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/heatequation/HeatEquation.ngen @@ -13,7 +13,7 @@ MainModule HeatEquation heatEquation { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterations; timeMax = stopTime; } diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.n b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.n index 6c5296656..174db9611 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.n +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.n @@ -19,20 +19,20 @@ int maxIterations; let real u0 = 1.0; let real[2] vectOne = real[2](1.0); -let real δt = 0.001; +let real delta_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 alpha{cells, cells}; iterate n while (t^{n+1} < stopTime && n+1 < maxIterations); InitTime: t^{n=0} = 0.0; -InitXc: ∀c∈cells(), Xc{c} = 0.25 * ∑{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms +InitXc: ∀c∈cells(), Xc{c} = 0.25 * sum{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms InitU: ∀c∈cells(), if (norm(Xc{c} - vectOne) < 0.5) @@ -42,21 +42,21 @@ InitU: ∀c∈cells(), InitD: ∀c∈cells(), D{c} = 1.0; -ComputeDeltaTn: δt = Min{c∈cells()}(V{c}/D{c}) * 0.24; -ComputeV: ∀j∈cells(), V{j} = 0.5 * ∑{p∈nodesOfCell(j)}(det(X{p}, X{p+1})); -ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * ∑{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); -ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈cellsOfFace(f)}(D{c1}) / ∑{c2∈cellsOfFace(f)}(D{c2}); +ComputeDeltaTn: delta_t = Min{c∈cells()}(V{c}/D{c}) * 0.24; +ComputeV: ∀j∈cells(), V{j} = 0.5 * sum{p∈nodesOfCell(j)}(det(X{p}, X{p+1})); +ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * sum{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); +ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * prod{c1∈cellsOfFace(f)}(D{c1}) / sum{c2∈cellsOfFace(f)}(D{c2}); // Assembling of the diffusion matrix ComputeAlphaCoeff: ∀c∈cells(), { - let real αDiag = 0.0; + let real alpha_Diag = 0.0; ∀d∈neighbourCells(c), ∀f∈commonFace(c,d), { - let real αExtraDiag = - δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); - α{c, d} = αExtraDiag; - αDiag = αDiag + αExtraDiag; + let real alpha_ExtraDiag = - delta_t / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); + alpha{c, d} = alpha_ExtraDiag; + alpha_Diag = alpha_Diag + alpha_ExtraDiag; } - α{c, c} = 1 - αDiag; + alpha{c, c} = 1 - alpha_Diag; } -UpdateU: u^{n+1} = solveLinearSystem(α, u^{n}); -ComputeTn: t^{n+1} = t^{n} + δt; +UpdateU: u^{n+1} = solveLinearSystem(alpha, u^{n}); +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.ngen b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.ngen index 779eab14d..4cf0f7deb 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.ngen +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/implicitheatequation/ImplicitHeatEquation.ngen @@ -13,7 +13,7 @@ MainModule ImplicitHeatEquation implicitHeatEquation { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterations; timeMax = stopTime; } diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.n b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.n index 077ebfdb4..58161fe6a 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.n +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.n @@ -21,23 +21,23 @@ int maxIterations; 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; +let real epsilon = 1.0e-8; +let real delta_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 alpha{cells, cells}; real residual; iterate n while (t^{n+1} < stopTime && n+1 < maxIterations), - k while (residual > ε && check(k+1 < maxIterationsK)); + k while (residual > epsilon && check(k+1 < maxIterationsK)); InitTime: t^{n=0} = 0.0; -InitXc: ∀c∈cells(), Xc{c} = 0.25 * ∑{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms +InitXc: ∀c∈cells(), Xc{c} = 0.25 * sum{p∈nodesOfCell(c)}(X{p}); // Only valid on parallelograms InitU: ∀c∈cells(), if (norm(Xc{c} - vectOne) < 0.5) @@ -47,22 +47,22 @@ InitU: ∀c∈cells(), InitD: ∀c∈cells(), D{c} = 1.0; -ComputeDeltaTn: δt = Min{c∈cells()}(V{c}/D{c}) * 0.1; -ComputeV: ∀j∈cells(), V{j} = 0.5 * ∑{p∈nodesOfCell(j)}(det(X{p}, X{p+1})); -ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * ∑{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); -ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * ∏{c1∈cellsOfFace(f)}(D{c1}) / ∑{c2∈cellsOfFace(f)}(D{c2}); +ComputeDeltaTn: delta_t = Min{c∈cells()}(V{c}/D{c}) * 0.1; +ComputeV: ∀j∈cells(), V{j} = 0.5 * sum{p∈nodesOfCell(j)}(det(X{p}, X{p+1})); +ComputeFaceLength: ∀f∈faces(), faceLength{f} = 0.5 * sum{p∈nodesOfFace(f)}(norm(X{p} - X{p+1})); +ComputeFaceConductivity: ∀f∈faces(), faceConductivity{f} = 2.0 * prod{c1∈cellsOfFace(f)}(D{c1}) / sum{c2∈cellsOfFace(f)}(D{c2}); // Assembling of the diffusion matrix ComputeAlphaCoeff: ∀c∈cells(), { - let real αDiag = 0.0; + let real alpha_Diag = 0.0; ∀d∈neighbourCells(c), ∀f∈commonFace(c,d), { - let real αExtraDiag = δt / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); - α{c, d} = αExtraDiag; - αDiag = αDiag + αExtraDiag; + let real alpha_ExtraDiag = delta_t / V{c} * (faceLength{f} * faceConductivity{f}) / norm(Xc{c} - Xc{d}); + alpha{c, d} = alpha_ExtraDiag; + alpha_Diag = alpha_Diag + alpha_ExtraDiag; } - α{c, c} = -αDiag; + alpha{c, c} = -alpha_Diag; } -UpdateU: ∀c∈cells(), u^{n+1, k+1}{c} = u^{n}{c} + α{c, c} * u^{n+1, k}{c} + ∑{d∈neighbourCells(c)} (α{c, d} * u^{n+1, k}{d}); +UpdateU: ∀c∈cells(), u^{n+1, k+1}{c} = u^{n}{c} + alpha{c, c} * u^{n+1, k}{c} + sum{d∈neighbourCells(c)} (alpha{c, d} * u^{n+1, k}{d}); ComputeResidual: residual = Max{j ∈ cells()}(abs(u^{n+1,k+1}{j} - u^{n+1,k}{j})); -ComputeTn: t^{n+1} = t^{n} + δt; +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.ngen b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.ngen index afad3f11a..2f2fe97c9 100644 --- a/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.ngen +++ b/plugins/fr.cea.nabla.ui/examples/NabLabExamples/src/iterativeheatequation/IterativeHeatEquation.ngen @@ -13,7 +13,7 @@ MainModule IterativeHeatEquation iterativeHeatEquation { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterations; timeMax = stopTime; } diff --git a/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/contentassist/NablaProposalProvider.xtend b/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/contentassist/NablaProposalProvider.xtend index cbb09c1a6..da381434c 100644 --- a/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/contentassist/NablaProposalProvider.xtend +++ b/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/contentassist/NablaProposalProvider.xtend @@ -9,30 +9,10 @@ *******************************************************************************/ package fr.cea.nabla.ui.contentassist -import org.eclipse.emf.ecore.EObject -import org.eclipse.xtext.Assignment -import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext -import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor -import fr.cea.nabla.ir.transformers.ReplaceUtf8Chars - /** * See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#content-assist * on how to customize the content assistant. */ class NablaProposalProvider extends AbstractNablaProposalProvider { - override completeSimpleVar_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) - { - proposeCompletion(acceptor, ReplaceUtf8Chars.UTF8Chars.keySet, context) - } - - override completeConnectivityVar_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) - { - proposeCompletion(acceptor, ReplaceUtf8Chars.UTF8Chars.keySet, context) - } - - private def proposeCompletion(ICompletionProposalAcceptor acceptor, Iterable proposals, ContentAssistContext context) - { - for (proposal : proposals) acceptor.accept(createCompletionProposal(proposal, context)) - } -} +} \ No newline at end of file diff --git a/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/wizards/NewNablaProjectWizard.xtend b/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/wizards/NewNablaProjectWizard.xtend index 982f88e79..2f615c5ac 100644 --- a/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/wizards/NewNablaProjectWizard.xtend +++ b/plugins/fr.cea.nabla.ui/src/fr/cea/nabla/ui/wizards/NewNablaProjectWizard.xtend @@ -259,7 +259,7 @@ class NewNablaProjectWizard extends Wizard implements INewWizard let int maxIter = 200; let real maxTime = 1.0; - real t, δt; + real t, delta_t; real[2] X{nodes}; real e{nodes}; diff --git a/plugins/fr.cea.nabla/nablalib/Math.n b/plugins/fr.cea.nabla/nablalib/Math.n index e179bb8df..a07515d9a 100644 --- a/plugins/fr.cea.nabla/nablalib/Math.n +++ b/plugins/fr.cea.nabla/nablalib/Math.n @@ -10,13 +10,13 @@ extension Math; // ***** REDUCTIONS ***** -def ∑, 0.0: real, (a, b) → return a + b; -def ∑, 0.0: x | real[x], (a, b) → return a + b; -def ∑, 0.0: x | real[x, x], (a, b) → return a + b; +def sum, 0.0: real, (a, b) → return a + b; +def sum, 0.0: x | real[x], (a, b) → return a + b; +def sum, 0.0: x | real[x, x], (a, b) → return a + b; -def ∏, 1.0: real, (a, b) → return a * b; -def ∏, 1.0: x | real[x], (a, b) → return a * b; -def ∏, 1.0: x | real[x, x], (a, b) → return a * b; +def prod, 1.0: real, (a, b) → return a * b; +def prod, 1.0: x | real[x], (a, b) → return a * b; +def prod, 1.0: x | real[x, x], (a, b) → return a * b; def Min, real.MaxValue: real, (a, b) → return min(a, b); def Max, real.MinValue: real, (a, b) → return max(a, b); @@ -40,7 +40,7 @@ def log10: real → real; def erf: real → real; def pow: real × real → real; -def √: real → real; +def sqrt: real → real; def matVectProduct: x, y | real[x,y] × real[y] → real[x], (a, b) → { @@ -67,4 +67,4 @@ def dot: x | real[x] × real[x] → real, (a, b) → def det: real[2] × real[2] → real, (a, b) → return (a[0]*b[1] - a[1]*b[0]); def det: real[2,2] → real, (a) → return a[0,0] * a[1,1] - a[0,1] * a[1,0]; -def norm: x | real[x] → real, (a) → return √(dot(a,a)); +def norm: x | real[x] → real, (a) → return sqrt(dot(a,a)); diff --git a/plugins/fr.cea.nabla/src/fr/cea/nabla/LatexLabelServices.xtend b/plugins/fr.cea.nabla/src/fr/cea/nabla/LatexLabelServices.xtend index 40c1466aa..4989ddca4 100644 --- a/plugins/fr.cea.nabla/src/fr/cea/nabla/LatexLabelServices.xtend +++ b/plugins/fr.cea.nabla/src/fr/cea/nabla/LatexLabelServices.xtend @@ -29,6 +29,7 @@ import fr.cea.nabla.nabla.FunctionCall import fr.cea.nabla.nabla.FunctionTypeDeclaration import fr.cea.nabla.nabla.If import fr.cea.nabla.nabla.InitTimeIteratorRef +import fr.cea.nabla.nabla.Instruction import fr.cea.nabla.nabla.InstructionBlock import fr.cea.nabla.nabla.IntConstant import fr.cea.nabla.nabla.Interval @@ -46,6 +47,7 @@ import fr.cea.nabla.nabla.Not import fr.cea.nabla.nabla.Or import fr.cea.nabla.nabla.Parenthesis import fr.cea.nabla.nabla.Plus +import fr.cea.nabla.nabla.PrimitiveType import fr.cea.nabla.nabla.RealConstant import fr.cea.nabla.nabla.Reduction import fr.cea.nabla.nabla.ReductionCall @@ -60,15 +62,17 @@ import fr.cea.nabla.nabla.VarGroupDeclaration import fr.cea.nabla.nabla.VectorConstant import java.util.List import org.eclipse.emf.ecore.EObject -import fr.cea.nabla.nabla.Instruction -import fr.cea.nabla.nabla.PrimitiveType class LatexLabelServices { + public static val String[] GreekLetter = #['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', + 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', + 'Psi', 'Omega', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', + 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega'] /* JOBS & INSTRUCTIONS ***********************************/ - static def dispatch String getLatex(Job it) { '\\texttt{' + name.pu + '} : '+ instruction?.latex } - static def dispatch String getLatex(SimpleVarDeclaration it) { if (value === null) variable?.name.pu else variable?.name.pu + '=' + value.latex } - static def dispatch String getLatex(VarGroupDeclaration it) { type.latex + '~' + variables.map[x|x.name.pu].join(', ') } + static def dispatch String getLatex(Job it) { '\\texttt{' + name.transformString + '} : '+ instruction?.latex } + static def dispatch String getLatex(SimpleVarDeclaration it) { if (value === null) variable?.name.transformString else variable?.name.transformString + '=' + value.latex } + static def dispatch String getLatex(VarGroupDeclaration it) { type.latex + '~' + variables.map[x|x.name.transformString].join(', ') } static def dispatch String getLatex(InstructionBlock it) { '\\{ ... \\}' } static def dispatch String getLatex(Loop it) { '\\forall{' + iterationBlock?.latex + '}, \\ ' + body.latex } static def dispatch String getLatex(Affectation it) { left?.latex + ' = ' + right?.latex } @@ -83,46 +87,46 @@ class LatexLabelServices static def dispatch String getLatex(Exit it) { 'exit~' + message } /* ITERATEURS ********************************************/ - static def dispatch String getLatex(SpaceIterator it) { name.pu + '\\in ' + container?.latex } + static def dispatch String getLatex(SpaceIterator it) { name.transformString + '\\in ' + container?.latex } static def dispatch String getLatex(Interval it) { index?.name + '\\in ' + nbElems.latex } static def dispatch String getLatex(ItemSetRef it) { target?.name } static def dispatch String getLatex(ConnectivityCall it) { if (group === null) if (args.empty) - connectivity?.name.pu + connectivity?.name.transformString else - connectivity?.name.pu + '(' + args.map[latex].join(',') + ')' + connectivity?.name.transformString + '(' + args.map[latex].join(',') + ')' else group.pu } static def dispatch String getLatex(SpaceIteratorRef it) { - if (inc > 0) target.name.pu + '+' + inc - else if (dec > 0) target.name.pu + '-' + dec - else target.name.pu + if (inc > 0) target.name.transformString + '+' + inc + else if (dec > 0) target.name.transformString + '-' + dec + else target.name.transformString } - static def dispatch String getLatex(CurrentTimeIteratorRef it) { target?.name.pu } - static def dispatch String getLatex(InitTimeIteratorRef it) { target?.name.pu + '=' + value } - static def dispatch String getLatex(NextTimeIteratorRef it) { target?.name.pu + '+' + value } + static def dispatch String getLatex(CurrentTimeIteratorRef it) { target?.name.transformString } + static def dispatch String getLatex(InitTimeIteratorRef it) { target?.name.transformString + '=' + value } + static def dispatch String getLatex(NextTimeIteratorRef it) { target?.name.transformString + '+' + value } /* FONCTIONS / REDUCTIONS ********************************/ - static def dispatch String getLatex(Function it) { 'def ' + name.pu + '~:~' + getLatex(variables, typeDeclaration) } - static def dispatch String getLatex(Reduction it) { 'def ' + name.pu + ',~' + seed?.latex + '~:~' + getLatex(variables, typeDeclaration) } + static def dispatch String getLatex(Function it) { 'def~ ' + name.transformString + '~:~' + getLatex(variables, typeDeclaration) } + static def dispatch String getLatex(Reduction it) { 'def~ ' + name.transformString + ',~' + seed?.latex + '~:~' + getLatex(variables, typeDeclaration) } private static def String getLatex(List vars, FunctionTypeDeclaration td) { var ret = '' if (vars !== null) { - ret += vars.map[name.pu].join(', ') + ret += vars.map[name.transformString].join(', ') if (!vars.empty) ret += '~|~' } if (td !== null) { - ret += td.inTypes?.map[latex].join(' \u00D7 ') - ret += ' \u2192 ' + td.returnType?.latex + ret += td.inTypes?.map[latex].join(' \\times ') + ret += ' \\rightarrow ' + td.returnType?.latex } return ret } @@ -132,7 +136,7 @@ class LatexLabelServices var ret = '' if (vars !== null) { - ret += vars.map[name.pu].join(', ') + ret += vars.map[name.transformString].join(', ') if (!vars.empty) ret += '~|~' } if (td !== null) @@ -157,24 +161,26 @@ class LatexLabelServices static def dispatch String getLatex(IntConstant it) { value.toString } static def dispatch String getLatex(RealConstant it) { value.toString } static def dispatch String getLatex(BoolConstant it) { value.toString } - static def dispatch String getLatex(MinConstant it) { '-\u221E' } - static def dispatch String getLatex(MaxConstant it) { '\u221E' } + static def dispatch String getLatex(MinConstant it) { '-\\infty' } + static def dispatch String getLatex(MaxConstant it) { '\\infty' } static def dispatch String getLatex(FunctionCall it) { - if (function.name == 'norm') - '\\|' + args.map[latex].join(',') + '\\|' - else - function.name.pu + '\\left(' + args.map[latex].join(',') + '\\right)' + switch (function.name) + { + case 'norm': { '\\|' + args.map[latex].join(',') + '\\|' } + case 'sqrt': { '\\sqrt{' + args.map[latex].join(',') + '}' } + default: function.name.transformString + '\\left(' + args.map[latex].join(',') + '\\right)' + } } static def dispatch String getLatex(ReductionCall it) { switch (reduction.name) { - case '\u2211': { '\\sum_{' + iterationBlock.latex + '}' + arg.latexArg } - case '\u220F': { '\\prod_{' + iterationBlock.latex + '}' + arg.latexArg } - default: reduction.name.pu + '_{' + iterationBlock.latex + '}' + arg.latexArg + case 'sum': { '\\sum_{' + iterationBlock.latex + '}' + arg.latexArg } + case 'prod': { '\\prod_{' + iterationBlock.latex + '}' + arg.latexArg } + default: reduction.name.transformString + '_{' + iterationBlock.latex + '}' + arg.latexArg } } @@ -184,7 +190,7 @@ class LatexLabelServices static def dispatch String getLatex(ArgOrVarRef it) { - var label = target.name.pu + var label = target.name.transformString if (!timeIterators.empty) label += '^{' + timeIterators.map[x | x.latex].join(', ') + '}' if (!spaceIterators.empty) label += '_{' + spaceIterators.map[x | x.latex].join('') + '}' if (!indices.empty) label += '\\left[' + indices.map[x | x.latex].join(',') + '\\right]' @@ -192,7 +198,7 @@ class LatexLabelServices } /* TYPES *************************************************/ - static def dispatch String getLatex(PrimitiveType it) + static def dispatch String getLatex(PrimitiveType it) { switch it { @@ -219,11 +225,34 @@ class LatexLabelServices '\\left(' + latex + '\\right)' } + private static def String transformString(String it) + { + var ret = if (!nullOrEmpty) it.convertToUnicode.pu else '' + return ret + } + // PRESERVE UNDERSCORES private static def String pu(String it) { - val ret = if (!nullOrEmpty) replaceAll('_', '\\\\_') else '' - return ret.replace('\u03B4', '\\delta ') + it.replaceAll('_', '\\\\_') + } + + private static def String convertToUnicode(String it) + { + var String[] splitIt = it.split("((?<=_)|(?>=_))") + var List splitRet = newArrayList + val ite = splitIt.iterator + while(ite.hasNext) + { + val subString = ite.next + if (GreekLetter.contains(substring(0, subString.length()-1)) && subString.substring(subString.length() -1) == '_' && ite.hasNext) + splitRet.add('\\'+ subString.substring(0, subString.length()-1) + ' ') + else if(GreekLetter.contains(subString)) + splitRet.add('\\'+ subString) + else + splitRet.add(subString) + } + return splitRet.join } /** Return the highest displayable object, Job, Instruction or Expression */ diff --git a/plugins/fr.cea.nabla/src/fr/cea/nabla/Nabla.xtext b/plugins/fr.cea.nabla/src/fr/cea/nabla/Nabla.xtext index fa16c0719..d9589ed02 100644 --- a/plugins/fr.cea.nabla/src/fr/cea/nabla/Nabla.xtext +++ b/plugins/fr.cea.nabla/src/fr/cea/nabla/Nabla.xtext @@ -164,6 +164,4 @@ QualifiedNameWithWildcard: QualifiedName '.*'?; //terminal REAL returns ecore::EDouble: ('0'..'9')+ '.' ('0'..'9')+ ('e'('+'|'-')('0'..'9')+)?; terminal REAL returns ecore::EDouble: INT '.' (INT (('e'|'E')('+'|'-')INT)?)?; -@Override -terminal ID: '^'? ('a'..'z'|'A'..'Z'|'\u0391'..'\u03C9'|'\u220F'..'\u221A'|'_') ('a'..'z'|'A'..'Z'|'\u0391'..'\u03C9'|'0'..'9'|'_')*; diff --git a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/NablagenFileGenerator.xtend b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/NablagenFileGenerator.xtend index 0a5e13f53..e00827d68 100644 --- a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/NablagenFileGenerator.xtend +++ b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/NablagenFileGenerator.xtend @@ -90,7 +90,7 @@ class NablagenFileGenerator extends StandaloneGeneratorBase { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } diff --git a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrItemIndexFactory.xtend b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrItemIndexFactory.xtend index 3837d3c2c..b79b89d0d 100644 --- a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrItemIndexFactory.xtend +++ b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrItemIndexFactory.xtend @@ -47,8 +47,8 @@ class IrItemIndexFactory * The 3 arguments of this method compose the primary key of the index. * Dependant items are needed. In the following example: * computeGradients: ∀c∈cells(), { - * gradpi{c} = ∑{p∈nodesOfCell(c)}(Fi{p,c}); - * gradpe{c} = ∑{p∈nodesOfCell(c)}(Fe{p,c}); + * gradpi{c} = sum{p∈nodesOfCell(c)}(Fi{p,c}); + * gradpe{c} = sum{p∈nodesOfCell(c)}(Fe{p,c}); * } * If Fi and Fe are defined {nodes, cellsOfNode}, the two reductions * need an index cCellsOfNodeP on the same item c. But it is not the diff --git a/tests/DepthInit/src-gen/depthinit/DepthInitDefault.json b/tests/DepthInit/src-gen/depthinit/DepthInitDefault.json index 4ebc139b6..96d168736 100644 --- a/tests/DepthInit/src-gen/depthinit/DepthInitDefault.json +++ b/tests/DepthInit/src-gen/depthinit/DepthInitDefault.json @@ -4,7 +4,7 @@ { "maxIter":3, "maxTime":3.0, - "deltat":3.0, + "delta_t":3.0, "bathyLib":{} }, "mesh": diff --git a/tests/DepthInit/src/depthinit/DepthInit.json b/tests/DepthInit/src/depthinit/DepthInit.json index fcc253217..31e3a3805 100644 --- a/tests/DepthInit/src/depthinit/DepthInit.json +++ b/tests/DepthInit/src/depthinit/DepthInit.json @@ -3,7 +3,7 @@ { "maxTime":0.1, "maxIter":500, - "deltat":1.0, + "delta_t":1.0, "bathyLib": { "depth":3.3, diff --git a/tests/DepthInit/src/depthinit/DepthInit.n b/tests/DepthInit/src/depthinit/DepthInit.n index a8c61a1aa..e22f4bab9 100644 --- a/tests/DepthInit/src/depthinit/DepthInit.n +++ b/tests/DepthInit/src/depthinit/DepthInit.n @@ -16,9 +16,9 @@ def two: → real, () → return 2.0; let real t = 0.0; int maxIter; -real maxTime, δt; +real maxTime, delta_t; real[2] X{nodes}; -real η{cells}; +real nu{cells}; -InitFromFile: ∀j∈cells(), η{j} = two() * nextWaveHeight(); +InitFromFile: ∀j∈cells(), nu{j} = two() * nextWaveHeight(); diff --git a/tests/DepthInit/src/depthinit/DepthInit.ngen b/tests/DepthInit/src/depthinit/DepthInit.ngen index 003ebf6e3..3fc0c35d7 100644 --- a/tests/DepthInit/src/depthinit/DepthInit.ngen +++ b/tests/DepthInit/src/depthinit/DepthInit.ngen @@ -14,7 +14,7 @@ MainModule DepthInit depthInit { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } diff --git a/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKmds.cpp b/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKmds.cpp index 9d9092618..2c31db603 100644 --- a/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKmds.cpp +++ b/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKmds.cpp @@ -53,7 +53,7 @@ class ParallelWhiteheatKmds int nbNodes, nbCells, nbFaces; // Global Variables - double t, deltat, t_n_plus_1; + double t, delta_t, t_n_plus_1; // Node Variables kmds::Variable* X; @@ -120,13 +120,13 @@ class ParallelWhiteheatKmds private: /** - * Job Init_δt @-1.0 + * Job Init_deltat @-1.0 * In variables: - * Out variables: δt + * Out variables: delta_t */ void init_deltat() { - deltat = 0.001; + delta_t = 0.001; } /** @@ -144,7 +144,7 @@ class ParallelWhiteheatKmds }); } - // δt = 1/4 * ∑{j∈cells()}(V{j}) + // delta_t = 1/4 * ∑{j∈cells()}(V{j}) void bidonVolume() { // kmds::GrowingView cells("CELLS", mesh.getNbFaces()); @@ -279,7 +279,7 @@ class ParallelWhiteheatKmds /** * Job ComputeTmp @1.0 - * In variables: δt, V, u, center, surface + * In variables: delta_t, V, u, center, surface * Out variables: tmp */ void computeTmp() @@ -298,14 +298,14 @@ class ParallelWhiteheatKmds int j2Cells = j2Id; // int j2Cells = cells.indexOf(j2Id); sum1 += (((*u)[j2Cells] - (*u)[j1Cells]) / (norm((*center)[j2Cells] -(*center)[j1Cells])) * (*surface)[mesh.getCommonFace(j1Id, j2Id)]); } - (*tmp)[j1Cells] = deltat / (*V)[j1Cells] * sum1; + (*tmp)[j1Cells] = delta_t / (*V)[j1Cells] * sum1; }); } /** * Job Compute_ComputeUnPlus1 @2.0 - * In variables: f, δt, u, tmp + * In variables: f, delta_t, u, tmp * Out variables: u_n_plus_1 */ void compute_ComputeUn() @@ -314,7 +314,7 @@ class ParallelWhiteheatKmds // mesh.getFaceIDs(&cells); Kokkos::parallel_for(mesh.getNbCells(), KOKKOS_LAMBDA(const int jCells) { - (*u_n_plus_1)[jCells] = (*f)[jCells] * deltat + (*u)[jCells] + (*tmp)[jCells]; + (*u_n_plus_1)[jCells] = (*f)[jCells] * delta_t + (*u)[jCells] + (*tmp)[jCells]; }); } @@ -332,12 +332,12 @@ class ParallelWhiteheatKmds /** * Job Compute_ComputeTn @1.0 - * In variables: t, δt + * In variables: t, delta_t * Out variables: t_n_plus_1 */ void compute_ComputeTn() { - t_n_plus_1 = t + deltat; + t_n_plus_1 = t + delta_t; } /** @@ -357,7 +357,7 @@ class ParallelWhiteheatKmds void simulate() { std::cout << "Début de l'exécution du module whiteheat" << std::endl; - init_deltat(); // @-1.0 + init_delta_t(); // @-1.0 iniF(); // @-1.0 iniCenter(); // @-1.0 computeV(); // @-1.0 diff --git a/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKokkos.cpp b/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKokkos.cpp index 7534e310a..abec23a60 100644 --- a/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKokkos.cpp +++ b/tests/NabLabDrafts/sauv/gmds/ParallelWhiteheatKokkos.cpp @@ -38,7 +38,7 @@ class ParallelWhiteheatKokkos int nbNodes, nbCells, nbFaces, nbNodesOfCell; // Global Variables - double t, deltat, t_n_plus_1; + double t, delta_t, t_n_plus_1; // Array Variables Kokkos::View X; @@ -91,7 +91,7 @@ class ParallelWhiteheatKokkos }); } - // δt = 1/4 * ∑{j∈cells()}(V{j}) + // delta_t = 1/4 * ∑{j∈cells()}(V{j}) void bidonVolume() { double sum = 0.0; @@ -215,16 +215,16 @@ class ParallelWhiteheatKokkos /** * Job Init_deltat @-1.0 * In variables: - * Out variables: deltat + * Out variables: delta_t */ void init_deltat() { - deltat = 0.001; + delta_t = 0.001; } /** * Job ComputeTmp @1.0 - * In variables: u, center, surface, deltat, V + * In variables: u, center, surface, delta_t, V * Out variables: tmp */ void computeTmp() @@ -240,18 +240,18 @@ class ParallelWhiteheatKokkos int j2Cells = j2Id; sum1 += ((u(j2Cells) - u(j1Cells)) / (MathFunctions::norm(center(j2Cells) - center(j1Cells))) * surface(mesh->getCommonFace(j1Id, j2Id))); } - tmp(j1Cells) = deltat / V(j1Cells) * sum1; + tmp(j1Cells) = delta_t / V(j1Cells) * sum1; }); } /** * Job Compute_ComputeTn @1.0 - * In variables: t, deltat + * In variables: t, delta_t * Out variables: t_n_plus_1 */ void compute_ComputeTn() { - t_n_plus_1 = t + deltat; + t_n_plus_1 = t + delta_t; } /** @@ -268,14 +268,14 @@ class ParallelWhiteheatKokkos /** * Job Compute_ComputeUn @2.0 - * In variables: f, deltat, u, tmp + * In variables: f, delta_t, u, tmp * Out variables: u_n_plus_1 */ void compute_ComputeUn() { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const int jCells) { - u_n_plus_1(jCells) = f(jCells) * deltat + u(jCells) + tmp(jCells); + u_n_plus_1(jCells) = f(jCells) * delta_t + u(jCells) + tmp(jCells); }); } diff --git a/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.cc b/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.cc index 5c9c63a46..358e0be00 100644 --- a/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.cc +++ b/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.cc @@ -238,7 +238,7 @@ Glace2d::Glace2d(gmds::Mesh& aMesh) , E_n(nbCells) , E_nplus1(nbCells) , V(nbCells) -, deltatj(nbCells) +, delta_tj(nbCells) , uj_n(nbCells) , uj_nplus1(nbCells) , l(nbCells, std::vector(4)) @@ -517,7 +517,7 @@ void Glace2d::executeTimeLoopN() noexcept computeEOSp(); // @4.0 computeEOSc(); // @5.0 computeAjr(); // @6.0 - computedeltatj(); // @6.0 + computedelta_tj(); // @6.0 computeAr(); // @7.0 computeBr(); // @7.0 computeDt(); // @7.0 @@ -567,7 +567,7 @@ void Glace2d::executeTimeLoopN() noexcept // Progress std::cout << progress_bar(n, maxIterations, t_n, stopTime, 25); std::cout << __BOLD__ << __CYAN__ << Timer::print( - eta(n, maxIterations, t_n, stopTime, deltat, globalTimer), true) + eta(n, maxIterations, t_n, stopTime, delta_t, globalTimer), true) << __RESET__ << "\r"; std::cout.flush(); @@ -628,7 +628,7 @@ void Glace2d::computeAjr() noexcept /** * Job computedeltatj called @6.0 in executeTimeLoopN method. * In variables: V, c, l - * Out variables: deltatj + * Out variables: delta_tj */ void Glace2d::computedeltatj() noexcept { @@ -644,7 +644,7 @@ void Glace2d::computedeltatj() noexcept reduction0 = glace2dfreefuncs::sumR0(reduction0, l[jCells][rNodesOfCellJ]); } } - deltatj[jCells] = 2.0 * V[jCells] / (c[jCells] * reduction0); + delta_tj[jCells] = 2.0 * V[jCells] / (c[jCells] * reduction0); }); } @@ -711,18 +711,18 @@ void Glace2d::computeBr() noexcept /** * Job computeDt called @7.0 in executeTimeLoopN method. - * In variables: deltatCfl, deltatj, stopTime, t_n - * Out variables: deltat + * In variables: delta_tCfl, delta_tj, stopTime, t_n + * Out variables: delta_t */ void Glace2d::computeDt() noexcept { double reduction0; reduction0 = parallel_reduce(nbCells, double(std::numeric_limits::max()), [&](double& accu, const size_t& jCells) { - return (accu = glace2dfreefuncs::minR0(accu, deltatj[jCells])); + return (accu = glace2dfreefuncs::minR0(accu, delta_tj[jCells])); }, &glace2dfreefuncs::minR0); - deltat = std::min((deltatCfl * reduction0), (stopTime - t_n)); + delta_t = std::min((delta_tCfl * reduction0), (stopTime - t_n)); } /** @@ -840,12 +840,12 @@ void Glace2d::computeMt() noexcept /** * Job computeTn called @8.0 in executeTimeLoopN method. - * In variables: deltat, t_n + * In variables: delta_t, t_n * Out variables: t_nplus1 */ void Glace2d::computeTn() noexcept { - t_nplus1 = t_n + deltat; + t_nplus1 = t_n + delta_t; } /** @@ -886,20 +886,20 @@ void Glace2d::computeFjr() noexcept /** * Job computeXn called @10.0 in executeTimeLoopN method. - * In variables: X_n, deltat, ur + * In variables: X_n, delta_t, ur * Out variables: X_nplus1 */ void Glace2d::computeXn() noexcept { parallel_exec(nbNodes, [&](const size_t& rNodes) { - X_nplus1[rNodes] = glace2dfreefuncs::operatorAdd(X_n[rNodes], glace2dfreefuncs::operatorMult(deltat, ur[rNodes])); + X_nplus1[rNodes] = glace2dfreefuncs::operatorAdd(X_n[rNodes], glace2dfreefuncs::operatorMult(delta_t, ur[rNodes])); }); } /** * Job computeEn called @11.0 in executeTimeLoopN method. - * In variables: E_n, F, deltat, m, ur + * In variables: E_n, F, delta_t, m, ur * Out variables: E_nplus1 */ void Glace2d::computeEn() noexcept @@ -918,13 +918,13 @@ void Glace2d::computeEn() noexcept reduction0 = glace2dfreefuncs::sumR0(reduction0, glace2dfreefuncs::dot(F[jCells][rNodesOfCellJ], ur[rNodes])); } } - E_nplus1[jCells] = E_n[jCells] - (deltat / m[jCells]) * reduction0; + E_nplus1[jCells] = E_n[jCells] - (delta_t / m[jCells]) * reduction0; }); } /** * Job computeUn called @11.0 in executeTimeLoopN method. - * In variables: F, deltat, m, uj_n + * In variables: F, delta_t, m, uj_n * Out variables: uj_nplus1 */ void Glace2d::computeUn() noexcept @@ -941,7 +941,7 @@ void Glace2d::computeUn() noexcept reduction0 = glace2dfreefuncs::sumR1(reduction0, F[jCells][rNodesOfCellJ]); } } - uj_nplus1[jCells] = glace2dfreefuncs::operatorSub(uj_n[jCells], glace2dfreefuncs::operatorMult((deltat / m[jCells]), reduction0)); + uj_nplus1[jCells] = glace2dfreefuncs::operatorSub(uj_n[jCells], glace2dfreefuncs::operatorMult((delta_t / m[jCells]), reduction0)); }); } diff --git a/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.h b/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.h index 2871ac6d2..57dd17949 100644 --- a/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.h +++ b/tests/NabLabDrafts/sauv/gmds/glace2d/Glace2d.h @@ -120,15 +120,15 @@ class Glace2d int maxIterations; static constexpr double gamma = 1.4; static constexpr double xInterface = 0.5; - static constexpr double deltatCfl = 0.4; - static constexpr double rhoIniZg = 1.0; - static constexpr double rhoIniZd = 0.125; + static constexpr double delta_tCfl = 0.4; + static constexpr double rho_IniZg = 1.0; + static constexpr double rho_IniZd = 0.125; static constexpr double pIniZg = 1.0; static constexpr double pIniZd = 0.1; double t_n; double t_nplus1; double t_n0; - double deltat; + double delta_t; std::vector> X_n; std::vector> X_nplus1; std::vector> X_n0; @@ -145,7 +145,7 @@ class Glace2d std::vector E_n; std::vector E_nplus1; std::vector V; - std::vector deltatj; + std::vector delta_tj; std::vector> uj_n; std::vector> uj_nplus1; std::vector> l; diff --git a/tests/NabLabDrafts/src/reduction/Reduction.n b/tests/NabLabDrafts/src/reduction/Reduction.n index 3664ba429..52416ec8e 100644 --- a/tests/NabLabDrafts/src/reduction/Reduction.n +++ b/tests/NabLabDrafts/src/reduction/Reduction.n @@ -20,7 +20,7 @@ def nodeVelocityBoundaryConditionCorner: int × real[2] × int × real[2] × rea // Simulation options let real maxTime = 0.1; let int maxIter = 500; -let real δt = 0.01; +let real delta_t = 0.01; real t; real[2] X{nodes}; @@ -31,6 +31,6 @@ iterate n while (n <= 2); ComputeGeometry: ∀c∈cells(), ∀p∈nodesOfCell(c), lpc_n{p,c} = [1.0, 1.0]; -ComputeBoundaryNodeVelocities: ∀p∈nodes("TopLeftNode"), Vnode^{n+1}{p} = nodeVelocityBoundaryConditionCorner(1, [0., 0.], 1, [0., 0.], [[1., 1.],[1., 1.]], [1., 1.], ∑{c∈cellsOfNode(p)}(lpc_n{p,c})); +ComputeBoundaryNodeVelocities: ∀p∈nodes("TopLeftNode"), Vnode^{n+1}{p} = nodeVelocityBoundaryConditionCorner(1, [0., 0.], 1, [0., 0.], [[1., 1.],[1., 1.]], [1., 1.], sum{c ∈ cellsOfNode(p)}(lpc_n{p,c})); -UpdateTime: t^{n+1} = t^{n}+δt; +UpdateTime: t^{n+1} = t^{n}+delta_t; diff --git a/tests/NabLabDrafts/src/reduction/Reduction.ngen b/tests/NabLabDrafts/src/reduction/Reduction.ngen index 019b77690..5c54ca2fc 100644 --- a/tests/NabLabDrafts/src/reduction/Reduction.ngen +++ b/tests/NabLabDrafts/src/reduction/Reduction.ngen @@ -13,7 +13,7 @@ MainModule Reduction reduction { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } diff --git a/tests/NabLabTests/src/hydroremap/Hydro.n b/tests/NabLabTests/src/hydroremap/Hydro.n index f2593c4c6..d7792fc5f 100644 --- a/tests/NabLabTests/src/hydroremap/Hydro.n +++ b/tests/NabLabTests/src/hydroremap/Hydro.n @@ -13,7 +13,7 @@ with CartesianMesh2D.*; with Assert.*; int maxIter; -real maxTime, δt; +real maxTime, delta_t; let real t = 0.0; real[2] X{nodes}; real hv1{cells}, hv2{cells}, hv3{cells}, hv4{cells}, hv5{cells}, hv6{cells}, hv7{cells}; diff --git a/tests/NabLabTests/src/hydroremap/HydroRemap.arc b/tests/NabLabTests/src/hydroremap/HydroRemap.arc index 346bd1e62..ff75e1552 100644 --- a/tests/NabLabTests/src/hydroremap/HydroRemap.arc +++ b/tests/NabLabTests/src/hydroremap/HydroRemap.arc @@ -21,7 +21,7 @@ 0.1 500 - 1.0 + 1.0 diff --git a/tests/NabLabTests/src/hydroremap/HydroRemap.json b/tests/NabLabTests/src/hydroremap/HydroRemap.json index b1d0966a2..abf1edee8 100644 --- a/tests/NabLabTests/src/hydroremap/HydroRemap.json +++ b/tests/NabLabTests/src/hydroremap/HydroRemap.json @@ -5,7 +5,7 @@ "nonRegression":"", "maxTime":0.1, "maxIter":500, - "deltat":1.0 + "delta_t":1.0 }, "r1": { diff --git a/tests/NabLabTests/src/hydroremap/HydroRemap.ngen b/tests/NabLabTests/src/hydroremap/HydroRemap.ngen index 5c359d846..047046565 100644 --- a/tests/NabLabTests/src/hydroremap/HydroRemap.ngen +++ b/tests/NabLabTests/src/hydroremap/HydroRemap.ngen @@ -13,7 +13,7 @@ MainModule Hydro hydro { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } diff --git a/tests/NabLabTests/src/iteration/Iteration.n b/tests/NabLabTests/src/iteration/Iteration.n index d1d5f5124..8fd09efca 100644 --- a/tests/NabLabTests/src/iteration/Iteration.n +++ b/tests/NabLabTests/src/iteration/Iteration.n @@ -13,7 +13,7 @@ with CartesianMesh2D.*; with Assert.*; let real maxTime = 0.1; -let real δt = 1.0; +let real delta_t = 1.0; real t; real[2] X{nodes}; @@ -44,4 +44,4 @@ OracleVl: ∀j∈cells(), let bool testVl = assertEquals(27.0, vl^{n+1}{j}); OracleVn: ∀j∈cells(), let bool testVn = assertEquals(54.0*n, vn^{n+1}{j}); -ComputeTn: t^{n+1} = t^{n} + δt; +ComputeTn: t^{n+1} = t^{n} + delta_t; diff --git a/tests/NabLabTests/src/iteration/Iteration.ngen b/tests/NabLabTests/src/iteration/Iteration.ngen index 10b5bddeb..089cbde40 100644 --- a/tests/NabLabTests/src/iteration/Iteration.ngen +++ b/tests/NabLabTests/src/iteration/Iteration.ngen @@ -13,7 +13,7 @@ MainModule Iteration iteration { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIterN; timeMax = maxTime; } diff --git a/tests/NabLabTests/src/variables/Variables.n b/tests/NabLabTests/src/variables/Variables.n index b3caab9d6..34f37fdc2 100644 --- a/tests/NabLabTests/src/variables/Variables.n +++ b/tests/NabLabTests/src/variables/Variables.n @@ -15,7 +15,7 @@ with Assert.*; // Simulation options let real maxTime = 0.1; let int maxIter = 500; -let real δt = 1.0; +let real delta_t = 1.0; let real t = 0.0; real[2] X{nodes}; diff --git a/tests/NabLabTests/src/variables/Variables.ngen b/tests/NabLabTests/src/variables/Variables.ngen index a291a4f7c..4ee1a1d3f 100644 --- a/tests/NabLabTests/src/variables/Variables.ngen +++ b/tests/NabLabTests/src/variables/Variables.ngen @@ -13,7 +13,7 @@ MainModule Variables variables { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/IteratorExtensionsTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/IteratorExtensionsTest.xtend index 2e41efd93..81691c04b 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/IteratorExtensionsTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/IteratorExtensionsTest.xtend @@ -55,9 +55,9 @@ class IteratorExtensionsTest with CartesianMesh2D.*; - def ∑, 0.0: real, (a, b) → return a + b; - def ∑, 0.0: x | real[x], (a, b) → return a + b; - def ∑, 0.0: x | real[x, x], (a, b) → return a + b; + def sum, 0.0: real, (a, b) → return a + b; + def sum, 0.0: x | real[x], (a, b) → return a + b; + def sum, 0.0: x | real[x, x], (a, b) → return a + b; «simulationVariables» @@ -69,8 +69,8 @@ class IteratorExtensionsTest J1: ∀j∈cells(), x{j} = 2.0; J2: ∀j∈cells(), ∀r∈nodesOfCell(j), Cjr{j,r} = 3.0; J3: ∀r∈nodes(), ∀j∈cellsOfNode(r), Cjr{j,r} = 1.0; - J4: ∀j∈cells(), u{j} = 0.5 * ∑{r∈nodesOfCell(j)}(X{r} - X{r+1}); - J5: ∀j1∈cells(), f{j1} = a * ∑{j2∈neighbourCells(j1)}(∑{cf∈commonFace(j1,j2)}((x{j2}-x{j1}) / surface{cf})); + J4: ∀j∈cells(), u{j} = 0.5 * sum{r∈nodesOfCell(j)}(X{r} - X{r+1}); + J5: ∀j1∈cells(), f{j1} = a * sum{j2∈neighbourCells(j1)}(sum{cf∈commonFace(j1,j2)}((x{j2}-x{j1}) / surface{cf})); J6: ∀j1∈cells(), ∀j2∈neighbourCells(j1), ∀cf∈commonFace(j1,j2), let real bidon = (x{j2}-x{j1}) / surface{cf}); ''' diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablaScopeProviderTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablaScopeProviderTest.xtend index 97cb7f100..2945841f2 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablaScopeProviderTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablaScopeProviderTest.xtend @@ -53,10 +53,10 @@ class NablaScopeProviderTest real d{nodes}; j1 : ∀j ∈ cells(), a{j} = 0.0; - j2 : ∀j ∈ cells(), c{j} = 0.25 * ∑{r ∈ nodes()}(d{r}); + j2 : ∀j ∈ cells(), c{j} = 0.25 * sum{r ∈ nodes()}(d{r}); j3 : ∀j ∈ cells(), ∀r ∈ nodesOfCell(j), b{j,r} = 0.; - j4 : ∀j ∈ cells(), a{j} = ∑{r∈nodesOfCell(j)}(b{j, r}); - j5 : let real z = ∑{j∈cells()}(∑{r∈nodesOfCell(j)}(X{r})); + j4 : ∀j ∈ cells(), a{j} = sum{r∈nodesOfCell(j)}(b{j, r}); + j5 : let real z = sum{j∈cells()}(sum{r∈nodesOfCell(j)}(X{r})); j6 : ∀j ∈ cells(), ∀ rj ∈ rightCell(j), ∀ lj ∈ leftCell(j), c{j} = a{rj}; j7 : ∀j ∈ cells(), { set rjset = rightCell(j); @@ -114,9 +114,9 @@ class NablaScopeProviderTest real d{nodes}; j1 : ∀j ∈ cells(), a{j} = 0.0; - j2 : ∀j ∈ cells(), c{j} = 0.25 * ∑{r ∈ nodes()}(d{r}); + j2 : ∀j ∈ cells(), c{j} = 0.25 * sum{r ∈ nodes()}(d{r}); j3 : ∀j ∈ cells(), ∀r ∈ nodesOfCell(j), b{j,r} = 0.; - j4 : ∀j ∈ cells(), a{j} = ∑{r∈nodesOfCell(j)}(b{j, r}); + j4 : ∀j ∈ cells(), a{j} = sum{r∈nodesOfCell(j)}(b{j, r}); j5 : ∀j ∈ cells(), ∀ rj ∈ rightCell(j), ∀ lj ∈ leftCell(j), c{j} = a{rj} + a{lj}; j6 : ∀j ∈ cells(), { set rjset = rightCell(j); @@ -207,7 +207,7 @@ class NablaScopeProviderTest } j3 : ∀j ∈ cells(), { set nOfCells = nodesOfCell(j); - a{j} = ∑{r∈nOfCells}(b{j, r}); + a{j} = sum{r∈nOfCells}(b{j, r}); } ''' val rs = resourceSetProvider.get @@ -265,7 +265,7 @@ class NablaScopeProviderTest } j3: { - let real z = ∑{j∈cells()}(∑{r∈nodesOfCell(j)}(∑{i∈[0;2[}(X{r}[i]))); + let real z = sum{j∈cells()}(sum{r∈nodesOfCell(j)}(sum{i∈[0;2[}(X{r}[i]))); z = z + 1; } ''' @@ -279,40 +279,40 @@ class NablaScopeProviderTest val iterators = module.iteration.eAllContents.filter(TimeIterator) val nRefInCondOfN = iterators.head.condition.eAllContents.filter(ArgOrVarRef).head Assert.assertNotNull(nRefInCondOfN) - nRefInCondOfN.assertScope(eref, "δt, t, a, b1, b2, X, c1, c2, n") + nRefInCondOfN.assertScope(eref, "delta_t, t, a, b1, b2, X, c1, c2, n") val nRefInCondOfK = iterators.last.condition.eAllContents.filter(ArgOrVarRef).head Assert.assertNotNull(nRefInCondOfK) - nRefInCondOfK.assertScope(eref, "δt, t, a, b1, b2, X, c1, c2, n, k") + nRefInCondOfK.assertScope(eref, "delta_t, t, a, b1, b2, X, c1, c2, n, k") val aDeclaration = module.getVarByName("a").eContainer as SimpleVarDeclaration - aDeclaration.assertScope(eref, "δt, t") + aDeclaration.assertScope(eref, "delta_t, t") val b1Declaration = module.getVarByName("b1").eContainer as SimpleVarDeclaration - b1Declaration.assertScope(eref, "δt, t, a") + b1Declaration.assertScope(eref, "delta_t, t, a") val b2Declaration = module.getVarByName("b2").eContainer as SimpleVarDeclaration - b2Declaration.assertScope(eref, "δt, t, a, b1") + b2Declaration.assertScope(eref, "delta_t, t, a, b1") val j1 = module.getJobByName("j1") val affectationc1 = j1.getVarAffectationByName("c1") - affectationc1.assertScope(eref, "δt, t, a, b1, b2, X, c1, c2, n, k") + affectationc1.assertScope(eref, "delta_t, t, a, b1, b2, X, c1, c2, n, k") val affectationc2 = j1.getVarAffectationByName("c2") - affectationc2.assertScope(eref, "d, " + "δt, t, a, b1, b2, X, c1, c2, n, k") + affectationc2.assertScope(eref, "d, " + "delta_t, t, a, b1, b2, X, c1, c2, n, k") val affectationf = j1.getVarAffectationByName("f") - affectationf.assertScope(eref, "e, f, countr, d, " + "δt, t, a, b1, b2, X, c1, c2, n, k") + affectationf.assertScope(eref, "e, f, countr, d, " + "delta_t, t, a, b1, b2, X, c1, c2, n, k") val j2 = module.getJobByName("j2") val affectationn = j2.getVarAffectationByName("o") - affectationn.assertScope(eref, "i, o, p, " + "δt, t, a, b1, b2, X, c1, c2, n, k") + affectationn.assertScope(eref, "i, o, p, " + "delta_t, t, a, b1, b2, X, c1, c2, n, k") val affectationm = j2.getVarAffectationByName("p") - affectationm.assertScope(eref, "j, i, o, p, " + "δt, t, a, b1, b2, X, c1, c2, n, k") + affectationm.assertScope(eref, "j, i, o, p, " + "delta_t, t, a, b1, b2, X, c1, c2, n, k") val j3 = module.getJobByName("j3") val j3_xvarref = j3.instruction.eAllContents.filter(ArgOrVarRef).findFirst[x | x.target.name == 'X'] - j3_xvarref.assertScope(eref, "i, " + "δt, t, a, b1, b2, X, c1, c2, n, k") + j3_xvarref.assertScope(eref, "i, " + "delta_t, t, a, b1, b2, X, c1, c2, n, k") } @Test @@ -407,7 +407,7 @@ class NablaScopeProviderTest } j3: { - let real z = ∑{j∈cells()}(∑{r∈nodesOfCell(j)}(∑{k∈[0;1[}(X{r}[k+1]))); + let real z = sum{j∈cells()}(sum{r∈nodesOfCell(j)}(sum{k∈[0;1[}(X{r}[k+1]))); z = z + 1; } ''' @@ -418,28 +418,28 @@ class NablaScopeProviderTest val eref = NablaPackage::eINSTANCE.argOrVarRef_Target val d1Decl = module.declarations.get(1) - d1Decl.assertScope(eref, "δt") + d1Decl.assertScope(eref, "delta_t") val d2Decl = module.declarations.get(2) - d2Decl.assertScope(eref, "δt, t") + d2Decl.assertScope(eref, "delta_t, t") val d3Decl = module.declarations.get(3) - d3Decl.assertScope(eref, "δt, t, X") + d3Decl.assertScope(eref, "delta_t, t, X") val j1 = module.getJobByName("j1") val affectationc1 = j1.getVarAffectationByName("c1") - affectationc1.assertScope(eref, "δt, t, X, c1") + affectationc1.assertScope(eref, "delta_t, t, X, c1") val j2 = module.getJobByName("j2") val affectationn = j2.getVarAffectationByName("n") - affectationn.left.assertScope(eref, "i, n, m, " + "δt, t, X, c1") + affectationn.left.assertScope(eref, "i, n, m, " + "delta_t, t, X, c1") val affectationm = j2.getVarAffectationByName("m") - affectationm.left.assertScope(eref, "j, i, n, m, " + "δt, t, X, c1") + affectationm.left.assertScope(eref, "j, i, n, m, " + "delta_t, t, X, c1") val j3 = module.getJobByName("j3") val j3_xvarref = j3.instruction.eAllContents.filter(ArgOrVarRef).findFirst[x | x.target.name == 'X'] - j3_xvarref.assertScope(eref, "k, " + "δt, t, X, c1") + j3_xvarref.assertScope(eref, "k, " + "delta_t, t, X, c1") } @Test diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablagenScopeProviderTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablagenScopeProviderTest.xtend index 204723c64..f7a4233c3 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablagenScopeProviderTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/NablagenScopeProviderTest.xtend @@ -49,7 +49,7 @@ class NablagenScopeProviderTest int maxIter; let real t = 0.0; - let real δt = 1.0; + let real delta_t = 1.0; real[2] X{nodes}; real hv1{cells}, hv2{cells}, hv3{cells}, hv4{cells}, hv5{cells}, hv6{cells}, hv7{cells}; @@ -82,7 +82,7 @@ class NablagenScopeProviderTest meshClassName = "CartesianMesh2D"; nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; } @@ -146,7 +146,7 @@ class NablagenScopeProviderTest { val eref = NablagenPackage::eINSTANCE.mainModule_Time val o = ngenApp.mainModule - o.assertScope(eref, "maxTime, t, δt") + o.assertScope(eref, "maxTime, t, delta_t") } @Test @@ -154,7 +154,7 @@ class NablagenScopeProviderTest { val eref = NablagenPackage::eINSTANCE.mainModule_TimeStep val o = ngenApp.mainModule - o.assertScope(eref, "maxTime, t, δt") + o.assertScope(eref, "maxTime, t, delta_t") } @Test @@ -170,7 +170,7 @@ class NablagenScopeProviderTest { val eref = NablagenPackage::eINSTANCE.mainModule_TimeMax val o = ngenApp.mainModule - o.assertScope(eref, "maxTime, t, δt") + o.assertScope(eref, "maxTime, t, delta_t") } @Test @@ -178,7 +178,7 @@ class NablagenScopeProviderTest { val eref = NablagenPackage::eINSTANCE.vtkOutput_PeriodReferenceVar val o = ngenApp.vtkOutput - o.assertScope(eref, "maxTime, maxIter, t, δt, n") + o.assertScope(eref, "maxTime, maxIter, t, delta_t, n") } @Test @@ -236,7 +236,7 @@ class NablagenScopeProviderTest val eref = NablagenPackage::eINSTANCE.varLink_MainVariable for (r : ngenApp.additionalModules) for (v : r.varLinks) - v.assertScope(eref, "maxTime, maxIter, t, δt, X, hv1, hv2, hv3, hv4, hv5, hv6, hv7") + v.assertScope(eref, "maxTime, maxIter, t, delta_t, X, hv1, hv2, hv3, hv4, hv5, hv6, hv7") } def private assertScope(EObject context, EReference reference, CharSequence expected) diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/TestUtils.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/TestUtils.xtend index 237e6b0cb..8fc83f6b7 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/TestUtils.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/TestUtils.xtend @@ -84,7 +84,7 @@ class TestUtils def getSimulationVariables() ''' - let real δt = 0.001; + let real delta_t = 0.001; real t; ''' @@ -109,7 +109,7 @@ class TestUtils { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; } ''' diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractExpressionInterpreterTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractExpressionInterpreterTest.xtend index 32093fa3f..e4a209af3 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractExpressionInterpreterTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractExpressionInterpreterTest.xtend @@ -256,15 +256,15 @@ abstract class AbstractExpressionInterpreterTest let real[2] v = real[2](2.); let real[2] w = add(u,v); //-> [3., 3.] - let real[3] α = real[3](1.); - let real[3] β = real[3](2.); - let real[3] res1 = add(α,β); //-> [3., 3., 3.] + let real[3] alpha = real[3](1.); + let real[3] beta = real[3](2.); + let real[3] res1 = add(alpha,beta); //-> [3., 3., 3.] - let real[2,2] δ = real[2,2](1.); - let real[2,2] ρ = real[2,2](2.); - let real[2,2] res2 = add(δ,ρ); //-> [3., 3][3., 3.] + let real[2,2] delta = real[2,2](1.); + let real[2,2] rho = real[2,2](2.); + let real[2,2] res2 = add(delta,rho); //-> [3., 3][3., 3.] - let real[3] res3 = add(res1 + α, β); //-> [6., 6., 6.] + let real[3] res3 = add(res1 + alpha, beta); //-> [6., 6., 6.] real[2] X{nodes}; InitT: t=0.0; diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractInstructionInterpreterTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractInstructionInterpreterTest.xtend index ee0e79c15..7f737075a 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractInstructionInterpreterTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractInstructionInterpreterTest.xtend @@ -102,7 +102,7 @@ abstract class AbstractInstructionInterpreterTest InitTab: ∀i∈[0;size[, tab[i] = 2.3; InitT: t^{n=0} = 0.0; - ComputeTn: t^{n+1} = t^{n} + δt; + ComputeTn: t^{n+1} = t^{n} + delta_t; ''' assertInterpreteLoop(model, 100, 100) diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractJobInterpreterTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractJobInterpreterTest.xtend index a90882975..7c6ddd2e0 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractJobInterpreterTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractJobInterpreterTest.xtend @@ -70,7 +70,7 @@ abstract class AbstractJobInterpreterTest InitTime: t^{n=0} = 0.0; IniU : u^{n=0} = 4.0; - IniCenter: ∀j∈cells(), center{j} = 0.25 * ∑{r∈nodesOfCell(j)}(X^{n=0}{r}); + IniCenter: ∀j∈cells(), center{j} = 0.25 * sum{r∈nodesOfCell(j)}(X^{n=0}{r}); UpdateU: u^{n+1} = u^{n} + 1; ''' assertInterpreteTimeLoopCopyJob(model) diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractOptionsInterpreterTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractOptionsInterpreterTest.xtend index a3854e5f7..938d72f4b 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractOptionsInterpreterTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/ir/interpreter/AbstractOptionsInterpreterTest.xtend @@ -35,7 +35,7 @@ abstract class AbstractOptionsInterpreterTest real final_time; let real t = 0.0; - let real δt = 0.001; + let real delta_t = 0.001; real[2] X{nodes}; J: let real s = 3.33; diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ArgOrVarTypeProviderTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ArgOrVarTypeProviderTest.xtend index a0897958e..361169f4d 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ArgOrVarTypeProviderTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ArgOrVarTypeProviderTest.xtend @@ -131,11 +131,11 @@ class ArgOrVarTypeProviderTest // linear algebra real u{cells}; - real α{cells, cells}; + real alpha{cells, cells}; iterate n while (true); - UpdateU: u^{n+1} = solveLinearSystem(α, u^{n}); + UpdateU: u^{n+1} = solveLinearSystem(alpha, u^{n}); // local variable ComputeX: ∀ j∈cells(), { @@ -215,7 +215,7 @@ class ArgOrVarTypeProviderTest Assert.assertEquals(new NablaConnectivityType(#[cells, nodesOfCell], new NSTRealArray1D(createIntConstant(2), 2)), module.getVarByName("w").typeFor) // linear algebra - Assert.assertEquals(new NLATMatrix(linearAlgebraExt, createCardExpression(cells), createCardExpression(cells), -1, -1), module.getVarByName("α").typeFor) + Assert.assertEquals(new NLATMatrix(linearAlgebraExt, createCardExpression(cells), createCardExpression(cells), -1, -1), module.getVarByName("alpha").typeFor) Assert.assertEquals(new NLATVector(linearAlgebraExt, createCardExpression(cells), -1), module.getVarByName("u").typeFor) // local variable diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ExpressionTypeProviderTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ExpressionTypeProviderTest.xtend index 83e7c152b..614621457 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ExpressionTypeProviderTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/typeprovider/ExpressionTypeProviderTest.xtend @@ -125,11 +125,11 @@ class ExpressionTypeProviderTest real u{cells}, v{cells}; real[2] w{cells, nodesOfCell}; real x{cells, nodesOfCell}; - real α{cells, cells}; + real alpha{cells, cells}; iterate n while (n < option_max_iterations); - UpdateU: u^{n+1} = solveLinearSystem(α, u^{n}); + UpdateU: u^{n+1} = solveLinearSystem(alpha, u^{n}); ComputeV: ∀j∈cells(), v{j} = reduceMin{r∈nodesOfCell(j)}(x{j,r} + s{j}); diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/BasicValidatorTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/BasicValidatorTest.xtend index 2c210b6d6..d21e60629 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/BasicValidatorTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/BasicValidatorTest.xtend @@ -225,7 +225,7 @@ class BasicValidatorTest val moduleKo = parseHelper.parse( ''' extension Test; - def ∑, 0.0: real, (a, b) → return a + b; + def sum, 0.0: real, (a, b) → return a + b; def G: → real, () → { real[4] n; @@ -241,7 +241,7 @@ class BasicValidatorTest val moduleOk = parseHelper.parse( ''' extension Test; - def ∑, 0.0: real, (a, b) → return a + b; + def sum, 0.0: real, (a, b) → return a + b; def g: → real, () → { real[4] n; @@ -319,7 +319,7 @@ class BasicValidatorTest ''' «emptyTestModule» real[3] x; - iterate n while(∑{x∈[0;3[}(x[i]])); + iterate n while(sum{x∈[0;3[}(x[i]])); ''') Assert.assertNotNull(moduleKo1) moduleKo1.assertError(NablaPackage.eINSTANCE.timeIterator, diff --git a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/NablagenValidatorTest.xtend b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/NablagenValidatorTest.xtend index 64543f631..59786dd03 100644 --- a/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/NablagenValidatorTest.xtend +++ b/tests/fr.cea.nabla.tests/src/fr/cea/nabla/tests/validation/NablagenValidatorTest.xtend @@ -45,7 +45,7 @@ class NablagenValidatorTest let real maxTime = 0.1; let int maxIter = 500; - let real δt = 1.0; + let real delta_t = 1.0; real t; real[2] X{nodes}; @@ -79,7 +79,7 @@ class NablagenValidatorTest { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; } AdditionalModule Remap r1 @@ -167,7 +167,7 @@ class NablagenValidatorTest CMAKE_CXX_COMPILER = "/usr/bin/g++"; }') - val okNgenModel = koNgenModel.replace("timeStep = δt;", "timeStep = δt; + val okNgenModel = koNgenModel.replace("timeStep = delta_t;", "timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime;") @@ -222,11 +222,11 @@ class NablagenValidatorTest let real t = 0.0; let real maxTime = 0.1; let int maxIter = 500; - let real δt = 1.0; + let real delta_t = 1.0; real[2] X{nodes}; - real η{cells}; + real nu{cells}; - InitFromFile: ∀j∈cells(), η{j} = nextWaveHeight(); + InitFromFile: ∀j∈cells(), nu{j} = nextWaveHeight(); ''' val appNgenModel = ''' @@ -236,7 +236,7 @@ class NablagenValidatorTest { nodeCoord = X; time = t; - timeStep = δt; + timeStep = delta_t; iterationMax = maxIter; timeMax = maxTime; }