diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..237fb3f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.hdf filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 40fdcc0..af596d9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ __pycache__ src/config_schema.h src/*-desugared.rg +src/version.h +src/version.rg +test/*.h +test/*-desugared.rg diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9188996 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,195 @@ +### +### Variables +### + +# Global variables (will be set in every job): +variables: + MAX_DIM: "4" + LEGION_BRANCH: "parallelizer-dcr-new" + HTR_DIR: "$CI_PROJECT_DIR" + REALM_BACKTRACE: "1" +# TIMELIMIT: "600" # each test should take less than 10 minutes + +# Local variables (included on a case-by-case basis in each job): +#.gcc48: &gcc48 +# CXX: "g++-4.8" +#.gcc49: &gcc49 +# CXX: "g++-4.9" +#.gcc5: &gcc5 +# CXX: "g++-5" +#.gcc6: &gcc6 +# CXX: "g++-6" +#.gcc7: &gcc7 +# CXX: "g++-7" +#.gcc8: &gcc8 +# CXX: "g++-8" +# +#.clang35: &clang35 +# CXX: "clang++-3.5" +#.clang38: &clang38 +# CXX: "clang++-3.8" +#.clang7: &clang7 +# CXX: "clang++-7" +#.clang8: &clang8 +# CXX: "clang++-8" +# +#.terra35: &terra35 +# LLVM_CONFIG: "llvm-config-3.5" +# TERRA_DIR: "/usr/local/terra35" +#.terra38: &terra38 +# LLVM_CONFIG: "llvm-config-3.8" +# TERRA_DIR: "/usr/local/terra38" +#.terra70: &terra70 +# LLVM_CONFIG: "llvm-config-7" +# TERRA_DIR: "/usr/local/terra70" + +.debug: &debug + DEBUG: "1" +.release: &release + DEBUG: "0" + +.openmp: &openmp + USE_OPENMP: "1" +.hdf5: &hdf5 + USE_HDF: "1" +.llvm: &llvm + USE_LLVM: "1" +.cuda: &cuda + USE_CUDA: "1" +.gasnet: &gasnet + USE_GASNET: "1" + +.prof: &prof + USE_PROF: "1" + +### +### Setup +### + +# These commands will run before each job. +before_script: + - | + if [[ "$(hostname)" = ctr-205-1.stanford.edu ]]; then + module load mpi/mpich-3.0-x86_64 + export CC=mpicc + export CXX=mpicxx + export LEGION_DIR=/home/gitlab-runner/legion + export HDF_ROOT=$LEGION_DIR/language/hdf/install + export USE_GASNET=0 + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent:$LEGION_DIR/language/hdf/install/lib" + cd $HTR_DIR + fi + + # Make sure that we are running the last version of Legion + - | + cd $LEGION_DIR/language + git fetch + LOCAL0=$(git rev-parse @) + git checkout $LEGION_BRANCH + UPSTREAM=${1:-'@{u}'} + LOCAL=$(git rev-parse @) + REMOTE=$(git rev-parse "$UPSTREAM") + if [ $LOCAL != $REMOTE ]; then + echo "Updating Legion" + git reset --hard $REMOTE + scripts/setup_env.py --llvm-version 38 + elif [ $LOCAL != $LOCAL0 ]; then + echo "Building Legion on the new branch" + scripts/setup_env.py --llvm-version 38 + fi + cd $HTR_DIR + + +### +### Tags +### + +.ctr-205-1: &ctr-205-1 + tags: + - centos7 + - ctr-205-1 + +### +### Docker Image +### + +# Each job will run in a fresh container with this image. +#.image: &image +# image: stanfordlegion/gitlab-ci:ubuntu16.04 # i.e. https://hub.docker.com/r/stanfordlegion/gitlab-ci/ + +### +### Tests +### + +# Unit tests that check the solver component by component. +.unitTests: &unitTests + script: + - cd unitTests/configTest + - make + - ./configTest.exec + - cd ../.. + + - cd unitTests/mathUtilsTest + - make + - ./mathUtilsTest.exec + - cd ../.. + + - cd unitTests/hdfTest + - make + - ./hdfTest.exec + - cd ../.. + + - cd unitTests/mixTest + - make + - ./mixTest.exec + - cd ../.. + + - cd unitTests/geometryTest + - make + - ./geometryTest.exec + - cd ../.. + + - cd unitTests/metricTest + - make -j + - ./metricTest_Periodic.exec + - ./metricTest_Collocated.exec + - ./metricTest_Staggered.exec + - cd ../.. + + - cd unitTests/cflTest + - make + - ./cflTest.exec + - cd ../.. + + - cd unitTests/chemTest + - make + - ./chemTest.exec + - cd ../.. + + - cd unitTests/variablesTest + - make + - ./variablesTest.exec + - cd ../.. + +.solverTests: &solverTests + script: + - NO_ATOMIC=1 make -j -C src/ + - cd solverTests + - python ./test.py + - cd ../.. + +### +### Jobs +### + +# Each item below defines a job. + +ctr-205-1_release_unitTests: + <<: [*ctr-205-1, *unitTests] + variables: + <<: [*release, *openmp, *hdf5] + +ctr-205-1_release_solverTests: + <<: [*ctr-205-1, *solverTests] + variables: + <<: [*release, *openmp, *hdf5] diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..a774ac1 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,11 @@ +This file lists the major changes as they appear in the master branch. + +Version 1.1.0 (April 23, 2020) + - basic test suite added to the repository + - timing infrastructure added to the main task of the solver + - NSCBC_Outflow available on the yNeg surface of the domain + - Added compile time flag to dump fields when a NaN appears + - Added compile time flag to deactivate atomic coherence mode + - New Sinh, SinhPlus, and SinhMinus grid stretching available to the user + - Less verbose input for BCs based on unions + diff --git a/README.md b/README.md index a8181c6..84fb453 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Organization of the repository > > [certainty.slurm](src/certainty.slurm): Submission script for Certainty (@ Stanford) (use as a template script for slurm system) > > [quartz.slurm](src/quartz.slurm): Submission script for Quartz (@ LLNL) (use as a template script for slurm system) > > [lassen.lsf](src/lassen.lsf): Submission script for Lassen (@ LLNL) (use as a template script for IBM Spectrum LSF system) + > > [galileo.slurm](src/galileo.slurm): Submission script for Galileo (@ Cineca) (use as a template script for slurm system) > > [blacklist](src/blacklist): Folder containing potential blacklists of nodes that should not be used > [scripts/](scripts/) @@ -52,7 +53,7 @@ Organization of the repository > > [modules/](scripts/modules/): Various utility modules used by the python scripts > [testcases/](testcases/) - > > [README.md](testcases/README.md): Instructions on how to run the provided testcases + > > [README.md](testcases/README.md): Instructions on how to run the provided testcases > > [SodProblem/](testcases/SodProblem/): Contains the setup and postporcessing files needed to run Sod's shock tube > > [LaxProblem/](testcases/LaxProblem/): Contains the setup and postporcessing files needed to run Lax's shock tube > > [ShuOsherProblem/](testcases/ShuOsherProblem/): Contains the setup and postporcessing files needed to run Shu-Osher's shock tube @@ -67,6 +68,23 @@ Organization of the repository > > [MultispeciesTBL/](testcases/MultispeciesTBL/): Contains the setup and postporcessing files needed to run Multispecies hypersonic boundary layer > > [scalingTest/WS](testcases/scalingTest/WS): Contains the setup and postporcessing files needed to run the weak saling test + > [unitTests/](unitTests/) + > > [cflTest/](unitTests/cflTest/): Contains the unit test for the cfl module + > > [chemTest/](unitTests/chemTest/): Contains the unit test for the chemistry module + > > [configTest/](unitTests/configTest/): Contains the unit test for the config schema module + > > [geometryTest/](unitTests/geometryTest/): Contains the unit test for the geometry module + > > [hdfTest/](unitTests/hdfTest/): Contains the unit test for the hdf helper module + > > [mathUtilsTest/](unitTests/mathUtilsTest/): Contains the unit test for the mathUtils module + > > [metricTest/](unitTests/metricTest/): Contains the unit test for the metric module + > > [mixTest/](unitTests/mixTest/): Contains the unit test for the mixture modules + > > [variablesTest/](unitTests/variablesTest/): Contains the unit test for the variables module + + > [solverTests/](solverTests/) + > > [3DPeriodic/](solverTests/3DPeriodic/): Contains the solver test for the tri-periodic 3D testcase + > > [3DPeriodic_Air/](solverTests/3DPeriodic_Air): Contains the solver test for the tri-periodic 3D testcase with AirMix + > > [ChannelFlow/](solverTests/ChannelFlow): Contains the solver test for the bi-periodic ChannelFlow testcase + > > [BoundaryLayer/](solverTests/BoundaryLayer): Contains the solver test for a compressible boundary layer + Setup (generic) =============== @@ -347,6 +365,8 @@ export CUDA_HOME=/usr/tce/packages/cuda/cuda-9.2.148 export CUDA="$CUDA_HOME" export GPU_ARCH=volta +export GROUP=??? + export USE_CUDA=1 export USE_OPENMP=1 export USE_GASNET=1 @@ -376,3 +396,59 @@ lalloc 1 scripts/setup_env.py --llvm-version 38 --terra-branch 'puc_lua_master' cd "$HTR_DIR"/src lalloc 1 -W 120 make ``` + +Setup (Galileo @ Cineca) +============================ + +### Add to shell startup + +``` +# Module loads +module load gnu +module load openmpi/3.1.1--gnu--6.1.0 +module load cuda/9.0 +module load python +# Build config +export CC=gcc +export CXX=g++ +export CONDUIT=ibv +# Path setup +export LEGION_DIR=??? +export HDF_ROOT="$LEGION_DIR"/language/hdf/install +export HTR_DIR=??? +export SCRATCH=??? +# CUDA config +export CUDA_HOME="/cineca/prod/compilers/cuda/9.0/none" +export CUDA="$CUDA_HOME" +export GPU_ARCH=kepler + +export ACCOUNT=[ACCOUNT TO BE CHARGED] + +export USE_CUDA=1 +export USE_OPENMP=1 +export USE_GASNET=1 +export USE_HDF=1 +export MAX_DIM=4 + +``` + +### Download software + +``` +git clone -b htr-release https://gitlab.com/mario.direnzo/legion.git "$LEGION_DIR" +git clone https://mdirenzo@bitbucket.org/mdirenzo/prometeo.git "$HTR_DIR" +``` + +### Install Legion + +``` +cd "$LEGION_DIR"/language +scripts/setup_env.py --llvm-version 38 --terra-url 'https://github.com/StanfordLegion/terra.git' --terra-branch 'luajit2.1' +``` + +### Compile Prometeo + +``` +cd "$HTR_DIR"/src +srun --cpus-per-task=3 --mem 30000 -p gll_usr_gpuprod -t 0:50:00 make -j & +``` diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml new file mode 100644 index 0000000..2c821a2 --- /dev/null +++ b/bitbucket-pipelines.yml @@ -0,0 +1,89 @@ +# This is a sample build configuration for C++ – Make. +# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples. +# Only use spaces to indent your .yml configuration. +# ----- +# You can specify a custom docker image from Docker Hub as your build environment. +image: mariodr/legion-docker:ubuntu16.04 + +pipelines: + default: +# - step: +# name: Compile prometeo +# script: # Modify the commands below to build your repository. +# - cd src +## - make +# + - parallel: + - step: + name: Test Config + script: + - cd unitTests/configTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./configTest.exec + + - step: + name: Test math_utils + script: + - cd unitTests/mathUtilsTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./mathUtilsTest.exec + + - step: + name: Test hdf_helper + script: + - cd unitTests/hdfTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./hdfTest.exec + + - step: + name: Test mixtures + script: + - cd unitTests/mixTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./mixTest.exec + + - step: + name: Test geometry + script: + - cd unitTests/geometryTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./geometryTest.exec + +# We do not have enough memory for all the tests + - step: + name: Test metric + script: + - cd unitTests/metricTest + - make metricTest_Periodic.exec + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./metricTest_Periodic.exec + + - step: + name: Test cfl + script: + - cd unitTests/cflTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./cflTest.exec + + - step: + name: Test chemistry + script: + - cd unitTests/chemTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./chemTest.exec + + - step: + name: Test variables + script: + - cd unitTests/variablesTest + - make + - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent" + - ./variablesTest.exec + diff --git a/dockerfiles/dockerfile.bitbucket b/dockerfiles/dockerfile.bitbucket new file mode 100644 index 0000000..3890fe5 --- /dev/null +++ b/dockerfiles/dockerfile.bitbucket @@ -0,0 +1,25 @@ +# Build Image for Bitbucket +# Use command: docker build -t mariodr/legion-docker:ubuntu16.04 -f dockerfile.bitbucket . + +FROM stanfordlegion/gitlab-ci:ubuntu16.04 + +MAINTAINER Mario Di Renzo + +ENV CC=gcc \ + CXX=c++ \ + LEGION_DIR="/usr/local/legion" \ + HDF_HEADER="hdf5/serial/hdf5.h" \ + HDF_LIBNAME="hdf5_serial" \ + TERRA_DIR="/usr/local/terra35" \ + LLVM_CONFIG="llvm-config-3.5" \ + MAX_DIM=4 \ + USE_CUDA=0 \ + USE_OPENMP=1 \ + USE_GASNET=0 \ + USE_HDF=1 \ + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LEGION_DIR/bindings/regent/" + +RUN git clone -b parallelizer-dcr-new https://gitlab.com/StanfordLegion/legion.git "$LEGION_DIR" && \ + cd $LEGION_DIR/language && \ + ./install.py --rdir "auto" --with-terra $TERRA_DIR + diff --git a/scripts/interpolate.py b/scripts/interpolate.py index 066b8a3..be728d1 100755 --- a/scripts/interpolate.py +++ b/scripts/interpolate.py @@ -41,13 +41,16 @@ ############################################################################## def interp(values, i, j, k, w1, w2, w3): - return(values[i-1,j-1,k-1] * w1 * w2 * w3 + - values[i-1,j-1,k ] * w1 * w2 * (1.0-w3) + - values[i-1,j ,k-1] * w1 * (1.0-w2) * w3 + - values[i ,j-1,k-1] * (1.0-w1) * w2 * w3 + - values[i-1,j ,k ] * w1 * (1.0-w2) * (1.0-w3) + - values[i ,j-1,k ] * (1.0-w1) * w2 * (1.0-w3) + - values[i ,j ,k-1] * (1.0-w1) * (1.0-w2) * w3 + + im1 = max(i-1, 0) + jm1 = max(j-1, 0) + km1 = max(k-1, 0) + return(values[im1,jm1,km1] * w1 * w2 * w3 + + values[im1,jm1,k ] * w1 * w2 * (1.0-w3) + + values[im1,j ,km1] * w1 * (1.0-w2) * w3 + + values[i ,jm1,km1] * (1.0-w1) * w2 * w3 + + values[im1,j ,k ] * w1 * (1.0-w2) * (1.0-w3) + + values[i ,jm1,k ] * (1.0-w1) * w2 * (1.0-w3) + + values[i ,j ,km1] * (1.0-w1) * (1.0-w2) * w3 + values[i ,j ,k ] * (1.0-w1) * (1.0-w2) * (1.0-w3)) ############################################################################## @@ -68,7 +71,9 @@ def interp(values, i, j, k, w1, w2, w3): MolarFracsIn = fin["MolarFracs"][:] temperatureIn = fin["temperature"][:] +simTime = fin.attrs["simTime"] channelForcing = fin.attrs["channelForcing"] +simTime = fin.attrs["simTime"] nSpec = MolarFracsIn.shape[3] @@ -76,26 +81,38 @@ def interp(values, i, j, k, w1, w2, w3): # New Generate Grid # ############################################################################## +dx0 = 1.0 +dy0 = 1.0 +dz0 = 1.0 + +if "xDelta0" in config["Grid"]: dx0 = config["Grid"]["xDelta0"] +if "yDelta0" in config["Grid"]: dy0 = config["Grid"]["yDelta0"] +if "zDelta0" in config["Grid"]: dz0 = config["Grid"]["zDelta0"] + + xGrid, dx = gridGen.GetGrid(config["Grid"]["origin"][0], config["Grid"]["xWidth"], config["Grid"]["xNum"], config["Grid"]["xType"], config["Grid"]["yStretching"], - args.Xper) + args.Xper, + dx0) yGrid, dy = gridGen.GetGrid(config["Grid"]["origin"][1], config["Grid"]["yWidth"], config["Grid"]["yNum"], config["Grid"]["yType"], config["Grid"]["yStretching"], - args.Yper) + args.Yper, + dy0) zGrid, dz = gridGen.GetGrid(config["Grid"]["origin"][2], config["Grid"]["zWidth"], config["Grid"]["zNum"], config["Grid"]["zType"], config["Grid"]["zStretching"], - args.Zper) + args.Zper, + dz0) # Load mapping Ntiles = config["Mapping"]["tiles"] @@ -143,13 +160,14 @@ def writeTile(xt, yt, zt): temperature = np.ndarray(shape) MolarFracs = np.ndarray(shape, dtype=np.dtype("("+str(nSpec)+",)f8")) velocity = np.ndarray(shape, dtype=np.dtype("(3,)f8")) - dudtBoundary = np.ndarray(shape) + dudtBoundary = np.ndarray(shape, dtype=np.dtype("(3,)f8")) dTdtBoundary = np.ndarray(shape) + dudtBoundary[:] = [0.0, 0.0, 0.0] + dTdtBoundary[:] = 0.0 for (k,kc) in enumerate(centerCoordinates): kIn = np.searchsorted(zIn, zGrid[k+lo_bound[2]]) if (kIn == 0): - kIn = 1 zweight = 0.0 elif (kIn > zIn.size-1): kIn = zIn.size-1 @@ -160,7 +178,6 @@ def writeTile(xt, yt, zt): for (j,jc) in enumerate(kc): jIn = np.searchsorted(yIn, yGrid[j+lo_bound[1]]) if (jIn == 0): - jIn = 1 yweight = 0.0 elif (jIn > yIn.size-1): jIn = yIn.size-1 @@ -171,7 +188,6 @@ def writeTile(xt, yt, zt): for (i,ic) in enumerate(jc): iIn = np.searchsorted(xIn, xGrid[i+lo_bound[0]]) if (iIn == 0): - iIn = 1 xweight = 0.0 elif (iIn > xIn.size-1): iIn = xIn.size-1 @@ -189,13 +205,11 @@ def writeTile(xt, yt, zt): velocity [k,j,i] = [ interp(velocityIn[:,:,:,0], kIn, jIn, iIn, zweight, yweight, xweight), interp(velocityIn[:,:,:,1], kIn, jIn, iIn, zweight, yweight, xweight), interp(velocityIn[:,:,:,2], kIn, jIn, iIn, zweight, yweight, xweight)] - dudtBoundary [k,j,i] = 0.0 - dTdtBoundary [k,j,i] = 0.0 with h5py.File(os.path.join(args.outputdir, filename), 'w') as fout: fout.attrs.create("SpeciesNames", ["MIX".encode()], dtype="S20") fout.attrs.create("timeStep", 0) - fout.attrs.create("simTime", 0.0) + fout.attrs.create("simTime", simTime) fout.attrs.create("channelForcing", channelForcing) fout.create_dataset("centerCoordinates", shape=shape, dtype = np.dtype("(3,)f8")) @@ -205,10 +219,8 @@ def writeTile(xt, yt, zt): fout.create_dataset("temperature", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs", shape=shape, dtype = np.dtype("("+str(nSpec)+",)f8")) fout.create_dataset("velocity", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("dTdtBoundary", shape=shape, dtype = np.dtype("f8")) - fout.create_dataset("velocity_old_NSCBC", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("temperature_old_NSCBC", shape=shape, dtype = np.dtype("f8")) fout["centerCoordinates"][:] = centerCoordinates fout["cellWidth"][:] = cellWidth @@ -219,7 +231,5 @@ def writeTile(xt, yt, zt): fout["velocity"][:] = velocity fout["dudtBoundary"][:] = dudtBoundary fout["dTdtBoundary"][:] = dTdtBoundary - fout["velocity_old_NSCBC"][:] = velocity - fout["temperature_old_NSCBC"][:] = temperature Parallel(n_jobs=args.np)(delayed(writeTile)(x, y, z) for x, y, z in np.ndindex((Ntiles[0], Ntiles[1], Ntiles[2]))) diff --git a/scripts/makeXdmfFile.py b/scripts/makeXdmfFile.py new file mode 100755 index 0000000..bb21fb0 --- /dev/null +++ b/scripts/makeXdmfFile.py @@ -0,0 +1,215 @@ +import os +import shutil +import sys +import h5py +import subprocess +import argparse +import glob + + +XMF_HEADER = """ + + + + +""" + +XMF_SOLUTION_HEADER = """ + + +""" + +XMF_FOOTER = """ + + + +""" + +def progressbar(it, prefix="", suffix = '', decimals = 1, length = 100, fill = '-', file=sys.stdout): + count = len(it) + def show(j): + percent = ("{0:." + str(decimals) + "f}").format(100 * (j / float(count))) + filledLength = int(length * j // count) + bar = fill * filledLength + '-' * (length - filledLength) + file.write("\r%s |%s| %s%% %s" % (prefix, bar, percent, suffix)) + file.flush() + show(0) + for i, item in enumerate(it): + yield i, item + show(i+1) + file.write("\n") + file.flush() + +parser = argparse.ArgumentParser() +parser.add_argument('--sampledir', nargs='?', const='.', default='.', + help='directory with all the simulation output') +args = parser.parse_args() +sample_dir = os.path.abspath(args.sampledir) + +# Make directories for viz data +out_dir = os.path.abspath("viz_data") +grid_dir = os.path.join(out_dir,"grid") + +if not os.path.exists(grid_dir): + os.makedirs(grid_dir) + +if not os.path.exists(out_dir): + os.makedirs(out_dir) + +# Check for solution snapshots +snapshots = glob.glob(os.path.join(sample_dir,"fluid_iter*")) + +# sort files by timestep +snapshots.sort(key=lambda x: x[len(os.path.join(sample_dir, "fluid_iter")):]) + +with open('out_fluid.xmf', 'w') as xmf_out: + xmf_out.write(XMF_HEADER) + + for i, sn in progressbar(snapshots, "Converting:"): + + # We still need to convert H5T_ARRAYs to numpy vectors... + # TODO: get rid of this step as soon as you find out how to read H5T_ARRAYs with XDMF + hdf_sol = None + solutionfile = os.path.join(out_dir,sn.split('/')[-1])+".hdf" + if not os.path.exists(solutionfile): + hdf_sol = h5py.File(solutionfile, "w") + #################################################################################### + + tiles = glob.glob(os.path.join(sn,"*hdf")) + + # Load attributes + hdf_in = h5py.File(tiles[0], 'r') + simTime = hdf_in.attrs.get("simTime") + SpeciesNames = hdf_in.attrs.get("SpeciesNames") + hdf_in.close() + + xmf_out.write(XMF_SOLUTION_HEADER + .replace('@NAME','%s'% sn.split('/')[-1]) + .replace('@TIMESTEP','%.8g'% simTime)) + + # Set reference to each tile + for j, tl in enumerate(tiles): + hdf_in = h5py.File(tl, 'r') + + # Sanity check + assert simTime == hdf_in.attrs.get("simTime") + assert (SpeciesNames == hdf_in.attrs.get("SpeciesNames")).all() + + # Extract domain size. + nx = hdf_in['pressure'].shape[0] + ny = hdf_in['pressure'].shape[1] + nz = hdf_in['pressure'].shape[2] + + # Generate grid file if it does not exist + gridfile = os.path.join(grid_dir, tl.split('/')[-1]) + + if not os.path.exists(gridfile): + with h5py.File(gridfile, "w") as hdf_grid: + centerCoordinates = hdf_in["centerCoordinates"][:][:,:,:,:] + cellWidth = hdf_in["cellWidth"][:][:,:,:,:] + XFaceCoordinates = [] + for i in range(nx): + XFaceCoordinates.append(centerCoordinates[i,0,0,2]-0.5*cellWidth[i,0,0,2]) + XFaceCoordinates.append(centerCoordinates[nx-1,0,0,2]+0.5*cellWidth[nx-1,0,0,2]) + YFaceCoordinates = [] + for i in range(ny): + YFaceCoordinates.append(centerCoordinates[0,i,0,1]-0.5*cellWidth[0,i,0,1]) + YFaceCoordinates.append(centerCoordinates[0,ny-1,0,1]+0.5*cellWidth[0,ny-1,0,1]) + ZFaceCoordinates = [] + for i in range(nz): + ZFaceCoordinates.append(centerCoordinates[0,0,i,0]-0.5*cellWidth[0,0,i,0]) + ZFaceCoordinates.append(centerCoordinates[0,0,nz-1,0]+0.5*cellWidth[0,0,nz-1,0]) + hdf_grid["XFaceCoordinates"] = XFaceCoordinates + hdf_grid["YFaceCoordinates"] = YFaceCoordinates + hdf_grid["ZFaceCoordinates"] = ZFaceCoordinates + + # We still need to convert H5T_ARRAYs to numpy vectors... + # TODO: get rid of this step as soon as you find out how to read H5T_ARRAYs with XDMF + group = tl.split('/')[-1][0:-4] + if hdf_sol != None: + hdf_sol[group+"/velocity"] = hdf_in["velocity"][:][:,:,:,:] + for isp, sp in enumerate(SpeciesNames): + hdf_sol[group+"/X_"+sp.decode()] = hdf_in['MolarFracs'][:][:,:,:,isp] + #################################################################################### + + xmf_out.write(XMF_TILE_HEADER + .replace("@N", "%s" % tl.split('/')[-1][0:-4]) + .replace("@XPOINTS", "%s" % str(nx+1)) + .replace("@YPOINTS", "%s" % str(ny+1)) + .replace("@ZPOINTS", "%s" % str(nz+1)) + .replace("@HDF_FILE", gridfile)) + + xmf_out.write(XMF_SOLUTION_SCALAR + .replace("@NAME", "%s" % "pressure") + .replace("@HDF_FILE", "%s" % tl) + .replace("@CELLS", "%s %s %s" % (nx,ny,nz))) + + xmf_out.write(XMF_SOLUTION_SCALAR + .replace("@NAME","%s" % "rho") + .replace("@HDF_FILE", "%s" % tl) + .replace("@CELLS", "%s %s %s" % (nx,ny,nz))) + + xmf_out.write(XMF_SOLUTION_SCALAR + .replace("@NAME","%s" % "temperature") + .replace("@HDF_FILE", "%s" % tl) + .replace("@CELLS", "%s %s %s" % (nx,ny,nz))) + + for sp in SpeciesNames: + xmf_out.write(XMF_SOLUTION_SCALAR2 + .replace("@NAME","%s" % "X_"+sp.decode()) + .replace("@GROUP", "%s" % group) + .replace("@HDF_FILE", "%s" % solutionfile) + #.replace("@HDF_FILE", "%s" % tl) + .replace('@CELLS', '%s %s %s' % (nx,ny,nz))) + + xmf_out.write(XMF_SOLUTION_VECTOR + .replace("@NAME", "%s" % "velocity") + .replace("@GROUP", "%s" % group) + .replace("@HDF_FILE", "%s" % solutionfile) + #.replace("@HDF_FILE", "%s" % tl) + .replace("@CELLS", "%s %s %s" % (nx,ny,nz))) + + + xmf_out.write(XMF_TILE_FOOTER) + hdf_in.close() + + xmf_out.write(XMF_SOLUTION_FOOTER) + if hdf_sol != None: hdf_sol.close() + + xmf_out.write(XMF_FOOTER) diff --git a/scripts/modules/Averages.py b/scripts/modules/Averages.py index 0a44989..227f332 100755 --- a/scripts/modules/Averages.py +++ b/scripts/modules/Averages.py @@ -16,29 +16,45 @@ def __init__(self, filename, symmetric = False): self.temperature_rms = f["temperature_rms"][:][0,:] self.MolarFracs_avg = f["MolarFracs_avg"][:][0,:,:] self.MolarFracs_rms = f["MolarFracs_rms"][:][0,:,:] + self.MassFracs_avg = f["MassFracs_avg"][:][0,:,:] + self.MassFracs_rms = f["MassFracs_rms"][:][0,:,:] self.velocity_avg = f["velocity_avg"][:][0,:,:] self.velocity_rms = f["velocity_rms"][:][0,:,:] self.velocity_rey = f["velocity_rey"][:][0,:,:] - self.rho_avg = f["rho_avg"][:][0,:] - self.rho_rms = f["rho_rms"][:][0,:] - self.mu_avg = f["mu_avg"][:][0,:] - self.mu_rms = f["mu_rms"][:][0,:] - self.lam_avg = f["lam_avg"][:][0,:] - self.lam_rms = f["lam_rms"][:][0,:] - self.Di_avg = f["Di_avg"][:][0,:,:] - self.Di_rms = f["Di_rms"][:][0,:,:] - self.SoS_avg = f["SoS_avg"][:][0,:] - self.SoS_rms = f["SoS_rms"][:][0,:] - + self.rho_avg = f["rho_avg"][:][0,:] + self.rho_rms = f["rho_rms"][:][0,:] + self.mu_avg = f["mu_avg"][:][0,:] + self.lam_avg = f["lam_avg"][:][0,:] + self.Di_avg = f["Di_avg"][:][0,:,:] + self.SoS_avg = f["SoS_avg"][:][0,:] + self.cp_avg = f["cp_avg"][:][0,:] + self.Ent_avg = f["Ent_avg"][:][0,:] + + self.ProductionRates_avg = f["ProductionRates_avg"][:][0,:,:] + self.ProductionRates_rms = f["ProductionRates_rms"][:][0,:,:] + self.HeatReleaseRate_avg = f["HeatReleaseRate_avg"][:][0,:] + self.HeatReleaseRate_rms = f["HeatReleaseRate_rms"][:][0,:] + + self.pressure_favg = f["pressure_favg"][:][0,:] + self.pressure_frms = f["pressure_frms"][:][0,:] self.temperature_favg = f["temperature_favg"][:][0,:] self.temperature_frms = f["temperature_frms"][:][0,:] self.MolarFracs_favg = f["MolarFracs_favg"][:][0,:,:] self.MolarFracs_frms = f["MolarFracs_frms"][:][0,:,:] + self.MassFracs_favg = f["MassFracs_favg"][:][0,:,:] + self.MassFracs_frms = f["MassFracs_frms"][:][0,:,:] self.velocity_favg = f["velocity_favg"][:][0,:,:] self.velocity_frms = f["velocity_frms"][:][0,:,:] self.velocity_frey = f["velocity_frey"][:][0,:,:] + self.mu_favg = f["mu_favg"][:][0,:] + self.lam_favg = f["lam_favg"][:][0,:] + self.Di_favg = f["Di_favg"][:][0,:,:] + self.SoS_favg = f["SoS_favg"][:][0,:] + self.cp_favg = f["cp_favg"][:][0,:] + self.Ent_favg = f["Ent_favg"][:][0,:] + self.rhoUUv = f["rhoUUv"][:][0,:,:] self.Up = f["Up"][:][0,:,:] self.tau = f["tau"][:][0,:,:] @@ -52,6 +68,18 @@ def __init__(self, filename, symmetric = False): self.Pr_rms = f["Pr_rms"][:][0,:] self.Ec = f["Ec"][:][0,:] self.Ec_rms = f["Ec_rms"][:][0,:] + self.Ma = f["Ma"][:][0,:] + self.Sc = f["Sc"][:][0,:,:] + + self.uT_avg = f["uT_avg"][:][0,:] + self.uYi_avg = f["uYi_avg"][:][0,:] + self.vYi_avg = f["vYi_avg"][:][0,:] + self.wYi_avg = f["wYi_avg"][:][0,:] + + self.uT_favg = f["uT_favg"][:][0,:] + self.uYi_favg = f["uYi_favg"][:][0,:] + self.vYi_favg = f["vYi_favg"][:][0,:] + self.wYi_favg = f["wYi_favg"][:][0,:] self.SpeciesNames = f.attrs.get("SpeciesNames") @@ -70,35 +98,43 @@ def __init__(self, filename, symmetric = False): for isp, sp in enumerate(self.SpeciesNames): self.MolarFracs_avg[:,isp] /= weight self.MolarFracs_rms[:,isp] /= weight - - #self.pressure_rms = np.sqrt(np.maximum( self.pressure_rms - self.pressure_avg**2, 0.0)) - #self.temperature_rms = np.sqrt(np.maximum(self.temperature_rms - self.temperature_avg**2, 0.0)) - #self.MolarFracs_rms = np.sqrt(np.maximum( self.MolarFracs_rms - self.MolarFracs_avg**2, 0.0)) - #self.velocity_rms = np.sqrt(np.maximum( self.velocity_rms - self.velocity_avg**2, 0.0)) - self.pressure_rms = self.pressure_rms - self.pressure_avg**2 - self.temperature_rms = self.temperature_rms - self.temperature_avg**2 - self.MolarFracs_rms = self.MolarFracs_rms - self.MolarFracs_avg**2 - self.velocity_rms = self.velocity_rms - self.velocity_avg**2 + self.MassFracs_avg[ :,isp] /= weight + self.MassFracs_rms[ :,isp] /= weight + + self.pressure_rms -= self.pressure_avg**2 + self.temperature_rms -= self.temperature_avg**2 + self.MolarFracs_rms -= self.MolarFracs_avg**2 + self.MassFracs_rms -= self.MassFracs_avg**2 + self.velocity_rms -= self.velocity_avg**2 + self.velocity_rey[:,0] -= self.velocity_avg[:,0]*self.velocity_avg[:,1] + self.velocity_rey[:,1] -= self.velocity_avg[:,0]*self.velocity_avg[:,2] + self.velocity_rey[:,2] -= self.velocity_avg[:,1]*self.velocity_avg[:,2] self.rho_avg /= weight self.rho_rms /= weight - self.mu_avg /= weight - self.mu_rms /= weight - self.lam_avg /= weight - self.lam_rms /= weight - self.SoS_avg /= weight - self.SoS_rms /= weight + self.mu_avg /= weight + self.lam_avg /= weight + self.SoS_avg /= weight + self.cp_avg /= weight + self.Ent_avg /= weight + for isp, sp in enumerate(self.SpeciesNames): + self.Di_avg[:,isp] /= weight + + self.rho_rms = self.rho_rms - self.rho_avg**2 + + self.HeatReleaseRate_avg /= weight + self.HeatReleaseRate_rms /= weight for isp, sp in enumerate(self.SpeciesNames): - self.Di_avg[:,isp] /= weight - self.Di_rms[:,isp] /= weight + self.ProductionRates_avg[:,isp] /= weight + self.ProductionRates_rms[:,isp] /= weight - self.mu_rms = np.sqrt(np.maximum( self.mu_rms - self.mu_avg**2, 0.0)) - self.lam_rms = np.sqrt(np.maximum(self.lam_rms - self.lam_avg**2, 0.0)) - self.Di_rms = np.sqrt(np.maximum( self.Di_rms - self.Di_avg**2, 0.0)) - self.SoS_rms = np.sqrt(np.maximum(self.SoS_rms - self.SoS_avg**2, 0.0)) + self.ProductionRates_rms -= self.ProductionRates_avg**2 + self.HeatReleaseRate_rms -= self.HeatReleaseRate_avg**2 - self.temperature_favg /= weight - self.temperature_frms /= weight + self.pressure_favg /= weight + self.pressure_frms /= weight + self.temperature_favg /= weight + self.temperature_frms /= weight for i in range(3): self.velocity_favg[:,i] /= weight self.velocity_frms[:,i] /= weight @@ -107,15 +143,27 @@ def __init__(self, filename, symmetric = False): for isp, sp in enumerate(self.SpeciesNames): self.MolarFracs_favg[:,isp] /= weight self.MolarFracs_frms[:,isp] /= weight + self.MassFracs_favg[ :,isp] /= weight + self.MassFracs_frms[ :,isp] /= weight - #self.temperature_frms = np.sqrt(np.maximum(self.temperature_frms - self.temperature_favg**2, 0.0)) - #self.MolarFracs_frms = np.sqrt(np.maximum( self.MolarFracs_frms - self.MolarFracs_favg**2, 0.0)) - #self.velocity_frms = np.sqrt(np.maximum( self.velocity_rms - self.velocity_avg**2, 0.0)) - self.temperature_frms = self.temperature_frms - self.temperature_favg**2//self.rho_avg[:] + self.pressure_frms -= self.pressure_favg**2/self.rho_avg[:] + self.temperature_frms -= self.temperature_favg**2/self.rho_avg[:] for isp, sp in enumerate(self.SpeciesNames): - self.MolarFracs_frms[:,isp] = self.MolarFracs_frms[:,isp] - self.MolarFracs_favg[:,isp]**2/self.rho_avg[:] + self.MolarFracs_frms[:,isp] -= self.MolarFracs_favg[:,isp]**2/self.rho_avg[:] + self.MassFracs_frms[ :,isp] -= self.MassFracs_favg[ :,isp]**2/self.rho_avg[:] for i in range(3): - self.velocity_frms[:,i] = self.velocity_frms[:,i] - self.velocity_favg[:,i]**2/self.rho_avg[:] + self.velocity_frms[:,i] -= self.velocity_favg[:,i]**2/self.rho_avg[:] + self.velocity_frey[:,0] -= self.velocity_favg[:,0]*self.velocity_favg[:,1]/self.rho_avg[:] + self.velocity_frey[:,1] -= self.velocity_favg[:,0]*self.velocity_favg[:,2]/self.rho_avg[:] + self.velocity_frey[:,2] -= self.velocity_favg[:,1]*self.velocity_favg[:,2]/self.rho_avg[:] + + self.mu_favg /= weight + self.lam_favg /= weight + self.SoS_favg /= weight + self.cp_favg /= weight + self.Ent_favg /= weight + for isp, sp in enumerate(self.SpeciesNames): + self.Di_favg[:,isp] /= weight for i in range(3): self.rhoUUv[:,i] /= weight @@ -134,6 +182,26 @@ def __init__(self, filename, symmetric = False): self.Pr_rms /= weight self.Ec /= weight self.Ec_rms /= weight + self.Ma /= weight + for isp, sp in enumerate(self.SpeciesNames): + self.Sc[:,isp] /= weight + + self.Pr_rms -= self.Pr**2 + self.Ec_rms -= self.Ec**2 + + for i in range(3): + self.uT_avg[:,i] /= weight + for isp, sp in enumerate(self.SpeciesNames): + self.uYi_avg[:,isp] /= weight + self.vYi_avg[:,isp] /= weight + self.wYi_avg[:,isp] /= weight + + for i in range(3): + self.uT_favg[:,i] /= weight + for isp, sp in enumerate(self.SpeciesNames): + self.uYi_favg[:,isp] /= weight + self.vYi_favg[:,isp] /= weight + self.wYi_favg[:,isp] /= weight def avgYSymmetric(self): self.pressure_avg = 0.5*(self.pressure_avg + self.pressure_avg[::-1]) @@ -143,6 +211,8 @@ def avgYSymmetric(self): for isp, sp in enumerate(self.SpeciesNames): self.MolarFracs_avg[:, isp] = 0.5*(self.MolarFracs_avg[:, isp] + self.MolarFracs_avg[::-1, isp]) self.MolarFracs_rms[:, isp] = 0.5*(self.MolarFracs_rms[:, isp] + self.MolarFracs_rms[::-1, isp]) + self.MassFracs_avg[ :, isp] = 0.5*(self.MassFracs_avg[ :, isp] + self.MassFracs_avg[ ::-1, isp]) + self.MassFracs_rms[ :, isp] = 0.5*(self.MassFracs_rms[ :, isp] + self.MassFracs_rms[ ::-1, isp]) self.velocity_avg[:,0] = 0.5*(self.velocity_avg[:,0] + self.velocity_avg[::-1,0]) self.velocity_avg[:,1] = 0.5*(self.velocity_avg[:,1] - self.velocity_avg[::-1,1]) self.velocity_avg[:,2] = 0.5*(self.velocity_avg[:,2] + self.velocity_avg[::-1,2]) @@ -151,23 +221,30 @@ def avgYSymmetric(self): self.velocity_rey[:,1] = 0.5*(self.velocity_rey[:,1] + self.velocity_rey[::-1,1]) self.velocity_rey[:,2] = 0.5*(self.velocity_rey[:,2] - self.velocity_rey[::-1,2]) - self.rho_avg = 0.5*(self.rho_avg + self.rho_avg[::-1]) - self.rho_rms = 0.5*(self.rho_rms + self.rho_rms[::-1]) - self.mu_avg = 0.5*(self.mu_avg + self.mu_avg [::-1]) - self.mu_rms = 0.5*(self.mu_rms + self.mu_rms [::-1]) - self.lam_avg = 0.5*(self.lam_avg + self.lam_avg[::-1]) - self.lam_rms = 0.5*(self.lam_rms + self.lam_rms[::-1]) + self.rho_avg = 0.5*(self.rho_avg + self.rho_avg [::-1]) + self.rho_rms = 0.5*(self.rho_rms + self.rho_rms [::-1]) + self.mu_avg = 0.5*(self.mu_avg + self.mu_avg [::-1]) + self.lam_avg = 0.5*(self.lam_avg + self.lam_avg [::-1]) for isp, sp in enumerate(self.SpeciesNames): - self.Di_avg[:, isp] = 0.5*(self.Di_avg[:, isp] + self.Di_avg [::-1, isp]) - self.Di_rms[:, isp] = 0.5*(self.Di_rms[:, isp] + self.Di_rms [::-1, isp]) - self.SoS_avg = 0.5*(self.SoS_avg + self.SoS_avg[::-1]) - self.SoS_rms = 0.5*(self.SoS_rms + self.SoS_rms[::-1]) - + self.Di_avg[:, isp] = 0.5*(self.Di_avg[:, isp] + self.Di_avg[::-1, isp]) + self.SoS_avg = 0.5*(self.SoS_avg + self.SoS_avg [::-1]) + self.cp_avg = 0.5*(self.cp_avg + self.cp_avg [::-1]) + self.Ent_avg = 0.5*(self.Ent_avg + self.Ent_avg [::-1]) + + self.ProductionRates_avg = 0.5*(self.ProductionRates_avg + self.ProductionRates_avg[::-1]) + self.ProductionRates_rms = 0.5*(self.ProductionRates_rms + self.ProductionRates_rms[::-1]) + self.HeatReleaseRate_avg = 0.5*(self.HeatReleaseRate_avg + self.HeatReleaseRate_avg[::-1]) + self.HeatReleaseRate_rms = 0.5*(self.HeatReleaseRate_rms + self.HeatReleaseRate_rms[::-1]) + + self.pressure_favg = 0.5*(self.pressure_favg + self.pressure_favg[ ::-1]) + self.pressure_frms = 0.5*(self.pressure_frms + self.pressure_frms[ ::-1]) self.temperature_favg = 0.5*(self.temperature_favg + self.temperature_favg[::-1]) self.temperature_frms = 0.5*(self.temperature_frms + self.temperature_frms[::-1]) for isp, sp in enumerate(self.SpeciesNames): self.MolarFracs_favg[:, isp] = 0.5*(self.MolarFracs_favg[:, isp] + self.MolarFracs_favg[::-1, isp]) self.MolarFracs_frms[:, isp] = 0.5*(self.MolarFracs_frms[:, isp] + self.MolarFracs_frms[::-1, isp]) + self.MassFracs_favg[ :, isp] = 0.5*(self.MassFracs_favg[ :, isp] + self.MassFracs_favg[ ::-1, isp]) + self.MassFracs_frms[ :, isp] = 0.5*(self.MassFracs_frms[ :, isp] + self.MassFracs_frms[ ::-1, isp]) self.velocity_favg[:,0] = 0.5*(self.velocity_favg[:,0] + self.velocity_favg[::-1,0]) self.velocity_favg[:,1] = 0.5*(self.velocity_favg[:,1] - self.velocity_favg[::-1,1]) self.velocity_favg[:,2] = 0.5*(self.velocity_favg[:,2] + self.velocity_favg[::-1,2]) @@ -176,6 +253,14 @@ def avgYSymmetric(self): self.velocity_frey[:,1] = 0.5*(self.velocity_frey[:,1] + self.velocity_frey[::-1,1]) self.velocity_frey[:,2] = 0.5*(self.velocity_frey[:,2] - self.velocity_frey[::-1,2]) + self.mu_favg = 0.5*(self.mu_favg + self.mu_favg [::-1]) + self.lam_favg = 0.5*(self.lam_favg + self.lam_favg [::-1]) + for isp, sp in enumerate(self.SpeciesNames): + self.Di_favg[:, isp] = 0.5*(self.Di_favg[:, isp] + self.Di_favg[::-1, isp]) + self.SoS_favg = 0.5*(self.SoS_favg + self.SoS_favg [::-1]) + self.cp_favg = 0.5*(self.cp_favg + self.cp_favg [::-1]) + self.Ent_favg = 0.5*(self.Ent_favg + self.Ent_favg [::-1]) + self.rhoUUv[:,:] = 0.5*( self.rhoUUv[:,:] - self.rhoUUv[::-1,:]) self.Up[:,0] = 0.5*( self.Up[:,0] + self.Up[::-1,0]) self.Up[:,1] = 0.5*( self.Up[:,1] - self.Up[::-1,1]) @@ -200,11 +285,25 @@ def avgYSymmetric(self): self.q[:,1] = 0.5*(self.q[:,1] - self.q[::-1,1]) self.q[:,2] = 0.5*(self.q[:,2] + self.q[::-1,2]) - self.Pr = 0.5*(self.Pr + self.Pr ) - self.Pr_rms = 0.5*(self.Pr_rms + self.Pr_rms) - self.Ec = 0.5*(self.Ec + self.Ec ) - self.Ec_rms = 0.5*(self.Ec_rms + self.Ec_rms) - - return - + self.Pr = 0.5*(self.Pr + self.Pr [::-1]) + self.Pr_rms = 0.5*(self.Pr_rms + self.Pr_rms[::-1]) + self.Ec = 0.5*(self.Ec + self.Ec [::-1]) + self.Ec_rms = 0.5*(self.Ec_rms + self.Ec_rms[::-1]) + self.Ma = 0.5*(self.Ma + self.Ma [::-1]) + for isp, sp in enumerate(self.SpeciesNames): + self.Sc[:, isp] = 0.5*(self.Sc[:, isp] + self.Sc[::-1, isp]) + + self.uT_avg [:,0] = 0.5*(self.uT_avg [:,0] + self.uT_avg [::-1,0]) + self.uT_avg [:,1] = 0.5*(self.uT_avg [:,1] - self.uT_avg [::-1,1]) + self.uT_avg [:,2] = 0.5*(self.uT_avg [:,2] + self.uT_avg [::-1,2]) + self.uYi_avg[:,:] = 0.5*(self.uYi_avg[:,:] + self.uYi_avg[::-1,:]) + self.vYi_avg[:,:] = 0.5*(self.vYi_avg[:,:] - self.vYi_avg[::-1,:]) + self.wYi_avg[:,:] = 0.5*(self.wYi_avg[:,:] + self.wYi_avg[::-1,:]) + + self.uT_favg [:,0] = 0.5*(self.uT_favg [:,0] + self.uT_favg [::-1,0]) + self.uT_favg [:,1] = 0.5*(self.uT_favg [:,1] - self.uT_favg [::-1,1]) + self.uT_favg [:,2] = 0.5*(self.uT_favg [:,2] + self.uT_favg [::-1,2]) + self.uYi_favg[:,:] = 0.5*(self.uYi_favg[:,:] + self.uYi_favg[::-1,:]) + self.vYi_favg[:,:] = 0.5*(self.vYi_favg[:,:] - self.vYi_favg[::-1,:]) + self.wYi_favg[:,:] = 0.5*(self.wYi_favg[:,:] + self.wYi_favg[::-1,:]) diff --git a/scripts/modules/ConstPropMix.py b/scripts/modules/ConstPropMix.py index 3a22537..883db31 100755 --- a/scripts/modules/ConstPropMix.py +++ b/scripts/modules/ConstPropMix.py @@ -4,12 +4,12 @@ def GetDensity(T, P, config): return P/(T*config["Flow"]["gasConstant"]) def GetViscosity(T, config): - if (config["Flow"]["viscosityModel"] == "Constant"): - viscosity = config["Flow"]["constantVisc"] - elif (config["Flow"]["viscosityModel"] == "PowerLaw"): - viscosity = config["Flow"]["powerlawViscRef"]*(T/config["Flow"]["powerlawTempRef"])**0.7 - elif (config["Flow"]["viscosityModel"] == "Sutherland"): - viscosity = (config["Flow"]["sutherlandViscRef"]*(T/config["Flow"]["sutherlandTempRef"])**1.5)*(config["Flow"]["sutherlandTempRef"]+config["Flow"]["sutherlandSRef"])/(T+config["Flow"]["sutherlandSRef"]) + if (config["Flow"]["viscosityModel"]["type"] == "Constant"): + viscosity = config["Flow"]["viscosityModel"]["Visc"] + elif (config["Flow"]["viscosityModel"]["type"] == "PowerLaw"): + viscosity = config["Flow"]["viscosityModel"]["ViscRef"]*(T/config["Flow"]["viscosityModel"]["TempRef"])**0.7 + elif (config["Flow"]["viscosityModel"]["type"] == "Sutherland"): + viscosity = (config["Flow"]["viscosityModel"]["ViscRef"]*(T/config["Flow"]["viscosityModel"]["TempRef"])**1.5)*(config["Flow"]["viscosityModel"]["TempRef"]+config["Flow"]["viscosityModel"]["SRef"])/(T+config["Flow"]["viscosityModel"]["SRef"]) else: assert False return viscosity diff --git a/scripts/modules/gridGen.py b/scripts/modules/gridGen.py index 2911217..63f8a7e 100755 --- a/scripts/modules/gridGen.py +++ b/scripts/modules/gridGen.py @@ -20,6 +20,22 @@ def GetGridFaces(Origin, Width, Num, Type, stretching, dx=1, xswitch=1, switch=1 x = np.linspace( 0.0, 1.0, Num+1) x = np.tanh(stretching*x)/np.tanh(stretching) x = Width*x+Origin + elif (Type == 'Tanh'): + x = np.linspace(-1.0, 1.0, Num+1) + x = np.tanh(stretching*x)/np.tanh(stretching) + x = 0.5*Width*(x+1.0)+Origin + elif (Type == 'SinhMinus'): + x = np.linspace( 0.0, 1.0, Num+1) + x = np.sinh(stretching*x)/np.sinh(stretching) + x = Width*x+Origin + elif (Type == 'SinhPlus'): + x = np.linspace(-1.0, 0.0, Num+1) + x = np.sinh(stretching*x)/np.sinh(stretching) + x = Width*(x+1.0)+Origin + elif (Type == 'Sinh'): + x = np.linspace(-1.0, 1.0, Num+1) + x = np.sinh(stretching*x)/np.sinh(stretching) + x = 0.5*Width*(x+1.0)+Origin elif (Type == 'GeometricMinus'): assert dx Solver version: %s" % version[0]) +print(" > Legion version: %s" % version[1]) diff --git a/scripts/restart_old2new.py b/scripts/restart_old2new.py new file mode 100755 index 0000000..fecd679 --- /dev/null +++ b/scripts/restart_old2new.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python2 + +import argparse +import h5py +import numpy as np +from joblib import Parallel, delayed + +parser = argparse.ArgumentParser() +parser.add_argument('--np', nargs='?', default=1, type=int, + help='number of cores') +parser.add_argument('hdf_file', nargs='+') +args = parser.parse_args() + +def processFile(f): + print(f) + with h5py.File(f, 'r+') as fout: + dudtBoundary_old = fout["dudtBoundary"][:] + del fout["dudtBoundary"] + del fout["velocity_old_NSCBC"] + del fout["temperature_old_NSCBC"] + shape = dudtBoundary_old.shape + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) + dudtBoundary = np.ndarray( shape, dtype = np.dtype('(3,)f8')) + for (k,j,i), v in np.ndenumerate(dudtBoundary_old): + dudtBoundary[k,j,i] = [v, 0.0, 0.0] + fout["dudtBoundary"][:] = dudtBoundary + +#for f in args.hdf_file: processFile(f) +Parallel(n_jobs=args.np)(delayed(processFile)(f) for f in args.hdf_file) diff --git a/solverTests/3DPeriodic/base.json b/solverTests/3DPeriodic/base.json new file mode 100644 index 0000000..b129c28 --- /dev/null +++ b/solverTests/3DPeriodic/base.json @@ -0,0 +1,76 @@ +{ + "Mapping" : { + "tiles" : [1,1,1], + "tilesPerRank" : [1,1,1], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 32, + "yNum" : 32, + "zNum" : 32, + "origin" : [0.0, 0.0, 0.0], + "xWidth" : 6.28318530718, + "yWidth" : 6.28318530718, + "zWidth" : 6.28318530718, + "xType" : "Uniform", + "yType" : "Uniform", + "zType" : "Uniform", + "xStretching" : 1.0, + "yStretching" : 1.0, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 20, + "maxTime" : 30.0, + "cfl" : -0.9, + "fixedDeltaTime" : 5.0e-3, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } + }, + + "Flow" : { + "mixture": "ConstPropMix", + "gasConstant" : 1.0, + "gamma" : 1.4, + "prandtl" : 0.71, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, + "initCase" : "TaylorGreen3DVortex", + "restartDir" : "", + "initParams" : [100.0, 100.0, 1.0, 1.0, 1.0], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + }, + "bodyForce" : [0.0, 0.0, 0.0], + "turbForcing" : { "type" : "OFF" } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 100, + "probes" : [], + "AveragesSamplingInterval": 10, + "ResetAverages": false, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } +} diff --git a/solverTests/3DPeriodic/cpu_ref.hdf b/solverTests/3DPeriodic/cpu_ref.hdf new file mode 100644 index 0000000..9d275c8 --- /dev/null +++ b/solverTests/3DPeriodic/cpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:932e933a0c2e82f745b3a9c51087b46019d04c3baacfa82b244e74b03e095222 +size 5772560 diff --git a/solverTests/3DPeriodic/gpu_ref.hdf b/solverTests/3DPeriodic/gpu_ref.hdf new file mode 100644 index 0000000..b2efc01 --- /dev/null +++ b/solverTests/3DPeriodic/gpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10023f56d81db76889244507d4fec07bea9b734c392c885d6b30e8315de128be +size 4986128 diff --git a/solverTests/3DPeriodic_Air/base.json b/solverTests/3DPeriodic_Air/base.json new file mode 100644 index 0000000..0755ea4 --- /dev/null +++ b/solverTests/3DPeriodic_Air/base.json @@ -0,0 +1,77 @@ +{ + "Mapping" : { + "tiles" : [1,1,1], + "tilesPerRank" : [1,1,1], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 32, + "yNum" : 32, + "zNum" : 32, + "origin" : [0.0, 0.0, 0.0], + "xWidth" : 6.28318530718, + "yWidth" : 6.28318530718, + "zWidth" : 6.28318530718, + "xType" : "Uniform", + "yType" : "Uniform", + "zType" : "Uniform", + "xStretching" : 1.0, + "yStretching" : 1.0, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 20, + "maxTime" : 30.0, + "cfl" : 0.5, + "fixedDeltaTime" : 5.0e-4, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } + }, + + "Flow" : { + "mixture": "AirMix", + "gasConstant" : 1.0, + "gamma" : 1.4, + "prandtl" : 0.71, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, + "initCase" : "TaylorGreen3DVortex", + "restartDir" : "", + "initParams" : [1e5, 500.0, 1.0, 1.0, 1.0], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, + {"Name" : "O2", "MolarFrac" : 0.21 }] + }, + "bodyForce" : [0.0, 0.0, 0.0], + "turbForcing" : { "type" : "OFF" } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 100, + "probes" : [], + "AveragesSamplingInterval": 10, + "ResetAverages": false, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } +} diff --git a/solverTests/3DPeriodic_Air/cpu_ref.hdf b/solverTests/3DPeriodic_Air/cpu_ref.hdf new file mode 100644 index 0000000..01860ed --- /dev/null +++ b/solverTests/3DPeriodic_Air/cpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c989a82bd70fa5c9c340b9ade41bd994742971c62ef5cfca1dcc4678540ae5e +size 5509680 diff --git a/solverTests/3DPeriodic_Air/gpu_ref.hdf b/solverTests/3DPeriodic_Air/gpu_ref.hdf new file mode 100644 index 0000000..e60dd6c --- /dev/null +++ b/solverTests/3DPeriodic_Air/gpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a9d5fe42c61a7a14ba3399fffe02a472c4908622049ebf7c35a09264afedf2f +size 6034792 diff --git a/solverTests/BoundaryLayer/MakeInput.py b/solverTests/BoundaryLayer/MakeInput.py new file mode 100755 index 0000000..5d07fec --- /dev/null +++ b/solverTests/BoundaryLayer/MakeInput.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python2 + +import argparse +import sys +import os +import json +import numpy as np +import h5py +from random import * +import pandas + +# load local modules +sys.path.insert(0, os.path.expandvars("$HTR_DIR/scripts/modules")) +import gridGen +import ConstPropMix + +parser = argparse.ArgumentParser() +parser.add_argument('base_json', type=argparse.FileType('r'), default='base.json') +args = parser.parse_args() + +############################################################################## +# Read similarity solution # +############################################################################## + +CBL = pandas.read_csv("SimilaritySolution.dat") +etaB = CBL["eta"][:].values +fB = CBL["f"][:].values +uB = CBL["u"][:].values +TB = CBL["T"][:].values + +############################################################################## +# Setup Case # +############################################################################## + +# Read base config +config = json.load(args.base_json) + +gamma = config["Flow"]["gamma"] +R = config["Flow"]["gasConstant"] +Pr = config["Flow"]["prandtl"] + +assert config["Flow"]["initCase"] == "Restart" +restartDir = config["Flow"]["restartDir"] + +config["BC"]["xBCLeft"]["VelocityProfile"]["FileDir"] = restartDir +config["BC"]["xBCLeft"]["TemperatureProfile"]["FileDir"] = restartDir +TInf = 300.0 +Tw = 300.0 +P = config["BC"]["xBCLeft"]["P"] +UInf = 2083.67 +Rex0 = 100000 + +aInf = np.sqrt(gamma*R*TInf) +MaInf = UInf/aInf + +RhoInf = ConstPropMix.GetDensity(TInf, P, config) +muInf = ConstPropMix.GetViscosity(TInf, config) +nuInf = muInf/RhoInf + +############################################################################## +# Generate Grid # +############################################################################## + +xGrid, dx = gridGen.GetGrid(config["Grid"]["origin"][0], + config["Grid"]["xWidth"], + config["Grid"]["xNum"], + config["Grid"]["xType"], + config["Grid"]["xStretching"], + False) + +yGrid, dy = gridGen.GetGrid(config["Grid"]["origin"][1], + config["Grid"]["yWidth"], + config["Grid"]["yNum"], + config["Grid"]["yType"], + config["Grid"]["yStretching"], + False) + +zGrid, dz = gridGen.GetGrid(config["Grid"]["origin"][2], + config["Grid"]["zWidth"], + config["Grid"]["zNum"], + config["Grid"]["zType"], + config["Grid"]["zStretching"], + False) + +# Load mapping +Ntiles = config["Mapping"]["tiles"] + +assert config["Grid"]["xNum"] % Ntiles[0] == 0 +assert config["Grid"]["yNum"] % Ntiles[1] == 0 +assert config["Grid"]["zNum"] % Ntiles[2] == 0 + +NxTile = int(config["Grid"]["xNum"]/Ntiles[0]) +NyTile = int(config["Grid"]["yNum"]/Ntiles[1]) +NzTile = int(config["Grid"]["zNum"]/Ntiles[2]) + +halo = [1, 1, 0] + +############################################################################## +# Rescale Reynodls number of similarity solution # +############################################################################## + +yB = np.zeros(etaB.size) +for i in range(etaB.size): + if (i != 0) : + rhoMid = 0.5*(ConstPropMix.GetDensity(TB[i ]*TInf, P, config) + + ConstPropMix.GetDensity(TB[i-1]*TInf, P, config)) + dyB = np.sqrt(2*Rex0)*muInf/(rhoMid*UInf)*(etaB[i] - etaB[i-1]) + yB[i] = yB[i-1] + dyB + +x0 = Rex0*nuInf/UInf +vB = 0.5*yB/x0*uB - TB/np.sqrt(2*Rex0)*fB + +uB *= UInf +vB *= UInf +TB *= TInf + +############################################################################## +# Produce restart and profile files # +############################################################################## +if not os.path.exists(restartDir): + os.makedirs(restartDir) + +for xt in range(0, Ntiles[0]): + for yt in range(0, Ntiles[1]): + for zt in range(0, Ntiles[2]): + lo_bound = [(xt )*NxTile +halo[0], (yt )*NyTile +halo[1], (zt )*NzTile +halo[2]] + hi_bound = [(xt+1)*NxTile-1+halo[0], (yt+1)*NyTile-1+halo[1], (zt+1)*NzTile-1+halo[2]] + if (xt == 0): lo_bound[0] -= halo[0] + if (yt == 0): lo_bound[1] -= halo[1] + if (zt == 0): lo_bound[2] -= halo[2] + if (xt == Ntiles[0]-1): hi_bound[0] += halo[0] + if (yt == Ntiles[1]-1): hi_bound[1] += halo[1] + if (zt == Ntiles[2]-1): hi_bound[2] += halo[2] + filename = ('%s,%s,%s-%s,%s,%s.hdf' + % (lo_bound[0], lo_bound[1], lo_bound[2], + hi_bound[0], hi_bound[1], hi_bound[2])) + print("Working on: ", filename) + + shape = [hi_bound[2] - lo_bound[2] +1, + hi_bound[1] - lo_bound[1] +1, + hi_bound[0] - lo_bound[0] +1] + + centerCoordinates = np.ndarray(shape, dtype=np.dtype('(3,)f8')) + cellWidth = np.ndarray(shape, dtype=np.dtype('(3,)f8')) + rho = np.ndarray(shape) + pressure = np.ndarray(shape) + temperature = np.ndarray(shape) + MolarFracs = np.ndarray(shape, dtype=np.dtype('(1,)f8')) + velocity = np.ndarray(shape, dtype=np.dtype('(3,)f8')) + dudtBoundary = np.ndarray(shape, dtype=np.dtype('(3,)f8')) + dTdtBoundary = np.ndarray(shape) + pressure[:] = P + dudtBoundary[:] = [ 0.0, 0.0, 0.0] + dTdtBoundary[:] = 0.0 + for (k,kc) in enumerate(centerCoordinates): + for (j,jc) in enumerate(kc): + for (i,ic) in enumerate(jc): + Re = (xGrid[i+lo_bound[0]]+x0)*UInf/nuInf + yB1 = yB*np.sqrt(Re/Rex0) + vB1 = vB/np.sqrt(Re/Rex0) + + u = np.interp(yGrid[j+lo_bound[1]], yB1, uB) + v = np.interp(yGrid[j+lo_bound[1]], yB1, vB1) + T = np.interp(yGrid[j+lo_bound[1]], yB1, TB) + + centerCoordinates[k,j,i] = [xGrid[i+lo_bound[0]], yGrid[j+lo_bound[1]], zGrid[k+lo_bound[2]]] + cellWidth [k,j,i] = [ dx[i+lo_bound[0]], dy[j+lo_bound[1]], dz[k+lo_bound[2]]] + temperature [k,j,i] = T + rho [k,j,i] = P/(R*temperature[k,j,i]) + MolarFracs [k,j,i] = [1.0,] + velocity [k,j,i] = [ u, v, 0.0] + + with h5py.File(os.path.join(restartDir, filename), 'w') as fout: + fout.attrs.create("SpeciesNames", ["MIX".encode()], dtype="S20") + fout.attrs.create("timeStep", 0) + fout.attrs.create("simTime", 0.0) + fout.attrs.create("channelForcing", 0.0) + + fout.create_dataset("centerCoordinates", shape=shape, dtype = np.dtype("(3,)f8")) + fout.create_dataset("cellWidth", shape=shape, dtype = np.dtype("(3,)f8")) + fout.create_dataset("rho", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("pressure", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("temperature", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("MolarFracs", shape=shape, dtype = np.dtype("(1,)f8")) + fout.create_dataset("velocity", shape=shape, dtype = np.dtype("(3,)f8")) + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) + fout.create_dataset("dTdtBoundary", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("MolarFracs_profile", shape=shape, dtype = np.dtype("(1,)f8")) + fout.create_dataset("velocity_profile", shape=shape, dtype = np.dtype("(3,)f8")) + fout.create_dataset("temperature_profile", shape=shape, dtype = np.dtype("f8")) + + fout["centerCoordinates"][:] = centerCoordinates + fout["cellWidth"][:] = cellWidth + fout["rho"][:] = rho + fout["pressure"][:] = pressure + fout["temperature"][:] = temperature + fout["MolarFracs"][:] = MolarFracs + fout["velocity"][:] = velocity + fout["dudtBoundary"][:] = dudtBoundary + fout["dTdtBoundary"][:] = dTdtBoundary + fout["MolarFracs_profile"][:] = MolarFracs + fout["velocity_profile"][:] = velocity + fout["temperature_profile"][:] = temperature + diff --git a/solverTests/BoundaryLayer/SimilaritySolution.dat b/solverTests/BoundaryLayer/SimilaritySolution.dat new file mode 100644 index 0000000..1604917 --- /dev/null +++ b/solverTests/BoundaryLayer/SimilaritySolution.dat @@ -0,0 +1,501 @@ +eta,f,u,T +0,-1.38691e-22,0,1 +0.0200401,8.45892e-05,0.00849764,1.04463 +0.0400802,0.000340587,0.0171047,1.0891 +0.0601202,0.000770148,0.0258175,1.13335 +0.0801603,0.00137536,0.0346326,1.17734 +0.1002,0.00215823,0.0435464,1.22103 +0.12024,0.00312071,0.0525557,1.26437 +0.140281,0.00426467,0.0616571,1.30733 +0.160321,0.00559193,0.0708474,1.34986 +0.180361,0.00710424,0.0801233,1.39192 +0.200401,0.00880329,0.0894817,1.43349 +0.220441,0.0106907,0.0989196,1.47451 +0.240481,0.012768,0.108434,1.51496 +0.260521,0.0150367,0.118021,1.5548 +0.280561,0.0174983,0.127678,1.59399 +0.300601,0.0201541,0.137403,1.63252 +0.320641,0.0230054,0.147191,1.67034 +0.340681,0.0260535,0.15704,1.70742 +0.360721,0.0292996,0.166946,1.74375 +0.380762,0.0327448,0.176908,1.77928 +0.400802,0.0363901,0.18692,1.814 +0.420842,0.0402365,0.196981,1.84787 +0.440882,0.0442851,0.207086,1.88088 +0.460922,0.0485366,0.217234,1.913 +0.480962,0.0529919,0.22742,1.94421 +0.501002,0.0576516,0.237641,1.97449 +0.521042,0.0625166,0.247894,2.00382 +0.541082,0.0675873,0.258175,2.03218 +0.561122,0.0728643,0.268482,2.05955 +0.581162,0.0783481,0.27881,2.08592 +0.601202,0.084039,0.289157,2.11127 +0.621242,0.0899375,0.299518,2.13559 +0.641283,0.0960437,0.30989,2.15887 +0.661323,0.102358,0.32027,2.1811 +0.681363,0.10888,0.330654,2.20227 +0.701403,0.115611,0.341039,2.22237 +0.721443,0.122549,0.35142,2.2414 +0.741483,0.129696,0.361795,2.25934 +0.761523,0.13705,0.372159,2.2762 +0.781563,0.144612,0.382509,2.29197 +0.801603,0.152381,0.392842,2.30666 +0.821643,0.160357,0.403152,2.32026 +0.841683,0.168539,0.413438,2.33277 +0.861723,0.176928,0.423694,2.3442 +0.881764,0.185521,0.433918,2.35456 +0.901804,0.194319,0.444106,2.36384 +0.921844,0.203321,0.454254,2.37206 +0.941884,0.212526,0.464358,2.37923 +0.961924,0.221932,0.474415,2.38535 +0.981964,0.23154,0.484421,2.39044 +1.002,0.241348,0.494373,2.39451 +1.02204,0.251355,0.504267,2.39757 +1.04208,0.261559,0.514099,2.39964 +1.06212,0.27196,0.523867,2.40074 +1.08216,0.282556,0.533566,2.40087 +1.1022,0.293345,0.543194,2.40007 +1.12224,0.304327,0.552746,2.39835 +1.14228,0.3155,0.562221,2.39573 +1.16232,0.326861,0.571615,2.39222 +1.18236,0.33841,0.580925,2.38787 +1.2024,0.350145,0.590147,2.38268 +1.22244,0.362063,0.599279,2.37668 +1.24248,0.374164,0.608319,2.36989 +1.26253,0.386445,0.617263,2.36235 +1.28257,0.398904,0.626109,2.35407 +1.30261,0.411539,0.634854,2.34508 +1.32265,0.424349,0.643497,2.33541 +1.34269,0.437331,0.652034,2.32509 +1.36273,0.450483,0.660464,2.31414 +1.38277,0.463802,0.668784,2.30259 +1.40281,0.477288,0.676993,2.29047 +1.42285,0.490936,0.685089,2.27781 +1.44289,0.504746,0.69307,2.26463 +1.46293,0.518715,0.700934,2.25096 +1.48297,0.53284,0.70868,2.23684 +1.50301,0.547119,0.716307,2.22228 +1.52305,0.561549,0.723814,2.20732 +1.54309,0.576129,0.731199,2.19198 +1.56313,0.590856,0.738461,2.17629 +1.58317,0.605727,0.7456,2.16029 +1.60321,0.62074,0.752615,2.14398 +1.62325,0.635892,0.759505,2.12741 +1.64329,0.651181,0.76627,2.11059 +1.66333,0.666604,0.77291,2.09355 +1.68337,0.682159,0.779424,2.07632 +1.70341,0.697843,0.785811,2.05892 +1.72345,0.713655,0.792073,2.04138 +1.74349,0.72959,0.798209,2.02371 +1.76353,0.745647,0.804219,2.00594 +1.78357,0.761823,0.810104,1.98809 +1.80361,0.778116,0.815864,1.97018 +1.82365,0.794523,0.8215,1.95223 +1.84369,0.811042,0.827011,1.93426 +1.86373,0.82767,0.8324,1.9163 +1.88377,0.844405,0.837666,1.89835 +1.90381,0.861244,0.84281,1.88043 +1.92385,0.878185,0.847835,1.86257 +1.94389,0.895225,0.852739,1.84478 +1.96393,0.912362,0.857525,1.82707 +1.98397,0.929595,0.862194,1.80945 +2.00401,0.946919,0.866747,1.79195 +2.02405,0.964334,0.871185,1.77456 +2.04409,0.981837,0.875509,1.75732 +2.06413,0.999425,0.879722,1.74022 +2.08417,1.0171,0.883824,1.72328 +2.10421,1.03485,0.887817,1.7065 +2.12425,1.05268,0.891703,1.68991 +2.14429,1.07059,0.895482,1.6735 +2.16433,1.08857,0.899158,1.65728 +2.18437,1.10663,0.902731,1.64126 +2.20441,1.12475,0.906203,1.62545 +2.22445,1.14295,0.909576,1.60986 +2.24449,1.16121,0.912851,1.59448 +2.26453,1.17953,0.916031,1.57933 +2.28457,1.19792,0.919117,1.56441 +2.30461,1.21637,0.922111,1.54972 +2.32465,1.23488,0.925014,1.53527 +2.34469,1.25345,0.92783,1.52106 +2.36473,1.27207,0.930558,1.50709 +2.38477,1.29074,0.933202,1.49337 +2.40481,1.30947,0.935762,1.47989 +2.42485,1.32825,0.938241,1.46666 +2.44489,1.34708,0.940641,1.45368 +2.46493,1.36595,0.942964,1.44095 +2.48497,1.38487,0.94521,1.42847 +2.50501,1.40384,0.947383,1.41624 +2.52505,1.42284,0.949483,1.40426 +2.54509,1.44189,0.951513,1.39253 +2.56513,1.46098,0.953475,1.38105 +2.58517,1.48011,0.955369,1.36981 +2.60521,1.49927,0.957198,1.35882 +2.62525,1.51847,0.958964,1.34808 +2.64529,1.53771,0.960668,1.33757 +2.66533,1.55697,0.962311,1.32731 +2.68537,1.57628,0.963896,1.31729 +2.70541,1.59561,0.965425,1.3075 +2.72545,1.61497,0.966897,1.29794 +2.74549,1.63436,0.968316,1.28862 +2.76553,1.65378,0.969683,1.27952 +2.78557,1.67323,0.970999,1.27065 +2.80561,1.6927,0.972266,1.262 +2.82565,1.71219,0.973486,1.25357 +2.84569,1.73172,0.974659,1.24535 +2.86573,1.75126,0.975787,1.23735 +2.88577,1.77082,0.976871,1.22956 +2.90581,1.79041,0.977913,1.22198 +2.92585,1.81002,0.978915,1.21459 +2.94589,1.82965,0.979877,1.20741 +2.96593,1.84929,0.980801,1.20042 +2.98597,1.86896,0.981688,1.19363 +3.00601,1.88864,0.982539,1.18702 +3.02605,1.90834,0.983355,1.1806 +3.04609,1.92805,0.984138,1.17436 +3.06613,1.94778,0.984889,1.1683 +3.08617,1.96753,0.985608,1.16242 +3.10621,1.98729,0.986298,1.1567 +3.12625,2.00706,0.986958,1.15115 +3.14629,2.02684,0.98759,1.14577 +3.16633,2.04664,0.988195,1.14055 +3.18637,2.06645,0.988775,1.13548 +3.20641,2.08627,0.989329,1.13057 +3.22645,2.1061,0.989858,1.12581 +3.24649,2.12594,0.990365,1.1212 +3.26653,2.1458,0.990849,1.11672 +3.28657,2.16566,0.991312,1.11239 +3.30661,2.18553,0.991753,1.1082 +3.32665,2.20541,0.992175,1.10414 +3.34669,2.2253,0.992578,1.1002 +3.36673,2.24519,0.992962,1.0964 +3.38677,2.26509,0.993328,1.09272 +3.40681,2.285,0.993677,1.08916 +3.42685,2.30492,0.99401,1.08571 +3.44689,2.32484,0.994327,1.08238 +3.46693,2.34477,0.99463,1.07917 +3.48697,2.36471,0.994917,1.07606 +3.50701,2.38465,0.995191,1.07305 +3.52705,2.4046,0.995452,1.07015 +3.54709,2.42455,0.9957,1.06735 +3.56713,2.4445,0.995935,1.06464 +3.58717,2.46446,0.99616,1.06203 +3.60721,2.48443,0.996373,1.05952 +3.62725,2.5044,0.996575,1.05709 +3.64729,2.52437,0.996767,1.05474 +3.66733,2.54435,0.996949,1.05248 +3.68737,2.56433,0.997122,1.05031 +3.70741,2.58431,0.997286,1.04821 +3.72745,2.6043,0.997442,1.04619 +3.74749,2.62429,0.99759,1.04424 +3.76754,2.64429,0.997729,1.04236 +3.78758,2.66428,0.997862,1.04056 +3.80762,2.68428,0.997987,1.03882 +3.82766,2.70428,0.998106,1.03715 +3.8477,2.72428,0.998218,1.03554 +3.86774,2.74429,0.998324,1.03399 +3.88778,2.7643,0.998425,1.0325 +3.90782,2.78431,0.99852,1.03107 +3.92786,2.80432,0.99861,1.0297 +3.9479,2.82433,0.998694,1.02838 +3.96794,2.84435,0.998774,1.02711 +3.98798,2.86436,0.99885,1.02589 +4.00802,2.88438,0.998921,1.02473 +4.02806,2.9044,0.998988,1.0236 +4.0481,2.92442,0.999052,1.02253 +4.06814,2.94444,0.999111,1.02149 +4.08818,2.96446,0.999167,1.0205 +4.10822,2.98449,0.99922,1.01955 +4.12826,3.00451,0.99927,1.01864 +4.1483,3.02454,0.999317,1.01777 +4.16834,3.04457,0.999361,1.01694 +4.18838,3.06459,0.999403,1.01614 +4.20842,3.08462,0.999442,1.01537 +4.22846,3.10465,0.999478,1.01464 +4.2485,3.12468,0.999513,1.01393 +4.26854,3.14471,0.999545,1.01326 +4.28858,3.16474,0.999575,1.01262 +4.30862,3.18478,0.999604,1.01201 +4.32866,3.20481,0.999631,1.01142 +4.3487,3.22484,0.999656,1.01086 +4.36874,3.24487,0.999679,1.01032 +4.38878,3.26491,0.999701,1.00981 +4.40882,3.28494,0.999721,1.00932 +4.42886,3.30498,0.999741,1.00885 +4.4489,3.32501,0.999759,1.00841 +4.46894,3.34505,0.999775,1.00798 +4.48898,3.36508,0.999791,1.00758 +4.50902,3.38512,0.999806,1.00719 +4.52906,3.40516,0.99982,1.00682 +4.5491,3.42519,0.999832,1.00647 +4.56914,3.44523,0.999844,1.00613 +4.58918,3.46527,0.999856,1.00581 +4.60922,3.4853,0.999866,1.00551 +4.62926,3.50534,0.999876,1.00522 +4.6493,3.52538,0.999885,1.00494 +4.66934,3.54542,0.999893,1.00468 +4.68938,3.56545,0.999901,1.00443 +4.70942,3.58549,0.999908,1.0042 +4.72946,3.60553,0.999915,1.00397 +4.7495,3.62557,0.999921,1.00376 +4.76954,3.64561,0.999927,1.00355 +4.78958,3.66565,0.999933,1.00336 +4.80962,3.68569,0.999938,1.00317 +4.82966,3.70572,0.999943,1.003 +4.8497,3.72576,0.999947,1.00283 +4.86974,3.7458,0.999951,1.00268 +4.88978,3.76584,0.999955,1.00253 +4.90982,3.78588,0.999958,1.00239 +4.92986,3.80592,0.999962,1.00225 +4.9499,3.82596,0.999965,1.00213 +4.96994,3.846,0.999967,1.002 +4.98998,3.86604,0.99997,1.00189 +5.01002,3.88608,0.999972,1.00178 +5.03006,3.90612,0.999975,1.00168 +5.0501,3.92616,0.999977,1.00158 +5.07014,3.9462,0.999978,1.00149 +5.09018,3.96624,0.99998,1.0014 +5.11022,3.98628,0.999982,1.00132 +5.13026,4.00632,0.999983,1.00125 +5.1503,4.02635,0.999985,1.00117 +5.17034,4.04639,0.999986,1.0011 +5.19038,4.06643,0.999987,1.00104 +5.21042,4.08647,0.999988,1.00097 +5.23046,4.10651,0.999989,1.00092 +5.2505,4.12655,0.99999,1.00086 +5.27054,4.14659,0.999991,1.00081 +5.29058,4.16663,0.999992,1.00076 +5.31062,4.18667,0.999992,1.00071 +5.33066,4.20671,0.999993,1.00067 +5.3507,4.22675,0.999994,1.00063 +5.37074,4.24679,0.999994,1.00059 +5.39078,4.26683,0.999995,1.00055 +5.41082,4.28687,0.999995,1.00052 +5.43086,4.30691,0.999996,1.00049 +5.4509,4.32695,0.999996,1.00046 +5.47094,4.34699,0.999996,1.00043 +5.49098,4.36703,0.999997,1.0004 +5.51102,4.38707,0.999997,1.00038 +5.53106,4.40711,0.999997,1.00035 +5.5511,4.42715,0.999997,1.00033 +5.57114,4.44719,0.999998,1.00031 +5.59118,4.46723,0.999998,1.00029 +5.61122,4.48727,0.999998,1.00027 +5.63126,4.50731,0.999998,1.00025 +5.6513,4.52735,0.999998,1.00024 +5.67134,4.54739,0.999999,1.00022 +5.69138,4.56743,0.999999,1.00021 +5.71142,4.58747,0.999999,1.00019 +5.73146,4.60751,0.999999,1.00018 +5.7515,4.62755,0.999999,1.00017 +5.77154,4.64759,0.999999,1.00016 +5.79158,4.66763,0.999999,1.00015 +5.81162,4.68767,0.999999,1.00014 +5.83166,4.70771,0.999999,1.00013 +5.8517,4.72775,0.999999,1.00012 +5.87174,4.74779,0.999999,1.00011 +5.89178,4.76783,0.999999,1.0001 +5.91182,4.78787,1,1.0001 +5.93186,4.80791,1,1.00009 +5.9519,4.82795,1,1.00008 +5.97194,4.84799,1,1.00008 +5.99198,4.86803,1,1.00007 +6.01202,4.88808,1,1.00007 +6.03206,4.90812,1,1.00006 +6.0521,4.92816,1,1.00006 +6.07214,4.9482,1,1.00005 +6.09218,4.96824,1,1.00005 +6.11222,4.98828,1,1.00005 +6.13226,5.00832,1,1.00004 +6.1523,5.02836,1,1.00004 +6.17234,5.0484,1,1.00004 +6.19238,5.06844,1,1.00003 +6.21242,5.08848,1,1.00003 +6.23246,5.10852,1,1.00003 +6.25251,5.12856,1,1.00003 +6.27255,5.1486,1,1.00003 +6.29259,5.16864,1,1.00002 +6.31263,5.18868,1,1.00002 +6.33267,5.20872,1,1.00002 +6.35271,5.22876,1,1.00002 +6.37275,5.2488,1,1.00002 +6.39279,5.26884,1,1.00002 +6.41283,5.28888,1,1.00001 +6.43287,5.30892,1,1.00001 +6.45291,5.32896,1,1.00001 +6.47295,5.349,1,1.00001 +6.49299,5.36904,1,1.00001 +6.51303,5.38908,1,1.00001 +6.53307,5.40912,1,1.00001 +6.55311,5.42916,1,1.00001 +6.57315,5.4492,1,1.00001 +6.59319,5.46924,1,1.00001 +6.61323,5.48928,1,1.00001 +6.63327,5.50932,1,1.00001 +6.65331,5.52936,1,1.00001 +6.67335,5.5494,1,1.00001 +6.69339,5.56944,1,1 +6.71343,5.58948,1,1 +6.73347,5.60952,1,1 +6.75351,5.62956,1,1 +6.77355,5.6496,1,1 +6.79359,5.66964,1,1 +6.81363,5.68968,1,1 +6.83367,5.70972,1,1 +6.85371,5.72976,1,1 +6.87375,5.7498,1,1 +6.89379,5.76984,1,1 +6.91383,5.78988,1,1 +6.93387,5.80992,1,1 +6.95391,5.82996,1,1 +6.97395,5.85,1,1 +6.99399,5.87004,1,1 +7.01403,5.89008,1,1 +7.03407,5.91012,1,1 +7.05411,5.93016,1,1 +7.07415,5.9502,1,1 +7.09419,5.97024,1,1 +7.11423,5.99028,1,1 +7.13427,6.01032,1,1 +7.15431,6.03036,1,1 +7.17435,6.0504,1,1 +7.19439,6.07044,1,1 +7.21443,6.09048,1,1 +7.23447,6.11052,1,1 +7.25451,6.13056,1,1 +7.27455,6.1506,1,1 +7.29459,6.17064,1,1 +7.31463,6.19068,1,1 +7.33467,6.21072,1,1 +7.35471,6.23076,1,1 +7.37475,6.2508,1,1 +7.39479,6.27084,1,1 +7.41483,6.29088,1,1 +7.43487,6.31092,1,1 +7.45491,6.33096,1,1 +7.47495,6.351,1,1 +7.49499,6.37104,1,1 +7.51503,6.39108,1,1 +7.53507,6.41112,1,1 +7.55511,6.43116,1,1 +7.57515,6.4512,1,1 +7.59519,6.47124,1,1 +7.61523,6.49128,1,1 +7.63527,6.51132,1,1 +7.65531,6.53136,1,1 +7.67535,6.5514,1,1 +7.69539,6.57144,1,1 +7.71543,6.59148,1,1 +7.73547,6.61152,1,1 +7.75551,6.63156,1,1 +7.77555,6.6516,1,1 +7.79559,6.67164,1,1 +7.81563,6.69168,1,1 +7.83567,6.71172,1,1 +7.85571,6.73176,1,1 +7.87575,6.7518,1,1 +7.89579,6.77184,1,1 +7.91583,6.79188,1,1 +7.93587,6.81192,1,1 +7.95591,6.83196,1,1 +7.97595,6.852,1,1 +7.99599,6.87204,1,1 +8.01603,6.89208,1,1 +8.03607,6.91212,1,1 +8.05611,6.93216,1,1 +8.07615,6.9522,1,1 +8.09619,6.97224,1,1 +8.11623,6.99228,1,1 +8.13627,7.01232,1,1 +8.15631,7.03236,1,1 +8.17635,7.0524,1,1 +8.19639,7.07244,1,1 +8.21643,7.09248,1,1 +8.23647,7.11252,1,1 +8.25651,7.13256,1,1 +8.27655,7.1526,1,1 +8.29659,7.17264,1,1 +8.31663,7.19268,1,1 +8.33667,7.21272,1,1 +8.35671,7.23276,1,1 +8.37675,7.2528,1,1 +8.39679,7.27284,1,1 +8.41683,7.29288,1,1 +8.43687,7.31292,1,1 +8.45691,7.33296,1,1 +8.47695,7.353,1,1 +8.49699,7.37304,1,1 +8.51703,7.39309,1,1 +8.53707,7.41313,1,1 +8.55711,7.43317,1,1 +8.57715,7.45321,1,1 +8.59719,7.47325,1,1 +8.61723,7.49329,1,1 +8.63727,7.51333,1,1 +8.65731,7.53337,1,1 +8.67735,7.55341,1,1 +8.69739,7.57345,1,1 +8.71743,7.59349,1,1 +8.73747,7.61353,1,1 +8.75752,7.63357,1,1 +8.77756,7.65361,1,1 +8.7976,7.67365,1,1 +8.81764,7.69369,1,1 +8.83768,7.71373,1,1 +8.85772,7.73377,1,1 +8.87776,7.75381,1,1 +8.8978,7.77385,1,1 +8.91784,7.79389,1,1 +8.93788,7.81393,1,1 +8.95792,7.83397,1,1 +8.97796,7.85401,1,1 +8.998,7.87405,1,1 +9.01804,7.89409,1,1 +9.03808,7.91413,1,1 +9.05812,7.93417,1,1 +9.07816,7.95421,1,1 +9.0982,7.97425,1,1 +9.11824,7.99429,1,1 +9.13828,8.01433,1,1 +9.15832,8.03437,1,1 +9.17836,8.05441,1,1 +9.1984,8.07445,1,1 +9.21844,8.09449,1,1 +9.23848,8.11453,1,1 +9.25852,8.13457,1,1 +9.27856,8.15461,1,1 +9.2986,8.17465,1,1 +9.31864,8.19469,1,1 +9.33868,8.21473,1,1 +9.35872,8.23477,1,1 +9.37876,8.25481,1,1 +9.3988,8.27485,1,1 +9.41884,8.29489,1,1 +9.43888,8.31493,1,1 +9.45892,8.33497,1,1 +9.47896,8.35501,1,1 +9.499,8.37505,1,1 +9.51904,8.39509,1,1 +9.53908,8.41513,1,1 +9.55912,8.43517,1,1 +9.57916,8.45521,1,1 +9.5992,8.47525,1,1 +9.61924,8.49529,1,1 +9.63928,8.51533,1,1 +9.65932,8.53537,1,1 +9.67936,8.55541,1,1 +9.6994,8.57545,1,1 +9.71944,8.59549,1,1 +9.73948,8.61553,1,1 +9.75952,8.63557,1,1 +9.77956,8.65561,1,1 +9.7996,8.67565,1,1 +9.81964,8.69569,1,1 +9.83968,8.71573,1,1 +9.85972,8.73577,1,1 +9.87976,8.75581,1,1 +9.8998,8.77585,1,1 +9.91984,8.79589,1,1 +9.93988,8.81593,1,1 +9.95992,8.83597,1,1 +9.97996,8.85601,1,1 +10,8.87605,1,1 diff --git a/solverTests/BoundaryLayer/base.json b/solverTests/BoundaryLayer/base.json new file mode 100644 index 0000000..50e1a94 --- /dev/null +++ b/solverTests/BoundaryLayer/base.json @@ -0,0 +1,106 @@ +{ + "Mapping" : { + "tiles" : [1,1,1], + "tilesPerRank" : [1,1,1], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 200, + "yNum" : 200, + "zNum" : 4, + "origin" : [0.0, 0.0, 0.0], + "xWidth" : 2.0, + "yWidth" : 0.4, + "zWidth" : 0.1, + "xType" : "Uniform", + "yType" : "TanhMinus", + "zType" : "Uniform", + "xStretching" : 1.0, + "yStretching" : 1.0, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 40, + "maxTime" : 20.0, + "cfl" : 0.5, + "fixedDeltaTime" : 4.0e-3, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "InflowProfile" + }, + "P" : 1.01325e5, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "InflowProfile" + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } + } + }, + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 + }, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 + } + }, + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 + }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } + }, + + "Flow" : { + "mixture": "ConstPropMix", + "gasConstant" : 287.15, + "gamma" : 1.4, + "prandtl" : 0.71, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 0.05, + "TempRef" : 300.0 + }, + "initCase" : "Restart", + "restartDir" : "InflowProfile", + "initParams" : [1.01325e5, 300.0, 2083.67, 0.0, 0.0], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + }, + "bodyForce" : [0.0, 0.0, 0.0], + "turbForcing" : { "type" : "OFF" } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 5000, + "probes" : [], + "AveragesSamplingInterval": 1, + "ResetAverages": false, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } +} diff --git a/solverTests/BoundaryLayer/cpu_ref.hdf b/solverTests/BoundaryLayer/cpu_ref.hdf new file mode 100644 index 0000000..d721a46 --- /dev/null +++ b/solverTests/BoundaryLayer/cpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dc4a0619dfda6e6444e74df57c4c0567c6997e7a132b8d0b87197cbd36ab4a2 +size 22201944 diff --git a/solverTests/ChannelFlow/base.json b/solverTests/ChannelFlow/base.json new file mode 100644 index 0000000..255a004 --- /dev/null +++ b/solverTests/ChannelFlow/base.json @@ -0,0 +1,92 @@ +{ + "Mapping" : { + "tiles" : [1,1,1], + "tilesPerRank" : [1,1,1], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 64, + "yNum" : 128, + "zNum" : 128, + "origin" : [0.0, 0.0, 0.0], + "xWidth" : 0.0002819697924580275, + "yWidth" : 0.00017950754508916364, + "zWidth" : 0.000563939584916055, + "xType" : "Uniform", + "yType" : "Tanh", + "zType" : "Uniform", + "xStretching" : 1.0, + "yStretching" : 1.697344715398394, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 10, + "maxTime" : 20.0, + "cfl" : 0.5, + "fixedDeltaTime" : 4.0e-3, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { "type" : "Periodic"}, + "xBCRight" : { "type" : "Periodic"}, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 + } + }, + "yBCRight" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 + } + }, + "zBCLeft" : { "type" : "Periodic"}, + "zBCRight" : { "type" : "Periodic"} + }, + + "Flow" : { + "mixture": "ConstPropMix", + "gasConstant" : 287.15, + "gamma" : 1.4, + "prandtl" : 0.7, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, + "initCase" : "ChannelFlow", + "restartDir" : "", + "initParams" : [1.01325e5, 300.0, 520.91, 0.08, 0.00], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + }, + "bodyForce" : [0.0, 0.0, 0.0], + "turbForcing" : { + "type" : "OFF" + } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 10000, + "probes" : [], + "AveragesSamplingInterval": 10, + "ResetAverages": true, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } + +} diff --git a/solverTests/ChannelFlow/cpu_ref.hdf b/solverTests/ChannelFlow/cpu_ref.hdf new file mode 100644 index 0000000..de6a6e0 --- /dev/null +++ b/solverTests/ChannelFlow/cpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e9467880881e5901bd6df3edffdc131ec15debf5607fcb8fa9768223388cc0a +size 144839128 diff --git a/solverTests/ChannelFlow/gpu_ref.hdf b/solverTests/ChannelFlow/gpu_ref.hdf new file mode 100644 index 0000000..679c09a --- /dev/null +++ b/solverTests/ChannelFlow/gpu_ref.hdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:468a0d8362685a15fa75533fde960aa5545ddde3b8af0e9f20f551c84a27f7eb +size 161879312 diff --git a/solverTests/test.py b/solverTests/test.py new file mode 100644 index 0000000..2fd0d9e --- /dev/null +++ b/solverTests/test.py @@ -0,0 +1,194 @@ +import unittest +import subprocess +import os +import shutil +import h5py +import glob +import numpy as np +import itertools +import json + +src_dir = os.path.join(os.path.expandvars("$HTR_DIR"), "src") +executable = os.path.join(src_dir, "prometeo.sh") + +# Leave a tollerance for the noise introduced by atomic +def checkSolutionFile(path, refFile, tol=1e-10): + tiles = glob.glob(os.path.join(path,"*hdf")) + for tl in tiles: + lb = map(int, tl.split("/")[-1].split("-")[0].split(",")) + tile = h5py.File(tl, "r") + for fld in tile: + f = tile[fld][:] + ref = refFile[fld][:] + if (len(f.shape) == 3): + for (k,j,i), value in np.ndenumerate(f): + rval = ref[k+lb[2],j+lb[1],i+lb[0]] + if (abs(value - rval) > max(tol*abs(rval), 1e-12)): + print(fld, value - rval, max(tol*abs(rval), 1e-12), rval) + return False + elif (len(f.shape) == 4): + for (k,j,i,l), value in np.ndenumerate(f): + rval = ref[k+lb[2],j+lb[1],i+lb[0],l] + if (abs(value - rval) > max(tol*abs(rval), 1e-12)): + print(fld, value - rval, max(tol*abs(rval), 1e-12), rval) + return False + tile.close() + # if we arrive here, the solution is good + return True + +class solverTest(unittest.TestCase): + + def test_3DPeriodic(self): + """ + Test tri-periodic domain. + """ + #print("Running 3DPeriodic test:") + baseDir = os.getcwd() + os.chdir(os.path.abspath("3DPeriodic")) + + # Load reference solution + if int(os.getenv("USE_CUDA", "0")): + ref = h5py.File("gpu_ref.hdf", "r") + else: + ref = h5py.File("cpu_ref.hdf", "r") + + npart = 2 + try: + for case in itertools.product(range(1, npart+1), repeat=3): + name = "%dx%dx%d"%(case) + #print(" > case: %s" % name) + # create directory + if os.path.exists(name): shutil.rmtree(name) + os.makedirs(name) + #create input file + with open("base.json", "r") as fin: + config = json.load(fin) + config["Mapping"]["tiles"] = case + config["Mapping"]["tilesPerRank"] = case + with open(name+".json", "w") as fout: + json.dump(config, fout, indent=3) + # run the case + MyOut = subprocess.check_output([executable, "-i", name+".json", "-o", name]) + # run the check + self.assertTrue(checkSolutionFile(os.path.join(name, "sample0/fluid_iter0000000020"), ref), + msg="Error on %s of 3DPeriodic test" % name) + + finally: + ref.close() + os.chdir(baseDir) + + def test_3DPeriodic_Air(self): + """ + Test tri-periodic domain with AirMixture. + """ + baseDir = os.getcwd() + os.chdir(os.path.abspath("3DPeriodic_Air")) + + # Load reference solution + if int(os.getenv("USE_CUDA", "0")): + ref = h5py.File("gpu_ref.hdf", "r") + else: + ref = h5py.File("cpu_ref.hdf", "r") + + npart = 2 + try: + for case in itertools.product(range(1, npart+1), repeat=3): + name = "%dx%dx%d"%(case) + # create directory + if os.path.exists(name): shutil.rmtree(name) + os.makedirs(name) + #create input file + with open("base.json", "r") as fin: + config = json.load(fin) + config["Mapping"]["tiles"] = case + config["Mapping"]["tilesPerRank"] = case + with open(name+".json", "w") as fout: + json.dump(config, fout, indent=3) + # run the case + MyOut = subprocess.check_output([executable, "-i", name+".json", "-o", name]) + # run the check + self.assertTrue(checkSolutionFile(os.path.join(name, "sample0/fluid_iter0000000020"), ref), + msg="Error on %s of 3DPeriodic_Air test" % name) + + finally: + ref.close() + os.chdir(baseDir) + + def test_ChannelFlow(self): + """ + Test a pseudo Channel Flow. + """ + baseDir = os.getcwd() + os.chdir(os.path.abspath("ChannelFlow")) + + # Load reference solution + if int(os.getenv("USE_CUDA", "0")): + ref = h5py.File("gpu_ref.hdf", "r") + else: + ref = h5py.File("cpu_ref.hdf", "r") + + npart = 2 + try: + for case in itertools.product(range(1, npart+1), repeat=3): + name = "%dx%dx%d"%(case) + # create directory + if os.path.exists(name): shutil.rmtree(name) + os.makedirs(name) + #create input file + with open("base.json", "r") as fin: + config = json.load(fin) + config["Mapping"]["tiles"] = case + config["Mapping"]["tilesPerRank"] = case + with open(name+".json", "w") as fout: + json.dump(config, fout, indent=3) + # run the case + MyOut = subprocess.check_output([executable, "-i", name+".json", "-o", name]) + # run the check + self.assertTrue(checkSolutionFile(os.path.join(name, "sample0/fluid_iter0000000010"), ref), + msg="Error on %s of ChannelFlow test" % name) + + finally: + ref.close() + os.chdir(baseDir) + + def test_BoundaryLayer(self): + """ + Test a boundary layer. + """ + baseDir = os.getcwd() + os.chdir(os.path.abspath("BoundaryLayer")) + + # Load reference solution + if int(os.getenv("USE_CUDA", "0")): +# ref = h5py.File("gpu_ref.hdf", "r") + ref = h5py.File("cpu_ref.hdf", "r") + else: + ref = h5py.File("cpu_ref.hdf", "r") + + npart = 2 + try: + for case in itertools.product(range(1, npart+1), repeat=3): + name = "%dx%dx%d"%(case) + # create directory + if os.path.exists(name): shutil.rmtree(name) + os.makedirs(name) + #create input file + with open("base.json", "r") as fin: + config = json.load(fin) + config["Mapping"]["tiles"] = case + config["Mapping"]["tilesPerRank"] = case + with open(name+".json", "w") as fout: + json.dump(config, fout, indent=3) + # run the case + MyOut = subprocess.check_output(["./MakeInput.py", name+".json"]) + MyOut = subprocess.check_output([executable, "-i", name+".json", "-o", name]) + # run the check + self.assertTrue(checkSolutionFile(os.path.join(name, "sample0/fluid_iter0000000040"), ref), + msg="Error on %s of BoundaryLayer test" % name) + + finally: + ref.close() + os.chdir(baseDir) + +if __name__ == "__main__": + unittest.main() diff --git a/src/ConstPropMix.rg b/src/ConstPropMix.rg index b79041f..f565451 100644 --- a/src/ConstPropMix.rg +++ b/src/ConstPropMix.rg @@ -57,15 +57,18 @@ struct Exports.Mixture { gamma : double -- Viscosisity model - viscosityModel : SCHEMA.ViscosityModel + viscosityModel : int -- Viscosity parameters + -- Constant model constantVisc : double + -- Power law model powerlawTempRef : double powerlawViscRef : double -- Sutherland model sutherlandSRef : double sutherlandTempRef : double sutherlandViscRef : double + -- Prandtl number Prandtl : double } @@ -78,15 +81,16 @@ task Exports.InitMixture(config : SCHEMA.Config) Mix.R = config.Flow.gasConstant Mix.gamma = config.Flow.gamma - Mix.viscosityModel = config.Flow.viscosityModel + Mix.viscosityModel = config.Flow.viscosityModel.type + + Mix.constantVisc = config.Flow.viscosityModel.u.Constant.Visc - Mix.constantVisc = config.Flow.constantVisc - Mix.powerlawTempRef = config.Flow.powerlawTempRef - Mix.powerlawViscRef = config.Flow.powerlawViscRef + Mix.powerlawTempRef = config.Flow.viscosityModel.u.PowerLaw.TempRef + Mix.powerlawViscRef = config.Flow.viscosityModel.u.PowerLaw.ViscRef - Mix.sutherlandSRef = config.Flow.sutherlandSRef - Mix.sutherlandTempRef = config.Flow.sutherlandTempRef - Mix.sutherlandViscRef = config.Flow.sutherlandViscRef + Mix.sutherlandSRef = config.Flow.viscosityModel.u.Sutherland.SRef + Mix.sutherlandTempRef = config.Flow.viscosityModel.u.Sutherland.TempRef + Mix.sutherlandViscRef = config.Flow.viscosityModel.u.Sutherland.ViscRef Mix.Prandtl = config.Flow.prandtl diff --git a/src/Makefile b/src/Makefile index ba24a62..5e77c67 100644 --- a/src/Makefile +++ b/src/Makefile @@ -73,8 +73,13 @@ ifeq ($(DEBUG), 1) LINK_FLAGS += -g endif -.PHONY: default all clean -.PRECIOUS: prometeo_%.o +# Get git commit version and date +SOLVER_VERSION := ""$(shell git --no-pager describe --tags --always --dirty)" committed on "$(firstword $(shell git --no-pager show --date=short --format="%ad" --name-only))"" + +LEGION_VERSION := ""$(shell cd $(LEGION_DIR); git --no-pager describe --tags --always --dirty)" committed on "$(firstword $(shell cd $(LEGION_DIR); git --no-pager show --date=short --format="%ad" --name-only))"" + +.PHONY: default all clean force +.PRECIOUS: prometeo_%.o solver_version~ legion_version~ version.rg .SUFFIXES: .rg .cc .h .o default: prometeo_ConstPropMix.exec prometeo_AirMix.exec @@ -88,7 +93,7 @@ ConstPropMix= ConstPropMix.rg AirMix= Species.rg Reaction.rg AirMix.rg clean: - $(RM) *.exec *.o *-desugared.rg config_schema.h + $(RM) *.exec *.o *-desugared.rg config_schema.h version.rg solver_version~ legion_version~ %-desugared.rg: %.rg ./desugar.py $< > $@ @@ -97,7 +102,7 @@ prometeo_%.exec: prometeo_%.o prometeo_mapper.o config_schema.o json.o $(CXX) -o $@ $^ $(LINK_FLAGS) .SECONDEXPANSION: -prometeo_%.o: prometeo-desugared.rg prometeo_mapper.h config_schema.o $$(wildcard $$**) $(Common) +prometeo_%.o: version.rg prometeo-desugared.rg prometeo_mapper.h config_schema.o $$(wildcard $$**) $(Common) EOS="$*" $(REGENT) prometeo-desugared.rg $(REGENT_FLAGS) prometeo_mapper.o: prometeo_mapper.cc prometeo_mapper.h config_schema.o @@ -108,3 +113,30 @@ config_schema.o: process_schema.rg config_schema.lua json.h util-desugared.rg json.o: json.c json.h $(CC) $(CFLAGS) -c -o $@ $< + +# recompile version.h dependants when GIT_VERSION changes, uses temporary file version~ +solver_version~: force + @echo "$(SOLVER_VERSION)" | cmp -s - $@ || echo "$(SOLVER_VERSION)" > $@ + +legion_version~: force + @echo "$(LEGION_VERSION)" | cmp -s - $@ || echo "$(LEGION_VERSION)" > $@ + +version.rg: solver_version~ legion_version~ + @touch $@ + @echo Solver version $(SOLVER_VERSION) + @echo Legion version $(LEGION_VERSION) + @echo "-- This file is automatically generated, please do not touch it" > $@ + @echo "" >> $@ + @echo "local Exports = {}" >> $@ + @echo "" >> $@ + @echo "local SolverLength = "$(shell echo $(SOLVER_VERSION) | awk "{print length}")"" >> $@ + @echo "Exports.SolverVersion = \""$(SOLVER_VERSION)"\"" >> $@ + @echo "" >> $@ + @echo "local LegionLength = "$(shell echo $(LEGION_VERSION) | awk "{print length}")"" >> $@ + @echo "Exports.LegionVersion = \""$(LEGION_VERSION)"\"" >> $@ + @echo "" >> $@ + @echo "Exports.Length = math.max(SolverLength, LegionLength)" >> $@ + @echo "" >> $@ + @echo "return Exports" >> $@ + @echo "" >> $@ + diff --git a/src/certainty.slurm b/src/certainty.slurm index 8f0b0f3..85da7f3 100644 --- a/src/certainty.slurm +++ b/src/certainty.slurm @@ -5,10 +5,12 @@ GPU_OPTS= if [[ "$QUEUE" == "all" ]]; then USE_CUDA=0 CORES_PER_NODE=24 + NUMA_PER_RANK=2 RAM_PER_NODE=25000 elif [[ "$QUEUE" == "32core" ]]; then USE_CUDA=0 CORES_PER_NODE=32 + OMPPROCS_PER_RANK=2 RAM_PER_NODE=50000 # 64GB RAM per node # 2 NUMA domains per node @@ -17,6 +19,7 @@ elif [[ "$QUEUE" == "32core" ]]; then elif [[ "$QUEUE" == "24core" ]]; then USE_CUDA=0 CORES_PER_NODE=24 + NUMA_PER_RANK=2 RAM_PER_NODE=25000 # 36GB RAM per node # 2 NUMA domains per node @@ -25,6 +28,7 @@ elif [[ "$QUEUE" == "24core" ]]; then elif [[ "$QUEUE" == "largemem" ]]; then USE_CUDA=0 CORES_PER_NODE=24 + NUMA_PER_RANK=2 RAM_PER_NODE=120000 # 144GB RAM per node # 2 NUMA domains per node @@ -33,6 +37,7 @@ elif [[ "$QUEUE" == "largemem" ]]; then elif [[ "$QUEUE" == "gpu" ]]; then USE_CUDA=1 CORES_PER_NODE=16 + NUMA_PER_RANK=2 RAM_PER_NODE=25000 GPUS_PER_NODE=4 FB_PER_GPU=1024 diff --git a/src/config_schema.lua b/src/config_schema.lua index e64175c..af36052 100644 --- a/src/config_schema.lua +++ b/src/config_schema.lua @@ -30,65 +30,102 @@ local Exports = {} -- Helper definitions Exports.Volume = { - fromCell = Array(3,int), - uptoCell = Array(3,int), + fromCell = Array(3,int), + uptoCell = Array(3,int), } Exports.Window = { - fromCell = Array(2,int), - uptoCell = Array(2,int), + fromCell = Array(2,int), + uptoCell = Array(2,int), } Exports.Species = { - Name = String(10), - MolarFrac = double, + Name = String(10), + MolarFrac = double, } Exports.Mixture = { - Species = UpTo(10, Exports.Species), + Species = UpTo(10, Exports.Species), } -- Unions & enumeration constants -Exports.FlowBC = Enum('Dirichlet','Periodic','Symmetry','AdiabaticWall','IsothermalWall','NSCBC_Inflow','NSCBC_Outflow','SuctionAndBlowingWall') -Exports.ViscosityModel = Enum('Constant','PowerLaw','Sutherland') -Exports.FlowInitCase = Enum('Uniform','Random','Restart','Perturbed','TaylorGreen2DVortex','TaylorGreen3DVortex','RiemannTestOne','RiemannTestTwo','SodProblem','LaxProblem','ShuOsherProblem','VortexAdvection2D','GrossmanCinnellaProblem','ChannelFlow') -Exports.GridType = Enum('Uniform','Cosine','TanhMinus','TanhPlus','Tanh') Exports.MixtureProfile = Union{ - Constant = { - Mixture = Exports.Mixture, - }, - File = { - FileDir = String(256), - }, - Incoming = {}, + Constant = { + Mixture = Exports.Mixture, + }, + File = { + FileDir = String(256), + }, + Incoming = {}, } Exports.TempProfile = Union{ - Constant = { - temperature = double, - }, - File = { - FileDir = String(256), - }, - Incoming = {}, + Constant = { + temperature = double, + }, + File = { + FileDir = String(256), + }, + Incoming = {}, } Exports.InflowProfile = Union{ - Constant = { - velocity = Array(3,double), - }, - File = { - FileDir = String(256), - }, - Incoming = { - addedVelocity = double, - }, - SuctionAndBlowing = { - Xmin = double, - Xmax = double, - X0 = double, - sigma = double, - Zw = double, - A = UpTo(20, double), - omega = UpTo(20, double), - beta = UpTo(20, double), - }, + Constant = { + velocity = Array(3,double), + }, + File = { + FileDir = String(256), + }, + Incoming = { + addedVelocity = double, + }, +} + +Exports.FlowBC = Union{ + Dirichlet = { + VelocityProfile = Exports.InflowProfile, + TemperatureProfile = Exports.TempProfile, + MixtureProfile = Exports.MixtureProfile, + P = double, + }, + Periodic = {}, + Symmetry = {}, + AdiabaticWall = {}, + IsothermalWall = { + TemperatureProfile = Exports.TempProfile, + }, + NSCBC_Inflow = { + VelocityProfile = Exports.InflowProfile, + TemperatureProfile = Exports.TempProfile, + MixtureProfile = Exports.MixtureProfile, + P = double, + }, + NSCBC_Outflow = { + P = double, + }, + SuctionAndBlowingWall = { + TemperatureProfile = Exports.TempProfile, + Xmin = double, + Xmax = double, + X0 = double, + sigma = double, + Zw = double, + A = UpTo(20, double), + omega = UpTo(20, double), + beta = UpTo(20, double), + }, +} + +Exports.ViscosityModel = Union{ + Constant = { + Visc = double, + }, + PowerLaw = { + ViscRef = double, + TempRef = double, + }, + Sutherland = { + ViscRef = double, + TempRef = double, + SRef = double, + }, } + Exports.TurbForcingModel = Union{ OFF = {}, CHANNEL = { @@ -97,6 +134,9 @@ Exports.TurbForcingModel = Union{ }, } +Exports.FlowInitCase = Enum('Uniform','Random','Restart','Perturbed','TaylorGreen2DVortex','TaylorGreen3DVortex','RiemannTestOne','RiemannTestTwo','SodProblem','LaxProblem','ShuOsherProblem','VortexAdvection2D','GrossmanCinnellaProblem','ChannelFlow') +Exports.GridType = Enum('Uniform','Cosine','TanhMinus','TanhPlus','Tanh','SinhMinus','SinhPlus','Sinh') + -- Sections of config struct Exports.MappingStruct = { -- number of tiles in which to split the domain @@ -136,36 +176,12 @@ Exports.GridStruct = { } Exports.BCStruct = { - xBCLeft = Exports.FlowBC, - xBCLeftInflowProfile = Exports.InflowProfile, - xBCLeftP = double, - xBCLeftHeat = Exports.TempProfile, - xBCLeftMixture = Exports.MixtureProfile, + xBCLeft = Exports.FlowBC, xBCRight = Exports.FlowBC, - xBCRightInflowProfile = Exports.InflowProfile, - xBCRightP = double, - xBCRightHeat = Exports.TempProfile, - xBCRightMixture = Exports.MixtureProfile, - yBCLeft = Exports.FlowBC, - yBCLeftInflowProfile = Exports.InflowProfile, - yBCLeftP = double, - yBCLeftHeat = Exports.TempProfile, - yBCLeftMixture = Exports.MixtureProfile, + yBCLeft = Exports.FlowBC, yBCRight = Exports.FlowBC, - yBCRightInflowProfile = Exports.InflowProfile, - yBCRightP = double, - yBCRightHeat = Exports.TempProfile, - yBCRightMixture = Exports.MixtureProfile, - zBCLeft = Exports.FlowBC, - zBCLeftInflowProfile = Exports.InflowProfile, - zBCLeftP = double, - zBCLeftHeat = Exports.TempProfile, - zBCLeftMixture = Exports.MixtureProfile, + zBCLeft = Exports.FlowBC, zBCRight = Exports.FlowBC, - zBCRightInflowProfile = Exports.InflowProfile, - zBCRightP = double, - zBCRightHeat = Exports.TempProfile, - zBCRightMixture = Exports.MixtureProfile, } Exports.IntegratorStruct = { @@ -186,12 +202,6 @@ Exports.FlowStruct = { gamma = double, prandtl = double, viscosityModel = Exports.ViscosityModel, - constantVisc = double, - powerlawViscRef = double, - powerlawTempRef = double, - sutherlandViscRef = double, - sutherlandTempRef = double, - sutherlandSRef = double, initCase = Exports.FlowInitCase, restartDir = String(256), initParams = Array(5,double), @@ -211,9 +221,9 @@ Exports.IOStruct = { -- One-diemnsional averages AveragesSamplingInterval = int, ResetAverages = bool, - YZAverages = UpTo(5, Exports.Volume), - XZAverages = UpTo(5, Exports.Volume), - XYAverages = UpTo(5, Exports.Volume), + YZAverages = UpTo(10, Exports.Volume), + XZAverages = UpTo(10, Exports.Volume), + XYAverages = UpTo(10, Exports.Volume), } -- Main config struct diff --git a/src/galileo.slurm b/src/galileo.slurm new file mode 100644 index 0000000..223c6ba --- /dev/null +++ b/src/galileo.slurm @@ -0,0 +1,42 @@ +#!/bin/bash -eu +#SBATCH --job-name=prometeo + +if [[ "$QUEUE" == "gll_usr_prod" ]]; then + USE_CUDA=0 + CORES_PER_NODE=36 + NUMA_PER_RANK=2 + RAM_PER_NODE=70000 + # Resources: + # 118GB RAM per node + # 2 NUMA domains per node + # 18 cores per NUMA domain +elif [[ "$QUEUE" == "gll_usr_gpuprod" ]]; then + USE_CUDA=1 + CORES_PER_NODE=36 + NUMA_PER_RANK=2 + RAM_PER_NODE=70000 + GPUS_PER_NODE=2 + FB_PER_GPU=10000 + # Resources: + # 118GB RAM per node + # 2 NUMA domains per node + # 18 cores per NUMA domain + # 1 nVidia K80 GPUs (seen as two K40 gpus) +else + echo "Unrecognized queue $QUEUE" >&2 + exit 1 +fi + +cd $SLURM_SUBMIT_DIR +source "$HTR_DIR"/src/jobscript_shared.sh + +srun -n "$NUM_RANKS" --ntasks-per-node="$RANKS_PER_NODE" --cpus-per-task="$CORES_PER_RANK" \ + --export=ALL \ + $COMMAND + +# Resources: +# 118GB RAM per node +# 2 NUMA domains per node +# 18 cores per NUMA domain +# 1 nVidia K80 GPUs (seen as two K40 gpus) + diff --git a/src/hdf_helper.rg b/src/hdf_helper.rg index b885920..7a6f063 100644 --- a/src/hdf_helper.rg +++ b/src/hdf_helper.rg @@ -17,7 +17,7 @@ return function(indexType, -- regentlib.index_type fSpace, -- terralib.struct flds, -- string* attrs, -- map(string,terralib.type) - StringAttrs -- map(string,int) + StringAttrs -- map(string,{int, int}) ) local MODULE = {} @@ -85,7 +85,9 @@ if not USE_HDF then end - for aName,aNum in pairs(StringAttrs) do + for aName,aPar in pairs(StringAttrs) do + + local aNum = aPar[1] local __demand(__inline) task writeAttr(_ : int, @@ -493,9 +495,10 @@ for aName,aType in pairs(attrs) do end -for aName,aNum in pairs(StringAttrs) do +for aName,aPar in pairs(StringAttrs) do - local aLenght = 20 -- Length of the written strings + local aNum = aPar[1] -- Number of the written strings + local aLength = aPar[2]+1 -- Length of the written strings (allow for traling characted of C) local terra write(fname : &int8, Strings : regentlib.string[aNum]) var fid = HDF5.H5Fopen(fname, HDF5.H5F_ACC_RDWR, HDF5.H5P_DEFAULT) @@ -505,14 +508,14 @@ for aName,aNum in pairs(StringAttrs) do var sid = HDF5.H5Screate_simple(1, aSize, [&uint64](0)) if sid < 0 then [err('create string attribute dataspace')] end var stringType = HDF5.H5Tcopy(HDF5.H5T_C_S1_g) - var res = HDF5.H5Tset_size (stringType, aLenght) + var res = HDF5.H5Tset_size (stringType, aLength) if res < 0 then [err('set attribute size')] end var aid = HDF5.H5Acreate2(fid, aName, stringType, sid, HDF5.H5P_DEFAULT, HDF5.H5P_DEFAULT) if aid < 0 then [err('create attribute')] end - var attr : int8[aLenght][aNum] + var attr : int8[aLength][aNum] for i = 0, aNum do - C.snprintf(attr[i], aLenght, Strings[i]) + C.snprintf(attr[i], aLength, Strings[i]) end res = HDF5.H5Awrite(aid, stringType, &attr) if res < 0 then [err('write attribute')] end diff --git a/src/jobscript_shared.sh b/src/jobscript_shared.sh index ca5d589..e089f67 100644 --- a/src/jobscript_shared.sh +++ b/src/jobscript_shared.sh @@ -54,11 +54,16 @@ echo "Sending output to $OUT_DIR" CORES_PER_RANK=$(( CORES_PER_NODE / RANKS_PER_NODE )) RAM_PER_RANK=$(( RAM_PER_NODE / RANKS_PER_NODE )) THREADS_PER_RANK=$(( CORES_PER_RANK - RESERVED_CORES )) +THREADS_PER_NUMA=$(( THREADS_PER_RANK / NUMA_PER_RANK )) if (( CORES_PER_NODE < RANKS_PER_NODE || CORES_PER_NODE % RANKS_PER_NODE != 0 || RESERVED_CORES >= CORES_PER_RANK )); then quit "Cannot split $CORES_PER_NODE core(s) into $RANKS_PER_NODE rank(s)" fi +if (( THREADS_PER_RANK < NUMA_PER_RANK || + THREADS_PER_RANK % NUMA_PER_RANK != 0)); then + quit "Cannot split $THREADS_PER_RANK thread(s) into $NUMA_PER_RANK openmp proc(s)" +fi if [[ "$USE_CUDA" == 1 ]]; then GPUS_PER_RANK=$(( GPUS_PER_NODE / RANKS_PER_NODE )) if (( GPUS_PER_NODE < RANKS_PER_NODE || @@ -90,7 +95,7 @@ fi # Synthesize final command COMMAND="$EXECUTABLE $ARGS \ $DEBUG_OPTS $PROFILER_OPTS \ - -ll:cpu 0 -ll:ocpu 1 -ll:onuma 0 -ll:okindhack -ll:othr $THREADS_PER_RANK \ + -ll:cpu 0 -ll:ocpu $NUMA_PER_RANK -ll:onuma 0 -ll:okindhack -ll:othr $THREADS_PER_NUMA \ $GPU_OPTS \ -ll:util 4 -ll:io 1 -ll:dma 2 \ -ll:csize $RAM_PER_RANK \ diff --git a/src/lassen.lsf b/src/lassen.lsf index f95623a..a16d30d 100644 --- a/src/lassen.lsf +++ b/src/lassen.lsf @@ -3,9 +3,10 @@ ##BSUB -alloc_flags smt1 CORES_PER_NODE=40 +NUMA_PER_RANK=4 RAM_PER_NODE=200000 GPUS_PER_NODE=4 -FB_PER_GPU=12700 +FB_PER_GPU=14000 source "$HTR_DIR"/src/jobscript_shared.sh GPUS_PER_RANK="${GPUS_PER_RANK:-0}" diff --git a/src/prometeo.rg b/src/prometeo.rg index a60449f..872db65 100644 --- a/src/prometeo.rg +++ b/src/prometeo.rg @@ -35,7 +35,61 @@ import "regent" local C = regentlib.c local MAPPER = terralib.includec("prometeo_mapper.h") local SCHEMA = terralib.includec("config_schema.h") -local UTIL = require 'util-desugared' +local UTIL = require "util-desugared" +local VERSION = require "version" + +------------------------------------------------------------------------------- +-- ACTIVATE TIMING +------------------------------------------------------------------------------- + +local T +local TIMING = false +if os.getenv("TIMING") == "1" then + TIMING = true + T = regentlib.newsymbol() + print("######################################################################################") + print("WARNING: You are compiling with timing tools.") + print(" This might affect the performance of the solver.") + print("######################################################################################") +end + +------------------------------------------------------------------------------- +-- ACTIVATE DEBUG_OUTPUT +------------------------------------------------------------------------------- + +local DEBUG_OUTPUT = false +if os.getenv("DEBUG_OUTPUT") == "1" then + DEBUG_OUTPUT = true + print("#############################################################################") + print("WARNING: You are compiling with debug output.") + print(" This might affect the performance of the solver.") + print("#############################################################################") +end + +------------------------------------------------------------------------------- +-- ACTIVATE ATOMIC COHERENCE MODE +------------------------------------------------------------------------------- + +local ATOMIC = true +if os.getenv("NO_ATOMIC") == "1" then + ATOMIC = false + print("#############################################################################") + print("WARNING: You are compiling without atomic coherence mode.") + print(" This might affect the performance of the solver.") + print("#############################################################################") +end + +------------------------------------------------------------------------------- +-- ACTIVATE AVERAGES +------------------------------------------------------------------------------- + +local AVERAGES = true +if os.getenv("AVERAGES") == "0" then + AVERAGES = false + print("#############################################################################") + print("WARNING: You are compiling without averaging tools.") + print("#############################################################################") +end ------------------------------------------------------------------------------- -- IMPORT MIXTURE @@ -64,7 +118,7 @@ local Config = SCHEMA.Config ------------------------------------------------------------------------------- local CONST = require "prometeo_const" --- Runge-Kutta coeffients +-- Runge-Kutta coefficients local RK_C = CONST.RK_C -- Variable indices @@ -134,7 +188,7 @@ local struct Fluid_columns { velocityGradientY : double[3]; velocityGradientZ : double[3]; temperatureGradient : double[3]; - -- Conserved varaibles + -- Conserved variables Conserved : double[nEq]; Conserved_old : double[nEq]; Conserved_hat : double[nEq]; @@ -151,7 +205,7 @@ local struct Fluid_columns { FluxYCorr : double[nEq]; FluxZCorr : double[nEq]; -- NSCBC variables - dudtBoundary : double; + dudtBoundary : double[3]; dTdtBoundary : double; velocity_old_NSCBC : double[3]; temperature_old_NSCBC : double; @@ -170,9 +224,21 @@ local IOVars = terralib.newlist({ 'MolarFracs', 'velocity', 'dudtBoundary', - 'dTdtBoundary', - 'velocity_old_NSCBC', - 'temperature_old_NSCBC' + 'dTdtBoundary' +}) + +local DebugVars = terralib.newlist({ + 'centerCoordinates', + 'cellWidth', + 'rho', + 'pressure', + 'temperature', + 'MolarFracs', + 'velocity', + 'Conserved', + 'FluxX', + 'FluxY', + 'FluxZ' }) fspace grid_partitions(Fluid : region(ispace(int3d), Fluid_columns), tiles : ispace(int3d)) { @@ -230,7 +296,15 @@ fspace grid_partitions(Fluid : region(ispace(int3d), Fluid_columns), tiles : is local HDF = (require 'hdf_helper')(int3d, int3d, Fluid_columns, IOVars, {timeStep=int,simTime=double,channelForcing=double}, - {SpeciesNames=nSpec}) + {SpeciesNames={nSpec, 20}, Versions={2, VERSION.Length}}) + +local HDF_DEBUG +if DEBUG_OUTPUT then + HDF_DEBUG = (require 'hdf_helper')(int3d, int3d, Fluid_columns, + DebugVars, + {timeStep=int,simTime=double,channelForcing=double}, + {SpeciesNames={nSpec, 20}, Versions={2, VERSION.Length}}) +end -- Macro local MACRO = require "prometeo_macro" @@ -241,111 +315,129 @@ local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns) -- Metric routines local METRIC = (require 'prometeo_metric')(SCHEMA, Fluid_columns) --- Initialization routines -local INIT = (require 'prometeo_init')(SCHEMA, MIX, Fluid_columns) - --- I/O rutines +-- I/O routines local IO = (require 'prometeo_IO')(SCHEMA) --- Stability conditions rutines +-- Stability conditions routines local CFL = (require 'prometeo_cfl')(MIX, Fluid_columns) --- Chemistry rutines -local CHEM = (require 'prometeo_chem')(SCHEMA, MIX, Fluid_columns) +-- Chemistry routines +local CHEM = (require 'prometeo_chem')(SCHEMA, MIX, Fluid_columns, ATOMIC) + +-- Initialization routines +local INIT = (require 'prometeo_init')(SCHEMA, MIX, CHEM, Fluid_columns) --- Conserved->Primitives/Primitives->Conserved and properties rutines +-- Conserved->Primitives/Primitives->Conserved and properties routines local VARS = (require 'prometeo_variables')(SCHEMA, MIX, Fluid_columns) --- Fluxes rutines +-- Fluxes routines local FLUX = (require 'prometeo_flux')(SCHEMA, MIX, Fluid_columns) --- BCOND rutines +-- BCOND routines local BCOND = (require 'prometeo_bc')(SCHEMA, MIX, Fluid_columns, grid_partitions) --- RK rutines +-- RK routines local RK = (require 'prometeo_rk')(nEq, Fluid_columns) --- RHS rutines -local RHS = (require 'prometeo_rhs')(SCHEMA, MIX, Fluid_columns) +-- RHS routines +local RHS = (require 'prometeo_rhs')(SCHEMA, MIX, Fluid_columns, ATOMIC) --- Volume averages rutines +-- Volume averages routines local STAT = (require 'prometeo_stat')(MIX, Fluid_columns) --- Profiles rutines +-- Profiles routines local PROFILES = (require 'prometeo_profiles')(SCHEMA, MIX, Fluid_columns) --- Averages rutines -local AVG = (require 'prometeo_average')(SCHEMA, MIX, Fluid_columns) +-- Averages routines +local AVG +if AVERAGES then + AVG = (require 'prometeo_average')(SCHEMA, MIX, Fluid_columns) +end ------------------------------------------------------------------------------- -- INITIALIZATION ROUTINES ------------------------------------------------------------------------------- +local function emitFill(p, t, f, val) + return rquote + var v = [val] + __demand(__index_launch) + for c in t do + fill(([p][c]).[f], v) + end + end +end + __demand(__inline) -task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns), + tiles : ispace(int3d), + Fluid_Partitions : grid_partitions(Fluid, tiles)) where writes(Fluid) do - fill(Fluid.centerCoordinates, array(0.0, 0.0, 0.0)) - fill(Fluid.cellWidth, array(0.0, 0.0, 0.0)) - fill(Fluid.reconXFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.reconYFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.reconZFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.reconXFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.reconYFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.reconZFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsXPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsYPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsZPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsXMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsYMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.TENOCoeffsZMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) - fill(Fluid.BCStencilX, false) - fill(Fluid.BCStencilY, false) - fill(Fluid.BCStencilZ, false) - fill(Fluid.interpXFace, array(0.0, 0.0)) - fill(Fluid.interpYFace, array(0.0, 0.0)) - fill(Fluid.interpZFace, array(0.0, 0.0)) - fill(Fluid.derivXFace, 0.0) - fill(Fluid.derivYFace, 0.0) - fill(Fluid.derivZFace, 0.0) - fill(Fluid.gradX, array(0.0, 0.0)) - fill(Fluid.gradY, array(0.0, 0.0)) - fill(Fluid.gradZ, array(0.0, 0.0)) - fill(Fluid.rho, 0.0) - fill(Fluid.mu , 0.0) - fill(Fluid.lam, 0.0) - fill(Fluid.Di , [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) - fill(Fluid.SoS, 0.0) - fill(Fluid.pressure, 0.0) - fill(Fluid.temperature, 0.0) - fill(Fluid.MolarFracs, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) - fill(Fluid.velocity, array(0.0, 0.0, 0.0)) - fill(Fluid.velocityGradientX, array(0.0, 0.0, 0.0)) - fill(Fluid.velocityGradientY, array(0.0, 0.0, 0.0)) - fill(Fluid.velocityGradientZ, array(0.0, 0.0, 0.0)) - fill(Fluid.temperatureGradient, array(0.0, 0.0, 0.0)) - fill(Fluid.Conserved, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.Conserved_old, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.Conserved_hat, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.Conserved_t, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.Conserved_t_old, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.EulerFluxX, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.EulerFluxY, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.EulerFluxZ, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxX, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxY, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxZ, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxXCorr, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxYCorr, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.FluxZCorr, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) - fill(Fluid.dudtBoundary, 0.0) - fill(Fluid.dTdtBoundary, 0.0) - fill(Fluid.velocity_old_NSCBC, array(0.0, 0.0, 0.0)) - fill(Fluid.temperature_old_NSCBC, 0.0) - fill(Fluid.MolarFracs_profile, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) - fill(Fluid.velocity_profile, array(0.0, 0.0, 0.0)) - fill(Fluid.temperature_profile, 0.0) + -- Unpack the partitions that we are going to need + var {p_All} = Fluid_Partitions; + + [emitFill(p_All, tiles, "centerCoordinates", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "cellWidth", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "reconXFacePlus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "reconYFacePlus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "reconZFacePlus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "reconXFaceMinus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "reconYFaceMinus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "reconZFaceMinus", UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsXPlus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsYPlus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsZPlus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsXMinus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsYMinus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "TENOCoeffsZMinus", UTIL.mkArrayConstant(nStencils, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "BCStencilX", rexpr false end)]; + [emitFill(p_All, tiles, "BCStencilY", rexpr false end)]; + [emitFill(p_All, tiles, "BCStencilZ", rexpr false end)]; + [emitFill(p_All, tiles, "interpXFace", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "interpYFace", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "interpZFace", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "derivXFace", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "derivYFace", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "derivZFace", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "gradX", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "gradY", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "gradZ", rexpr array(0.0, 0.0) end)]; + [emitFill(p_All, tiles, "rho", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "mu" , rexpr 0.0 end)]; + [emitFill(p_All, tiles, "lam", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "Di" , UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "SoS", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "pressure", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "temperature", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "MolarFracs", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "velocity", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "velocityGradientX", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "velocityGradientY", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "velocityGradientZ", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "temperatureGradient", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "Conserved", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "Conserved_old", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "Conserved_hat", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "Conserved_t", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "Conserved_t_old", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "EulerFluxX", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "EulerFluxY", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "EulerFluxZ", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxX", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxY", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxZ", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxXCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxYCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "FluxZCorr", UTIL.mkArrayConstant(nEq, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "dudtBoundary", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "dTdtBoundary", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "velocity_old_NSCBC", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "temperature_old_NSCBC", rexpr 0.0 end)]; + [emitFill(p_All, tiles, "MolarFracs_profile", UTIL.mkArrayConstant(nSpec, rexpr 0.0 end))]; + [emitFill(p_All, tiles, "velocity_profile", rexpr array(0.0, 0.0, 0.0) end)]; + [emitFill(p_All, tiles, "temperature_profile", rexpr 0.0 end)]; end ------------------------------------------------------------------------------- @@ -371,7 +463,7 @@ do [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] (Fluid, tiles, int3d{Grid_xBnum,Grid_yBnum,Grid_zBnum}, int3d{0,0,0}) - -- This partion accommodates 27 regions, in the order: + -- This partition accommodates 27 regions, in the order: -- - [ 0]: Interior -- (6 faces) -- - [ 1]: Faces xNeg @@ -415,10 +507,10 @@ do var p_Fluid_AllGhost = p_Fluid - p_Fluid_Interior ----------------------------------------------------------------------------------------------- - -- Boudary conditions regions + -- Boundary conditions regions ----------------------------------------------------------------------------------------------- -- !!! We need to be very careful here !!! - -- A corner beween two outflow conditions requires the bc conditions to be aliased + -- A corner between two outflow conditions requires the bc conditions to be aliased -- therefore define one color for each side var xNeg_coloring = regentlib.c.legion_multi_domain_point_coloring_create() var xPos_coloring = regentlib.c.legion_multi_domain_point_coloring_create() @@ -446,12 +538,12 @@ do -- - Y -- - Z - var BC_xBCLeft = config.BC.xBCLeft - var BC_xBCRight = config.BC.xBCRight - var BC_yBCLeft = config.BC.yBCLeft - var BC_yBCRight = config.BC.yBCRight - var BC_zBCLeft = config.BC.zBCLeft - var BC_zBCRight = config.BC.zBCRight + var BC_xBCLeft = config.BC.xBCLeft.type + var BC_xBCRight = config.BC.xBCRight.type + var BC_yBCLeft = config.BC.yBCLeft.type + var BC_yBCRight = config.BC.yBCRight.type + var BC_zBCLeft = config.BC.zBCLeft.type + var BC_zBCRight = config.BC.zBCRight.type ------------------------------------------------------ -- Break ties with other boundary conditions for edges @@ -478,6 +570,8 @@ do [addToBcColoring(rexpr xNeg_coloring end , rexpr Fluid_regions[7].bounds end, rexpr int3d{ 1, 0, 0} end)] -- NSCBC_Outflow + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[7].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCLeft == SCHEMA.FlowBC_Periodic) and @@ -588,8 +682,13 @@ do -- NSCBC_Inflow -- NSCBC_Outflow + elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow and BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[11].bounds end, rexpr int3d{-1, 0, 0} end)]; + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[11].bounds end, rexpr int3d{ 0, 1, 0} end)] elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[11].bounds end, rexpr int3d{-1, 0, 0} end)] + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[11].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCRight == SCHEMA.FlowBC_Periodic) and @@ -702,6 +801,8 @@ do -- NSCBC_Inflow -- NSCBC_Outflow + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[15].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_yBCLeft == SCHEMA.FlowBC_Periodic) and @@ -729,6 +830,8 @@ do -- NSCBC_Inflow -- NSCBC_Outflow + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[16].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_yBCLeft == SCHEMA.FlowBC_Periodic) and @@ -820,6 +923,8 @@ do [addToBcColoring(rexpr xNeg_coloring end , rexpr Fluid_regions[19].bounds end, rexpr int3d{ 1, 0, 0} end)] -- NSCBC_Outflow + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[19].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCLeft == SCHEMA.FlowBC_Periodic) and @@ -889,6 +994,8 @@ do [addToBcColoring(rexpr xNeg_coloring end , rexpr Fluid_regions[21].bounds end, rexpr int3d{ 1, 0, 0} end)] -- NSCBC_Outflow + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[21].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCLeft == SCHEMA.FlowBC_Periodic) and @@ -955,8 +1062,13 @@ do -- NSCBC_Inflow -- NSCBC_Outflow + elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow and BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[23].bounds end, rexpr int3d{-1, 0, 0} end)]; + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[23].bounds end, rexpr int3d{ 0, 1, 0} end)] elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[23].bounds end, rexpr int3d{-1, 0, 0} end)] + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[23].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCRight == SCHEMA.FlowBC_Periodic) and @@ -1027,8 +1139,13 @@ do -- NSCBC_Inflow -- NSCBC_Outflow + elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow and BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[25].bounds end, rexpr int3d{-1, 0, 0} end)]; + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[25].bounds end, rexpr int3d{ 0, 1, 0} end)] elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then [addToBcColoring(rexpr xPos_coloring end , rexpr Fluid_regions[25].bounds end, rexpr int3d{-1, 0, 0} end)] + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + [addToBcColoring(rexpr yNeg_coloring end , rexpr Fluid_regions[25].bounds end, rexpr int3d{ 0, 1, 0} end)] -- Periodic elseif ((BC_xBCRight == SCHEMA.FlowBC_Periodic) and @@ -1101,7 +1218,7 @@ do regentlib.c.legion_multi_domain_point_coloring_destroy(zPos_coloring) ----------------------------------------------------------------------------------------------- - -- END - Boudary conditions regions + -- END - Boundary conditions regions ----------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------- -- Regions for RHS functions @@ -1159,6 +1276,18 @@ do regentlib.c.legion_multi_domain_point_coloring_color_domain(yfaces_coloring, int1d(0), Fluid_regions[11].bounds) regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[12].bounds) end + + if (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + -- yNeg is an NSCBC + regentlib.c.legion_multi_domain_point_coloring_color_domain(xdivg_coloring, int1d(0), Fluid_regions[ 3].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(zdivg_coloring, int1d(0), Fluid_regions[ 3].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(solve_coloring, int1d(0), Fluid_regions[ 3].bounds) + + regentlib.c.legion_multi_domain_point_coloring_color_domain(xfaces_coloring, int1d(0), Fluid_regions[ 3].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[ 3].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(xfaces_coloring, int1d(0), Fluid_regions[ 7].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[15].bounds) + end if (BC_yBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then -- yPos is an NSCBC regentlib.c.legion_multi_domain_point_coloring_color_domain(xdivg_coloring, int1d(0), Fluid_regions[ 4].bounds) @@ -1170,6 +1299,25 @@ do regentlib.c.legion_multi_domain_point_coloring_color_domain(xfaces_coloring, int1d(0), Fluid_regions[ 9].bounds) regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[17].bounds) end + + if ((BC_xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow) and + (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow)) then + -- Edge xNeg-yNeg is an NSCBC + regentlib.c.legion_multi_domain_point_coloring_color_domain(zdivg_coloring, int1d(0), Fluid_regions[ 7].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(solve_coloring, int1d(0), Fluid_regions[ 7].bounds) + + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[ 7].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[19].bounds) + end + if ((BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) and + (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow)) then + -- Edge xPos-yNeg is an NSCBC + regentlib.c.legion_multi_domain_point_coloring_color_domain(zdivg_coloring, int1d(0), Fluid_regions[11].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(solve_coloring, int1d(0), Fluid_regions[11].bounds) + + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[11].bounds) + regentlib.c.legion_multi_domain_point_coloring_color_domain(zfaces_coloring, int1d(0), Fluid_regions[23].bounds) + end if ((BC_xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow) and (BC_yBCRight == SCHEMA.FlowBC_NSCBC_Outflow)) then -- Edge xNeg-yPos is an NSCBC @@ -1262,6 +1410,72 @@ do } end +------------------------------------------------------------------------------- +-- DEBUG ROUTINES +------------------------------------------------------------------------------- + +local DetectNaN +local CheckDebugOutput +if DEBUG_OUTPUT then + +local isnan = regentlib.isnan(double) +__demand(__cuda, __leaf) -- MANUALLY PARALLELIZED +task DetectNaN(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.{pressure, temperature}) +do + var err = 0 + __demand(__openmp) + for c in Fluid do + if ([bool](isnan(Fluid[c].pressure ))) then err += 1 end + if ([bool](isnan(Fluid[c].temperature))) then err += 1 end + end + return err +end + +__demand(__inline) +task CheckDebugOutput(Fluid : region(ispace(int3d), Fluid_columns), + Fluid_copy : region(ispace(int3d), Fluid_columns), + Fluid_bounds : rect3d, + tiles : ispace(int3d), + Fluid_Partitions : grid_partitions(Fluid, tiles), + Fluid_Partitions_copy : grid_partitions(Fluid_copy, tiles), + config : Config, + Mix : MIX.Mixture, + Integrator_timeStep : int, + Integrator_simTime : double) +where + reads(Fluid), + reads writes(Fluid_copy), + Fluid * Fluid_copy +do + -- Unpack the partitions that we are going to need + var {p_All} = Fluid_Partitions + + var err = 0 + __demand(__index_launch) + for c in tiles do + err += DetectNaN(p_All[c]) + end + if err ~= 0 then + var SpeciesNames = MIX.GetSpeciesNames(Mix) + var dirname = [&int8](C.malloc(256)) + C.snprintf(dirname, 256, '%s/debugOut', config.Mapping.outDir) + var _1 = IO.createDir(dirname) + _1 = HDF_DEBUG.dump( _1, tiles, dirname, Fluid, Fluid_copy, p_All, Fluid_Partitions_copy.p_All) + _1 = HDF_DEBUG.write.timeStep( _1, tiles, dirname, Fluid, p_All, Integrator_timeStep) + _1 = HDF_DEBUG.write.simTime( _1, tiles, dirname, Fluid, p_All, Integrator_simTime) + _1 = HDF_DEBUG.write.SpeciesNames( _1, tiles, dirname, Fluid, p_All, SpeciesNames) + _1 = HDF_DEBUG.write.Versions( _1, tiles, dirname, Fluid, p_All, array(regentlib.string([VERSION.SolverVersion]), regentlib.string([VERSION.LegionVersion]))) + _1 = HDF_DEBUG.write.channelForcing( _1, tiles, dirname, Fluid, p_All, config.Flow.turbForcing.u.CHANNEL.Forcing); + C.free(dirname) + + __fence(__execution, __block) + regentlib.assert(false, "NaN detected! Debug fields dumped in debugOut") + end +end +end + ------------------------------------------------------------------------------- -- RK-LOOP ROUTINES ------------------------------------------------------------------------------- @@ -1285,7 +1499,11 @@ where do -- Unpack the partitions that we are going to need - var {p_All, p_Interior, p_AllGhost, p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Partitions + var {p_All, p_Interior, p_AllGhost, p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Partitions; + +@ESCAPE if TIMING then @EMIT + var [T] = IO.Console_WriteTiming(0, config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Update all primitive variables... __demand(__index_launch) @@ -1293,13 +1511,21 @@ do VARS.UpdatePrimitiveFromConserved(p_All[c], p_Interior[c], Mix) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- ...also in the ghost cells BCOND.UpdateGhostPrimitives(Fluid, tiles, Fluid_Partitions, config, Mix, - Integrator_simTime) + Integrator_simTime); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Update the mixture properties everywhere __demand(__index_launch) @@ -1307,14 +1533,26 @@ do VARS.UpdatePropertiesFromPrimitive(p_All[c], p_All[c], Mix) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- update values of conserved variables in ghost cells __demand(__index_launch) for c in tiles do VARS.UpdateConservedFromPrimitive(p_All[c], p_AllGhost[c], Mix) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Compute velocity gradients - VARS.GetVelocityGradients(Fluid, Fluid_bounds) + VARS.GetVelocityGradients(Fluid, Fluid_bounds); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Compute local Euler fluxes __demand(__index_launch) @@ -1322,11 +1560,29 @@ do FLUX.GetEulerFlux(p_All[c]) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Compute fluxes [FLUX.mkGetFlux("x")](Fluid, x_faces, Fluid_bounds, Mix); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + [FLUX.mkGetFlux("y")](Fluid, y_faces, Fluid_bounds, Mix); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + [FLUX.mkGetFlux("z")](Fluid, z_faces, Fluid_bounds, Mix); +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateFluxesFromConserved", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + end __demand(__inline) @@ -1348,7 +1604,11 @@ where do -- Unpack the partitions that we are going to need - var {p_All, p_Interior, p_solved, p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Partitions + var {p_All, p_Interior, p_solved, p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Partitions; + +@ESCAPE if TIMING then @EMIT + var [T] = IO.Console_WriteTiming(0, config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Initialize time derivatives to 0 or minus the old value if UseOldDerivatives then @@ -1363,6 +1623,10 @@ do end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + if (not config.Integrator.implicitChemistry) then -- Add chemistry source terms __demand(__index_launch) @@ -1371,12 +1635,20 @@ do end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Add body forces __demand(__index_launch) for c in tiles do RHS.AddBodyForces(p_All[c], p_solved[c], config.Flow.bodyForce) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Add turbulent forcing if config.Flow.turbForcing.type == SCHEMA.TurbForcingModel_CHANNEL then -- Add forcing @@ -1387,13 +1659,31 @@ do end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Use fluxes to update conserved value derivatives [RHS.mkUpdateUsingFlux("z")](Fluid, z_divg, Fluid_bounds); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + [RHS.mkUpdateUsingFlux("y")](Fluid, y_divg, Fluid_bounds); - [RHS.mkUpdateUsingFlux("x")](Fluid, x_divg, Fluid_bounds) + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + + [RHS.mkUpdateUsingFlux("x")](Fluid, x_divg, Fluid_bounds); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Update using NSCBC_Outflow bcs - if (config.BC.xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then + if (config.BC.xBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then var MaxMach = 0.0 __demand(__index_launch) for c in tiles do @@ -1403,30 +1693,54 @@ do for c in tiles do [RHS.mkUpdateUsingFluxNSCBCOutflow("xPos")](p_All[c], p_xPos[c], - Mix, MaxMach, config.Grid.xWidth, config.BC.xBCRightP) + Mix, MaxMach, config.Grid.xWidth, config.BC.xBCRight.u.NSCBC_Outflow.P) end end - if (config.BC.yBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + + if (config.BC.yBCLeft.type == SCHEMA.FlowBC_NSCBC_Outflow or config.BC.yBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then var MaxMach = 0.0 __demand(__index_launch) for c in tiles do MaxMach max= STAT.CalculateMaxMachNumber(p_All[c], p_Interior[c], 1) end - __demand(__index_launch) - for c in tiles do - [RHS.mkUpdateUsingFluxNSCBCOutflow("yPos")](p_All[c], - p_yPos[c], - Mix, MaxMach, config.Grid.yWidth, config.BC.yBCRightP) + if (config.BC.yBCLeft.type == SCHEMA.FlowBC_NSCBC_Outflow) then + __demand(__index_launch) + for c in tiles do + [RHS.mkUpdateUsingFluxNSCBCOutflow("yNeg")](p_All[c], + p_yNeg[c], + Mix, MaxMach, config.Grid.yWidth, config.BC.yBCLeft.u.NSCBC_Outflow.P) + end + end + if (config.BC.yBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then + __demand(__index_launch) + for c in tiles do + [RHS.mkUpdateUsingFluxNSCBCOutflow("yPos")](p_All[c], + p_yPos[c], + Mix, MaxMach, config.Grid.yWidth, config.BC.yBCRight.u.NSCBC_Outflow.P) + end end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Update using NSCBC_Inflow bcs - if (config.BC.xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow) then + if (config.BC.xBCLeft.type == SCHEMA.FlowBC_NSCBC_Inflow) then __demand(__index_launch) for c in tiles do RHS.UpdateUsingFluxNSCBCInflow(p_All[c], p_xNeg[c], Mix) end end + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "UpdateDerivativesFromFluxes", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + end __demand(__inline) @@ -1445,9 +1759,29 @@ where reads writes(y_divg), y_divg <= Fluid, reads writes(z_divg), z_divg <= Fluid do + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + [RHS.mkCorrectUsingFlux("z")](Fluid, z_divg, Fluid_bounds, Mix); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + [RHS.mkCorrectUsingFlux("y")](Fluid, y_divg, Fluid_bounds, Mix); - [RHS.mkCorrectUsingFlux("x")](Fluid, x_divg, Fluid_bounds, Mix) + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + + [RHS.mkCorrectUsingFlux("x")](Fluid, x_divg, Fluid_bounds, Mix); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "CorrectDerivatives", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + end ------------------------------------------------------------------------------- @@ -1465,15 +1799,15 @@ local function mkInstance() local INSTANCE = {} xBnum = regentlib.newsymbol(), yBnum = regentlib.newsymbol(), zBnum = regentlib.newsymbol(), + NX = regentlib.newsymbol(), + NY = regentlib.newsymbol(), + NZ = regentlib.newsymbol(), + numTiles = regentlib.newsymbol(), } local BC = { readProfiles = regentlib.newsymbol(bool), ProfilesDir = regentlib.newsymbol(&int8), } - local NX = regentlib.newsymbol() - local NY = regentlib.newsymbol() - local NZ = regentlib.newsymbol() - local numTiles = regentlib.newsymbol() local Integrator_deltaTime = regentlib.newsymbol() local Integrator_simTime = regentlib.newsymbol() @@ -1505,33 +1839,10 @@ local function mkInstance() local INSTANCE = {} local p_y_faces = regentlib.newsymbol("p_y_faces") local p_z_faces = regentlib.newsymbol("p_z_faces") - local Averages = { - XAverages = regentlib.newsymbol(), - YAverages = regentlib.newsymbol(), - ZAverages = regentlib.newsymbol(), - XAverages_copy = regentlib.newsymbol(), - YAverages_copy = regentlib.newsymbol(), - ZAverages_copy = regentlib.newsymbol(), - is_Xrakes = regentlib.newsymbol(), - is_Yrakes = regentlib.newsymbol(), - is_Zrakes = regentlib.newsymbol(), - Xrakes = regentlib.newsymbol(), - Yrakes = regentlib.newsymbol(), - Zrakes = regentlib.newsymbol(), - Xrakes_copy = regentlib.newsymbol(), - Yrakes_copy = regentlib.newsymbol(), - Zrakes_copy = regentlib.newsymbol(), - - XAverages_local = regentlib.newsymbol(), - YAverages_local = regentlib.newsymbol(), - ZAverages_local = regentlib.newsymbol(), - is_Xrakes_local = regentlib.newsymbol(), - is_Yrakes_local = regentlib.newsymbol(), - is_Zrakes_local = regentlib.newsymbol(), - p_Xrakes_local = regentlib.newsymbol(), - p_Yrakes_local = regentlib.newsymbol(), - p_Zrakes_local = regentlib.newsymbol(), - } + local Averages + if AVERAGES then + Averages = AVG.AvgList + end ----------------------------------------------------------------------------- -- Exported symbols @@ -1603,14 +1914,14 @@ local function mkInstance() local INSTANCE = {} var [Grid.xBnum] = 1 var [Grid.yBnum] = 1 var [Grid.zBnum] = 1 - if config.BC.xBCLeft == SCHEMA.FlowBC_Periodic then Grid.xBnum = 0 end - if config.BC.yBCLeft == SCHEMA.FlowBC_Periodic then Grid.yBnum = 0 end - if config.BC.zBCLeft == SCHEMA.FlowBC_Periodic then Grid.zBnum = 0 end + if config.BC.xBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.xBnum = 0 end + if config.BC.yBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.yBnum = 0 end + if config.BC.zBCLeft.type == SCHEMA.FlowBC_Periodic then Grid.zBnum = 0 end - var [NX] = config.Mapping.tiles[0] - var [NY] = config.Mapping.tiles[1] - var [NZ] = config.Mapping.tiles[2] - var [numTiles] = NX * NY * NZ + var [Grid.NX] = config.Mapping.tiles[0] + var [Grid.NY] = config.Mapping.tiles[1] + var [Grid.NZ] = config.Mapping.tiles[2] + var [Grid.numTiles] = Grid.NX * Grid.NY * Grid.NZ var [Integrator_exitCond] = true var [Integrator_simTime] = config.Integrator.startTime @@ -1618,112 +1929,28 @@ local function mkInstance() local INSTANCE = {} var [Integrator_deltaTime] = config.Integrator.fixedDeltaTime -- Set up flow BC's in x direction - if (not((config.BC.xBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.xBCRight == SCHEMA.FlowBC_Periodic))) then - if (config.BC.xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow) then - if config.BC.xBCLeftInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftInflowProfile.type == SCHEMA.InflowProfile_File then - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftInflowProfile.u.File.FileDir - elseif config.BC.xBCLeftInflowProfile.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_File then - if (BC.readProfiles) then - regentlib.assert(C.strcmp(BC.ProfilesDir, config.BC.xBCLeftHeat.u.File.FileDir) == 0, 'Only one file is allowed for profiles') - else - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftHeat.u.File.FileDir - end - elseif config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_File then - if (BC.readProfiles) then - regentlib.assert(C.strcmp(BC.ProfilesDir, config.BC.xBCLeftMixture.u.File.FileDir) == 0, 'Only one file is allowed for profiles') - else - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftMixture.u.File.FileDir - end - elseif config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end - - elseif (config.BC.xBCLeft == SCHEMA.FlowBC_Dirichlet) then - if config.BC.xBCLeftInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftInflowProfile.type == SCHEMA.InflowProfile_File then - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftInflowProfile.u.File.FileDir - elseif config.BC.xBCLeftHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_File then - if (BC.readProfiles) then - regentlib.assert(C.strcmp(BC.ProfilesDir, config.BC.xBCLeftHeat.u.File.FileDir) == 0, 'Only one file is allowed for profiles') - else - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftHeat.u.File.FileDir - end - elseif config.BC.xBCLeftHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_File then - if (BC.readProfiles) then - regentlib.assert(C.strcmp(BC.ProfilesDir, config.BC.xBCLeftMixture.u.File.FileDir) == 0, 'Only one file is allowed for profiles') - else - BC.readProfiles = true - BC.ProfilesDir = config.BC.xBCLeftMixture.u.File.FileDir - end - elseif config.BC.xBCLeftMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end + if (not((config.BC.xBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.xBCRight.type == SCHEMA.FlowBC_Periodic))) then + + if (config.BC.xBCLeft.type == SCHEMA.FlowBC_NSCBC_Inflow) then + [BCOND.CheckNSCBC_Inflow(BC, rexpr config.BC.xBCLeft.u.NSCBC_Inflow end)]; - elseif (config.BC.xBCLeft == SCHEMA.FlowBC_AdiabaticWall) then + elseif (config.BC.xBCLeft.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.xBCLeft.u.Dirichlet end)]; + + elseif (config.BC.xBCLeft.type == SCHEMA.FlowBC_AdiabaticWall) then -- Do nothing else regentlib.assert(false, "Boundary conditions in xBCLeft not implemented") end - if (config.BC.xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then + if (config.BC.xBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then -- Do nothing - elseif (config.BC.xBCRight == SCHEMA.FlowBC_Dirichlet) then - if config.BC.xBCRightInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.xBCRightHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.xBCRightHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.xBCRightHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.xBCRightMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.xBCRightMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end - - elseif (config.BC.xBCRight == SCHEMA.FlowBC_AdiabaticWall) then + elseif (config.BC.xBCRight.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.xBCRight.u.Dirichlet end)]; + + elseif (config.BC.xBCRight.type == SCHEMA.FlowBC_AdiabaticWall) then -- Do nothing else @@ -1732,141 +1959,56 @@ local function mkInstance() local INSTANCE = {} end -- Set up flow BC's in y direction - if (not((config.BC.yBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.yBCRight == SCHEMA.FlowBC_Periodic))) then - if (config.BC.yBCLeft == SCHEMA.FlowBC_Dirichlet) then - if config.BC.yBCLeftInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.yBCLeftHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.yBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.yBCLeftHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.yBCLeftMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.yBCLeftMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end - --- if (config.BC.yBCLeft == SCHEMA.FlowBC_Symmetry) then - elseif (config.BC.yBCLeft == SCHEMA.FlowBC_AdiabaticWall) then - -- Do nothing + if (not((config.BC.yBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.yBCRight.type == SCHEMA.FlowBC_Periodic))) then - elseif (config.BC.yBCLeft == SCHEMA.FlowBC_IsothermalWall) then - if config.BC.yBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - else - regentlib.assert(false, 'Only constant heat model supported') - end - - elseif (config.BC.yBCLeft == SCHEMA.FlowBC_SuctionAndBlowingWall) then - regentlib.assert(config.BC.yBCLeftInflowProfile.type == SCHEMA.InflowProfile_SuctionAndBlowing, - "SuctionAndBlowingWall BC requires a SuctionAndBlowing InflowProfile") + if (config.BC.yBCLeft.type == SCHEMA.FlowBC_NSCBC_Outflow) then + -- Do nothing + elseif (config.BC.yBCLeft.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.yBCLeft.u.Dirichlet end)]; - regentlib.assert(config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.A.length == config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.omega.length, - "Equal number of amplitudes and frequencies must be specified") + elseif (config.BC.yBCLeft.type == SCHEMA.FlowBC_AdiabaticWall) then + -- Do nothing - regentlib.assert(config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.A.length == config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.beta.length, - "Equal number of amplitudes and spanwise wave numbers must be specified") + elseif (config.BC.yBCLeft.type == SCHEMA.FlowBC_IsothermalWall) then + [BCOND.CheckIsothermalWall(rexpr config.BC.yBCLeft.u.IsothermalWall end)]; - if config.BC.yBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - else - regentlib.assert(false, 'Only constant heat model supported') - end + elseif (config.BC.yBCLeft.type == SCHEMA.FlowBC_SuctionAndBlowingWall) then + [BCOND.CheckSuctionAndBlowingWall(rexpr config.BC.yBCLeft.u.SuctionAndBlowingWall end)]; else regentlib.assert(false, "Boundary conditions in yBCLeft not implemented") end - if (config.BC.yBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then - -- Do nothing - elseif (config.BC.yBCRight == SCHEMA.FlowBC_Dirichlet) then - if config.BC.yBCRightInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.yBCRightHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.yBCRightHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.yBCRightHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.yBCRightMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.yBCRightMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end - - elseif (config.BC.yBCRight == SCHEMA.FlowBC_AdiabaticWall) then + if (config.BC.yBCRight.type == SCHEMA.FlowBC_NSCBC_Outflow) then -- Do nothing - elseif (config.BC.yBCRight == SCHEMA.FlowBC_IsothermalWall) then + elseif (config.BC.yBCRight.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.yBCRight.u.Dirichlet end)]; + + elseif (config.BC.yBCRight.type == SCHEMA.FlowBC_AdiabaticWall) then -- Do nothing - if config.BC.yBCRightHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - else - regentlib.assert(false, 'Only constant heat model supported') - end + + elseif (config.BC.yBCRight.type == SCHEMA.FlowBC_IsothermalWall) then + [BCOND.CheckIsothermalWall(rexpr config.BC.yBCRight.u.IsothermalWall end)]; + else regentlib.assert(false, "Boundary conditions in yBCRight not implemented") end end -- Set up flow BC's in z direction - if (not((config.BC.zBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.zBCRight == SCHEMA.FlowBC_Periodic))) then - if (config.BC.zBCLeft == SCHEMA.FlowBC_Dirichlet) then - if config.BC.zBCLeftInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.zBCLeftHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.zBCLeftHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.zBCLeftHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.zBCLeftMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.zBCLeftMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end + if (not((config.BC.zBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.zBCRight.type == SCHEMA.FlowBC_Periodic))) then + + if (config.BC.zBCLeft.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.zBCLeft.u.Dirichlet end)]; else regentlib.assert(false, "Boundary conditions in zBCLeft not implemented") end - if (config.BC.zBCRight == SCHEMA.FlowBC_Dirichlet) then - if config.BC.zBCRightInflowProfile.type == SCHEMA.InflowProfile_Constant then - -- Do nothing - elseif config.BC.zBCRightHeat.type == SCHEMA.InflowProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming InflowProfile not supported') - else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end - if config.BC.zBCRightHeat.type == SCHEMA.TempProfile_Constant then - -- Do nothing - elseif config.BC.zBCRightHeat.type == SCHEMA.TempProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming heat model not supported') - else regentlib.assert(false, 'Unhandled case in TempProfile switch') end - if config.BC.zBCRightMixture.type == SCHEMA.MixtureProfile_Constant then - -- Do nothing - elseif config.BC.zBCRightMixture.type == SCHEMA.MixtureProfile_Incoming then - -- Do nothing - regentlib.assert(false, 'Incoming mixture model not supported') - else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end + if (config.BC.zBCRight.type == SCHEMA.FlowBC_Dirichlet) then + [BCOND.CheckDirichlet(BC, rexpr config.BC.yBCRight.u.Dirichlet end)]; else regentlib.assert(false, "Boundary conditions in zBCRight not implemented") @@ -1874,16 +2016,16 @@ local function mkInstance() local INSTANCE = {} end -- Check if boundary conditions in each direction are either both periodic or both non-periodic - if (not (((config.BC.xBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.xBCRight == SCHEMA.FlowBC_Periodic)) - or ((not (config.BC.xBCLeft == SCHEMA.FlowBC_Periodic)) and (not (config.BC.xBCRight == SCHEMA.FlowBC_Periodic))))) then + if (not (((config.BC.xBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.xBCRight.type == SCHEMA.FlowBC_Periodic)) + or ((not (config.BC.xBCLeft.type == SCHEMA.FlowBC_Periodic)) and (not (config.BC.xBCRight.type == SCHEMA.FlowBC_Periodic))))) then regentlib.assert(false, "Boundary conditions in x should match for periodicity") end - if (not (((config.BC.yBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.yBCRight == SCHEMA.FlowBC_Periodic)) - or ((not (config.BC.yBCLeft == SCHEMA.FlowBC_Periodic)) and (not (config.BC.yBCRight == SCHEMA.FlowBC_Periodic))))) then + if (not (((config.BC.yBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.yBCRight.type == SCHEMA.FlowBC_Periodic)) + or ((not (config.BC.yBCLeft.type == SCHEMA.FlowBC_Periodic)) and (not (config.BC.yBCRight.type == SCHEMA.FlowBC_Periodic))))) then regentlib.assert(false, "Boundary conditions in y should match for periodicity") end - if (not (((config.BC.zBCLeft == SCHEMA.FlowBC_Periodic) and (config.BC.zBCRight == SCHEMA.FlowBC_Periodic)) - or ((not (config.BC.zBCLeft == SCHEMA.FlowBC_Periodic)) and (not (config.BC.zBCRight == SCHEMA.FlowBC_Periodic))))) then + if (not (((config.BC.zBCLeft.type == SCHEMA.FlowBC_Periodic) and (config.BC.zBCRight.type == SCHEMA.FlowBC_Periodic)) + or ((not (config.BC.zBCLeft.type == SCHEMA.FlowBC_Periodic)) and (not (config.BC.zBCRight.type == SCHEMA.FlowBC_Periodic))))) then regentlib.assert(false, "Boundary conditions in z should match for periodicity") end @@ -1912,7 +2054,7 @@ local function mkInstance() local INSTANCE = {} [UTIL.emitRegionTagAttach(Fluid_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; -- Partitioning domain - var [tiles] = ispace(int3d, {NX,NY,NZ}) + var [tiles] = ispace(int3d, {Grid.NX, Grid.NY, Grid.NZ}) -- Fluid Partitioning var [Fluid_Partitions] = PartitionGrid(Fluid, tiles, config, Grid.xBnum, Grid.yBnum, Grid.zBnum) @@ -1944,96 +2086,14 @@ local function mkInstance() local INSTANCE = {} var [z_faces] = z_faces_t[0] var [p_x_faces] = p_x_faces_t[0] var [p_y_faces] = p_y_faces_t[0] - var [p_z_faces] = p_z_faces_t[0] + var [p_z_faces] = p_z_faces_t[0]; --------------------------------------------------------------------------- -- Create one-dimensional averages --------------------------------------------------------------------------- - - -- Create averages regions - var is_XAverages = ispace(int2d, {x = config.Grid.xNum + 2*Grid.xBnum, - y = config.IO.YZAverages.length }) - - var is_YAverages = ispace(int2d, {x = config.Grid.yNum + 2*Grid.yBnum, - y = config.IO.XZAverages.length }) - - var is_ZAverages = ispace(int2d, {x = config.Grid.zNum + 2*Grid.zBnum, - y = config.IO.XYAverages.length }) - - var [Averages.XAverages] = region(is_XAverages, AVG.Averages_columns) - var [Averages.YAverages] = region(is_YAverages, AVG.Averages_columns) - var [Averages.ZAverages] = region(is_ZAverages, AVG.Averages_columns) - var [Averages.XAverages_copy] = region(is_XAverages, AVG.Averages_columns) - var [Averages.YAverages_copy] = region(is_YAverages, AVG.Averages_columns) - var [Averages.ZAverages_copy] = region(is_ZAverages, AVG.Averages_columns); - - [UTIL.emitRegionTagAttach(Averages.XAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.YAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.ZAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.XAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.YAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.ZAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - - -- Partitioning averages in rakes - var [Averages.is_Xrakes] = ispace(int2d, {1, max(config.IO.YZAverages.length, 1)}) - var [Averages.is_Yrakes] = ispace(int2d, {1, max(config.IO.XZAverages.length, 1)}) - var [Averages.is_Zrakes] = ispace(int2d, {1, max(config.IO.XYAverages.length, 1)}) - - var [Averages.Xrakes] = partition(equal, Averages.XAverages, Averages.is_Xrakes) - var [Averages.Yrakes] = partition(equal, Averages.YAverages, Averages.is_Yrakes) - var [Averages.Zrakes] = partition(equal, Averages.ZAverages, Averages.is_Zrakes) - - var [Averages.Xrakes_copy] = partition(equal, Averages.XAverages_copy, Averages.is_Xrakes) - var [Averages.Yrakes_copy] = partition(equal, Averages.YAverages_copy, Averages.is_Yrakes) - var [Averages.Zrakes_copy] = partition(equal, Averages.ZAverages_copy, Averages.is_Zrakes) - --- -- TODO: in the future we might want to partition these also along the rakes --- var is_XrakesTiles = ispace(int2d, {NX, config.IO.YZAverages.length}) --- var is_YrakesTiles = ispace(int2d, {NY, config.IO.XZAverages.length}) --- var is_ZrakesTiles = ispace(int2d, {NZ, config.IO.XYAverages.length}); --- --- var [Averages.p_Xrakes] = [UTIL.mkPartitionByTile(int2d, int2d, AVG.Averages_columns)] --- (Averages.Xrakes, is_XrakesTiles, int2d{Grid.xBnum,0}, int2d{0,0}) --- var [Averages.p_Yrakes] = [UTIL.mkPartitionByTile(int2d, int2d, AVG.Averages_columns)] --- (Averages.Yrakes, is_YrakesTiles, int2d{Grid.yBnum,0}, int2d{0,0}) --- var [Averages.p_Zrakes] = [UTIL.mkPartitionByTile(int2d, int2d, AVG.Averages_columns)] --- (Averages.Zrakes, is_ZrakesTiles, int2d{Grid.zBnum,0}, int2d{0,0}) - - -- Create local buffers for averages regions - var is_XAverages_local = ispace(int4d, {x = config.Grid.xNum + 2*Grid.xBnum, - y = config.IO.YZAverages.length , - z = NY , - w = NZ }) - - var is_YAverages_local = ispace(int4d, {x = config.Grid.yNum + 2*Grid.yBnum, - y = config.IO.XZAverages.length , - z = NX , - w = NZ }) - - var is_ZAverages_local = ispace(int4d, {x = config.Grid.zNum + 2*Grid.zBnum, - y = config.IO.XYAverages.length , - z = NX , - w = NY }) - - var [Averages.XAverages_local] = region(is_XAverages_local, AVG.Averages_columns) - var [Averages.YAverages_local] = region(is_YAverages_local, AVG.Averages_columns) - var [Averages.ZAverages_local] = region(is_ZAverages_local, AVG.Averages_columns); - - [UTIL.emitRegionTagAttach(Averages.XAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.YAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - [UTIL.emitRegionTagAttach(Averages.ZAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; - - -- Partitioning local buffer in rakes - var [Averages.is_Xrakes_local] = ispace(int4d, {NX, max(config.IO.YZAverages.length, 1), NY, NZ}) - var [Averages.is_Yrakes_local] = ispace(int4d, {NY, max(config.IO.XZAverages.length, 1), NX, NZ}) - var [Averages.is_Zrakes_local] = ispace(int4d, {NZ, max(config.IO.XYAverages.length, 1), NX, NY}) - - var [Averages.p_Xrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, AVG.Averages_columns)] - (Averages.XAverages_local, Averages.is_Xrakes_local, int4d{Grid.xBnum,0,0,0}, int4d{0,0,0,0}) - var [Averages.p_Yrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, AVG.Averages_columns)] - (Averages.YAverages_local, Averages.is_Yrakes_local, int4d{Grid.yBnum,0,0,0}, int4d{0,0,0,0}) - var [Averages.p_Zrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, AVG.Averages_columns)] - (Averages.ZAverages_local, Averages.is_Zrakes_local, int4d{Grid.zBnum,0,0,0}, int4d{0,0,0,0}) +@ESCAPE if AVERAGES then @EMIT + [AVG.DeclSymbols(Averages, Grid, config, MAPPER)]; +@TIME end @EPACSE end end -- DeclSymbols @@ -2043,7 +2103,7 @@ local function mkInstance() local INSTANCE = {} function INSTANCE.InitRegions(config) return rquote - InitializeCell(Fluid) + InitializeCell(Fluid, tiles, Fluid_Partitions) -- Unpack the partitions that we are going to need var {p_All, p_Interior, p_AllGhost, @@ -2073,15 +2133,12 @@ local function mkInstance() local INSTANCE = {} end end +@ESCAPE if AVERAGES then @EMIT -- Initialize averages - [AVG.mkInitializeAverages(int2d)](Averages.XAverages); - [AVG.mkInitializeAverages(int2d)](Averages.YAverages); - [AVG.mkInitializeAverages(int2d)](Averages.ZAverages); - - -- Reinitialize reduction buffers - [AVG.mkInitializeAverages(int4d)](Averages.XAverages_local); - [AVG.mkInitializeAverages(int4d)](Averages.YAverages_local); - [AVG.mkInitializeAverages(int4d)](Averages.ZAverages_local) + [AVG.InitRakes(Averages)]; + -- Initialize reduction buffers + [AVG.InitBuffers(Averages)]; +@TIME end @EPACSE -- Initialize BC profiles -- Read from file... @@ -2189,23 +2246,12 @@ local function mkInstance() local INSTANCE = {} if config.Flow.turbForcing.type == SCHEMA.TurbForcingModel_CHANNEL then config.Flow.turbForcing.u.CHANNEL.Forcing = HDF.read.channelForcing( 0, tiles, config.Flow.restartDir, Fluid, p_All) end - HDF.load(0, tiles, config.Flow.restartDir, Fluid, Fluid_copy, p_All, Fluid_Partitions_copy.p_All) - if not config.IO.ResetAverages then - var dirname = [&int8](C.malloc(256)) - if config.IO.YZAverages.length ~= 0 then - C.snprintf(dirname, 256, '%s/YZAverages', config.Flow.restartDir) - AVG.HDF.load(0, Averages.is_Xrakes, dirname, Averages.XAverages, Averages.XAverages_copy, Averages.Xrakes, Averages.Xrakes_copy) - end - if config.IO.XZAverages.length ~= 0 then - C.snprintf(dirname, 256, '%s/XZAverages', config.Flow.restartDir) - AVG.HDF.load(0, Averages.is_Yrakes, dirname, Averages.YAverages, Averages.YAverages_copy, Averages.Yrakes, Averages.Yrakes_copy) - end - if config.IO.XYAverages.length ~= 0 then - C.snprintf(dirname, 256, '%s/XYAverages', config.Flow.restartDir) - AVG.HDF.load(0, Averages.is_Zrakes, dirname, Averages.ZAverages, Averages.ZAverages_copy, Averages.Zrakes, Averages.Zrakes_copy) - end - C.free(dirname) - end + HDF.load(0, tiles, config.Flow.restartDir, Fluid, Fluid_copy, p_All, Fluid_Partitions_copy.p_All); + +@ESCAPE if AVERAGES then @EMIT + [AVG.ReadAverages(Averages, config)]; +@TIME end @EPACSE + else regentlib.assert(false, 'Unhandled case in switch') end if config.Integrator.resetTime then @@ -2228,18 +2274,15 @@ local function mkInstance() local INSTANCE = {} Grid.zBnum, config.Grid.zNum); -- Enforce BCs on the metric - [METRIC.mkCorrectGhostMetric("x")](Fluid, Fluid_bounds, config.BC.xBCLeft, config.BC.xBCRight, Grid.xBnum, config.Grid.xNum); - [METRIC.mkCorrectGhostMetric("y")](Fluid, Fluid_bounds, config.BC.yBCLeft, config.BC.yBCRight, Grid.yBnum, config.Grid.yNum); - [METRIC.mkCorrectGhostMetric("z")](Fluid, Fluid_bounds, config.BC.zBCLeft, config.BC.zBCRight, Grid.zBnum, config.Grid.zNum) - - -- initialize ghost cells to their specified values in NSCBC case - if (config.Flow.initCase ~= SCHEMA.FlowInitCase_Restart) then - -- only if we did not read these values from the restart file - if config.BC.xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow then - __demand(__index_launch) - for c in tiles do - BCOND.InitializeGhostNSCBC(p_All[c], p_xNeg[c], Mix) - end + [METRIC.mkCorrectGhostMetric("x")](Fluid, Fluid_bounds, config.BC.xBCLeft.type, config.BC.xBCRight.type, Grid.xBnum, config.Grid.xNum); + [METRIC.mkCorrectGhostMetric("y")](Fluid, Fluid_bounds, config.BC.yBCLeft.type, config.BC.yBCRight.type, Grid.yBnum, config.Grid.yNum); + [METRIC.mkCorrectGhostMetric("z")](Fluid, Fluid_bounds, config.BC.zBCLeft.type, config.BC.zBCRight.type, Grid.zBnum, config.Grid.zNum) + + -- initialize ghost cells values for NSCBC + if config.BC.xBCLeft.type == SCHEMA.FlowBC_NSCBC_Inflow then + __demand(__index_launch) + for c in tiles do + BCOND.InitializeGhostNSCBC(p_All[c], p_xNeg[c], Mix) end end @@ -2277,7 +2320,11 @@ local function mkInstance() local INSTANCE = {} function INSTANCE.MainLoopHeader(config) return rquote -- Unpack the partitions that we are going to need - var {p_All} = Fluid_Partitions + var {p_All} = Fluid_Partitions; + +@ESCAPE if TIMING then @EMIT + var [T] = IO.Console_WriteTiming(0, config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Calculate exit condition Integrator_exitCond = @@ -2294,6 +2341,10 @@ local function mkInstance() local INSTANCE = {} Integrator_deltaTime = config.Integrator.cfl/Integrator_maxSpectralRadius end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + end end -- MainLoopHeader ----------------------------------------------------------------------------- @@ -2303,7 +2354,11 @@ local function mkInstance() local INSTANCE = {} function INSTANCE.PerformIO(config) return rquote -- Unpack the partitions that we are going to need - var {p_All, p_Interior} = Fluid_Partitions + var {p_All, p_Interior} = Fluid_Partitions; + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- Write to console var AveragePressure = 0.0 @@ -2337,6 +2392,10 @@ local function mkInstance() local INSTANCE = {} interior_volume += STAT.CalculateInteriorVolume(p_All[c], p_Interior[c]) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + AveragePressure = (AveragePressure /interior_volume) AverageTemperature = (AverageTemperature /interior_volume) AverageKineticEnergy = (AverageKineticEnergy/interior_volume) @@ -2354,6 +2413,11 @@ local function mkInstance() local INSTANCE = {} config.Flow.turbForcing.u.CHANNEL.Forcing *= config.Flow.turbForcing.u.CHANNEL.RhoUbulk/averageRhoU end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + +@ESCAPE if AVERAGES then @EMIT -- Add averages if (Integrator_timeStep % config.IO.AveragesSamplingInterval == 0 and ((config.IO.YZAverages.length ~= 0) or @@ -2361,31 +2425,18 @@ local function mkInstance() local INSTANCE = {} (config.IO.XYAverages.length ~= 0) )) then -- Update temperature gradient for mean heat flux - VARS.GetTemperatureGradients(Fluid, Fluid_bounds) - - for rake=0, config.IO.YZAverages.length do - __demand(__index_launch) - for c in tiles do - [AVG.mkAddAverages('x')](p_All[c], Averages.p_Xrakes_local[int4d{c.x,rake,c.y,c.z}], Mix, - config.IO.YZAverages.values[rake], Integrator_deltaTime) - end - end - for rake=0, config.IO.XZAverages.length do - __demand(__index_launch) - for c in tiles do - [AVG.mkAddAverages('y')](p_All[c], Averages.p_Yrakes_local[int4d{c.y,rake,c.x,c.z}], Mix, - config.IO.XZAverages.values[rake], Integrator_deltaTime) - end - end - for rake=0, config.IO.XYAverages.length do - __demand(__index_launch) - for c in tiles do - [AVG.mkAddAverages('z')](p_All[c], Averages.p_Zrakes_local[int4d{c.z,rake,c.x,c.y}], Mix, - config.IO.XYAverages.values[rake], Integrator_deltaTime) - end - end + VARS.GetTemperatureGradients(Fluid, Fluid_bounds); + + [AVG.AddAverages(Averages, tiles, p_All, Integrator_deltaTime, config, Mix)] + end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + +@TIME end @EPACSE + -- Dump restart files if config.IO.wrtRestart then if Integrator_exitCond or Integrator_timeStep % config.IO.restartEveryTimeSteps == 0 then @@ -2397,50 +2448,21 @@ local function mkInstance() local INSTANCE = {} _1 = HDF.write.timeStep( _1, tiles, dirname, Fluid, p_All, Integrator_timeStep) _1 = HDF.write.simTime( _1, tiles, dirname, Fluid, p_All, Integrator_simTime) _1 = HDF.write.SpeciesNames( _1, tiles, dirname, Fluid, p_All, SpeciesNames) - _1 = HDF.write.channelForcing( _1, tiles, dirname, Fluid, p_All, config.Flow.turbForcing.u.CHANNEL.Forcing) - if config.IO.YZAverages.length ~= 0 then --- AVG.DummyAverages(Averages.XAverages) - -- Reduce from reduction buffers - [AVG.mkReduceAverages('x')](Averages.XAverages, Averages.XAverages_local, tiles); - -- Reinitialize reduction buffers - [AVG.mkInitializeAverages(int4d)](Averages.XAverages_local) - var Avgdirname = [&int8](C.malloc(256)) - C.snprintf(Avgdirname, 256, '%s/YZAverages', dirname) - var _1 = IO.createDir(Avgdirname) - _1 = AVG.HDF.dump( _1, Averages.is_Xrakes, Avgdirname, Averages.XAverages, Averages.XAverages_copy, Averages.Xrakes, Averages.Xrakes_copy) - _1 = AVG.HDF.write.SpeciesNames( _1, Averages.is_Xrakes, Avgdirname, Averages.XAverages, Averages.Xrakes, SpeciesNames) - C.free(Avgdirname) - end - if config.IO.XZAverages.length ~= 0 then --- AVG.DummyAverages(Averages.YAverages) - -- Reduce from reduction buffers - [AVG.mkReduceAverages('y')](Averages.YAverages, Averages.YAverages_local, tiles); - -- Reinitialize reduction buffers - [AVG.mkInitializeAverages(int4d)](Averages.YAverages_local) - var Avgdirname = [&int8](C.malloc(256)) - C.snprintf(Avgdirname, 256, '%s/XZAverages', dirname) - var _1 = IO.createDir(Avgdirname) - _1 = AVG.HDF.dump( _1, Averages.is_Yrakes, Avgdirname, Averages.YAverages, Averages.YAverages_copy, Averages.Yrakes, Averages.Yrakes_copy) - _1 = AVG.HDF.write.SpeciesNames( _1, Averages.is_Yrakes, Avgdirname, Averages.YAverages, Averages.Yrakes, SpeciesNames) - C.free(Avgdirname) - end - if config.IO.XYAverages.length ~= 0 then --- AVG.DummyAverages(Averages.ZAverages) - -- Reduce from reduction buffers - [AVG.mkReduceAverages('z')](Averages.ZAverages, Averages.ZAverages_local, tiles); - -- Reinitialize reduction buffers - [AVG.mkInitializeAverages(int4d)](Averages.ZAverages_local) - var Avgdirname = [&int8](C.malloc(256)) - C.snprintf(Avgdirname, 256, '%s/XYAverages', dirname) - var _1 = IO.createDir(Avgdirname) - _1 = AVG.HDF.dump( _1, Averages.is_Zrakes, Avgdirname, Averages.ZAverages, Averages.ZAverages_copy, Averages.Zrakes, Averages.Zrakes_copy) - _1 = AVG.HDF.write.SpeciesNames( _1, Averages.is_Zrakes, Avgdirname, Averages.ZAverages, Averages.Zrakes, SpeciesNames) - C.free(Avgdirname) - end - C.free(dirname); + _1 = HDF.write.Versions( _1, tiles, dirname, Fluid, p_All, array(regentlib.string([VERSION.SolverVersion]), regentlib.string([VERSION.LegionVersion]))) + _1 = HDF.write.channelForcing( _1, tiles, dirname, Fluid, p_All, config.Flow.turbForcing.u.CHANNEL.Forcing); + +@ESCAPE if AVERAGES then @EMIT + [AVG.WriteAverages(Averages, tiles, dirname,IO, SpeciesNames, config)]; +@TIME end @EPACSE + + C.free(dirname) end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + end end -- PerformIO ----------------------------------------------------------------------------- @@ -2449,6 +2471,10 @@ local function mkInstance() local INSTANCE = {} function INSTANCE.MainLoopBody(config) return rquote +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + var Integrator_time_old = Integrator_simTime -- Unpack the partitions that we are going to need @@ -2466,7 +2492,11 @@ local function mkInstance() local INSTANCE = {} x_divg, y_divg, z_divg, config, Mix, - false) + false); + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE -- TODO: it is not clear if here we need to correct the derivatives to -- preserve boundness @@ -2477,6 +2507,10 @@ local function mkInstance() local INSTANCE = {} CHEM.UpdateChemistry(p_All[c], p_solved[c], Integrator_deltaTime, Mix) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Update the fluxes in preparation to the RK algorithm UpdateFluxesFromConserved(Fluid, Fluid_bounds, @@ -2491,6 +2525,10 @@ local function mkInstance() local INSTANCE = {} Integrator_simTime = Integrator_time_old + Integrator_deltaTime*0.5 end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Set iteration-specific fields that persist across RK sub-steps __demand(__index_launch) for c in tiles do @@ -2500,6 +2538,10 @@ local function mkInstance() local INSTANCE = {} -- RK sub-time-stepping loop @ESCAPE for STAGE = 1, 3 do @EMIT +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Update the time derivatives UpdateDerivativesFromFluxes(Fluid, Fluid_bounds, @@ -2510,6 +2552,10 @@ local function mkInstance() local INSTANCE = {} Mix, config.Integrator.implicitChemistry); +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Predictor part of the time step __demand(__index_launch) for c in tiles do @@ -2531,6 +2577,10 @@ local function mkInstance() local INSTANCE = {} [RK.mkUpdateVarsCorr(STAGE)](p_All[c], Integrator_deltaTime, config.Integrator.implicitChemistry) end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + -- Update the fluxes UpdateFluxesFromConserved(Fluid, Fluid_bounds, @@ -2541,7 +2591,21 @@ local function mkInstance() local INSTANCE = {} Mix, Integrator_simTime); - ---- Advance the time for the next sub-step +@ESCAPE if DEBUG_OUTPUT then @EMIT + CheckDebugOutput(Fluid, Fluid_copy, + Fluid_bounds, tiles, + Fluid_Partitions, Fluid_Partitions_copy, + config, + Mix, + Integrator_timeStep, + Integrator_simTime); +@TIME end @EPACSE + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + + -- Advance the time for the next sub-step @ESCAPE if STAGE == 3 then @EMIT Integrator_simTime = Integrator_time_old + Integrator_deltaTime @TIME else @EMIT @@ -2552,16 +2616,25 @@ local function mkInstance() local INSTANCE = {} Integrator_simTime = Integrator_time_old + [RK_C[STAGE][3]] * Integrator_deltaTime end @TIME end @EPACSE + +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + @TIME end @EPACSE-- RK sub-time-stepping -- Update time derivatives at boundary for NSCBC - if config.BC.xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow then + if config.BC.xBCLeft.type == SCHEMA.FlowBC_NSCBC_Inflow then __demand(__index_launch) for c in tiles do BCOND.UpdateNSCBCGhostCellTimeDerivatives(p_All[c], p_xNeg[c], Integrator_deltaTime) end end +@ESCAPE if TIMING then @EMIT + [T] = IO.Console_WriteTiming([T], config.Mapping, "workSingle", @LINE, C.legion_get_current_time_in_nanos()) +@TIME end @EPACSE + Integrator_timeStep += 1 end end -- MainLoopBody diff --git a/src/prometeo_IO.rg b/src/prometeo_IO.rg index 41297e1..62b7469 100644 --- a/src/prometeo_IO.rg +++ b/src/prometeo_IO.rg @@ -160,6 +160,35 @@ end -- avgFluidT)]; --end +-- regentlib.rexpr, regentlib.rexpr, regentlib.rexpr* -> regentlib.rquote +local function emitTimingWrite(config_Mapping, format, ...) + local args = terralib.newlist{...} + return rquote + var consoleFile = [&int8](C.malloc(256)) + C.snprintf(consoleFile, 256, '%s/timing.txt', config_Mapping.outDir) + var console = UTIL.openFile(consoleFile, 'a') + C.free(consoleFile) + C.fprintf(console, format, [args]) + C.fflush(console) + C.fclose(console) + end +end + +-- MANUALLY PARALLELIZED, NO CUDA, NO OPENMP +task Exports.Console_WriteTiming( _ : int, + config_Mapping : SCHEMA.MappingStruct, + taskname : regentlib.string, + line : int, + currTime : uint64) + [emitTimingWrite(config_Mapping, + "TIMING: %s task is on line %d at time %llu.%06llu\n", + taskname, + line, + rexpr currTime / 1000000 end, + rexpr currTime % 1000000 end)]; + return _ +end + -- MANUALLY PARALLELIZED, NO CUDA, NO OPENMP task Exports.createDir(dirname : regentlib.string) UTIL.createDir(dirname) diff --git a/src/prometeo_average.rg b/src/prometeo_average.rg index 78dde3d..e87aafb 100644 --- a/src/prometeo_average.rg +++ b/src/prometeo_average.rg @@ -35,6 +35,7 @@ return function(SCHEMA, MIX, Fluid_columns) local Exports = {} -- IMPORTS ------------------------------------------------------------------------------- local C = regentlib.c +local sqrt = regentlib.sqrt(double) local UTIL = require 'util-desugared' local CONST = require "prometeo_const" local MACRO = require "prometeo_macro" @@ -52,7 +53,7 @@ local Properties = CONST.Properties -- DATA STRUCTURES ------------------------------------------------------------------------------- -struct Exports.Averages_columns { +local struct Averages_columns { weight : double; -- Primitive variables pressure_avg : double; @@ -61,37 +62,44 @@ struct Exports.Averages_columns { temperature_rms : double; MolarFracs_avg : double[nSpec]; MolarFracs_rms : double[nSpec]; + MassFracs_avg : double[nSpec]; + MassFracs_rms : double[nSpec]; velocity_avg : double[3]; velocity_rms : double[3]; velocity_rey : double[3]; -- Properties - rho_avg : double; - rho_rms : double; - mu_avg : double; - mu_rms : double; - lam_avg : double; - lam_rms : double; - Di_avg : double[nSpec]; - Di_rms : double[nSpec]; - SoS_avg : double; - SoS_rms : double; - cp_avg : double; - cp_rms : double; - MixW_avg : double; - MixW_rms : double; + rho_avg : double; + rho_rms : double; + mu_avg : double; + lam_avg : double; + Di_avg : double[nSpec]; + SoS_avg : double; + cp_avg : double; + Ent_avg : double; -- Chemical production rates ProductionRates_avg : double[nSpec]; ProductionRates_rms : double[nSpec]; HeatReleaseRate_avg : double; HeatReleaseRate_rms : double; - -- Favre averages + -- Favre averaged primitives + pressure_favg : double; + pressure_frms : double; temperature_favg : double; temperature_frms : double; MolarFracs_favg : double[nSpec]; MolarFracs_frms : double[nSpec]; + MassFracs_favg : double[nSpec]; + MassFracs_frms : double[nSpec]; velocity_favg : double[3]; velocity_frms : double[3]; velocity_frey : double[3]; + -- Favre averaged properties + mu_favg : double; + lam_favg : double; + Di_favg : double[nSpec]; + SoS_favg : double; + cp_favg : double; + Ent_favg : double; -- Kinetic energy budgets (y is the inhomogeneous direction) rhoUUv : double[3]; Up : double[3]; @@ -106,6 +114,18 @@ struct Exports.Averages_columns { Pr_rms : double; Ec : double; Ec_rms : double; + Ma : double; + Sc : double[nSpec]; + -- Correlations + uT_avg : double[3]; + uT_favg : double[3]; + uYi_avg : double[nSpec]; + vYi_avg : double[nSpec]; + wYi_avg : double[nSpec]; + uYi_favg : double[nSpec]; + vYi_favg : double[nSpec]; + wYi_favg : double[nSpec]; + } local AveragesVars = terralib.newlist({ @@ -117,6 +137,8 @@ local AveragesVars = terralib.newlist({ 'temperature_rms', 'MolarFracs_avg', 'MolarFracs_rms', + 'MassFracs_avg', + 'MassFracs_rms', 'velocity_avg', 'velocity_rms', 'velocity_rey', @@ -124,27 +146,32 @@ local AveragesVars = terralib.newlist({ 'rho_avg', 'rho_rms', 'mu_avg', - 'mu_rms', 'lam_avg', - 'lam_rms', 'Di_avg', - 'Di_rms', 'SoS_avg', - 'SoS_rms', 'cp_avg', - 'cp_rms', - 'MixW_avg', - 'MixW_rms', + 'Ent_avg', + -- Favre averaged properties + 'mu_favg', + 'lam_favg', + 'Di_favg', + 'SoS_favg', + 'cp_favg', + 'Ent_favg', -- Chemical production rates 'ProductionRates_avg', 'ProductionRates_rms', 'HeatReleaseRate_avg', 'HeatReleaseRate_rms', -- Favre averages + 'pressure_favg', + 'pressure_frms', 'temperature_favg', 'temperature_frms', 'MolarFracs_favg', 'MolarFracs_frms', + 'MassFracs_favg', + 'MassFracs_frms', 'velocity_favg', 'velocity_frms', 'velocity_frey', @@ -161,21 +188,60 @@ local AveragesVars = terralib.newlist({ 'Pr', 'Pr_rms', 'Ec', - 'Ec_rms' + 'Ec_rms', + 'Ma', + 'Sc', + -- Correlations + 'uT_avg', + 'uT_favg', + 'uYi_avg', + 'vYi_avg', + 'wYi_avg', + 'uYi_favg', + 'vYi_favg', + 'wYi_favg' }) -Exports.HDF = (require 'hdf_helper')(int2d, int2d, Exports.Averages_columns, - AveragesVars, - {}, - {SpeciesNames=nSpec}) +local HDF = (require 'hdf_helper')(int2d, int2d, Averages_columns, + AveragesVars, + {}, + {SpeciesNames={nSpec,20}}) + +Exports.AvgList = { + XAverages = regentlib.newsymbol(), + YAverages = regentlib.newsymbol(), + ZAverages = regentlib.newsymbol(), + XAverages_copy = regentlib.newsymbol(), + YAverages_copy = regentlib.newsymbol(), + ZAverages_copy = regentlib.newsymbol(), + is_Xrakes = regentlib.newsymbol(), + is_Yrakes = regentlib.newsymbol(), + is_Zrakes = regentlib.newsymbol(), + Xrakes = regentlib.newsymbol(), + Yrakes = regentlib.newsymbol(), + Zrakes = regentlib.newsymbol(), + Xrakes_copy = regentlib.newsymbol(), + Yrakes_copy = regentlib.newsymbol(), + Zrakes_copy = regentlib.newsymbol(), + + XAverages_local = regentlib.newsymbol(), + YAverages_local = regentlib.newsymbol(), + ZAverages_local = regentlib.newsymbol(), + is_Xrakes_local = regentlib.newsymbol(), + is_Yrakes_local = regentlib.newsymbol(), + is_Zrakes_local = regentlib.newsymbol(), + p_Xrakes_local = regentlib.newsymbol(), + p_Yrakes_local = regentlib.newsymbol(), + p_Zrakes_local = regentlib.newsymbol(), +} ------------------------------------------------------------------------------- -- AVERAGES ROUTINES ------------------------------------------------------------------------------- -function Exports.mkInitializeAverages(nd) +local function mkInitializeAverages(nd) local InitializeAverages __demand(__inline) - task InitializeAverages(Averages : region(ispace(nd), Exports.Averages_columns)) + task InitializeAverages(Averages : region(ispace(nd), Averages_columns)) where writes(Averages) do @@ -187,6 +253,8 @@ function Exports.mkInitializeAverages(nd) fill(Averages.temperature_rms, 0.0) fill(Averages.MolarFracs_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.MolarFracs_rms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.MassFracs_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.MassFracs_rms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.velocity_avg, array(0.0, 0.0, 0.0)) fill(Averages.velocity_rms, array(0.0, 0.0, 0.0)) fill(Averages.velocity_rey, array(0.0, 0.0, 0.0)) @@ -194,30 +262,35 @@ function Exports.mkInitializeAverages(nd) fill(Averages.rho_avg, 0.0) fill(Averages.rho_rms, 0.0) fill(Averages.mu_avg, 0.0) - fill(Averages.mu_rms, 0.0) fill(Averages.lam_avg, 0.0) - fill(Averages.lam_rms, 0.0) fill(Averages.Di_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) - fill(Averages.Di_rms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) - fill(Averages.SoS_avg, 0.0) - fill(Averages.SoS_rms, 0.0) - fill(Averages.cp_avg, 0.0) - fill(Averages.cp_rms, 0.0) - fill(Averages.MixW_avg, 0.0) - fill(Averages.MixW_rms, 0.0) + fill(Averages.SoS_avg, 0.0) + fill(Averages.cp_avg, 0.0) + fill(Averages.Ent_avg, 0.0) -- Chemical production rates fill(Averages.ProductionRates_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.ProductionRates_rms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.HeatReleaseRate_avg, 0.0) fill(Averages.HeatReleaseRate_rms, 0.0) - -- Favre averages + -- Favre averaged primitives + fill(Averages.pressure_favg, 0.0) + fill(Averages.pressure_frms, 0.0) fill(Averages.temperature_favg, 0.0) fill(Averages.temperature_frms, 0.0) fill(Averages.MolarFracs_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.MolarFracs_frms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.MassFracs_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.MassFracs_frms, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) fill(Averages.velocity_favg, array(0.0, 0.0, 0.0)) fill(Averages.velocity_frms, array(0.0, 0.0, 0.0)) fill(Averages.velocity_frey, array(0.0, 0.0, 0.0)) + -- Favre averaged properties + fill(Averages.mu_favg, 0.0) + fill(Averages.lam_favg, 0.0) + fill(Averages.Di_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.SoS_favg, 0.0) + fill(Averages.cp_favg, 0.0) + fill(Averages.Ent_favg, 0.0) -- Kinetic energy budgets (y is the inhomogeneous direction) fill(Averages.rhoUUv, array(0.0, 0.0, 0.0)) fill(Averages.Up, array(0.0, 0.0, 0.0)) @@ -232,16 +305,26 @@ function Exports.mkInitializeAverages(nd) fill(Averages.Pr_rms, 0.0) fill(Averages.Ec, 0.0) fill(Averages.Ec_rms, 0.0) - + fill(Averages.Ma, 0.0) + fill(Averages.Sc, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + -- Correlations + fill(Averages.uT_avg, array(0.0, 0.0, 0.0)) + fill(Averages.uT_favg, array(0.0, 0.0, 0.0)) + fill(Averages.uYi_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.vYi_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.wYi_avg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.uYi_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.vYi_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Averages.wYi_favg, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) end return InitializeAverages end -function Exports.mkAddAverages(dir) +local function mkAddAverages(dir) local AddAverages __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED task AddAverages(Fluid : region(ispace(int3d), Fluid_columns), - Averages : region(ispace(int4d), Exports.Averages_columns), + Averages : region(ispace(int4d), Averages_columns), mix : MIX.Mixture, rake : SCHEMA.Volume, Integrator_deltaTime : double) @@ -263,6 +346,7 @@ function Exports.mkAddAverages(dir) var c_avg = int4d{c.[dir], Averages.bounds.lo.y, Averages.bounds.lo.z, Averages.bounds.lo.w} var weight = Fluid[c].cellWidth[0]*Fluid[c].cellWidth[1]*Fluid[c].cellWidth[2]*Integrator_deltaTime + var rhoWeight = weight*Fluid[c].rho Averages[c_avg].weight += weight @@ -279,16 +363,18 @@ function Exports.mkAddAverages(dir) Fluid[c].velocity[0]*Fluid[c].velocity[2]*weight, Fluid[c].velocity[1]*Fluid[c].velocity[2]*weight) - -- Favre averages - Averages[c_avg].temperature_favg += weight*Fluid[c].rho*Fluid[c].temperature - Averages[c_avg].temperature_frms += weight*Fluid[c].rho*Fluid[c].temperature*Fluid[c].temperature - Averages[c_avg].MolarFracs_favg += [UTIL.mkArrayConstant(nSpec, rexpr weight*Fluid[c].rho end)]*Fluid[c].MolarFracs - Averages[c_avg].MolarFracs_frms += [UTIL.mkArrayConstant(nSpec, rexpr weight*Fluid[c].rho end)]*Fluid[c].MolarFracs*Fluid[c].MolarFracs - Averages[c_avg].velocity_favg += [UTIL.mkArrayConstant(3, rexpr weight*Fluid[c].rho end)]*Fluid[c].velocity - Averages[c_avg].velocity_frms += [UTIL.mkArrayConstant(3, rexpr weight*Fluid[c].rho end)]*Fluid[c].velocity*Fluid[c].velocity - Averages[c_avg].velocity_frey += array(Fluid[c].rho*Fluid[c].velocity[0]*Fluid[c].velocity[1]*weight, - Fluid[c].rho*Fluid[c].velocity[0]*Fluid[c].velocity[2]*weight, - Fluid[c].rho*Fluid[c].velocity[1]*Fluid[c].velocity[2]*weight) + -- Favre averaged primitives + Averages[c_avg].pressure_favg += rhoWeight*Fluid[c].pressure + Averages[c_avg].pressure_frms += rhoWeight*Fluid[c].pressure*Fluid[c].pressure + Averages[c_avg].temperature_favg += rhoWeight*Fluid[c].temperature + Averages[c_avg].temperature_frms += rhoWeight*Fluid[c].temperature*Fluid[c].temperature + Averages[c_avg].MolarFracs_favg += [UTIL.mkArrayConstant(nSpec, rhoWeight)]*Fluid[c].MolarFracs + Averages[c_avg].MolarFracs_frms += [UTIL.mkArrayConstant(nSpec, rhoWeight)]*Fluid[c].MolarFracs*Fluid[c].MolarFracs + Averages[c_avg].velocity_favg += [UTIL.mkArrayConstant(3, rhoWeight)]*Fluid[c].velocity + Averages[c_avg].velocity_frms += [UTIL.mkArrayConstant(3, rhoWeight)]*Fluid[c].velocity*Fluid[c].velocity + Averages[c_avg].velocity_frey += array(Fluid[c].velocity[0]*Fluid[c].velocity[1]*rhoWeight, + Fluid[c].velocity[0]*Fluid[c].velocity[2]*rhoWeight, + Fluid[c].velocity[1]*Fluid[c].velocity[2]*rhoWeight) -- Kinetic energy budgets (y is the inhomogeneous direction) var tau_xx = Fluid[c].mu*(4.0*Fluid[c].velocityGradientX[0] - 2.0*Fluid[c].velocityGradientY[1] - 2.0*Fluid[c].velocityGradientZ[2])/3.0 @@ -331,31 +417,48 @@ function Exports.mkAddAverages(dir) var c_avg = int4d{c.[dir], Averages.bounds.lo.y, Averages.bounds.lo.z, Averages.bounds.lo.w} var weight = Fluid[c].cellWidth[0]*Fluid[c].cellWidth[1]*Fluid[c].cellWidth[2]*Integrator_deltaTime + var rhoWeight = weight*Fluid[c].rho -- Properties var MixW = MIX.GetMolarWeightFromXi(Fluid[c].MolarFracs, mix) var Yi = MIX.GetMassFractions(MixW, Fluid[c].MolarFracs, mix) var cp = MIX.GetHeatCapacity(Fluid[c].temperature, Yi, mix) + var hi : double[nSpec] + var Ent = 0.0 + for i=0, nSpec do + hi[i] = MIX.GetSpeciesEnthalpy(i, Fluid[c].temperature, mix) + Ent += Yi[i]*hi[i] + end Averages[c_avg].rho_avg += weight*Fluid[c].rho Averages[c_avg].rho_rms += weight*Fluid[c].rho*Fluid[c].rho Averages[c_avg].mu_avg += weight*Fluid[c].mu - Averages[c_avg].mu_rms += weight*Fluid[c].mu*Fluid[c].mu Averages[c_avg].lam_avg += weight*Fluid[c].lam - Averages[c_avg].lam_rms += weight*Fluid[c].lam*Fluid[c].lam Averages[c_avg].Di_avg += [UTIL.mkArrayConstant(nSpec, weight)]*Fluid[c].Di - Averages[c_avg].Di_rms += [UTIL.mkArrayConstant(nSpec, weight)]*Fluid[c].Di*Fluid[c].Di Averages[c_avg].SoS_avg += weight*Fluid[c].SoS - Averages[c_avg].SoS_rms += weight*Fluid[c].SoS*Fluid[c].SoS - Averages[c_avg].cp_avg += weight*cp - Averages[c_avg].cp_rms += weight*cp*cp - Averages[c_avg].MixW_avg += weight*MixW - Averages[c_avg].MixW_rms += weight*MixW*MixW + Averages[c_avg].cp_avg += weight*cp + Averages[c_avg].Ent_avg += weight*Ent + + -- Mass fractions + Averages[c_avg].MassFracs_avg += [UTIL.mkArrayConstant(nSpec, weight)]*Yi + Averages[c_avg].MassFracs_rms += [UTIL.mkArrayConstant(nSpec, weight)]*Yi*Yi + + -- Favre averaged properties + Averages[c_avg].mu_favg += rhoWeight*Fluid[c].mu + Averages[c_avg].lam_favg += rhoWeight*Fluid[c].lam + Averages[c_avg].Di_favg += [UTIL.mkArrayConstant(nSpec, rhoWeight)]*Fluid[c].Di + Averages[c_avg].SoS_favg += rhoWeight*Fluid[c].SoS + Averages[c_avg].cp_favg += rhoWeight*cp + Averages[c_avg].Ent_favg += rhoWeight*Ent + + -- Favre averaged mass fractions + Averages[c_avg].MassFracs_favg += [UTIL.mkArrayConstant(nSpec, rhoWeight)]*Yi + Averages[c_avg].MassFracs_frms += [UTIL.mkArrayConstant(nSpec, rhoWeight)]*Yi*Yi -- Chemical production rates var w = MIX.GetProductionRates(Fluid[c].rho, Fluid[c].pressure, Fluid[c].temperature, Yi, mix) var HR = 0.0 for i=0, nSpec do - HR -= w[i]*MIX.GetSpeciesEnthalpy(i, Fluid[c].temperature, mix) + HR -= w[i]*hi[i] end Averages[c_avg].ProductionRates_avg += [UTIL.mkArrayConstant(nSpec, weight)]*w Averages[c_avg].ProductionRates_rms += [UTIL.mkArrayConstant(nSpec, weight)]*w*w @@ -364,13 +467,41 @@ function Exports.mkAddAverages(dir) -- Dimensionless numbers var u2 = MACRO.dot(Fluid[c].velocity, Fluid[c].velocity) - var Hi = MIX.GetEnthalpy(Fluid[c].temperature, Yi, mix) + 0.5*u2 var Pr = cp*Fluid[c].mu/Fluid[c].lam - var Ec = u2/Hi + var Ec = u2/(cp*Fluid[c].temperature) + var nu = Fluid[c].mu/Fluid[c].rho + var Sc : double[nSpec] + for i=0, nSpec do + Sc[i] = nu/Fluid[c].Di[i] + end Averages[c_avg].Pr += weight*Pr Averages[c_avg].Pr_rms += weight*Pr*Pr Averages[c_avg].Ec += weight*Ec Averages[c_avg].Ec_rms += weight*Ec*Ec + Averages[c_avg].Ma += weight*sqrt(u2)/Fluid[c].SoS + Averages[c_avg].Sc += [UTIL.mkArrayConstant(nSpec, weight)]*Sc + + -- Correlations + var weightU = weight*Fluid[c].velocity[0] + var weightV = weight*Fluid[c].velocity[1] + var weightW = weight*Fluid[c].velocity[2] + var weightRhoU = weight*Fluid[c].velocity[0]*Fluid[c].rho + var weightRhoV = weight*Fluid[c].velocity[1]*Fluid[c].rho + var weightRhoW = weight*Fluid[c].velocity[2]*Fluid[c].rho + + Averages[c_avg].uT_avg += array( weightU*Fluid[c].temperature, + weightV*Fluid[c].temperature, + weightW*Fluid[c].temperature) + Averages[c_avg].uT_favg += array(weightRhoU*Fluid[c].temperature, + weightRhoV*Fluid[c].temperature, + weightRhoW*Fluid[c].temperature) + + Averages[c_avg].uYi_avg += [UTIL.mkArrayConstant(nSpec, weightU)]*Yi + Averages[c_avg].vYi_avg += [UTIL.mkArrayConstant(nSpec, weightV)]*Yi + Averages[c_avg].wYi_avg += [UTIL.mkArrayConstant(nSpec, weightW)]*Yi + Averages[c_avg].uYi_favg += [UTIL.mkArrayConstant(nSpec, weightRhoU)]*Yi + Averages[c_avg].vYi_favg += [UTIL.mkArrayConstant(nSpec, weightRhoV)]*Yi + Averages[c_avg].wYi_favg += [UTIL.mkArrayConstant(nSpec, weightRhoW)]*Yi end end @@ -378,8 +509,8 @@ function Exports.mkAddAverages(dir) return AddAverages end -__demand(__leaf) -task Exports.DummyAverages(Averages : region(ispace(int2d), Exports.Averages_columns)) +local __demand(__leaf) +task DummyAverages(Averages : region(ispace(int2d), Averages_columns)) where reads writes(Averages) do @@ -387,7 +518,7 @@ do -- It is just to avoid the bug of HDF libraries with parallel reduction end -function Exports.mkReduceAverages(dir) +local function mkReduceAverages(dir) local dir1 local dir2 if dir=='x' then @@ -402,8 +533,8 @@ function Exports.mkReduceAverages(dir) end local ReduceAverages __demand(__leaf) - task ReduceAverages(Averages : region(ispace(int2d), Exports.Averages_columns), - Averages_local : region(ispace(int4d), Exports.Averages_columns), + task ReduceAverages(Averages : region(ispace(int2d), Averages_columns), + Averages_local : region(ispace(int4d), Averages_columns), tiles : ispace(int3d)) where reads(Averages_local), @@ -423,6 +554,8 @@ function Exports.mkReduceAverages(dir) Averages[c].temperature_rms += Averages_local[c_buf].temperature_rms Averages[c].MolarFracs_avg += Averages_local[c_buf].MolarFracs_avg Averages[c].MolarFracs_rms += Averages_local[c_buf].MolarFracs_rms + Averages[c].MassFracs_avg += Averages_local[c_buf].MassFracs_avg + Averages[c].MassFracs_rms += Averages_local[c_buf].MassFracs_rms Averages[c].velocity_avg += Averages_local[c_buf].velocity_avg Averages[c].velocity_rms += Averages_local[c_buf].velocity_rms Averages[c].velocity_rey += Averages_local[c_buf].velocity_rey @@ -431,17 +564,11 @@ function Exports.mkReduceAverages(dir) Averages[c].rho_avg += Averages_local[c_buf].rho_avg Averages[c].rho_rms += Averages_local[c_buf].rho_rms Averages[c].mu_avg += Averages_local[c_buf].mu_avg - Averages[c].mu_rms += Averages_local[c_buf].mu_rms Averages[c].lam_avg += Averages_local[c_buf].lam_avg - Averages[c].lam_rms += Averages_local[c_buf].lam_rms Averages[c].Di_avg += Averages_local[c_buf].Di_avg - Averages[c].Di_rms += Averages_local[c_buf].Di_rms Averages[c].SoS_avg += Averages_local[c_buf].SoS_avg - Averages[c].SoS_rms += Averages_local[c_buf].SoS_rms Averages[c].cp_avg += Averages_local[c_buf].cp_avg - Averages[c].cp_rms += Averages_local[c_buf].cp_rms - Averages[c].MixW_avg += Averages_local[c_buf].MixW_avg - Averages[c].MixW_rms += Averages_local[c_buf].MixW_rms + Averages[c].Ent_avg += Averages_local[c_buf].Ent_avg -- Chemical production rates Averages[c].ProductionRates_avg += Averages_local[c_buf].ProductionRates_avg @@ -449,15 +576,27 @@ function Exports.mkReduceAverages(dir) Averages[c].HeatReleaseRate_avg += Averages_local[c_buf].HeatReleaseRate_avg Averages[c].HeatReleaseRate_rms += Averages_local[c_buf].HeatReleaseRate_rms - -- Favre averages + -- Favre averaged primitives + Averages[c].pressure_favg += Averages_local[c_buf].pressure_favg + Averages[c].pressure_frms += Averages_local[c_buf].pressure_frms Averages[c].temperature_favg += Averages_local[c_buf].temperature_favg Averages[c].temperature_frms += Averages_local[c_buf].temperature_frms Averages[c].MolarFracs_favg += Averages_local[c_buf].MolarFracs_favg Averages[c].MolarFracs_frms += Averages_local[c_buf].MolarFracs_frms + Averages[c].MassFracs_favg += Averages_local[c_buf].MassFracs_favg + Averages[c].MassFracs_frms += Averages_local[c_buf].MassFracs_frms Averages[c].velocity_favg += Averages_local[c_buf].velocity_favg Averages[c].velocity_frms += Averages_local[c_buf].velocity_frms Averages[c].velocity_frey += Averages_local[c_buf].velocity_frey + -- Favre averaged properties + Averages[c].mu_favg += Averages_local[c_buf].mu_favg + Averages[c].lam_favg += Averages_local[c_buf].lam_favg + Averages[c].Di_favg += Averages_local[c_buf].Di_favg + Averages[c].SoS_favg += Averages_local[c_buf].SoS_favg + Averages[c].cp_favg += Averages_local[c_buf].cp_favg + Averages[c].Ent_favg += Averages_local[c_buf].Ent_favg + -- Kinetic energy budgets (y is the inhomogeneous direction) Averages[c].rhoUUv += Averages_local[c_buf].rhoUUv Averages[c].Up += Averages_local[c_buf].Up @@ -474,11 +613,231 @@ function Exports.mkReduceAverages(dir) Averages[c].Pr_rms += Averages_local[c_buf].Pr_rms Averages[c].Ec += Averages_local[c_buf].Ec Averages[c].Ec_rms += Averages_local[c_buf].Ec_rms + Averages[c].Ma += Averages_local[c_buf].Ma + Averages[c].Sc += Averages_local[c_buf].Sc + + -- Correlations + Averages[c].uT_avg += Averages_local[c_buf].uT_avg + Averages[c].uYi_avg += Averages_local[c_buf].uYi_avg + Averages[c].vYi_avg += Averages_local[c_buf].vYi_avg + Averages[c].wYi_avg += Averages_local[c_buf].wYi_avg + + Averages[c].uT_favg += Averages_local[c_buf].uT_favg + Averages[c].uYi_favg += Averages_local[c_buf].uYi_favg + Averages[c].vYi_favg += Averages_local[c_buf].vYi_favg + Averages[c].wYi_favg += Averages_local[c_buf].wYi_favg + end end end return ReduceAverages end +------------------------------------------------------------------------------- +-- EXPORTED ROUTINES +------------------------------------------------------------------------------- +function Exports.DeclSymbols(s, Grid, config, MAPPER) + return rquote + + var sampleId = config.Mapping.sampleId + + -- Create averages regions + var is_XAverages = ispace(int2d, {x = config.Grid.xNum + 2*Grid.xBnum, + y = config.IO.YZAverages.length }) + + var is_YAverages = ispace(int2d, {x = config.Grid.yNum + 2*Grid.yBnum, + y = config.IO.XZAverages.length }) + + var is_ZAverages = ispace(int2d, {x = config.Grid.zNum + 2*Grid.zBnum, + y = config.IO.XYAverages.length }) + + var [s.XAverages] = region(is_XAverages, Averages_columns) + var [s.YAverages] = region(is_YAverages, Averages_columns) + var [s.ZAverages] = region(is_ZAverages, Averages_columns) + var [s.XAverages_copy] = region(is_XAverages, Averages_columns) + var [s.YAverages_copy] = region(is_YAverages, Averages_columns) + var [s.ZAverages_copy] = region(is_ZAverages, Averages_columns); + + [UTIL.emitRegionTagAttach(s.XAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.YAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.ZAverages, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.XAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.YAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.ZAverages_copy, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + + -- Partitioning averages in rakes + var [s.is_Xrakes] = ispace(int2d, {1, max(config.IO.YZAverages.length, 1)}) + var [s.is_Yrakes] = ispace(int2d, {1, max(config.IO.XZAverages.length, 1)}) + var [s.is_Zrakes] = ispace(int2d, {1, max(config.IO.XYAverages.length, 1)}) + + var [s.Xrakes] = partition(equal, s.XAverages, s.is_Xrakes) + var [s.Yrakes] = partition(equal, s.YAverages, s.is_Yrakes) + var [s.Zrakes] = partition(equal, s.ZAverages, s.is_Zrakes) + + var [s.Xrakes_copy] = partition(equal, s.XAverages_copy, s.is_Xrakes) + var [s.Yrakes_copy] = partition(equal, s.YAverages_copy, s.is_Yrakes) + var [s.Zrakes_copy] = partition(equal, s.ZAverages_copy, s.is_Zrakes) + +-- -- TODO: in the future we might want to partition these also along the rakes +-- var is_XrakesTiles = ispace(int2d, {Grid.NX, config.IO.YZAverages.length}) +-- var is_YrakesTiles = ispace(int2d, {Grid.NY, config.IO.XZAverages.length}) +-- var is_ZrakesTiles = ispace(int2d, {Grid.NZ, config.IO.XYAverages.length}); +-- +-- var [s.p_Xrakes] = [UTIL.mkPartitionByTile(int2d, int2d, Averages_columns)] +-- (s.Xrakes, is_XrakesTiles, int2d{Grid.xBnum,0}, int2d{0,0}) +-- var [s.p_Yrakes] = [UTIL.mkPartitionByTile(int2d, int2d, Averages_columns)] +-- (s.Yrakes, is_YrakesTiles, int2d{Grid.yBnum,0}, int2d{0,0}) +-- var [s.p_Zrakes] = [UTIL.mkPartitionByTile(int2d, int2d, Averages_columns)] +-- (s.Zrakes, is_ZrakesTiles, int2d{Grid.zBnum,0}, int2d{0,0}) + + -- Create local buffers for averages regions + var is_XAverages_local = ispace(int4d, {x = config.Grid.xNum + 2*Grid.xBnum, + y = config.IO.YZAverages.length , + z = Grid.NY , + w = Grid.NZ }) + + var is_YAverages_local = ispace(int4d, {x = config.Grid.yNum + 2*Grid.yBnum, + y = config.IO.XZAverages.length , + z = Grid.NX , + w = Grid.NZ }) + + var is_ZAverages_local = ispace(int4d, {x = config.Grid.zNum + 2*Grid.zBnum, + y = config.IO.XYAverages.length , + z = Grid.NX , + w = Grid.NY }) + + var [s.XAverages_local] = region(is_XAverages_local, Averages_columns) + var [s.YAverages_local] = region(is_YAverages_local, Averages_columns) + var [s.ZAverages_local] = region(is_ZAverages_local, Averages_columns); + + [UTIL.emitRegionTagAttach(s.XAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.YAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + [UTIL.emitRegionTagAttach(s.ZAverages_local, MAPPER.SAMPLE_ID_TAG, sampleId, int)]; + + -- Partitioning local buffer in rakes + var [s.is_Xrakes_local] = ispace(int4d, {Grid.NX, max(config.IO.YZAverages.length, 1), Grid.NY, Grid.NZ}) + var [s.is_Yrakes_local] = ispace(int4d, {Grid.NY, max(config.IO.XZAverages.length, 1), Grid.NX, Grid.NZ}) + var [s.is_Zrakes_local] = ispace(int4d, {Grid.NZ, max(config.IO.XYAverages.length, 1), Grid.NX, Grid.NY}) + + var [s.p_Xrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, Averages_columns, "p_Xrakes_local")] + (s.XAverages_local, s.is_Xrakes_local, int4d{Grid.xBnum,0,0,0}, int4d{0,0,0,0}) + var [s.p_Yrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, Averages_columns, "p_Yrakes_local")] + (s.YAverages_local, s.is_Yrakes_local, int4d{Grid.yBnum,0,0,0}, int4d{0,0,0,0}) + var [s.p_Zrakes_local] = [UTIL.mkPartitionByTile(int4d, int4d, Averages_columns, "p_Zrakes_local")] + (s.ZAverages_local, s.is_Zrakes_local, int4d{Grid.zBnum,0,0,0}, int4d{0,0,0,0}) + + end +end + +function Exports.InitRakes(s) + return rquote + [mkInitializeAverages(int2d)](s.XAverages); + [mkInitializeAverages(int2d)](s.YAverages); + [mkInitializeAverages(int2d)](s.ZAverages); + end +end + +function Exports.InitBuffers(s) + return rquote + [mkInitializeAverages(int4d)](s.XAverages_local); + [mkInitializeAverages(int4d)](s.YAverages_local); + [mkInitializeAverages(int4d)](s.ZAverages_local); + end +end + +function Exports.ReadAverages(s, config) + return rquote + if not config.IO.ResetAverages then + var dirname = [&int8](C.malloc(256)) + if config.IO.YZAverages.length ~= 0 then + C.snprintf(dirname, 256, '%s/YZAverages', config.Flow.restartDir) + HDF.load(0, s.is_Xrakes, dirname, s.XAverages, s.XAverages_copy, s.Xrakes, s.Xrakes_copy) + end + if config.IO.XZAverages.length ~= 0 then + C.snprintf(dirname, 256, '%s/XZAverages', config.Flow.restartDir) + HDF.load(0, s.is_Yrakes, dirname, s.YAverages, s.YAverages_copy, s.Yrakes, s.Yrakes_copy) + end + if config.IO.XYAverages.length ~= 0 then + C.snprintf(dirname, 256, '%s/XYAverages', config.Flow.restartDir) + HDF.load(0, s.is_Zrakes, dirname, s.ZAverages, s.ZAverages_copy, s.Zrakes, s.Zrakes_copy) + end + C.free(dirname) + end + end +end + +function Exports.AddAverages(s, tiles, p_All, deltaTime, config, Mix) + return rquote + for rake=0, config.IO.YZAverages.length do + __demand(__index_launch) + for c in tiles do + [mkAddAverages('x')](p_All[c], s.p_Xrakes_local[int4d{c.x,rake,c.y,c.z}], Mix, + config.IO.YZAverages.values[rake], deltaTime) + end + end + for rake=0, config.IO.XZAverages.length do + __demand(__index_launch) + for c in tiles do + [mkAddAverages('y')](p_All[c], s.p_Yrakes_local[int4d{c.y,rake,c.x,c.z}], Mix, + config.IO.XZAverages.values[rake], deltaTime) + end + end + for rake=0, config.IO.XYAverages.length do + __demand(__index_launch) + for c in tiles do + [mkAddAverages('z')](p_All[c], s.p_Zrakes_local[int4d{c.z,rake,c.x,c.y}], Mix, + config.IO.XYAverages.values[rake], deltaTime) + end + end + end +end + +function Exports.WriteAverages(s, tiles, dirname, IO, SpeciesNames, config) + return rquote + if config.IO.YZAverages.length ~= 0 then +-- DummyAverages(s.XAverages) + -- Reduce from reduction buffers + [mkReduceAverages('x')](s.XAverages, s.XAverages_local, tiles); + -- Reinitialize reduction buffers + [mkInitializeAverages(int4d)](s.XAverages_local) + + var Avgdirname = [&int8](C.malloc(256)) + C.snprintf(Avgdirname, 256, '%s/YZAverages', dirname) + var _1 = IO.createDir(Avgdirname) + _1 = HDF.dump( _1, s.is_Xrakes, Avgdirname, s.XAverages, s.XAverages_copy, s.Xrakes, s.Xrakes_copy) + _1 = HDF.write.SpeciesNames( _1, s.is_Xrakes, Avgdirname, s.XAverages, s.Xrakes, SpeciesNames) + C.free(Avgdirname) + end + if config.IO.XZAverages.length ~= 0 then +-- DummyAverages(s.YAverages) + -- Reduce from reduction buffers + [mkReduceAverages('y')](s.YAverages, s.YAverages_local, tiles); + -- Reinitialize reduction buffers + [mkInitializeAverages(int4d)](s.YAverages_local) + + var Avgdirname = [&int8](C.malloc(256)) + C.snprintf(Avgdirname, 256, '%s/XZAverages', dirname) + var _1 = IO.createDir(Avgdirname) + _1 = HDF.dump( _1, s.is_Yrakes, Avgdirname, s.YAverages, s.YAverages_copy, s.Yrakes, s.Yrakes_copy) + _1 = HDF.write.SpeciesNames( _1, s.is_Yrakes, Avgdirname, s.YAverages, s.Yrakes, SpeciesNames) + C.free(Avgdirname) + end + if config.IO.XYAverages.length ~= 0 then +-- DummyAverages(s.ZAverages) + -- Reduce from reduction buffers + [mkReduceAverages('z')](s.ZAverages, s.ZAverages_local, tiles); + -- Reinitialize reduction buffers + [mkInitializeAverages(int4d)](s.ZAverages_local) + + var Avgdirname = [&int8](C.malloc(256)) + C.snprintf(Avgdirname, 256, '%s/XYAverages', dirname) + var _1 = IO.createDir(Avgdirname) + _1 = HDF.dump( _1, s.is_Zrakes, Avgdirname, s.ZAverages, s.ZAverages_copy, s.Zrakes, s.Zrakes_copy) + _1 = HDF.write.SpeciesNames( _1, s.is_Zrakes, Avgdirname, s.ZAverages, s.Zrakes, SpeciesNames) + C.free(Avgdirname) + end + end +end + return Exports end diff --git a/src/prometeo_bc.rg b/src/prometeo_bc.rg index d8055ea..7e8e82a 100644 --- a/src/prometeo_bc.rg +++ b/src/prometeo_bc.rg @@ -52,6 +52,127 @@ local nEq = CONST.GetnEq(MIX) -- Total number of unknowns for the implicit solve local Primitives = CONST.Primitives local ProfilesVars = CONST.ProfilesVars +------------------------------------------------------------------------------- +-- CHECK FUNCTIONS +------------------------------------------------------------------------------- +function Exports.CheckNSCBC_Inflow(BC, NSCBC_Inflow) + return rquote + -- Check velocity profile + if NSCBC_Inflow.VelocityProfile.type == SCHEMA.InflowProfile_Constant then + -- Do nothing + elseif NSCBC_Inflow.VelocityProfile.type == SCHEMA.InflowProfile_File then + BC.readProfiles = true + BC.ProfilesDir = NSCBC_Inflow.VelocityProfile.u.File.FileDir + elseif NSCBC_Inflow.VelocityProfile.type == SCHEMA.InflowProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming InflowProfile not supported') + else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end + + -- Check temperature profile + if NSCBC_Inflow.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + -- Do nothing + elseif NSCBC_Inflow.TemperatureProfile.type == SCHEMA.TempProfile_File then + if (BC.readProfiles) then + regentlib.assert(C.strcmp(BC.ProfilesDir, NSCBC_Inflow.TemperatureProfile.u.File.FileDir) == 0, 'Only one file is allowed for profiles') + else + BC.readProfiles = true + BC.ProfilesDir = NSCBC_Inflow.TemperatureProfile.u.File.FileDir + end + elseif NSCBC_Inflow.TemperatureProfile.type == SCHEMA.TempProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming heat model not supported') + else regentlib.assert(false, 'Unhandled case in TempProfile switch') end + + -- Check mixture profile + if NSCBC_Inflow.MixtureProfile.type == SCHEMA.MixtureProfile_Constant then + -- Do nothing + elseif NSCBC_Inflow.MixtureProfile.type == SCHEMA.MixtureProfile_File then + if (BC.readProfiles) then + regentlib.assert(C.strcmp(BC.ProfilesDir, NSCBC_Inflow.MixtureProfile.u.File.FileDir) == 0, 'Only one file is allowed for profiles') + else + BC.readProfiles = true + BC.ProfilesDir = NSCBC_Inflow.MixtureProfile.u.File.FileDir + end + elseif NSCBC_Inflow.MixtureProfile.type == SCHEMA.MixtureProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming mixture model not supported') + + else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end + end +end + +function Exports.CheckDirichlet(BC, Dirichlet) + return rquote + -- Check velocity profile + if Dirichlet.VelocityProfile.type == SCHEMA.InflowProfile_Constant then + -- Do nothing + elseif Dirichlet.VelocityProfile.type == SCHEMA.InflowProfile_File then + BC.readProfiles = true + BC.ProfilesDir = Dirichlet.VelocityProfile.u.File.FileDir + elseif Dirichlet.VelocityProfile.type == SCHEMA.InflowProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming InflowProfile not supported') + else regentlib.assert(false, 'Unhandled case in InflowProfile switch') end + + -- Check temperature profile + if Dirichlet.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + -- Do nothing + elseif Dirichlet.TemperatureProfile.type == SCHEMA.TempProfile_File then + if (BC.readProfiles) then + regentlib.assert(C.strcmp(BC.ProfilesDir, Dirichlet.TemperatureProfile.u.File.FileDir) == 0, 'Only one file is allowed for profiles') + else + BC.readProfiles = true + BC.ProfilesDir = Dirichlet.TemperatureProfile.u.File.FileDir + end + elseif Dirichlet.TemperatureProfile.type == SCHEMA.TempProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming heat model not supported') + else regentlib.assert(false, 'Unhandled case in TempProfile switch') end + + -- Check mixture profile + if Dirichlet.MixtureProfile.type == SCHEMA.MixtureProfile_Constant then + -- Do nothing + elseif Dirichlet.MixtureProfile.type == SCHEMA.MixtureProfile_File then + if (BC.readProfiles) then + regentlib.assert(C.strcmp(BC.ProfilesDir, Dirichlet.MixtureProfile.u.File.FileDir) == 0, 'Only one file is allowed for profiles') + else + BC.readProfiles = true + BC.ProfilesDir = Dirichlet.MixtureProfile.u.File.FileDir + end + elseif Dirichlet.MixtureProfile.type == SCHEMA.MixtureProfile_Incoming then + -- Do nothing + regentlib.assert(false, 'Incoming mixture model not supported') + + else regentlib.assert(false, 'Unhandled case in MixtureProfile switch') end + end +end + +function Exports.CheckIsothermalWall(IsothermalWall) + return rquote + if IsothermalWall.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + -- Do nothing + else + regentlib.assert(false, 'Only constant heat model supported') + end + end +end + +function Exports.CheckSuctionAndBlowingWall(SuctionAndBlowingWall) + return rquote + regentlib.assert(SuctionAndBlowingWall.A.length == SuctionAndBlowingWall.omega.length, + "Equal number of amplitudes and frequencies must be specified") + + regentlib.assert(SuctionAndBlowingWall.A.length == SuctionAndBlowingWall.beta.length, + "Equal number of amplitudes and spanwise wave numbers must be specified") + + if SuctionAndBlowingWall.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + -- Do nothing + else + regentlib.assert(false, 'Only constant heat model supported') + end + end +end + ------------------------------------------------------------------------------- -- BC ROUTINES ------------------------------------------------------------------------------- @@ -62,7 +183,7 @@ task Exports.InitializeGhostNSCBC(Fluid : region(ispace(int3d), Fluid_columns), mix : MIX.Mixture) where reads(Fluid.[Primitives]), - writes(Fluid.{velocity_old_NSCBC, temperature_old_NSCBC, dudtBoundary, dTdtBoundary}) + writes(Fluid.{velocity_old_NSCBC, temperature_old_NSCBC}) do var BC = Fluid_BC[0] @@ -70,8 +191,6 @@ do for c in BC do BC[c].velocity_old_NSCBC = BC[c].velocity BC[c].temperature_old_NSCBC = BC[c].temperature - BC[c].dudtBoundary = 0.0 - BC[c].dTdtBoundary= 0.0 end end @@ -353,12 +472,12 @@ task Exports.UpdateGhostPrimitives(Fluid : region(ispace(int3d), Fluid_columns), where reads writes(Fluid) do - var BC_xBCLeft = config.BC.xBCLeft - var BC_xBCRight = config.BC.xBCRight - var BC_yBCLeft = config.BC.yBCLeft - var BC_yBCRight = config.BC.yBCRight - var BC_zBCLeft = config.BC.zBCLeft - var BC_zBCRight = config.BC.zBCRight + var BC_xBCLeft = config.BC.xBCLeft.type + var BC_xBCRight = config.BC.xBCRight.type + var BC_yBCLeft = config.BC.yBCLeft.type + var BC_yBCRight = config.BC.yBCRight.type + var BC_zBCLeft = config.BC.zBCLeft.type + var BC_zBCRight = config.BC.zBCRight.type var {p_All, p_xNeg, p_xPos, p_yNeg, p_yPos, p_zNeg, p_zPos} = Fluid_Partitions -- Start updating BCs that are local @@ -366,12 +485,12 @@ do if (BC_xBCLeft == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_xNeg[c], config.BC.xBCLeftP) + SetDirichletBC(p_All[c], p_xNeg[c], config.BC.xBCLeft.u.Dirichlet.P) end elseif (BC_xBCLeft == SCHEMA.FlowBC_NSCBC_Inflow) then __demand(__index_launch) for c in tiles do - [mkSetNSCBC_InflowBC("x")](p_All[c], p_xNeg[c], Mix, config.BC.xBCLeftP) + [mkSetNSCBC_InflowBC("x")](p_All[c], p_xNeg[c], Mix, config.BC.xBCLeft.u.NSCBC_Inflow.P) end end @@ -379,7 +498,7 @@ do if (BC_xBCRight == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_xPos[c], config.BC.xBCRightP) + SetDirichletBC(p_All[c], p_xPos[c], config.BC.xBCRight.u.Dirichlet.P) end elseif (BC_xBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then __demand(__index_launch) @@ -392,7 +511,12 @@ do if (BC_yBCLeft == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_yNeg[c], config.BC.yBCLeftP) + SetDirichletBC(p_All[c], p_yNeg[c], config.BC.yBCLeft.u.Dirichlet.P) + end + elseif (BC_yBCLeft == SCHEMA.FlowBC_NSCBC_Outflow) then + __demand(__index_launch) + for c in tiles do + SetNSCBC_OutflowBC(p_All[c], p_yNeg[c], Mix) end end @@ -400,7 +524,7 @@ do if (BC_yBCRight == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_yPos[c], config.BC.yBCRightP) + SetDirichletBC(p_All[c], p_yPos[c], config.BC.yBCRight.u.Dirichlet.P) end elseif (BC_yBCRight == SCHEMA.FlowBC_NSCBC_Outflow) then __demand(__index_launch) @@ -413,7 +537,7 @@ do if (BC_zBCLeft == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_zNeg[c], config.BC.zBCLeftP) + SetDirichletBC(p_All[c], p_zNeg[c], config.BC.zBCLeft.u.Dirichlet.P) end end @@ -421,7 +545,7 @@ do if (BC_zBCRight == SCHEMA.FlowBC_Dirichlet) then __demand(__index_launch) for c in tiles do - SetDirichletBC(p_All[c], p_zPos[c], config.BC.zBCRightP) + SetDirichletBC(p_All[c], p_zPos[c], config.BC.zBCRight.u.Dirichlet.P) end end @@ -441,15 +565,15 @@ do __demand(__index_launch) for c in tiles do [mkSetSuctionAndBlowingWallBC("yNeg")](p_All[c], p_yNeg[c], - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.Xmin, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.Xmax, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.X0, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.sigma, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.Zw, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.A.length, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.A.values, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.omega.values, - config.BC.yBCLeftInflowProfile.u.SuctionAndBlowing.beta.values, + config.BC.yBCLeft.u.SuctionAndBlowingWall.Xmin, + config.BC.yBCLeft.u.SuctionAndBlowingWall.Xmax, + config.BC.yBCLeft.u.SuctionAndBlowingWall.X0, + config.BC.yBCLeft.u.SuctionAndBlowingWall.sigma, + config.BC.yBCLeft.u.SuctionAndBlowingWall.Zw, + config.BC.yBCLeft.u.SuctionAndBlowingWall.A.length, + config.BC.yBCLeft.u.SuctionAndBlowingWall.A.values, + config.BC.yBCLeft.u.SuctionAndBlowingWall.omega.values, + config.BC.yBCLeft.u.SuctionAndBlowingWall.beta.values, config.Grid.zWidth, config.Grid.origin[2], Integrator_simTime) @@ -493,13 +617,15 @@ task Exports.UpdateNSCBCGhostCellTimeDerivatives(Fluid : region(ispace(int3d), F Integrator_deltaTime : double) where reads(Fluid.{velocity, temperature}), - writes(Fluid.{dudtBoundary, dTdtBoundary}), + reads writes(Fluid.{dudtBoundary, dTdtBoundary}), reads writes(Fluid.{velocity_old_NSCBC, temperature_old_NSCBC}) do var BC = Fluid_BC[0] __demand(__openmp) for c in BC do - BC[c].dudtBoundary = (BC[c].velocity[0] - BC[c].velocity_old_NSCBC[0]) / Integrator_deltaTime + for i=1, 3 do + BC[c].dudtBoundary[i] = (BC[c].velocity[i] - BC[c].velocity_old_NSCBC[i]) / Integrator_deltaTime + end BC[c].dTdtBoundary = (BC[c].temperature - BC[c].temperature_old_NSCBC) / Integrator_deltaTime BC[c].velocity_old_NSCBC = BC[c].velocity BC[c].temperature_old_NSCBC = BC[c].temperature diff --git a/src/prometeo_chem.rg b/src/prometeo_chem.rg index 1b1d79a..806cf17 100644 --- a/src/prometeo_chem.rg +++ b/src/prometeo_chem.rg @@ -29,7 +29,7 @@ import "regent" -return function(SCHEMA, MIX, Fluid_columns) local Exports = {} +return function(SCHEMA, MIX, Fluid_columns, ATOMIC) local Exports = {} ------------------------------------------------------------------------------- -- IMPORTS @@ -54,6 +54,15 @@ local ImplicitVars = terralib.newlist({ 'temperature' }) +-- Atomic switch +local Fluid = regentlib.newsymbol(region(ispace(int3d), Fluid_columns), "Fluid") +local coherence_mode +if ATOMIC then + coherence_mode = regentlib.coherence(regentlib.atomic, Fluid, "Conserved_t") +else + coherence_mode = regentlib.coherence(regentlib.exclusive, Fluid, "Conserved_t") +end + ------------------------------------------------------------------------------- -- CHEMISTRY ROUTINES ------------------------------------------------------------------------------- @@ -143,12 +152,13 @@ do end __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED -task Exports.AddChemistrySources(Fluid : region(ispace(int3d), Fluid_columns), +task Exports.AddChemistrySources([Fluid], ModCells : region(ispace(int3d), Fluid_columns), mix : MIX.Mixture) where reads(Fluid.{rho, MolarFracs, pressure, temperature}), - reads writes atomic(Fluid.Conserved_t) + reads writes (Fluid.Conserved_t), + [coherence_mode] do __demand(__openmp) for c in ModCells do diff --git a/src/prometeo_flux.rg b/src/prometeo_flux.rg index 4a16107..62d37eb 100644 --- a/src/prometeo_flux.rg +++ b/src/prometeo_flux.rg @@ -751,7 +751,7 @@ local function emitAddDiffusionFlux(dir, r, Flux, c, cp1, mix) sigma = array(muFace*(dUdZFace+dWdXFace), muFace*(dVdZFace+dWdYFace), - muFace*(4.0*dWdZFace-2.0*dUdXFace-2.0*dWdZFace)/3.0) + muFace*(4.0*dWdZFace-2.0*dUdXFace-2.0*dVdYFace)/3.0) end else assert(false) end diff --git a/src/prometeo_grid.rg b/src/prometeo_grid.rg index 508ee48..0958dd2 100644 --- a/src/prometeo_grid.rg +++ b/src/prometeo_grid.rg @@ -203,6 +203,27 @@ task transform_uniform_to_nonuniform(x : double, var x_non_uniform_minus1_to_plus1 = tanh(Grid_Stretching*x_scaled_minus1_to_plus1)/tanh(Grid_Stretching) -- map non-uniform sample back to origional interval x_min to x_max transformed = linear_interpolation(x_non_uniform_minus1_to_plus1, -1.0, 1.0, x_min, x_max) + elseif (Grid_Type == SCHEMA.GridType_SinhMinus) then + -- map x onto the interval 0 to 1 + var x_scaled_zero_to_plus1 = linear_interpolation(x, x_min, x_max, 0.0, 1.0) + -- map non-uniformly onto the interval 0 to 1 + var x_non_uniform_zero_to_plus1 = sinh(Grid_Stretching*x_scaled_zero_to_plus1)/sinh(Grid_Stretching) + -- map non-uniform sample back to origional interval x_min to x_max + transformed = linear_interpolation(x_non_uniform_zero_to_plus1, 0.0, 1.0, x_min, x_max) + elseif (Grid_Type == SCHEMA.GridType_SinhPlus) then + -- map x onto the interval -1 to 0 + var x_scaled_minus1_to_zero = linear_interpolation(x, x_min, x_max, -1.0, 0.0) + -- map non-uniformly onto the interval -1 to 0 + var x_non_uniform_minus1_to_zero = sinh(Grid_Stretching*x_scaled_minus1_to_zero)/sinh(Grid_Stretching) + -- map non-uniform sample back to origional interval x_min to x_max + transformed = linear_interpolation(x_non_uniform_minus1_to_zero, -1.0, 0.0, x_min, x_max) + elseif (Grid_Type == SCHEMA.GridType_Sinh) then + -- map x onto the interval -1 to 1 + var x_scaled_minus1_to_plus1 = linear_interpolation(x, x_min, x_max, -1.0, 1.0) + -- map non-uniformly onto the interval -1 to 1 + var x_non_uniform_minus1_to_plus1 = sinh(Grid_Stretching*x_scaled_minus1_to_plus1)/sinh(Grid_Stretching) + -- map non-uniform sample back to origional interval x_min to x_max + transformed = linear_interpolation(x_non_uniform_minus1_to_plus1, -1.0, 1.0, x_min, x_max) end return transformed end diff --git a/src/prometeo_init.rg b/src/prometeo_init.rg index d48d473..3244e97 100644 --- a/src/prometeo_init.rg +++ b/src/prometeo_init.rg @@ -29,7 +29,7 @@ import "regent" -return function(SCHEMA, MIX, Fluid_columns) local Exports = {} +return function(SCHEMA, MIX, CHEM, Fluid_columns) local Exports = {} -- Variable indices local nSpec = MIX.nSpec -- Number of species composing the mixture @@ -47,7 +47,6 @@ local pow = regentlib.pow(double) local CONST = require "prometeo_const" local MACRO = require "prometeo_macro" -local CHEM = (require 'prometeo_chem')(SCHEMA, MIX, Fluid_columns) local PI = CONST.PI local Primitives = CONST.Primitives diff --git a/src/prometeo_profiles.rg b/src/prometeo_profiles.rg index 6cf05aa..e3e11f2 100644 --- a/src/prometeo_profiles.rg +++ b/src/prometeo_profiles.rg @@ -66,38 +66,42 @@ function Exports.mkInitializeProfilesField(Side) where reads writes(BC.[ProfilesVars]) do - if (config.BC.[Side] == SCHEMA.FlowBC_Dirichlet) then - if config.BC.[Side .. "Mixture"].type == SCHEMA.MixtureProfile_Constant then - var BC_Mixture = CHEM.ParseConfigMixture(config.BC.[Side .. "Mixture"].u.Constant.Mixture, mix) + if (config.BC.[Side].type == SCHEMA.FlowBC_Dirichlet) then + var Dirichlet = config.BC.[Side].u.Dirichlet + if Dirichlet.MixtureProfile.type == SCHEMA.MixtureProfile_Constant then + var BC_Mixture = CHEM.ParseConfigMixture(Dirichlet.MixtureProfile.u.Constant.Mixture, mix) fill(BC.MolarFracs_profile, BC_Mixture) end - if config.BC.[Side .. "InflowProfile"].type == SCHEMA.InflowProfile_Constant then - fill(BC.velocity_profile, config.BC.[Side .. "InflowProfile"].u.Constant.velocity) + if Dirichlet.VelocityProfile.type == SCHEMA.InflowProfile_Constant then + fill(BC.velocity_profile, Dirichlet.VelocityProfile.u.Constant.velocity) end - if config.BC.[Side .. "Heat"].type == SCHEMA.TempProfile_Constant then - fill(BC.temperature_profile, config.BC.[Side .. "Heat"].u.Constant.temperature) + if Dirichlet.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + fill(BC.temperature_profile, Dirichlet.TemperatureProfile.u.Constant.temperature) end - elseif (config.BC.[Side] == SCHEMA.FlowBC_NSCBC_Inflow) then - if config.BC.[Side .. "Mixture"].type == SCHEMA.MixtureProfile_Constant then - var BC_Mixture = CHEM.ParseConfigMixture(config.BC.[Side .. "Mixture"].u.Constant.Mixture, mix) + elseif (config.BC.[Side].type == SCHEMA.FlowBC_NSCBC_Inflow) then + var NSCBC_Inflow = config.BC.[Side].u.NSCBC_Inflow + if NSCBC_Inflow.MixtureProfile.type == SCHEMA.MixtureProfile_Constant then + var BC_Mixture = CHEM.ParseConfigMixture(NSCBC_Inflow.MixtureProfile.u.Constant.Mixture, mix) fill(BC.MolarFracs_profile, BC_Mixture) end - if config.BC.[Side .. "InflowProfile"].type == SCHEMA.InflowProfile_Constant then - fill(BC.velocity_profile, config.BC.[Side .. "InflowProfile"].u.Constant.velocity) + if NSCBC_Inflow.VelocityProfile.type == SCHEMA.InflowProfile_Constant then + fill(BC.velocity_profile, NSCBC_Inflow.VelocityProfile.u.Constant.velocity) end - if config.BC.[Side .. "Heat"].type == SCHEMA.TempProfile_Constant then - fill(BC.temperature_profile, config.BC.[Side .. "Heat"].u.Constant.temperature) + if NSCBC_Inflow.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + fill(BC.temperature_profile, NSCBC_Inflow.TemperatureProfile.u.Constant.temperature) end - elseif (config.BC.[Side] == SCHEMA.FlowBC_IsothermalWall) then - if config.BC.[Side .. "Heat"].type == SCHEMA.TempProfile_Constant then - fill(BC.temperature_profile, config.BC.[Side .. "Heat"].u.Constant.temperature) + elseif (config.BC.[Side].type == SCHEMA.FlowBC_IsothermalWall) then + var IsothermalWall = config.BC.[Side].u.IsothermalWall + if IsothermalWall.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + fill(BC.temperature_profile, IsothermalWall.TemperatureProfile.u.Constant.temperature) end - elseif (config.BC.[Side] == SCHEMA.FlowBC_SuctionAndBlowingWall) then - if config.BC.[Side .. "Heat"].type == SCHEMA.TempProfile_Constant then - fill(BC.temperature_profile, config.BC.[Side .. "Heat"].u.Constant.temperature) + elseif (config.BC.[Side].type == SCHEMA.FlowBC_SuctionAndBlowingWall) then + var SuctionAndBlowingWall = config.BC.[Side].u.SuctionAndBlowingWall + if SuctionAndBlowingWall.TemperatureProfile.type == SCHEMA.TempProfile_Constant then + fill(BC.temperature_profile, SuctionAndBlowingWall.TemperatureProfile.u.Constant.temperature) end end diff --git a/src/prometeo_rhs.rg b/src/prometeo_rhs.rg index 338bc39..75e01fc 100644 --- a/src/prometeo_rhs.rg +++ b/src/prometeo_rhs.rg @@ -29,7 +29,7 @@ import "regent" -return function(SCHEMA, MIX, Fluid_columns) local Exports = {} +return function(SCHEMA, MIX, Fluid_columns, ATOMIC) local Exports = {} ------------------------------------------------------------------------------- -- IMPORTS @@ -48,6 +48,15 @@ local nEq = CONST.GetnEq(MIX) -- Total number of unknowns for the implicit solve local Primitives = CONST.Primitives local Properties = CONST.Properties +-- Atomic switch +local Fluid = regentlib.newsymbol(region(ispace(int3d), Fluid_columns), "Fluid") +local coherence_mode +if ATOMIC then + coherence_mode = regentlib.coherence(regentlib.atomic, Fluid, "Conserved_t") +else + coherence_mode = regentlib.coherence(regentlib.exclusive, Fluid, "Conserved_t") +end + ------------------------------------------------------------------------------- -- FLUX-DIVERGENCE ROUTINES ------------------------------------------------------------------------------- @@ -73,14 +82,15 @@ Exports.mkUpdateUsingFlux = terralib.memoize(function(dir) else assert(false) end local __demand(__parallel, __cuda, __leaf) - task UpdateUsingFlux(Fluid : region(ispace(int3d), Fluid_columns), + task UpdateUsingFlux([Fluid], ModCells : region(ispace(int3d), Fluid_columns), Fluid_bounds : rect3d) where ModCells <= Fluid, reads(Fluid.cellWidth), reads(Fluid.[Flux]), - reads writes atomic(Fluid.Conserved_t) + reads writes(Fluid.Conserved_t), + [coherence_mode] do __demand(__openmp) for c in ModCells do @@ -152,7 +162,7 @@ do for i=0, nSpec do LS[i] = lambda*(dY_dx[i]) end - var LN = L1 - 2*BC[c].rho*BC[c].SoS*BC[c].dudtBoundary + var LN = L1 - 2*BC[c].rho*BC[c].SoS*BC[c].dudtBoundary[0] var L2 = BC[c].dTdtBoundary/BC[c].temperature +(LN+L1)/(2.0*BC[c].rho*Cp_bnd*BC[c].temperature) @@ -181,7 +191,7 @@ function Exports.mkUpdateUsingFluxNSCBCOutflow(dir) if dir == "xPos" then __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED - task UpdateUsingFluxNSCBCOutflow(Fluid : region(ispace(int3d), Fluid_columns), + task UpdateUsingFluxNSCBCOutflow([Fluid], Fluid_BC : partition(disjoint, Fluid, ispace(int1d)), mix : MIX.Mixture, MaxMach : double, @@ -196,7 +206,8 @@ function Exports.mkUpdateUsingFluxNSCBCOutflow(dir) reads(Fluid.{MolarFracs, pressure, velocity}), reads(Fluid.{rho, mu}), reads(Fluid.{velocityGradientX, velocityGradientY, velocityGradientZ}), - reads writes atomic(Fluid.Conserved_t) + reads writes(Fluid.Conserved_t), + [coherence_mode] do var BC = Fluid_BC[0] var BCst = Fluid_BC[1] @@ -300,10 +311,135 @@ function Exports.mkUpdateUsingFluxNSCBCOutflow(dir) end end + elseif dir == "yNeg" then + + __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED + task UpdateUsingFluxNSCBCOutflow([Fluid], + Fluid_BC : partition(disjoint, Fluid, ispace(int1d)), + mix : MIX.Mixture, + MaxMach : double, + LengthScale : double, + Pinf : double) + where + reads(Fluid.gradY), + reads(Fluid.{rho, mu, SoS}), + reads(Fluid.[Primitives]), + reads(Fluid.Conserved), + reads(Fluid.{velocityGradientX, velocityGradientY, velocityGradientZ}), + reads(Fluid.{MolarFracs, pressure, velocity}), + reads(Fluid.{rho, mu}), + reads(Fluid.{velocityGradientX, velocityGradientY, velocityGradientZ}), + reads writes(Fluid.Conserved_t), + [coherence_mode] + do + var BC = Fluid_BC[0] + var BCst = Fluid_BC[1] + + __demand(__openmp) + for c in BC do + var c_int = c + int3d{ 0, 1, 0} + + -- Thermo-chemical quantities + var MixW_bnd = MIX.GetMolarWeightFromXi( BC [c ].MolarFracs, mix) + var Yi_bnd = MIX.GetMassFractions(MixW_bnd, BC [c ].MolarFracs, mix) + var MixW_int = MIX.GetMolarWeightFromXi( BCst[c_int].MolarFracs, mix) + var Yi_int = MIX.GetMassFractions(MixW_int, BCst[c_int].MolarFracs, mix) + var Cp_bnd = MIX.GetHeatCapacity(BC[c].temperature, Yi_bnd, mix) + + var drho_dy = [OP.emitderivLeftBCBase(rexpr BC [c ].gradY end, + rexpr BC [c ].rho end, + rexpr BCst[c_int].rho end)] + var dp_dy = [OP.emitderivLeftBCBase(rexpr BC [c ].gradY end, + rexpr BC [c ].pressure end, + rexpr BCst[c_int].pressure end)] + var du_dy = BC[c].velocityGradientY[0] + var dv_dy = BC[c].velocityGradientY[1] + var dw_dy = BC[c].velocityGradientY[2] + var dY_dy : double[nSpec] + for i=0, nSpec do + dY_dy[i] = [OP.emitderivLeftBCBase(rexpr BC[c].gradY end, + rexpr Yi_bnd[i] end, + rexpr Yi_int[i] end)] + end + + var lambda_1 = BC[c].velocity[1] - BC[c].SoS + var lambda = BC[c].velocity[1] + var lambda_N = BC[c].velocity[1] + BC[c].SoS + + + var L1 = lambda_1*(dp_dy - BC[c].rho*BC[c].SoS*dv_dy) + var L2 = lambda*(du_dy) + var L3 = lambda*(dp_dy - BC[c].SoS*BC[c].SoS*drho_dy) + var L4 = lambda*(dw_dy) + var LS : double[nSpec] + for i=0, nSpec do + LS[i] = lambda*(dY_dy[i]) + end + + var LN : double + if lambda_N > 0 then + -- We are supersonic + LN = lambda_N*(dp_dy + BC[c].rho*BC[c].SoS*dv_dy) + else + -- It is either a subsonic or partially subsonic outlet + var K = sigma*(1.0-MaxMach*MaxMach)*BC[c].SoS/LengthScale + if MaxMach > 0.99 then + -- This means that MaxMach[0] > 1.0 + -- Use the local Mach number for partialy supersonic outflows + K = sigma*(BC[c].SoS-(BC[c].velocity[1]*BC[c].velocity[1])/BC[c].SoS)/LengthScale + end + LN = K*(BC[c].pressure - Pinf) + end + + var d1 = (0.5*(LN + L1) - L3)/(BC[c].SoS*BC[c].SoS) + var d2 = L2 + var d3 = (LN - L1)/(2.0*BC[c].rho*BC[c].SoS) + var d4 = L4 + var dS = LS + var dN = L3/(BC[c].SoS*BC[c].SoS) + + var tau12_bnd = BC[c].mu*(BC[c].velocityGradientY[0] + BC[c].velocityGradientX[1]) + var tau22_bnd = BC[c].mu*(4.0*BC[c].velocityGradientY[1] - 2.0*BC[c].velocityGradientX[0] - 2.0*BC[c].velocityGradientZ[2])/3.0 + var tau32_bnd = BC[c].mu*(BC[c].velocityGradientY[2] + BC[c].velocityGradientZ[1]) + + var tau22_int = BCst[c_int].mu*(4.0*BCst[c_int].velocityGradientY[1] - 2.0*BCst[c_int].velocityGradientX[0] - 2.0*BCst[c_int].velocityGradientZ[2])/3.0 + + -- Diffusion in momentum equations + var dtau22_dy = [OP.emitderivLeftBCBase(rexpr BC[c].gradY end, + rexpr tau22_bnd end, + rexpr tau22_int end)] + + -- Source in energy equation + var energy_term_y = [OP.emitderivLeftBCBase(rexpr BC[c].gradY end, + rexpr BC [c ].velocity[1]*tau22_bnd end, + rexpr BCst[c_int].velocity[1]*tau22_int end)] + + BC[c].velocityGradientY[0]*tau12_bnd + + BC[c].velocityGradientY[2]*tau32_bnd + + -- Update the RHS of conservation equations with x fluxes + for i=0, nSpec do + BC[c].Conserved_t[i] -= d1*Yi_bnd[i] + BC[c].rho*dS[i] + end + BC[c].Conserved_t[irU+0] -= BC[c].velocity[0]*d1 + BC[c].rho*d2 + BC[c].Conserved_t[irU+1] -= BC[c].velocity[1]*d1 + BC[c].rho*d3 - dtau22_dy + BC[c].Conserved_t[irU+2] -= BC[c].velocity[2]*d1 + BC[c].rho*d4 + BC[c].Conserved_t[irE] -= (BC[c].Conserved[irE] + BC[c].pressure)*d1/BC[c].rho + + BC[c].Conserved[irU+0]*d2 + + BC[c].Conserved[irU+1]*d3 + + BC[c].Conserved[irU+2]*d4 + + Cp_bnd*BC[c].temperature*dN + - energy_term_y + for i=0, nSpec do + var dedYi = MIX.GetSpecificInternalEnergy(i, BC[c].temperature, mix) + BC[c].Conserved_t[irE] -= BC[c].rho*dedYi*dS[i] + end + end + end + elseif dir == "yPos" then __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED - task UpdateUsingFluxNSCBCOutflow(Fluid : region(ispace(int3d), Fluid_columns), + task UpdateUsingFluxNSCBCOutflow([Fluid], Fluid_BC : partition(disjoint, Fluid, ispace(int1d)), mix : MIX.Mixture, MaxMach : double, @@ -318,14 +454,14 @@ function Exports.mkUpdateUsingFluxNSCBCOutflow(dir) reads(Fluid.{MolarFracs, pressure, velocity}), reads(Fluid.{rho, mu}), reads(Fluid.{velocityGradientX, velocityGradientY, velocityGradientZ}), - reads writes atomic(Fluid.Conserved_t) + reads writes(Fluid.Conserved_t), + [coherence_mode] do var BC = Fluid_BC[0] var BCst = Fluid_BC[1] __demand(__openmp) for c in BC do - -- Add in the x fluxes using NSCBC for outflow var c_int = c + int3d{ 0,-1, 0} -- Thermo-chemical quantities @@ -421,6 +557,7 @@ function Exports.mkUpdateUsingFluxNSCBCOutflow(dir) end end end + end return UpdateUsingFluxNSCBCOutflow end @@ -430,12 +567,13 @@ end ------------------------------------------------------------------------------- __demand(__cuda, __leaf) -- MANUALLY PARALLELIZED -task Exports.AddBodyForces(Fluid : region(ispace(int3d), Fluid_columns), +task Exports.AddBodyForces([Fluid], ModCells : region(ispace(int3d), Fluid_columns), Flow_bodyForce : double[3]) where reads(Fluid.{rho, velocity}), - reads writes atomic(Fluid.Conserved_t) + reads writes(Fluid.Conserved_t), + [coherence_mode] do __demand(__openmp) for c in ModCells do @@ -496,7 +634,7 @@ Exports.mkCorrectUsingFlux = terralib.memoize(function(dir) else assert(false) end __demand(__parallel, __cuda, __leaf) - task CorrectUsingFlux(Fluid : region(ispace(int3d), Fluid_columns), + task CorrectUsingFlux([Fluid], ModCells : region(ispace(int3d), Fluid_columns), Fluid_bounds : rect3d, mix : MIX.Mixture) @@ -505,7 +643,8 @@ Exports.mkCorrectUsingFlux = terralib.memoize(function(dir) reads(Fluid.cellWidth), reads(Fluid.Conserved_hat), reads(Fluid.[Flux]), - reads writes atomic(Fluid.Conserved_t) + reads writes(Fluid.Conserved_t), + [coherence_mode] do __demand(__openmp) for c in ModCells do diff --git a/src/quartz.slurm b/src/quartz.slurm index 6219b4a..03920e7 100644 --- a/src/quartz.slurm +++ b/src/quartz.slurm @@ -4,7 +4,8 @@ #MSUB -l partition=quartz USE_CUDA=0 -CORES_PER_NODE=38 +CORES_PER_NODE=72 +NUMA_PER_RANK=2 RAM_PER_NODE=100000 # 128GB RAM per node diff --git a/src/run.sh b/src/run.sh index f6b041b..515a5d6 100644 --- a/src/run.sh +++ b/src/run.sh @@ -101,6 +101,8 @@ function run_sapling { fi # Synthesize final command CORES_PER_NODE=12 + RESERVED_CORES=4 + NUMA_PER_RANK=2 RAM_PER_NODE=30000 GPUS_PER_NODE=2 FB_PER_GPU=5000 @@ -134,6 +136,29 @@ function run_quartz { # 18 cores per NUMA domain } +function run_galileo { + export QUEUE="${QUEUE:-gll_usr_gpuprod}" + RESOURCES= + if [[ "$QUEUE" == "gll_usr_gpuprod" ]]; then + RESOURCES="gpu:kepler:2" + fi + DEPS= + if [[ ! -z "$AFTER" ]]; then + DEPS="-d afterok:$AFTER" + fi + CORES_PER_RANK=$(( 36/$RANKS_PER_NODE )) + sbatch --export=ALL \ + -N "$NUM_RANKS" -t "$WALLTIME" -p "$QUEUE" --gres="$RESOURCES" $DEPS \ + --ntasks-per-node="$RANKS_PER_NODE" --cpus-per-task="$CORES_PER_RANK" \ + --account="$ACCOUNT" \ + "$HTR_DIR"/src/galileo.slurm + # Resources: + # 118GB RAM per node + # 2 NUMA domains per node + # 18 cores per NUMA domain + # 1 nVidia K80 GPUs (seen as two K40 gpus) +} + function run_local { if (( NUM_NODES > 1 )); then quit "Too many nodes requested" @@ -142,6 +167,7 @@ function run_local { LOCAL_RUN=1 USE_CUDA=0 RESERVED_CORES=2 + NUMA_PER_RANK=1 # Synthesize final command CORES_PER_NODE="$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}')" RAM_PER_NODE="$(free -m | head -2 | tail -1 | awk '{print $2}')" @@ -162,6 +188,8 @@ elif [[ "$(uname -n)" == *"sapling"* ]]; then run_sapling elif [[ "$(uname -n)" == *"quartz"* ]]; then run_quartz +elif [[ "$(uname -n)" == *"r033c01s"* ]]; then + run_galileo else echo 'Hostname not recognized; assuming local machine run w/o GPUs' run_local diff --git a/testcases/Blasius/Blasius.json b/testcases/Blasius/Blasius.json index d27bcf2..48a2bfc 100644 --- a/testcases/Blasius/Blasius.json +++ b/testcases/Blasius/Blasius.json @@ -35,105 +35,44 @@ }, "BC" : { - "xBCLeft" : "NSCBC_Inflow", - "xBCLeftInflowProfile" : { - "type" : "File", - "FileDir" : "InflowProfile", - "Reynolds" : 500, - "velocity" : 10.0 - }, - "xBCLeftP" : 1.01325e5, - "xBCLeftHeat" : { - "type" : "File", - "FileDir" : "InflowProfile", - "temperature" : 300.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 1.01325e5, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "InflowProfile", + "Reynolds" : 500, + "velocity" : 10.0 + }, + "P" : 1.01325e5, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "InflowProfile", + "temperature" : 300.0 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCLeft" : "IsothermalWall", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "yBCRight" : "NSCBC_Outflow", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 1.01325e5, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -141,13 +80,10 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 5.0e-3, - "powerlawViscRef" : 5.0e-3, - "powerlawTempRef" : 300.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 5.0e-3 + }, "initCase" : "Uniform", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 10.0, 0.0, 0.0], diff --git a/testcases/Blasius/MakeProfile.py b/testcases/Blasius/MakeProfile.py index b1e8a1b..2f486a3 100644 --- a/testcases/Blasius/MakeProfile.py +++ b/testcases/Blasius/MakeProfile.py @@ -7,7 +7,10 @@ from scipy.integrate import odeint from scipy.optimize import fsolve -muExp = 0.75 +# load local modules +sys.path.insert(0, os.path.expandvars("$HTR_DIR/scripts/modules")) +import gridGen +import ConstPropMix ############################################################################## # Read Prometeo Input File # @@ -33,42 +36,20 @@ gamma = data["Flow"]["gamma"] R = data["Flow"]["gasConstant"] -muRef = data["Flow"]["powerlawViscRef"] -TRef = data["Flow"]["powerlawTempRef"] Pr = data["Flow"]["prandtl"] -TInf = data["BC"]["xBCLeftHeat"]["temperature"] -Tw = data["BC"]["xBCLeftHeat"]["temperature"] -P = data["BC"]["xBCLeftP"] -U = data["BC"]["xBCLeftInflowProfile"]["velocity"] -Re = data["BC"]["xBCLeftInflowProfile"]["Reynolds"] +TInf = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] +Tw = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] +P = data["BC"]["xBCLeft"]["P"] +U = data["BC"]["xBCLeft"]["VelocityProfile"]["velocity"] +Re = data["BC"]["xBCLeft"]["VelocityProfile"]["Reynolds"] aInf = np.sqrt(gamma*R*TInf) MaInf = U/aInf -RhoInf = P/(R*TInf) -nuInf = muRef*(TInf/TRef)**muExp/RhoInf - -############################################################################## -# Compute grid # -############################################################################## -def GetGrid(Origin, Width, Num, Type, stretching): - if (Type == 'Uniform'): - x = np.linspace(0.0, 1.0, Num+1) - x *= Width - x += Origin - elif (Type == 'TanhMinus'): - x = np.linspace(-1.0, 0.0, Num+1) - x = np.tanh(stretching*x)/np.tanh(stretching) - x = Width*(x+1.0)+Origin - - xc = np.zeros(Num+2) - for i in range(1,Num+1): - xc[i] = 0.5*(x[i-1]+x[i]) - xc[0] = Origin - xc[1] - xc[Num+1] = 2.0*(Origin+Width)-xc[Num] - - return xc +RhoInf = ConstPropMix.GetDensity(TInf, P, data) +muInf = ConstPropMix.GetViscosity(TInf, data) +nuInf = muInf/RhoInf ############################################################################## # Compute Blasius Solution # @@ -77,7 +58,7 @@ def GetCBL(): def CBLFun(U, y): u, F, h, G, g = U.T T = 1.0 + 0.5*h*(gamma - 1.0)*MaInf**2 - mu = T**muExp + mu = T**0.7 return [ F/mu, -0.5*g*F/mu, Pr*G/mu, @@ -110,7 +91,12 @@ def objective(A): ############################################################################## # Generate y grid that will be used in the solver # ############################################################################## -y = GetGrid(yOrigin, yWidth, yNum, yType, yStretching) +y, dy = gridGen.GetGrid(data["Grid"]["origin"][1], + data["Grid"]["yWidth"], + data["Grid"]["yNum"], + data["Grid"]["yType"], + data["Grid"]["yStretching"], + False) ############################################################################## # Compute the profile on this grid # diff --git a/testcases/Blasius/postProc.py b/testcases/Blasius/postProc.py index dbd42ca..0246bc4 100644 --- a/testcases/Blasius/postProc.py +++ b/testcases/Blasius/postProc.py @@ -57,12 +57,12 @@ def process(): yOrigin = data["Grid"]["origin"][1] R = data["Flow"]["gasConstant"] - mu = data["Flow"]["constantVisc"] + mu = data["Flow"]["viscosityModel"]["Visc"] - T = data["BC"]["xBCLeftHeat"]["temperature"] - P = data["BC"]["xBCLeftP"] - U = data["BC"]["xBCLeftInflowProfile"]["velocity"] - Re = data["BC"]["xBCLeftInflowProfile"]["Reynolds"] + T = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] + P = data["BC"]["xBCLeft"]["P"] + U = data["BC"]["xBCLeft"]["VelocityProfile"]["velocity"] + Re = data["BC"]["xBCLeft"]["VelocityProfile"]["Reynolds"] Rho = P/(R*T) nu = mu/Rho diff --git a/testcases/Coleman/MakeChannel.py b/testcases/Coleman/MakeChannel.py index 0b2793d..61370f4 100755 --- a/testcases/Coleman/MakeChannel.py +++ b/testcases/Coleman/MakeChannel.py @@ -26,12 +26,12 @@ del config["Case"] # Read boundary conditions -assert config["BC"]["yBCLeft"] == "IsothermalWall" -assert config["BC"]["yBCLeftHeat"]["type"] == "Constant" -assert config["BC"]["yBCRight"] == "IsothermalWall" -assert config["BC"]["yBCRightHeat"]["type"] == "Constant" -assert config["BC"]["yBCLeftHeat"]["temperature"] == config["BC"]["yBCRightHeat"]["temperature"] -Tw = config["BC"]["yBCLeftHeat"]["temperature"] +assert config["BC"]["yBCLeft"]["type"] == "IsothermalWall" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["type"] == "Constant" +assert config["BC"]["yBCRight"]["type"] == "IsothermalWall" +assert config["BC"]["yBCRight"]["TemperatureProfile"]["type"] == "Constant" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] == config["BC"]["yBCRight"]["TemperatureProfile"]["temperature"] +Tw = config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] # Read properties Pb = config["Flow"]["initParams"][0] diff --git a/testcases/Coleman/base.json b/testcases/Coleman/base.json index cf08f92..fe97150 100644 --- a/testcases/Coleman/base.json +++ b/testcases/Coleman/base.json @@ -43,102 +43,24 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "xBCRight" : "Periodic", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "yBCRight" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "yBCLeft" : "IsothermalWall", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : -1.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "IsothermalWall", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : -1.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -146,13 +68,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.7, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 1.716e-5, - "powerlawTempRef" : 273.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, "initCase" : "ChannelFlow", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 0.0, 0.08, 0.05], diff --git a/testcases/CompressibleBL/CBL.json b/testcases/CompressibleBL/CBL.json index 89a677d..8080f4c 100644 --- a/testcases/CompressibleBL/CBL.json +++ b/testcases/CompressibleBL/CBL.json @@ -35,105 +35,44 @@ }, "BC" : { - "xBCLeft" : "NSCBC_Inflow", - "xBCLeftInflowProfile" : { - "type" : "File", - "FileDir" : "InflowProfile", - "Reynolds" : 100000, - "velocity" : 2083.67 - }, - "xBCLeftP" : 1.01325e5, - "xBCLeftHeat" : { - "type" : "File", - "FileDir" : "InflowProfile", - "temperature" : 300.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 1.01325e5, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCLeft" : "IsothermalWall", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "InflowProfile", + "Reynolds" : 100000, + "velocity" : 2083.67 + }, + "P" : 1.01325e5, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "InflowProfile", + "temperature" : 300.0 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCRight" : "NSCBC_Outflow", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 1.01325e5, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -141,13 +80,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 0.05, - "powerlawTempRef" : 300.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 0.05, + "TempRef" : 300.0 + }, "initCase" : "Restart", "restartDir" : "InflowProfile", "initParams" : [1.01325e5, 300.0, 2083.67, 0.0, 0.0], diff --git a/testcases/CompressibleBL/MakeInput.py b/testcases/CompressibleBL/MakeInput.py index e49a814..7dab1e2 100755 --- a/testcases/CompressibleBL/MakeInput.py +++ b/testcases/CompressibleBL/MakeInput.py @@ -37,27 +37,25 @@ gamma = config["Flow"]["gamma"] R = config["Flow"]["gasConstant"] -muRef = config["Flow"]["powerlawViscRef"] -TRef = config["Flow"]["powerlawTempRef"] Pr = config["Flow"]["prandtl"] assert config["Flow"]["initCase"] == "Restart" restartDir = config["Flow"]["restartDir"] -config["BC"]["xBCLeftInflowProfile"]["FileDir"] = restartDir -config["BC"]["xBCLeftHeat"]["FileDir"] = restartDir -TInf = config["BC"]["xBCLeftHeat"]["temperature"] -Tw = config["BC"]["xBCLeftHeat"]["temperature"] -P = config["BC"]["xBCLeftP"] -UInf = config["BC"]["xBCLeftInflowProfile"]["velocity"] -Rex0 = config["BC"]["xBCLeftInflowProfile"]["Reynolds"] +config["BC"]["xBCLeft"]["VelocityProfile"]["FileDir"] = restartDir +config["BC"]["xBCLeft"]["TemperatureProfile"]["FileDir"] = restartDir +TInf = config["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] +Tw = config["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] +P = config["BC"]["xBCLeft"]["P"] +UInf = config["BC"]["xBCLeft"]["VelocityProfile"]["velocity"] +Rex0 = config["BC"]["xBCLeft"]["VelocityProfile"]["Reynolds"] aInf = np.sqrt(gamma*R*TInf) MaInf = UInf/aInf RhoInf = ConstPropMix.GetDensity(TInf, P, config) muInf = ConstPropMix.GetViscosity(TInf, config) -nuInf = ConstPropMix.GetViscosity(TInf, config)/RhoInf +nuInf = muInf/RhoInf ############################################################################## # Generate Grid # @@ -149,9 +147,11 @@ temperature = np.ndarray(shape) MolarFracs = np.ndarray(shape, dtype=np.dtype('(1,)f8')) velocity = np.ndarray(shape, dtype=np.dtype('(3,)f8')) - dudtBoundary = np.ndarray(shape) + dudtBoundary = np.ndarray(shape, dtype=np.dtype('(3,)f8')) dTdtBoundary = np.ndarray(shape) pressure[:] = P + dudtBoundary[:] = [0.0, 0.0, 0.0] + dTdtBoundary[:] = 0.0 for (k,kc) in enumerate(centerCoordinates): for (j,jc) in enumerate(kc): for (i,ic) in enumerate(jc): @@ -183,10 +183,8 @@ fout.create_dataset("temperature", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs", shape=shape, dtype = np.dtype("(1,)f8")) fout.create_dataset("velocity", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("dTdtBoundary", shape=shape, dtype = np.dtype("f8")) - fout.create_dataset("velocity_old_NSCBC", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("temperature_old_NSCBC", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs_profile", shape=shape, dtype = np.dtype("(1,)f8")) fout.create_dataset("velocity_profile", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("temperature_profile", shape=shape, dtype = np.dtype("f8")) @@ -200,8 +198,6 @@ fout["velocity"][:] = velocity fout["dudtBoundary"][:] = dudtBoundary fout["dTdtBoundary"][:] = dTdtBoundary - fout["velocity_old_NSCBC"][:] = velocity - fout["temperature_old_NSCBC"][:] = temperature fout["MolarFracs_profile"][:] = MolarFracs fout["velocity_profile"][:] = velocity fout["temperature_profile"][:] = temperature diff --git a/testcases/CompressibleBL/postProc.py b/testcases/CompressibleBL/postProc.py index c88dd7c..fce775e 100644 --- a/testcases/CompressibleBL/postProc.py +++ b/testcases/CompressibleBL/postProc.py @@ -35,28 +35,24 @@ gamma = data["Flow"]["gamma"] R = data["Flow"]["gasConstant"] -muRef = data["Flow"]["powerlawViscRef"] -TRef = data["Flow"]["powerlawTempRef"] Pr = data["Flow"]["prandtl"] -TInf = data["BC"]["xBCLeftHeat"]["temperature"] -Tw = data["BC"]["yBCLeftHeat"]["temperature"] -P = data["BC"]["xBCLeftP"] -U = data["BC"]["xBCLeftInflowProfile"]["velocity"] -Re = data["BC"]["xBCLeftInflowProfile"]["Reynolds"] +TInf = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"] +Tw = data["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] +P = data["BC"]["xBCLeft"]["P"] +U = data["BC"]["xBCLeft"]["VelocityProfile"]["velocity"] +Re = data["BC"]["xBCLeft"]["VelocityProfile"]["Reynolds"] aInf = np.sqrt(gamma*R*TInf) MaInf = U/aInf -def visc(T): - return muRef*(T/TRef)**0.7 - ############################################################################## # Process result file # ############################################################################## def process(frac): - RhoInf = P/(R*TInf) - nuInf = visc(TInf)/RhoInf + RhoInf = ConstPropMix.GetDensity(TInf, P, data) + muInf = ConstPropMix.GetViscosity(TInf, data) + nuInf = muInf/RhoInf dt = data["Integrator"]["fixedDeltaTime"] nstep = int(data["Integrator"]["maxIter"]) @@ -118,7 +114,7 @@ def process(frac): for i in range(y.size) : if (i > 0) : rhoMid = 0.5*(rho[i] + rho[i-1]) - eta[i] = eta[i-1] + U/(visc(TInf)*np.sqrt(2*myRe))*rhoMid*(y[i] - y[i-1]) + eta[i] = eta[i-1] + U/(muInf*np.sqrt(2*myRe))*rhoMid*(y[i] - y[i-1]) return eta, u/U, v*np.sqrt(2.0*myRe)/U, T/TInf, p diff --git a/testcases/Franko/MakeInput.py b/testcases/Franko/MakeInput.py index a123b26..6b9a3cf 100755 --- a/testcases/Franko/MakeInput.py +++ b/testcases/Franko/MakeInput.py @@ -157,33 +157,32 @@ def VanDriestII(Cf): ############################################################################## # Boundary conditions # ############################################################################## -assert config["BC"]["xBCLeft"] == "NSCBC_Inflow" -assert config["BC"]["xBCLeftInflowProfile"]["type"] == "File" -config["BC"]["xBCLeftInflowProfile"]["FileDir"] = restartDir -assert config["BC"]["xBCLeftHeat"]["type"] == "File" -config["BC"]["xBCLeftHeat"]["FileDir"] = restartDir -config["BC"]["xBCLeftP"] = PInf - -assert config["BC"]["xBCRight"] == "NSCBC_Outflow" -config["BC"]["xBCRightP"] = PInf - -assert config["BC"]["yBCLeft"] == "SuctionAndBlowingWall" -assert config["BC"]["yBCLeftHeat"]["type"] == "Constant" -config['BC']["yBCLeftHeat"]["temperature"] = Tw -assert config["BC"]["yBCLeftInflowProfile"]["type"] == "SuctionAndBlowing" - -config["BC"]["yBCLeftInflowProfile"]["Xmin"] = 15*deltaStarIn + x0 -config["BC"]["yBCLeftInflowProfile"]["Xmax"] = 20*deltaStarIn + x0 -config["BC"]["yBCLeftInflowProfile"]["X0"] = 0.5*(config["BC"]["yBCLeftInflowProfile"]["Xmin"] + config["BC"]["yBCLeftInflowProfile"]["Xmax"]) -config["BC"]["yBCLeftInflowProfile"]["sigma"] = 0.3*(config["BC"]["yBCLeftInflowProfile"]["X0"] - config["BC"]["yBCLeftInflowProfile"]["Xmin"]) -config["BC"]["yBCLeftInflowProfile"]["Zw"] = 0.1*config["Grid"]["zWidth"] - -config["BC"]["yBCLeftInflowProfile"]["A"] = [ 0.05*UInf, 0.05*UInf] -config["BC"]["yBCLeftInflowProfile"]["omega"] = [ 0.9*cInf/deltaStarIn, 0.9*cInf/deltaStarIn] -config["BC"]["yBCLeftInflowProfile"]["beta"] = [ 0.3/deltaStarIn, -0.3/deltaStarIn] - -assert config["BC"]["yBCRight"] == "NSCBC_Outflow" -config["BC"]["yBCRightP"] = PInf +assert config["BC"]["xBCLeft"]["type"] == "NSCBC_Inflow" +assert config["BC"]["xBCLeft"]["VelocityProfile"]["type"] == "File" +config["BC"]["xBCLeft"]["VelocityProfile"]["FileDir"] = restartDir +assert config["BC"]["xBCLeft"]["TemperatureProfile"]["type"] == "File" +config["BC"]["xBCLeft"]["TemperatureProfile"]["FileDir"] = restartDir +config["BC"]["xBCLeft"]["P"] = PInf + +assert config["BC"]["xBCRight"]["type"] == "NSCBC_Outflow" +config["BC"]["xBCRight"]["P"] = PInf + +assert config["BC"]["yBCLeft"]["type"] == "SuctionAndBlowingWall" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["type"] == "Constant" +config['BC']["yBCLeft"]["TemperatureProfile"]["temperature"] = Tw + +config["BC"]["yBCLeft"]["Xmin"] = 15*deltaStarIn + x0 +config["BC"]["yBCLeft"]["Xmax"] = 20*deltaStarIn + x0 +config["BC"]["yBCLeft"]["X0"] = 0.5*(config["BC"]["yBCLeft"]["Xmin"] + config["BC"]["yBCLeft"]["Xmax"]) +config["BC"]["yBCLeft"]["sigma"] = 0.3*(config["BC"]["yBCLeft"]["X0"] - config["BC"]["yBCLeft"]["Xmin"]) +config["BC"]["yBCLeft"]["Zw"] = 0.1*config["Grid"]["zWidth"] + +config["BC"]["yBCLeft"]["A"] = [ 0.05*UInf, 0.05*UInf] +config["BC"]["yBCLeft"]["omega"] = [ 0.9*cInf/deltaStarIn, 0.9*cInf/deltaStarIn] +config["BC"]["yBCLeft"]["beta"] = [ 0.3/deltaStarIn, -0.3/deltaStarIn] + +assert config["BC"]["yBCRight"]["type"] == "NSCBC_Outflow" +config["BC"]["yBCRight"]["P"] = PInf ############################################################################## # Generate Grid # @@ -291,9 +290,11 @@ def writeTile(xt, yt, zt): temperature = np.ndarray(shape) MolarFracs = np.ndarray(shape, dtype=np.dtype('(1,)f8')) velocity = np.ndarray(shape, dtype=np.dtype('(3,)f8')) - dudtBoundary = np.ndarray(shape) + dudtBoundary = np.ndarray(shape, dtype=np.dtype('(3,)f8')) dTdtBoundary = np.ndarray(shape) pressure[:] = PInf + dudtBoundary[:] = [0.0, 0.0, 0.0] + dTdtBoundary[:] = 0.0 for (k,kc) in enumerate(centerCoordinates): for (j,jc) in enumerate(kc): for (i,ic) in enumerate(jc): @@ -325,10 +326,8 @@ def writeTile(xt, yt, zt): fout.create_dataset("temperature", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs", shape=shape, dtype = np.dtype("(1,)f8")) fout.create_dataset("velocity", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("dTdtBoundary", shape=shape, dtype = np.dtype("f8")) - fout.create_dataset("velocity_old_NSCBC", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("temperature_old_NSCBC", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs_profile", shape=shape, dtype = np.dtype("(1,)f8")) fout.create_dataset("velocity_profile", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("temperature_profile", shape=shape, dtype = np.dtype("f8")) @@ -342,8 +341,6 @@ def writeTile(xt, yt, zt): fout["velocity"][:] = velocity fout["dudtBoundary"][:] = dudtBoundary fout["dTdtBoundary"][:] = dTdtBoundary - fout["velocity_old_NSCBC"][:] = velocity - fout["temperature_old_NSCBC"][:] = temperature fout["MolarFracs_profile"][:] = MolarFracs fout["velocity_profile"][:] = velocity fout["temperature_profile"][:] = temperature diff --git a/testcases/Franko/base.json b/testcases/Franko/base.json index aa304bd..ee054e8 100644 --- a/testcases/Franko/base.json +++ b/testcases/Franko/base.json @@ -47,108 +47,48 @@ }, "BC" : { - "xBCLeft" : "NSCBC_Inflow", - "xBCLeftInflowProfile" : { - "type" : "File", - "FileDir" : "" - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "File", - "FileDir" : "" - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "" + }, + "P" : -1.0, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "" + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : -1.0 }, - "yBCLeft" : "SuctionAndBlowingWall", - "yBCLeftInflowProfile" : { - "type" : "SuctionAndBlowing", + "yBCLeft" : { + "type" : "SuctionAndBlowingWall", "Xmin" : 0.0, "Xmax" : 0.0, "X0" : 0.0, "sigma" : 0.0, "A" : [0.0, 0.0, 0.0], "omega" : [0.0, 0.0, 0.0], - "beta" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : -1.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "beta" : [0.0, 0.0, 0.0], + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : -1.0 } }, - "yBCRight" : "NSCBC_Outflow", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : -1.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : -1.0 }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -156,13 +96,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 1.716e-5, - "powerlawTempRef" : 273.0, - "sutherlandViscRef" : 1.81e-5, - "sutherlandTempRef" : 300.0, - "sutherlandSRef" : 110.4, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, "initCase" : "Restart", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 0.0, 0.1, 0.05], diff --git a/testcases/GrossmanCinnellaProblem/600.json b/testcases/GrossmanCinnellaProblem/600.json index 6a1420d..815f6d0 100644 --- a/testcases/GrossmanCinnellaProblem/600.json +++ b/testcases/GrossmanCinnellaProblem/600.json @@ -35,113 +35,36 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeft" : "NSCBC_Inflow", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : 1.95256e5, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : 9000.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 1.279631e-02 }, - {"Name" : "O2", "MolarFrac" : 3.695112e-06 }, - {"Name" : "NO", "MolarFrac" : 2.694521e-04 }, - {"Name" : "N", "MolarFrac" : 7.743854e-01 }, - {"Name" : "O", "MolarFrac" : 2.125451e-01 }] - } - }, - "xBCRight" : "Periodic", - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 1.0e4, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [0.0, 0.0, 0.0] + }, + "P" : 1.95256e5, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 9000.0 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "N2", "MolarFrac" : 1.279631e-02 }, + {"Name" : "O2", "MolarFrac" : 3.695112e-06 }, + {"Name" : "NO", "MolarFrac" : 2.694521e-04 }, + {"Name" : "N", "MolarFrac" : 7.743854e-01 }, + {"Name" : "O", "MolarFrac" : 2.125451e-01 }] + } } }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.0e4 }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - } + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -149,13 +72,10 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 0.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, "initCase" : "Uniform", "initCase" : "GrossmanCinnellaProblem", "restartDir" : "", diff --git a/testcases/LaxProblem/100.json b/testcases/LaxProblem/100.json index 76b7276..47846ca 100644 --- a/testcases/LaxProblem/100.json +++ b/testcases/LaxProblem/100.json @@ -35,102 +35,46 @@ }, "BC" : { - "xBCLeft" : "Dirichlet", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.698, 0.0, 0.0] - }, - "xBCLeftP" : 3.528, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : 7.92808988764 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "Dirichlet", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 0.5710, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : 1.142 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "Dirichlet", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [0.698, 0.0, 0.0] + }, + "P" : 3.528, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 7.92808988764 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCRight" : { + "type" : "Dirichlet", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [0.0, 0.0, 0.0] + }, + "P" : 0.5710, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 1.142 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -138,13 +82,10 @@ "gasConstant" : 1.0, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 0.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, "initCase" : "LaxProblem", "restartDir" : "", "initParams" : [1.0, 1.0, 0.80, 0.0, 0.0], diff --git a/testcases/MultispeciesTBL/MakeInput.py b/testcases/MultispeciesTBL/MakeInput.py index b48c405..d643584 100755 --- a/testcases/MultispeciesTBL/MakeInput.py +++ b/testcases/MultispeciesTBL/MakeInput.py @@ -149,35 +149,33 @@ def VanDriestII(Cf): ############################################################################## # Boundary conditions # ############################################################################## -assert config["BC"]["xBCLeft"] == "NSCBC_Inflow" -assert config["BC"]["xBCLeftInflowProfile"]["type"] == "File" -config["BC"]["xBCLeftInflowProfile"]["FileDir"] = restartDir -assert config["BC"]["xBCLeftHeat"]["type"] == "File" -config["BC"]["xBCLeftHeat"]["FileDir"] = restartDir -assert config["BC"]["xBCLeftMixture"]["type"] == "File" -config["BC"]["xBCLeftMixture"]["FileDir"] = restartDir -config["BC"]["xBCLeftP"] = PInf - -assert config["BC"]["xBCRight"] == "NSCBC_Outflow" -config["BC"]["xBCRightP"] = PInf - -assert config["BC"]["yBCLeft"] == "SuctionAndBlowingWall" -assert config["BC"]["yBCLeftHeat"]["type"] == "Constant" -config['BC']["yBCLeftHeat"]["temperature"] = Tw -assert config["BC"]["yBCLeftInflowProfile"]["type"] == "SuctionAndBlowing" - -config["BC"]["yBCLeftInflowProfile"]["Xmin"] = 15*deltaStarIn + x0 -config["BC"]["yBCLeftInflowProfile"]["Xmax"] = 20*deltaStarIn + x0 -config["BC"]["yBCLeftInflowProfile"]["X0"] = 0.5*(config["BC"]["yBCLeftInflowProfile"]["Xmin"] + config["BC"]["yBCLeftInflowProfile"]["Xmax"]) -config["BC"]["yBCLeftInflowProfile"]["sigma"] = 0.3*(config["BC"]["yBCLeftInflowProfile"]["X0"] - config["BC"]["yBCLeftInflowProfile"]["Xmin"]) -config["BC"]["yBCLeftInflowProfile"]["Zw"] = 0.1*config["Grid"]["zWidth"] - -config["BC"]["yBCLeftInflowProfile"]["A"] = [ 0.05*UInf, 0.05*UInf] -config["BC"]["yBCLeftInflowProfile"]["omega"] = [ 0.9*cInf/deltaStarIn, 0.9*cInf/deltaStarIn] -config["BC"]["yBCLeftInflowProfile"]["beta"] = [ 0.3/deltaStarIn, -0.3/deltaStarIn] - -assert config["BC"]["yBCRight"] == "NSCBC_Outflow" -config["BC"]["yBCRightP"] = PInf +assert config["BC"]["xBCLeft"]["type"] == "NSCBC_Inflow" +assert config["BC"]["xBCLeft"]["VelocityProfile"]["type"] == "File" +config["BC"]["xBCLeft"]["VelocityProfile"]["FileDir"] = restartDir +assert config["BC"]["xBCLeft"]["TemperatureProfile"]["type"] == "File" +config["BC"]["xBCLeft"]["TemperatureProfile"]["FileDir"] = restartDir +assert config["BC"]["xBCLeft"]["MixtureProfile"]["type"] == "File" +config["BC"]["xBCLeftMixture"]["MixtureProfile"]["FileDir"] = restartDir +config["BC"]["xBCLeft"]["P"] = PInf + +assert config["BC"]["xBCRight"]["type"] == "NSCBC_Outflow" +config["BC"]["xBCRight"]["P"] = PInf + +assert config["BC"]["yBCLeft"]["type"] == "SuctionAndBlowingWall" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["type"] == "Constant" +config['BC']["yBCLeft"]["TemperatureProfile"]["temperature"] = Tw +config["BC"]["yBCLeft"]["Xmin"] = 15*deltaStarIn + x0 +config["BC"]["yBCLeft"]["Xmax"] = 20*deltaStarIn + x0 +config["BC"]["yBCLeft"]["X0"] = 0.5*(config["BC"]["yBCLeft"]["Xmin"] + config["BC"]["yBCLeft"]["Xmax"]) +config["BC"]["yBCLeft"]["sigma"] = 0.3*(config["BC"]["yBCLeft"]["X0"] - config["BC"]["yBCLeft"]["Xmin"]) +config["BC"]["yBCLeft"]["Zw"] = 0.1*config["Grid"]["zWidth"] + +config["BC"]["yBCLeft"]["A"] = [ 0.05*UInf, 0.05*UInf] +config["BC"]["yBCLeft"]["omega"] = [ 0.9*cInf/deltaStarIn, 0.9*cInf/deltaStarIn] +config["BC"]["yBCLeft"]["beta"] = [ 0.3/deltaStarIn, -0.3/deltaStarIn] + +assert config["BC"]["yBCRight"]["type"] == "NSCBC_Outflow" +config["BC"]["yBCRight"]["P"] = PInf ############################################################################## # Generate Grid # @@ -284,9 +282,11 @@ def writeTile(xt, yt, zt): temperature = np.ndarray(shape) MolarFracs = np.ndarray(shape, dtype=np.dtype('(5,)f8')) velocity = np.ndarray(shape, dtype=np.dtype('(3,)f8')) - dudtBoundary = np.ndarray(shape) + dudtBoundary = np.ndarray(shape, dtype=np.dtype('(3,)f8')) dTdtBoundary = np.ndarray(shape) pressure[:] = PInf + dudtBoundary[:] = [0.0, 0.0, 0.0] + dTdtBoundary[:] = 0.0 for (k,kc) in enumerate(centerCoordinates): for (j,jc) in enumerate(kc): for (i,ic) in enumerate(jc): @@ -328,10 +328,8 @@ def writeTile(xt, yt, zt): fout.create_dataset("temperature", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs", shape=shape, dtype = np.dtype("(5,)f8")) fout.create_dataset("velocity", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("f8")) + fout.create_dataset("dudtBoundary", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("dTdtBoundary", shape=shape, dtype = np.dtype("f8")) - fout.create_dataset("velocity_old_NSCBC", shape=shape, dtype = np.dtype("(3,)f8")) - fout.create_dataset("temperature_old_NSCBC", shape=shape, dtype = np.dtype("f8")) fout.create_dataset("MolarFracs_profile", shape=shape, dtype = np.dtype("(5,)f8")) fout.create_dataset("velocity_profile", shape=shape, dtype = np.dtype("(3,)f8")) fout.create_dataset("temperature_profile", shape=shape, dtype = np.dtype("f8")) @@ -345,8 +343,6 @@ def writeTile(xt, yt, zt): fout["velocity"][:] = velocity fout["dudtBoundary"][:] = dudtBoundary fout["dTdtBoundary"][:] = dTdtBoundary - fout["velocity_old_NSCBC"][:] = velocity - fout["temperature_old_NSCBC"][:] = temperature fout["MolarFracs_profile"][:] = MolarFracs fout["velocity_profile"][:] = velocity fout["temperature_profile"][:] = temperature diff --git a/testcases/MultispeciesTBL/base.json b/testcases/MultispeciesTBL/base.json index 6b80e12..f2b7b7a 100644 --- a/testcases/MultispeciesTBL/base.json +++ b/testcases/MultispeciesTBL/base.json @@ -47,111 +47,47 @@ }, "BC" : { - "xBCLeft" : "NSCBC_Inflow", - "xBCLeftInflowProfile" : { - "type" : "File", - "FileDir" : "" - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "File", - "FileDir" : "" - }, - "xBCLeftMixture" : { - "type" : "File", - "FileDir" : "" - }, - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "" + }, + "P" : -1.0, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "" + }, + "MixtureProfile" : { + "type" : "File", + "FileDir" : "" } }, - "yBCLeft" : "SuctionAndBlowingWall", - "yBCLeftInflowProfile" : { - "type" : "SuctionAndBlowing", + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : -1.0 + }, + "yBCLeft" : { + "type" : "SuctionAndBlowingWall", "Xmin" : 0.0, "Xmax" : 0.0, "X0" : 0.0, "sigma" : 0.0, "A" : [0.0, 0.0, 0.0], "omega" : [0.0, 0.0, 0.0], - "beta" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : -1.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - }, - "yBCRight" : "NSCBC_Outflow", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : -1.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] + "beta" : [0.0, 0.0, 0.0], + "P" : -1.0, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : -1.0 } }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : -1.0 }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "N2", "MolarFrac" : 0.79 }, - {"Name" : "O2", "MolarFrac" : 0.21 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -159,13 +95,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 1.716e-5, - "powerlawTempRef" : 273.0, - "sutherlandViscRef" : 1.81e-5, - "sutherlandTempRef" : 300.0, - "sutherlandSRef" : 110.4, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, "initCase" : "Restart", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 0.0, 0.1, 0.05], diff --git a/testcases/Sciacovelli/MakeChannel.py b/testcases/Sciacovelli/MakeChannel.py index 32b1032..87afaed 100755 --- a/testcases/Sciacovelli/MakeChannel.py +++ b/testcases/Sciacovelli/MakeChannel.py @@ -26,12 +26,12 @@ del config["Case"] # Read boundary conditions -assert config["BC"]["yBCLeft"] == "IsothermalWall" -assert config["BC"]["yBCLeftHeat"]["type"] == "Constant" -assert config["BC"]["yBCRight"] == "IsothermalWall" -assert config["BC"]["yBCRightHeat"]["type"] == "Constant" -assert config["BC"]["yBCLeftHeat"]["temperature"] == config["BC"]["yBCRightHeat"]["temperature"] -Tw = config["BC"]["yBCLeftHeat"]["temperature"] +assert config["BC"]["yBCLeft"]["type"] == "IsothermalWall" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["type"] == "Constant" +assert config["BC"]["yBCRight"]["type"] == "IsothermalWall" +assert config["BC"]["yBCRight"]["TemperatureProfile"]["type"] == "Constant" +assert config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] == config["BC"]["yBCRight"]["TemperatureProfile"]["temperature"] +Tw = config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] # Read properties Pb = config["Flow"]["initParams"][0] diff --git a/testcases/Sciacovelli/base.json b/testcases/Sciacovelli/base.json index bba296b..e4ccd76 100644 --- a/testcases/Sciacovelli/base.json +++ b/testcases/Sciacovelli/base.json @@ -43,102 +43,24 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "xBCRight" : "Periodic", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "yBCRight" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "yBCLeft" : "IsothermalWall", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : -1.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "IsothermalWall", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : -1.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -146,13 +68,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.70, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 1.716e-5, - "powerlawTempRef" : 273.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, "initCase" : "ChannelFlow", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 0.0, 0.10, 0.01], diff --git a/testcases/ShuOsherProblem/200.json b/testcases/ShuOsherProblem/200.json index 437430a..efaf2a0 100644 --- a/testcases/ShuOsherProblem/200.json +++ b/testcases/ShuOsherProblem/200.json @@ -35,102 +35,32 @@ }, "BC" : { - "xBCLeft" : "Dirichlet", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [2.629, 0.0, 0.0] - }, - "xBCLeftP" : 10.333, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : 2.67902514908 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "NSCBC_Outflow", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : 1.02719008098016 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "Dirichlet", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [2.629, 0.0, 0.0] + }, + "P" : 10.333, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 2.67902514908 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.0 }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -138,13 +68,10 @@ "gasConstant" : 1.0, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 0.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, "initCase" : "ShuOsherProblem", "restartDir" : "", "initParams" : [1.0, 1.0, 0.80, 0.0, 0.0], diff --git a/testcases/SodProblem/100.json b/testcases/SodProblem/100.json index 7daa0b1..01e8153 100644 --- a/testcases/SodProblem/100.json +++ b/testcases/SodProblem/100.json @@ -35,102 +35,46 @@ }, "BC" : { - "xBCLeft" : "Dirichlet", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : 1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : 1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "Dirichlet", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : 0.1, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : 0.8 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { + "type" : "Dirichlet", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [0.0, 0.0, 0.0] + }, + "P" : 1.0, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 1.0 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCRight" : { + "type" : "Dirichlet", + "VelocityProfile" : { + "type" : "Constant", + "velocity" : [0.0, 0.0, 0.0] + }, + "P" : 0.1, + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 0.8 + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } } }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -138,13 +82,10 @@ "gasConstant" : 1.0, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 0.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, "initCase" : "SodProblem", "restartDir" : "", "initParams" : [1.0, 1.0, 0.80, 0.0, 0.0], diff --git a/testcases/TaylorGreen2D/base.json b/testcases/TaylorGreen2D/base.json index 78542b3..40d8461 100644 --- a/testcases/TaylorGreen2D/base.json +++ b/testcases/TaylorGreen2D/base.json @@ -35,102 +35,12 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "Periodic", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -138,13 +48,10 @@ "gasConstant" : 1.0, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 1.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 1.0 + }, "initCase" : "TaylorGreen2DVortex", "restartDir" : "", "initParams" : [1.0e4, 1.0e4, 1.0, 1.0, 1.0], diff --git a/testcases/TaylorGreen2D/postProc.py b/testcases/TaylorGreen2D/postProc.py index 1c15583..1af0506 100644 --- a/testcases/TaylorGreen2D/postProc.py +++ b/testcases/TaylorGreen2D/postProc.py @@ -40,7 +40,7 @@ def process(case): yNum = data["Grid"]["yNum"] xWidth = data["Grid"]["xWidth"] yWidth = data["Grid"]["yWidth"] - constantVisc = data["Flow"]["constantVisc"] + constantVisc = data["Flow"]["viscosityModel"]["Visc"] Area = xWidth*yWidth diff --git a/testcases/VortexAdvection2D/base.json b/testcases/VortexAdvection2D/base.json index 0f66d0d..ca3f85c 100644 --- a/testcases/VortexAdvection2D/base.json +++ b/testcases/VortexAdvection2D/base.json @@ -35,102 +35,12 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "xBCRight" : "Periodic", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCLeft" : "Periodic", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : 0.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "Periodic", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : 0.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -138,13 +48,10 @@ "gasConstant" : 1.0, "gamma" : 1.4, "prandtl" : 0.71, - "viscosityModel" : "Constant", - "constantVisc" : 0.0, - "powerlawViscRef" : -1.0, - "powerlawTempRef" : -1.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 0.0 + }, "initCase" : "VortexAdvection2D", "restartDir" : "", "initParams" : [1.0, 1.0, 1.0, 1.0, 0.0], diff --git a/testcases/scalingTest/WS/base.json b/testcases/scalingTest/WS/base.json index 4c2938b..85eb73a 100644 --- a/testcases/scalingTest/WS/base.json +++ b/testcases/scalingTest/WS/base.json @@ -43,102 +43,24 @@ }, "BC" : { - "xBCLeft" : "Periodic", - "xBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCLeftP" : -1.0, - "xBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "xBCRight" : "Periodic", - "xBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "xBCRightP" : -1.0, - "xBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "xBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + "yBCRight" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 } }, - "yBCLeft" : "IsothermalWall", - "yBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCLeftP" : -1.0, - "yBCLeftHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "yBCRight" : "IsothermalWall", - "yBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "yBCRightP" : -1.0, - "yBCRightHeat" : { - "type" : "Constant", - "temperature" : 300.0 - }, - "yBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCLeft" : "Periodic", - "zBCLeftInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCLeftP" : 0.0, - "zBCLeftHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCLeftMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - }, - "zBCRight" : "Periodic", - "zBCRightInflowProfile" : { - "type" : "Constant", - "velocity" : [0.0, 0.0, 0.0] - }, - "zBCRightP" : 0.0, - "zBCRightHeat" : { - "type" : "Constant", - "temperature" : -1.0 - }, - "zBCRightMixture" : { - "type" : "Constant", - "Mixture" : { - "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] - } - } + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } }, "Flow" : { @@ -146,13 +68,11 @@ "gasConstant" : 287.15, "gamma" : 1.4, "prandtl" : 0.70, - "viscosityModel" : "PowerLaw", - "constantVisc" : -1.0, - "powerlawViscRef" : 1.716e-5, - "powerlawTempRef" : 273.0, - "sutherlandViscRef" : -1.0, - "sutherlandTempRef" : -1.0, - "sutherlandSRef" : -1.0, + "viscosityModel" : { + "type" : "PowerLaw", + "ViscRef" : 1.716e-5, + "TempRef" : 273.0 + }, "initCase" : "ChannelFlow", "restartDir" : "", "initParams" : [1.01325e5, 300.0, 1041.8382791969202, 0.10, 0.01], diff --git a/testcases/scalingTest/WS/post.py b/testcases/scalingTest/WS/post.py index 5370dde..58a00f8 100644 --- a/testcases/scalingTest/WS/post.py +++ b/testcases/scalingTest/WS/post.py @@ -32,7 +32,7 @@ def postFile(Dir): nodes = [] wt = [] for i in range(0,args.num_times): - nodes.append(2**i) + nodes.append(int(2**i)) wt.append(postFile(args.baseDir + "/" + str(nodes[i]))) scale = wt[0] diff --git a/testcases/scalingTest/WS/scale_up.py b/testcases/scalingTest/WS/scale_up.py index f76de7f..bb71d62 100755 --- a/testcases/scalingTest/WS/scale_up.py +++ b/testcases/scalingTest/WS/scale_up.py @@ -22,7 +22,7 @@ # Scale up for i in range(0,args.num_times): - nodes = config["Mapping"]["tiles"][0]/config["Mapping"]["tilesPerRank"][0] + nodes = int(config["Mapping"]["tiles"][0]/config["Mapping"]["tilesPerRank"][0]) with open(baseDir + "/" + str(nodes) + ".json", "w") as fout: json.dump(config, fout, indent=3) diff --git a/unitTests/cflTest/Makefile b/unitTests/cflTest/Makefile new file mode 100644 index 0000000..20adb33 --- /dev/null +++ b/unitTests/cflTest/Makefile @@ -0,0 +1,89 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MODULES= $(HTR_DIR)/src/ConstPropMix.rg \ + $(HTR_DIR)/src/prometeo_cfl.rg + +default: cflTest.exec + +clean: + $(RM) *.exec *.o + +cflTest.exec: cflTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +cflTest.o: cflTest.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) cflTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg + diff --git a/unitTests/cflTest/cflTest.rg b/unitTests/cflTest/cflTest.rg new file mode 100644 index 0000000..4a21296 --- /dev/null +++ b/unitTests/cflTest/cflTest.rg @@ -0,0 +1,99 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' + +local Config = SCHEMA.Config + +MIX = (require "ConstPropMix")(SCHEMA) +local nSpec = MIX.nSpec + +local struct Fluid_columns { + -- Grid point + cellWidth : double[3]; + -- Primitive variables + temperature : double; + MolarFracs : double[nSpec]; + velocity : double[3]; + -- Properties + rho : double; + mu : double; + lam : double; + Di : double[nSpec]; + SoS : double; +} + +--External modules +local CFL = (require 'prometeo_cfl')(MIX, Fluid_columns) + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid) +do + fill(Fluid.cellWidth, array(1.0, 1.0, 1.0)) + fill(Fluid.temperature, 0.0) + fill(Fluid.MolarFracs, [UTIL.mkArrayConstant(nSpec, rexpr 1.0 end)]) + fill(Fluid.velocity, array(0.0, 0.0, 0.0)) + fill(Fluid.rho, 1.0) + fill(Fluid.mu, 0.0) + fill(Fluid.lam, 0.0) + fill(Fluid.Di, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Fluid.SoS, 0.0) +end + +task main() + + -- Init the mixture + var config : Config + config.Flow.gasConstant = 1.0 + config.Flow.gamma = 1.4 + + var Mix = MIX.InitMixture(config) + + -- Define the domain + var is_Fluid = ispace(int3d, {1, 1, 1}) + var Fluid = region(is_Fluid, Fluid_columns) + + InitializeCell(Fluid) + + -- Test acustic cfl + fill(Fluid.velocity, array(1.0, 1.0, 1.0)) + fill(Fluid.SoS, 10.0) + var s = CFL.CalculateMaxSpectralRadius(Fluid, Mix) + regentlib.assert(fabs(s/11.0 - 1.0) < 1e-3, "cflTest: ERROR in acustic cfl calculation") + fill(Fluid.velocity, array(0.0, 0.0, 0.0)) + + -- Test momentum diffusion cfl + fill(Fluid.mu, 10.0) + s = CFL.CalculateMaxSpectralRadius(Fluid, Mix) + regentlib.assert(fabs(s/40.0 - 1.0) < 1e-3, "cflTest: ERROR in momentum diffusion cfl calculation") + fill(Fluid.mu, 0.0) + + -- Test energy diffusion cfl + fill(Fluid.lam, 10.0) + s = CFL.CalculateMaxSpectralRadius(Fluid, Mix) + regentlib.assert(fabs(s/11.42857 - 1.0) < 1e-3, "cflTest: ERROR in energy diffusion cfl calculation") + fill(Fluid.lam, 0.0) + + -- Test species diffusion cfl + fill(Fluid.Di, [UTIL.mkArrayConstant(nSpec, rexpr 10.0 end)]) + s = CFL.CalculateMaxSpectralRadius(Fluid, Mix) + regentlib.assert(fabs(s/40.0 - 1.0) < 1e-3, "cflTest: ERROR in species diffusion cfl calculation") + fill(Fluid.Di, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + + __fence(__execution, __block) + + C.printf("cflTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "cflTest.o", "object") diff --git a/unitTests/chemTest/Makefile b/unitTests/chemTest/Makefile new file mode 100644 index 0000000..ef9a7a8 --- /dev/null +++ b/unitTests/chemTest/Makefile @@ -0,0 +1,89 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MODULES= $(HTR_DIR)/src/AirMix.rg \ + $(HTR_DIR)/src/prometeo_chem.rg + +default: chemTest.exec + +clean: + $(RM) *.exec *.o + +chemTest.exec: chemTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +chemTest.o: chemTest.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) chemTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg + diff --git a/unitTests/chemTest/chemTest.rg b/unitTests/chemTest/chemTest.rg new file mode 100644 index 0000000..4488d67 --- /dev/null +++ b/unitTests/chemTest/chemTest.rg @@ -0,0 +1,109 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' + +local Config = SCHEMA.Config + +MIX = (require "AirMix")(SCHEMA) +local nSpec = MIX.nSpec +local nEq = nSpec+4 + +local struct Fluid_columns { + -- Primitive variables + pressure : double; + temperature : double; + MolarFracs : double[nSpec]; + velocity : double[3]; + -- Properties + rho : double; + -- Conserved varaibles + Conserved : double[nEq]; + Conserved_t : double[nEq]; + Conserved_t_old : double[nEq]; +} + +--External modules +local CHEM = (require 'prometeo_chem')(SCHEMA,MIX, Fluid_columns, true) + +local R = rexpr 8.3144598 end +local P = rexpr 101325.0 end +local T = rexpr 5000.0 end +local Yi = rexpr array(0.78, 0.22, 1.0e-60, 1.0e-60, 1.0e-60) end +local Eprod = rexpr array(-1.658328e-01,-1.445940e+03, 1.332770e-54, 1.658328e-01, 1.445940e+03, 0.0, 0.0, 0.0, 0.0) end +local Cres = rexpr array( 5.460212e-02, 1.296359e-02, 2.994386e-04, 1.502734e-05, 2.321006e-03, 0.0, 0.0, 0.0, 3.141423e+05) end + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns), Mix : MIX.Mixture) +where + writes(Fluid) +do + var MixW = MIX.GetMolarWeightFromYi([Yi], Mix) + var Xi = MIX.GetMolarFractions(MixW, [Yi], Mix) + var e = MIX.GetInternalEnergy([T], [Yi], Mix) + var rho = MIX.GetRho([P], [T], MixW, Mix) + fill(Fluid.pressure, [P]) + fill(Fluid.temperature, [T]) + fill(Fluid.MolarFracs, Xi) + fill(Fluid.velocity, array(0.0, 0.0, 0.0)) + fill(Fluid.rho, rho) + fill(Fluid.Conserved, array(rho*[Yi][0], + rho*[Yi][1], + rho*[Yi][2], + rho*[Yi][3], + rho*[Yi][4], + 0.0, + 0.0, + 0.0, + rho*e)) + fill(Fluid.Conserved_t, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) + fill(Fluid.Conserved_t_old, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) +end + +task main() + -- Init the mixture + var config : Config + var Mix = MIX.InitMixture(config) + + -- Define the domain + var is_Fluid = ispace(int3d, {1, 1, 1}) + var Fluid = region(is_Fluid, Fluid_columns) + + InitializeCell(Fluid, Mix) + + -- Test explicit chem advancing + CHEM.AddChemistrySources(Fluid, Fluid, Mix) + for c in Fluid do + for i = 0, nEq do + var err = Fluid[c].Conserved_t[i] - [Eprod][i] + if ( [Eprod][i] ~= 0) then err /= [Eprod][i] end + regentlib.assert(fabs(err) < 1e-5, "chemTest: ERROR in explicit chem advancing") + end + end + + -- Test implicit chem advancing + CHEM.UpdateChemistry(Fluid, Fluid, 1e-6, Mix) + + for c in Fluid do + for i = 0, nEq do + var err = Fluid[c].Conserved[i] - [Cres][i] + if ([Cres][i] ~= 0) then err /= [Cres][i] end + regentlib.assert(fabs(err) < 1e-5, "chemTest: ERROR in implicit chem advancing") + end + end + + __fence(__execution, __block) + + C.printf("chemTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "chemTest.o", "object") diff --git a/unitTests/configTest/Makefile b/unitTests/configTest/Makefile new file mode 100644 index 0000000..30bf87f --- /dev/null +++ b/unitTests/configTest/Makefile @@ -0,0 +1,81 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +default: configTest.exec + +clean: + $(RM) *.exec *.o + +configTest.exec: configTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +configTest.o: configTest.rg $(HTR_DIR)/src/config_schema.h + $(REGENT) configTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h : $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o diff --git a/unitTests/configTest/configTest.rg b/unitTests/configTest/configTest.rg new file mode 100644 index 0000000..f2a3713 --- /dev/null +++ b/unitTests/configTest/configTest.rg @@ -0,0 +1,95 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local SCHEMA = terralib.includec("../../src/config_schema.h") +local Config = SCHEMA.Config + +function testMixture(fl, name) + return rquote + regentlib.assert([fl].Species.length == 1, ["configTest: ERROR on "..name..".Species.length"]) + regentlib.assert(C.strcmp([fl].Species.values[0].Name, "Mix") == 0, ["configTest: ERROR on "..name..".Species.values[0].Name"]) + regentlib.assert( [fl].Species.values[0].MolarFrac == 1.0, ["configTest: ERROR on "..name..".Species.values[0].MolarFrac"]) + end +end + +-- I do not know why but this inline reduces the compile time a lot! +__demand(__inline) +task check(config : Config) + -- Mapping section + regentlib.assert(config.Mapping.tiles[0] == 1, "configTest: ERROR on config.Mapping.tiles[0]") + regentlib.assert(config.Mapping.tiles[1] == 2, "configTest: ERROR on config.Mapping.tiles[1]") + regentlib.assert(config.Mapping.tiles[2] == 3, "configTest: ERROR on config.Mapping.tiles[2]") + regentlib.assert(config.Mapping.tilesPerRank[0] == 1, "configTest: ERROR on config.Mapping.tilesPerRank[0]") + regentlib.assert(config.Mapping.tilesPerRank[1] == 2, "configTest: ERROR on config.Mapping.tilesPerRank[1]") + regentlib.assert(config.Mapping.tilesPerRank[2] == 3, "configTest: ERROR on config.Mapping.tilesPerRank[2]") + regentlib.assert(config.Mapping.sampleId == -1, "configTest: ERROR on config.Mapping.sampleId") + regentlib.assert(C.strcmp(config.Mapping.outDir, "") == 0, "configTest: ERROR on config.Mapping.outDir") + regentlib.assert(config.Mapping.wallTime == 10000, "configTest: ERROR on config.Mapping.wallTime") + -- Grid section + regentlib.assert(config.Grid.xNum == 400, "configTest: ERROR on config.Grid.xNum") + regentlib.assert(config.Grid.yNum == 100, "configTest: ERROR on config.Grid.yNum") + regentlib.assert(config.Grid.zNum == 1, "configTest: ERROR on config.Grid.zNum") + regentlib.assert(config.Grid.origin[0] == 0.0, "configTest: ERROR on config.Grid.origin[0]") + regentlib.assert(config.Grid.origin[1] == 4.0, "configTest: ERROR on config.Grid.origin[1]") + regentlib.assert(config.Grid.origin[2] == 8.0, "configTest: ERROR on config.Grid.origin[2]") + regentlib.assert(config.Grid.xWidth == 1.0, "configTest: ERROR on config.Grid.xWidth") + regentlib.assert(config.Grid.yWidth == 0.5, "configTest: ERROR on config.Grid.yWidth") + regentlib.assert(config.Grid.zWidth == 0.1, "configTest: ERROR on config.Grid.zWidth") + regentlib.assert(config.Grid.xType == SCHEMA.GridType_TanhMinus, "configTest: ERROR on config.Mapping.xType") + regentlib.assert(config.Grid.yType == SCHEMA.GridType_TanhMinus, "configTest: ERROR on config.Mapping.yType") + regentlib.assert(config.Grid.zType == SCHEMA.GridType_Uniform, "configTest: ERROR on config.Mapping.zType") + regentlib.assert(config.Grid.xStretching == 0.9, "configTest: ERROR on config.Grid.xStretching") + regentlib.assert(config.Grid.yStretching == 0.9, "configTest: ERROR on config.Grid.yStretching") + regentlib.assert(config.Grid.zStretching == 1.0, "configTest: ERROR on config.Grid.zStretching") + -- Integrator section + regentlib.assert(config.Integrator.startIter == 0, "configTest: ERROR on config.Integrator.startIter") + regentlib.assert(config.Integrator.startTime == 0.0, "configTest: ERROR on config.Integrator.startTime") + regentlib.assert(config.Integrator.resetTime == false, "configTest: ERROR on config.Integrator.resetTime") + regentlib.assert(config.Integrator.maxIter == 200000, "configTest: ERROR on config.Integrator.maxIter") + regentlib.assert(config.Integrator.maxTime == 20.0, "configTest: ERROR on config.Integrator.maxTime") + regentlib.assert(config.Integrator.cfl == 0.9, "configTest: ERROR on config.Integrator.cfl") + regentlib.assert(config.Integrator.fixedDeltaTime == 4.0e-3, "configTest: ERROR on config.Integrator.fixedDeltaTime") + -- Flow section + regentlib.assert(C.strcmp(config.Flow.mixture, "ConstPropMix") == 0, "configTest: ERROR on config.Flow.mixture") + regentlib.assert(config.Flow.gasConstant == 287.15, "configTest: ERROR on config.Flow.gasConstant") + regentlib.assert(config.Flow.gamma == 1.4, "configTest: ERROR on config.Flow.gamma") + regentlib.assert(config.Flow.prandtl == 0.71, "configTest: ERROR on config.Flow.prandtl") + regentlib.assert(config.Flow.viscosityModel.type == SCHEMA.ViscosityModel_Constant, "configTest: ERROR on config.Grid.viscosityModel") + regentlib.assert(config.Flow.viscosityModel.u.Constant.Visc == 5.0e-3, "configTest: ERROR on config.Flow.constantVisc") + regentlib.assert(config.Flow.initCase == SCHEMA.FlowInitCase_Uniform, "configTest: ERROR on config.Flow.initCase") + regentlib.assert(C.strcmp(config.Flow.restartDir, "restartDir") == 0, "configTest: ERROR on config.Flow.restartDir"); + [testMixture( rexpr config.Flow.initMixture end, "config.Flow.initMixture")]; + regentlib.assert(config.Flow.initParams[0] == 1.01325e5, "configTest: ERROR on config.Flow.initParams[0]") + regentlib.assert(config.Flow.initParams[1] == 300.0, "configTest: ERROR on config.Flow.initParams[1]") + regentlib.assert(config.Flow.initParams[2] == 10.0, "configTest: ERROR on config.Flow.initParams[2]") + regentlib.assert(config.Flow.initParams[3] == 20.0, "configTest: ERROR on config.Flow.initParams[3]") + regentlib.assert(config.Flow.initParams[4] == 30.0, "configTest: ERROR on config.Flow.initParams[4]") + regentlib.assert(config.Flow.resetMixture == false, "configTest: ERROR on config.Flow.resetMixture") + regentlib.assert(config.Flow.bodyForce[0] == 1.0, "configTest: ERROR on config.Flow.bodyForce[0]") + regentlib.assert(config.Flow.bodyForce[1] == 2.0, "configTest: ERROR on config.Flow.bodyForce[1]") + regentlib.assert(config.Flow.bodyForce[2] == 3.0, "configTest: ERROR on config.Flow.bodyForce[2]") + regentlib.assert(config.Flow.turbForcing.type == SCHEMA.TurbForcingModel_CHANNEL, "configTest: ERROR on config.Flow.turbForcing.type") + regentlib.assert(config.Flow.turbForcing.u.CHANNEL.Forcing == 1000.0, "configTest: ERROR on config.Flow.turbForcing.u.CHANNEL.Forcing") + regentlib.assert(config.Flow.turbForcing.u.CHANNEL.RhoUbulk == 20.0, "configTest: ERROR on config.Flow.turbForcing.u.CHANNEL.RhoUbulk") + -- IO section + regentlib.assert(config.IO.wrtRestart == true, "configTest: ERROR on config.IO.wrtRestart") + regentlib.assert(config.IO.restartEveryTimeSteps == 10000, "configTest: ERROR on config.IO.restartEveryTimeSteps") + regentlib.assert(config.IO.AveragesSamplingInterval == 10, "configTest: ERROR on config.IO.AveragesSamplingInterval") + return 1 +end + +task main() + var config : Config + SCHEMA.parse_Config(&config, "test.json") + var _ = check(config) + C.printf("configTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "configTest.o", "object") diff --git a/unitTests/configTest/test.json b/unitTests/configTest/test.json new file mode 100644 index 0000000..1dba4b4 --- /dev/null +++ b/unitTests/configTest/test.json @@ -0,0 +1,110 @@ +{ + "Mapping" : { + "tiles" : [1,2,3], + "tilesPerRank" : [1,2,3], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 400, + "yNum" : 100, + "zNum" : 1, + "origin" : [0.0, 4.0, 8.0], + "xWidth" : 1.0, + "yWidth" : 0.5, + "zWidth" : 0.1, + "xType" : "TanhMinus", + "yType" : "TanhMinus", + "zType" : "Uniform", + "xStretching" : 0.9, + "yStretching" : 0.9, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 200000, + "maxTime" : 20.0, + "cfl" : 0.9, + "fixedDeltaTime" : 4.0e-3, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { + "type" : "NSCBC_Inflow", + "VelocityProfile" : { + "type" : "File", + "FileDir" : "InflowProfile" + }, + "P" : 1.01325e5, + "TemperatureProfile" : { + "type" : "File", + "FileDir" : "InflowProfile" + }, + "MixtureProfile" : { + "type" : "Constant", + "Mixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + } + } + }, + "xBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 + }, + "yBCLeft" : { + "type" : "IsothermalWall", + "TemperatureProfile" : { + "type" : "Constant", + "temperature" : 300.0 + } + }, + "yBCRight" : { + "type" : "NSCBC_Outflow", + "P" : 1.01325e5 + }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } + }, + + "Flow" : { + "mixture": "ConstPropMix", + "gasConstant" : 287.15, + "gamma" : 1.4, + "prandtl" : 0.71, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 5.0e-3 + }, + "initCase" : "Uniform", + "restartDir" : "restartDir", + "initParams" : [1.01325e5, 300.0, 10.0, 20.0, 30.0], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + }, + "bodyForce" : [1.0, 2.0, 3.0], + "turbForcing" : { + "type" : "CHANNEL", + "Forcing" : 1000.0, + "RhoUbulk" : 20.0 + + } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 10000, + "probes" : [], + "AveragesSamplingInterval": 10, + "ResetAverages": false, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } +} diff --git a/unitTests/geometryTest/Makefile b/unitTests/geometryTest/Makefile new file mode 100644 index 0000000..38f4e98 --- /dev/null +++ b/unitTests/geometryTest/Makefile @@ -0,0 +1,90 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MODULES= $(HTR_DIR)/src/prometeo_const.rg \ + $(HTR_DIR)/src/prometeo_macro.rg \ + $(HTR_DIR)/src/prometeo_grid.rg + +default: geometryTest.exec + +clean: + $(RM) *.exec *.o + +geometryTest.exec: geometryTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +geometryTest.o: geometryTest.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) geometryTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg + diff --git a/unitTests/geometryTest/geometryTest.rg b/unitTests/geometryTest/geometryTest.rg new file mode 100644 index 0000000..40579fb --- /dev/null +++ b/unitTests/geometryTest/geometryTest.rg @@ -0,0 +1,285 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local sqrt = regentlib.sqrt(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' + +local Config = SCHEMA.Config + +local struct Fluid_columns { + -- Grid point + centerCoordinates : double[3]; + cellWidth : double[3]; +} + +--External modules +local MACRO = require "prometeo_macro" +local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns) + +-- Test parameters +local Npx = 32 +local Npy = 32 +local Npz = 32 +local Nx = 2 +local Ny = 2 +local Nz = 2 +local xO = 0.0 +local yO = 0.0 +local zO = 0.0 +local xW = 1.0 +local yW = 1.0 +local zW = 1.0 + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid.centerCoordinates), + writes(Fluid.cellWidth) +do + fill(Fluid.centerCoordinates, array(0.0, 0.0, 0.0)) + fill(Fluid.cellWidth, array(0.0, 0.0, 0.0)) +end + +function runPeriodic() + + local task checkGeometry(Fluid : region(ispace(int3d), Fluid_columns), + Grid_xType : SCHEMA.GridType, Grid_yType : SCHEMA.GridType, Grid_zType : SCHEMA.GridType, + Grid_xStretching : double, Grid_yStretching : double, Grid_zStretching : double, + Grid_xBnum : int32, Grid_xNum : int32, Grid_xOrigin : double, Grid_xWidth : double, + Grid_yBnum : int32, Grid_yNum : int32, Grid_yOrigin : double, Grid_yWidth : double, + Grid_zBnum : int32, Grid_zNum : int32, Grid_zOrigin : double, Grid_zWidth : double) + where + reads(Fluid.centerCoordinates), + reads(Fluid.cellWidth) + do + regentlib.assert(Grid_xType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + regentlib.assert(Grid_yType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + regentlib.assert(Grid_zType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + for c in Fluid do + var x_exp = (c.x+0.5)/Grid_xNum*Grid_xWidth + Grid_xOrigin + var dx_exp = Grid_xWidth/Grid_xNum + regentlib.assert(fabs((Fluid[c].centerCoordinates[0]/(x_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry x coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[0]/(dx_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry dx") + + var y_exp = (c.y+0.5)/Grid_yNum*Grid_yWidth + Grid_yOrigin + var dy_exp = Grid_yWidth/Grid_yNum + regentlib.assert(fabs((Fluid[c].centerCoordinates[1]/(y_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry y coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[1]/(dy_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry dy") + + var z_exp = (c.z+0.5)/Grid_zNum*Grid_zWidth + Grid_zOrigin + var dz_exp = Grid_zWidth/Grid_zNum + regentlib.assert(fabs((Fluid[c].centerCoordinates[2]/(z_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry z coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[2]/(dz_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometry dz") + end + end + + return rquote + + -- No ghost cells + var xBnum = 0 + var yBnum = 0 + var zBnum = 0 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns); + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + end + + checkGeometry(Fluid, + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end +end + +function runBC() + + local task checkGeometry(Fluid : region(ispace(int3d), Fluid_columns), + Grid_xType : SCHEMA.GridType, Grid_yType : SCHEMA.GridType, Grid_zType : SCHEMA.GridType, + Grid_xStretching : double, Grid_yStretching : double, Grid_zStretching : double, + Grid_xBnum : int32, Grid_xNum : int32, Grid_xOrigin : double, Grid_xWidth : double, + Grid_yBnum : int32, Grid_yNum : int32, Grid_yOrigin : double, Grid_yWidth : double, + Grid_zBnum : int32, Grid_zNum : int32, Grid_zOrigin : double, Grid_zWidth : double) + where + reads(Fluid.centerCoordinates), + reads(Fluid.cellWidth) + do + regentlib.assert(Grid_xType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + regentlib.assert(Grid_yType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + regentlib.assert(Grid_zType == SCHEMA.GridType_Uniform, "geometryTest: only Uniform supported for now") + for c in Fluid do + + var xNegGhost = MACRO.is_xNegGhost(c, Grid_xBnum) + var xPosGhost = MACRO.is_xPosGhost(c, Grid_xBnum, Grid_xNum) + var yNegGhost = MACRO.is_yNegGhost(c, Grid_yBnum) + var yPosGhost = MACRO.is_yPosGhost(c, Grid_yBnum, Grid_yNum) + var zNegGhost = MACRO.is_zNegGhost(c, Grid_zBnum) + var zPosGhost = MACRO.is_zPosGhost(c, Grid_zBnum, Grid_zNum) + + + var dx_exp : double + var x_exp : double + var dy_exp : double + var y_exp : double + var dz_exp : double + var z_exp : double + + if xNegGhost then + dx_exp = Grid_xWidth/Grid_xNum + x_exp = Grid_xOrigin - 0.5*dx_exp + elseif xPosGhost then + dx_exp = Grid_xWidth/Grid_xNum + x_exp = Grid_xOrigin + Grid_xWidth + 0.5*dx_exp + else + dx_exp = Grid_xWidth/Grid_xNum + x_exp = (c.x-Grid_xBnum+0.5)/Grid_xNum*Grid_xWidth + Grid_xOrigin + end + + if yNegGhost then + dy_exp = Grid_yWidth/Grid_yNum + y_exp = Grid_yOrigin - 0.5*dy_exp + elseif yPosGhost then + dy_exp = Grid_yWidth/Grid_yNum + y_exp = Grid_yOrigin + Grid_yWidth + 0.5*dy_exp + else + dy_exp = Grid_yWidth/Grid_yNum + y_exp = (c.y-Grid_yBnum+0.5)/Grid_yNum*Grid_yWidth + Grid_yOrigin + end + + if zNegGhost then + dz_exp = Grid_zWidth/Grid_zNum + z_exp = Grid_zOrigin - 0.5*dz_exp + elseif zPosGhost then + dz_exp = Grid_zWidth/Grid_zNum + z_exp = Grid_zOrigin + Grid_zWidth + 0.5*dz_exp + else + dz_exp = Grid_zWidth/Grid_zNum + z_exp = (c.z-Grid_zBnum+0.5)/Grid_zNum*Grid_zWidth + Grid_zOrigin + end + + regentlib.assert(fabs((Fluid[c].centerCoordinates[0]/(x_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC x coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[0]/(dx_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC dx") + + regentlib.assert(fabs((Fluid[c].centerCoordinates[1]/(y_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC y coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[1]/(dy_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC dy") + + + regentlib.assert(fabs((Fluid[c].centerCoordinates[2]/(z_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC z coordinate") + regentlib.assert(fabs((Fluid[c].cellWidth[2]/(dz_exp)) - 1.0) < 1e-3, "geometryTest: ERROR in checkGeometryBC dz") + + end + end + + return rquote + + -- No ghost cells + var xBnum = 1 + var yBnum = 1 + var zBnum = 1 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns); + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGhostGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + end + + checkGeometry(Fluid, + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + + end +end + +task main() + -- Start with a periodic case + [runPeriodic()]; + + -- Start with a Staggered bc case + [runBC()]; + + __fence(__execution, __block) + + C.printf("geometryTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "geometryTest.o", "object") diff --git a/unitTests/hdfTest/Makefile b/unitTests/hdfTest/Makefile new file mode 100644 index 0000000..0b1450e --- /dev/null +++ b/unitTests/hdfTest/Makefile @@ -0,0 +1,79 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +default: hdfTest.exec + +clean: + $(RM) *.exec *.o + +hdfTest.exec: hdfTest.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +hdfTest.o: hdfTest.rg $(HTR_DIR)/src/hdf_helper.rg $(HTR_DIR)/src/util-desugared.rg + $(REGENT) hdfTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg diff --git a/unitTests/hdfTest/hdfTest.rg b/unitTests/hdfTest/hdfTest.rg new file mode 100644 index 0000000..daa55f8 --- /dev/null +++ b/unitTests/hdfTest/hdfTest.rg @@ -0,0 +1,115 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local UTIL = require 'util-desugared' + +local struct columns { + a : double; + b : double[3]; +} + +local IOVars = terralib.newlist({ + "a", + "b" +}) + +local NP = 32 +local NT = 2 + +local HDF = (require 'hdf_helper')(int3d, int3d, columns, + IOVars, + {timeStep=int,simTime=double}, + {}) + +local __demand(__inline) +task drand48_r(rngState : &C.drand48_data) + var res : double + C.drand48_r(rngState, &res) + return res +end + +task init(r0 : region(ispace(int3d), columns), + r1 : region(ispace(int3d), columns)) +where + writes(r0.[IOVars]), + writes(r1.[IOVars]) +do + var rngState : C.drand48_data + C.srand48_r(C.legion_get_current_time_in_nanos(), &rngState) + for c in r0 do + var val1 = drand48_r(&rngState) + var val2 = array(drand48_r(&rngState), drand48_r(&rngState), drand48_r(&rngState)) + r0[c].a = val1 + r1[c].a = val1 + r0[c].b = val2 + r1[c].b = val2 + end +end + +task check(r0 : region(ispace(int3d), columns), + r1 : region(ispace(int3d), columns)) +where + reads(r0.[IOVars]), + reads(r1.[IOVars]) +do + for c in r0 do + regentlib.assert(r0[c].a == r1[c].a, "mathUtilsTest: ERROR on region") + regentlib.assert(r0[c].b[0] == r1[c].b[0], "mathUtilsTest: ERROR on region") + regentlib.assert(r0[c].b[1] == r1[c].b[1], "mathUtilsTest: ERROR on region") + regentlib.assert(r0[c].b[2] == r1[c].b[2], "mathUtilsTest: ERROR on region") + end +end + + +task main() + + var r0 = region(ispace(int3d,{NP,NP,NP}), columns) + var r1 = region(ispace(int3d,{NP,NP,NP}), columns) + var r1_copy = region(ispace(int3d,{NP,NP,NP}), columns) + + var tiles = ispace(int3d, {NT,NT,NT}) + var p_r1 = + [UTIL.mkPartitionByTile(int3d, int3d, columns, "p_All")] + (r1, tiles, int3d{0,0,0}, int3d{0,0,0}) + var p_r1_copy = + [UTIL.mkPartitionByTile(int3d, int3d, columns, "p_All")] + (r1_copy, tiles, int3d{0,0,0}, int3d{0,0,0}) + + init(r0, r1) + var timeStep = 12345 + var simTime = 123.4567 + + var dirname = [&int8](C.malloc(256)) + C.snprintf(dirname, 256, '.') + var _1 : int + _1 = HDF.dump( _1, tiles, dirname, r1, r1_copy, p_r1, p_r1_copy) + _1 = HDF.write.timeStep( _1, tiles, dirname, r1, p_r1, timeStep) + _1 = HDF.write.simTime( _1, tiles, dirname, r1, p_r1, simTime) + + __fence(__execution, __block) + + fill(r1.a, 0.0) + fill(r1.b, array(0.0, 0.0, 0.0)) + + timeStep = HDF.read.timeStep(0, tiles, dirname, r1, p_r1) + simTime = HDF.read.simTime( 0, tiles, dirname, r1, p_r1) + HDF.load(0, tiles, dirname, r1, r1_copy, p_r1, p_r1_copy) + + regentlib.assert(timeStep == 12345, "mathUtilsTest: ERROR on timeStep") + regentlib.assert(simTime == 123.4567, "mathUtilsTest: ERROR on simTime") + check(r0, r1) + + __fence(__execution, __block) + + C.printf("hdfTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "hdfTest.o", "object") diff --git a/unitTests/mathUtilsTest/Makefile b/unitTests/mathUtilsTest/Makefile new file mode 100644 index 0000000..fef3111 --- /dev/null +++ b/unitTests/mathUtilsTest/Makefile @@ -0,0 +1,76 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +default: mathUtilsTest.exec + +clean: + $(RM) *.exec *.o + +mathUtilsTest.exec: mathUtilsTest.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +mathUtilsTest.o: mathUtilsTest.rg $(HTR_DIR)/src/math_utils.rg + $(REGENT) mathUtilsTest.rg $(REGENT_FLAGS) diff --git a/unitTests/mathUtilsTest/mathUtilsTest.rg b/unitTests/mathUtilsTest/mathUtilsTest.rg new file mode 100644 index 0000000..854103d --- /dev/null +++ b/unitTests/mathUtilsTest/mathUtilsTest.rg @@ -0,0 +1,143 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local MATH = require 'math_utils' + +task checkMatMul() + var A = array( 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0) + var b = array(1.0, 2.0, 3.0) + var c = [MATH.mkMatMul(3)](b,A) + regentlib.assert(c[0] == b[0], "mathUtilsTest: ERROR in checkMatMul") + regentlib.assert(c[1] == b[1], "mathUtilsTest: ERROR in checkMatMul") + regentlib.assert(c[2] == b[2], "mathUtilsTest: ERROR in checkMatMul") +end + +LUdec, ludcmp, lubksb = unpack(MATH.mkLUdec(3)) +task checkLUdec() + var LU : LUdec + LU.A = array(4.0, 3.0, 0.0, + 3.0, 4.0,-1.0, + 0.0,-1.0, 4.0) + LU = ludcmp(LU) + + var b = array(24.0, 30.0,-24.0) + var x = lubksb(LU, b) + regentlib.assert(fabs(1.0 - x[0]/( 3.0)) < 1e-12, "mathUtilsTest: ERROR in checkLUdec") + regentlib.assert(fabs(1.0 - x[1]/( 4.0)) < 1e-12, "mathUtilsTest: ERROR in checkLUdec") + regentlib.assert(fabs(1.0 - x[2]/(-5.0)) < 1e-12, "mathUtilsTest: ERROR in checkLUdec") +end + +--task checkInverseMatrix() +-- var A = array(4.0, 3.0, 0.0, +-- 3.0, 4.0,-1.0, +-- 0.0,-1.0, 4.0) +-- var Ainv = [MATH.mkInverseMatrix(3)](A) +-- regentlib.assert(fabs(1.0 - Ainv[0]/( 0.6250000000000000)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[1]/(-0.5000000000000000)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[2]/(-0.1250000000000000)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[3]/(-0.5000000000000000)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[4]/( 0.6666666666666667)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[5]/( 0.1666666666666667)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[6]/(-0.1250000000000000)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[7]/( 0.1666666666666667)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +-- regentlib.assert(fabs(1.0 - Ainv[8]/( 0.2916666666666667)) < 1e-12, "mathUtilsTest: ERROR in checkInverseMatrix") +--end + +task checkReconCoeff() + var xf = array(-2.0, -1.0, 0.0, 1.0, 2.0) + var c = [MATH.mkReconCoeff(4)](xf, 0.0) + regentlib.assert(fabs(1.0 - c[0]/(-1.0/12)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeff") + regentlib.assert(fabs(1.0 - c[1]/( 7.0/12)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeff") + regentlib.assert(fabs(1.0 - c[2]/( 7.0/12)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeff") + regentlib.assert(fabs(1.0 - c[3]/(-1.0/12)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeff") +end + +task checkReconCoeffLeftBC() + var xf = array(-1.0, 0.0, 1.0, 2.0) + var c = [MATH.mkReconCoeffLeftBC(4)](xf, 0.0) + regentlib.assert(fabs(1.0 - c[0]/(-12.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffLeftBC") + regentlib.assert(fabs(1.0 - c[1]/( 34.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffLeftBC") + regentlib.assert(fabs(1.0 - c[2]/( 16.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffLeftBC") + regentlib.assert(fabs(1.0 - c[3]/(- 2.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffLeftBC") +end + +task checkReconCoeffRightBC() + var xf = array(-2.0, -1.0, 0.0, 1.0) + var c = [MATH.mkReconCoeffRightBC(4)](xf, 0.0) + regentlib.assert(fabs(1.0 - c[0]/(- 2.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffRightBC") + regentlib.assert(fabs(1.0 - c[1]/( 16.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffRightBC") + regentlib.assert(fabs(1.0 - c[2]/( 34.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffRightBC") + regentlib.assert(fabs(1.0 - c[3]/(-12.0/36)) < 1e-12, "mathUtilsTest: ERROR in checkReconCoeffRightBC") +end + +local struct columns { + Conserved : double[3]; +} + +local struct dummy { + aa : int; +} + +local ImplicitVars = terralib.newlist({ + "Conserved" +}) + +-- RHS function for the implicit solver +local __demand(__inline) +task func( r : region(ispace(int3d), columns), + c : int3d, + dum : dummy) +where + reads writes(r.[ImplicitVars]) +do + return array(-0.013* r[c].Conserved[0] - 1000.0*r[c].Conserved[0]*r[c].Conserved[2], + -2500.0*r[c].Conserved[1]*r[c].Conserved[2], + -0.013* r[c].Conserved[0] - 1000.0*r[c].Conserved[0]*r[c].Conserved[2] - 2500.0*r[c].Conserved[1]*r[c].Conserved[2]) +end + +task checkRosenbrock() + var dum : dummy + var r = region(ispace(int3d,{1,1,1}), columns) + fill(r.Conserved, array(1.0, 1.0, 0.0)) + for c in r do + var err = [MATH.mkRosenbrock(3, columns, ImplicitVars, "Conserved", dummy, func)] + (r, c, 1.0e-3, 25.0, dum) + regentlib.assert(err==0, "mathUtilsTest: ERROR in Rosenbrock returned an error") + regentlib.assert(fabs(1.0 - r[c].Conserved[0]/( 7.818640e-01)) < 1e-6, "mathUtilsTest: ERROR in checkRosenbrock") + regentlib.assert(fabs(1.0 - r[c].Conserved[1]/( 1.218133e+00)) < 1e-6, "mathUtilsTest: ERROR in checkRosenbrock") + regentlib.assert(fabs(1.0 - r[c].Conserved[2]/(-2.655799e-06)) < 1e-6, "mathUtilsTest: ERROR in checkRosenbrock") + end +end + +task main() + -- Check MatMul + checkMatMul() + -- Check LUdec + checkLUdec() +-- -- Check InverseMatrix +-- checkInverseMatrix() + -- Check ReconCoeff + checkReconCoeff() + -- Check ReconCoeffLeftBC + checkReconCoeffLeftBC() + -- Check ReconCoeffRightBC + checkReconCoeffRightBC() + -- Check Rosenbrock + checkRosenbrock() + + __fence(__execution, __block) + + C.printf("mathUtilsTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "mathUtilsTest.o", "object") diff --git a/unitTests/metricTest/Makefile b/unitTests/metricTest/Makefile new file mode 100644 index 0000000..fabcee4 --- /dev/null +++ b/unitTests/metricTest/Makefile @@ -0,0 +1,103 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 #-fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MODULES= $(HTR_DIR)/src/prometeo_const.rg \ + $(HTR_DIR)/src/prometeo_macro.rg \ + $(HTR_DIR)/src/prometeo_grid.rg \ + $(HTR_DIR)/src/prometeo_metric.rg + +default: metricTest_Periodic.exec metricTest_Staggered.exec metricTest_Collocated.exec + +clean: + $(RM) *.exec *.o + +metricTest_Collocated.exec: metricTest_Collocated.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +metricTest_Collocated.o: metricTest_Collocated.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) metricTest_Collocated.rg $(REGENT_FLAGS) + +metricTest_Staggered.exec: metricTest_Staggered.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +metricTest_Staggered.o: metricTest_Staggered.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) metricTest_Staggered.rg $(REGENT_FLAGS) + +metricTest_Periodic.exec: metricTest_Periodic.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +metricTest_Periodic.o: metricTest_Periodic.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) metricTest_Periodic.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg + diff --git a/unitTests/metricTest/metricTest_Collocated.rg b/unitTests/metricTest/metricTest_Collocated.rg new file mode 100644 index 0000000..37af95c --- /dev/null +++ b/unitTests/metricTest/metricTest_Collocated.rg @@ -0,0 +1,1004 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local sqrt = regentlib.sqrt(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' +local CONST = require "prometeo_const" + +-- Stencil indices +local Stencil1 = CONST.Stencil1 +local Stencil2 = CONST.Stencil2 +local Stencil3 = CONST.Stencil3 +local Stencil4 = CONST.Stencil4 +local nStencils = CONST.nStencils + +local struct Fluid_columns { + -- Grid point + centerCoordinates : double[3]; + cellWidth : double[3]; + -- Face reconstruction operators [c-2, ..., c+3] + reconXFacePlus : double[nStencils*6]; + reconYFacePlus : double[nStencils*6]; + reconZFacePlus : double[nStencils*6]; + reconXFaceMinus : double[nStencils*6]; + reconYFaceMinus : double[nStencils*6]; + reconZFaceMinus : double[nStencils*6]; + -- Blending coefficients to obtain sixth order reconstruction + TENOCoeffsXPlus : double[nStencils]; + TENOCoeffsYPlus : double[nStencils]; + TENOCoeffsZPlus : double[nStencils]; + TENOCoeffsXMinus : double[nStencils]; + TENOCoeffsYMinus : double[nStencils]; + TENOCoeffsZMinus : double[nStencils]; + -- Flags for modified reconstruction on BCs + BCStencilX : bool; + BCStencilY : bool; + BCStencilZ : bool; + -- Face interpolation operator [c, c+1] + interpXFace : double[2]; + interpYFace : double[2]; + interpZFace : double[2]; + -- Face derivative operator [c+1 - c] + derivXFace : double; + derivYFace : double; + derivZFace : double; + -- Cell center gradient operator [c - c-1, c+1 - c] + gradX : double[2]; + gradY : double[2]; + gradZ : double[2]; +} + +--External modules +local MACRO = require "prometeo_macro" +local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns) +local METRIC = (require 'prometeo_metric')(SCHEMA, Fluid_columns) + +-- Test parameters +local Npx = 32 +local Npy = 32 +local Npz = 32 +local Nx = 2 +local Ny = 2 +local Nz = 2 +local xO = 0.0 +local yO = 0.0 +local zO = 0.0 +local xW = 1.0 +local yW = 1.0 +local zW = 1.0 + +function checkInternal(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == false, ["metricTest: error in Internal Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + end +end + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid) +do + fill(Fluid.centerCoordinates, array(0.0, 0.0, 0.0)) + fill(Fluid.cellWidth, array(0.0, 0.0, 0.0)) + fill(Fluid.reconXFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconXFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.BCStencilX, false) + fill(Fluid.BCStencilY, false) + fill(Fluid.BCStencilZ, false) + fill(Fluid.interpXFace, array(0.0, 0.0)) + fill(Fluid.interpYFace, array(0.0, 0.0)) + fill(Fluid.interpZFace, array(0.0, 0.0)) + fill(Fluid.derivXFace, 0.0) + fill(Fluid.derivYFace, 0.0) + fill(Fluid.derivZFace, 0.0) + fill(Fluid.gradX, array(0.0, 0.0)) + fill(Fluid.gradY, array(0.0, 0.0)) + fill(Fluid.gradZ, array(0.0, 0.0)) +end + +local function checkLeft(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2] ) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3] ) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2] ) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1] ) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in Left Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir] ) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. grad]) + end +end + +local function checkLeftPlusOne(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in LeftPlusOne Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. grad]) + end +end + +local function checkRightMinusTwo(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(0.5 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in RightMinusTwo Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. grad]) + end +end + +local function checkRightMinusOne(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2] ) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3] ) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2] ) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1] ) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4] ) ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in RightMinusOne Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. grad]) + end +end + +local function checkRight(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == false, ["metricTest: error in Right Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir] ) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. grad]) + end +end + +local task checkMetric(Fluid : region(ispace(int3d), Fluid_columns)) +where +reads(Fluid.centerCoordinates), +reads(Fluid.cellWidth), +reads(Fluid.{reconXFacePlus, reconXFaceMinus}), +reads(Fluid.{reconYFacePlus, reconYFaceMinus}), +reads(Fluid.{reconZFacePlus, reconZFaceMinus}), +reads(Fluid.{TENOCoeffsXPlus, TENOCoeffsXMinus}), +reads(Fluid.{TENOCoeffsYPlus, TENOCoeffsYMinus}), +reads(Fluid.{TENOCoeffsZPlus, TENOCoeffsZMinus}), +reads(Fluid.{BCStencilX, BCStencilY, BCStencilZ}), +reads(Fluid.{interpXFace, interpYFace, interpZFace}), +reads(Fluid.{ derivXFace, derivYFace, derivZFace}), +reads(Fluid.{ gradX, gradY, gradZ}) + +do + for c in Fluid do + -- Check x-direction + if c.x == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx+1 then + [checkRight(rexpr Fluid end, rexpr c end, "x")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "x")]; + end + -- Check y-direction + if c.y == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy+1 then + [checkRight(rexpr Fluid end, rexpr c end, "y")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "y")]; + end + -- Check z-direction + if c.z == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz+1 then + [checkRight(rexpr Fluid end, rexpr c end, "z")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "z")]; + end + end +end + +task main() + + C.printf("metricTest_Collocated: run...") + + -- No ghost cells + var xBnum = 1 + var yBnum = 1 + var zBnum = 1 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns); + var Fluid_bounds = Fluid.bounds + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGhostGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + METRIC.InitializeMetric(Fluid, + Fluid_bounds, + xBnum, Npx, + yBnum, Npy, + zBnum, Npz); + + -- Enforce BCs on the metric + [METRIC.mkCorrectGhostMetric("x")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_NSCBC_Inflow, SCHEMA.FlowBC_NSCBC_Inflow, + xBnum, Npx); + [METRIC.mkCorrectGhostMetric("y")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_NSCBC_Inflow, SCHEMA.FlowBC_NSCBC_Inflow, + yBnum, Npy); + [METRIC.mkCorrectGhostMetric("z")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_NSCBC_Inflow, SCHEMA.FlowBC_NSCBC_Inflow, + zBnum, Npz); + + end + checkMetric(Fluid) + + __fence(__execution, __block) + + C.printf("metricTest_Collocated: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "metricTest_Collocated.o", "object") diff --git a/unitTests/metricTest/metricTest_Periodic.rg b/unitTests/metricTest/metricTest_Periodic.rg new file mode 100644 index 0000000..b918433 --- /dev/null +++ b/unitTests/metricTest/metricTest_Periodic.rg @@ -0,0 +1,320 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local sqrt = regentlib.sqrt(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' +local CONST = require "prometeo_const" + +-- Stencil indices +local Stencil1 = CONST.Stencil1 +local Stencil2 = CONST.Stencil2 +local Stencil3 = CONST.Stencil3 +local Stencil4 = CONST.Stencil4 +local nStencils = CONST.nStencils + +local struct Fluid_columns { + -- Grid point + centerCoordinates : double[3]; + cellWidth : double[3]; + -- Face reconstruction operators [c-2, ..., c+3] + reconXFacePlus : double[nStencils*6]; + reconYFacePlus : double[nStencils*6]; + reconZFacePlus : double[nStencils*6]; + reconXFaceMinus : double[nStencils*6]; + reconYFaceMinus : double[nStencils*6]; + reconZFaceMinus : double[nStencils*6]; + -- Blending coefficients to obtain sixth order reconstruction + TENOCoeffsXPlus : double[nStencils]; + TENOCoeffsYPlus : double[nStencils]; + TENOCoeffsZPlus : double[nStencils]; + TENOCoeffsXMinus : double[nStencils]; + TENOCoeffsYMinus : double[nStencils]; + TENOCoeffsZMinus : double[nStencils]; + -- Flags for modified reconstruction on BCs + BCStencilX : bool; + BCStencilY : bool; + BCStencilZ : bool; + -- Face interpolation operator [c, c+1] + interpXFace : double[2]; + interpYFace : double[2]; + interpZFace : double[2]; + -- Face derivative operator [c+1 - c] + derivXFace : double; + derivYFace : double; + derivZFace : double; + -- Cell center gradient operator [c - c-1, c+1 - c] + gradX : double[2]; + gradY : double[2]; + gradZ : double[2]; +} + +--External modules +local MACRO = require "prometeo_macro" +local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns) +local METRIC = (require 'prometeo_metric')(SCHEMA, Fluid_columns) + +-- Test parameters +local Npx = 32 +local Npy = 32 +local Npz = 32 +local Nx = 2 +local Ny = 2 +local Nz = 2 +local xO = 0.0 +local yO = 0.0 +local zO = 0.0 +local xW = 1.0 +local yW = 1.0 +local zW = 1.0 + +function checkInternal(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == false, ["metricTest: error in Internal Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + end +end + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid) +do + fill(Fluid.centerCoordinates, array(0.0, 0.0, 0.0)) + fill(Fluid.cellWidth, array(0.0, 0.0, 0.0)) + fill(Fluid.reconXFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconXFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.BCStencilX, false) + fill(Fluid.BCStencilY, false) + fill(Fluid.BCStencilZ, false) + fill(Fluid.interpXFace, array(0.0, 0.0)) + fill(Fluid.interpYFace, array(0.0, 0.0)) + fill(Fluid.interpZFace, array(0.0, 0.0)) + fill(Fluid.derivXFace, 0.0) + fill(Fluid.derivYFace, 0.0) + fill(Fluid.derivZFace, 0.0) + fill(Fluid.gradX, array(0.0, 0.0)) + fill(Fluid.gradY, array(0.0, 0.0)) + fill(Fluid.gradZ, array(0.0, 0.0)) +end + +__demand(__inline) +task checkMetric(Fluid : region(ispace(int3d), Fluid_columns)) +where +reads(Fluid.centerCoordinates), +reads(Fluid.cellWidth), +reads(Fluid.{reconXFacePlus, reconXFaceMinus}), +reads(Fluid.{reconYFacePlus, reconYFaceMinus}), +reads(Fluid.{reconZFacePlus, reconZFaceMinus}), +reads(Fluid.{TENOCoeffsXPlus, TENOCoeffsXMinus}), +reads(Fluid.{TENOCoeffsYPlus, TENOCoeffsYMinus}), +reads(Fluid.{TENOCoeffsZPlus, TENOCoeffsZMinus}), +reads(Fluid.{BCStencilX, BCStencilY, BCStencilZ}), +reads(Fluid.{interpXFace, interpYFace, interpZFace}), +reads(Fluid.{ derivXFace, derivYFace, derivZFace}), +reads(Fluid.{ gradX, gradY, gradZ}) + +do + for c in Fluid do + -- Check x-direction + [checkInternal(rexpr Fluid end, rexpr c end, "x")]; + -- Check y-direction + [checkInternal(rexpr Fluid end, rexpr c end, "y")]; + -- Check z-direction + [checkInternal(rexpr Fluid end, rexpr c end, "z")]; + end +end + +task main() + + C.printf("metricTest_Periodic: run...\n") + + -- No ghost cells + var xBnum = 0 + var yBnum = 0 + var zBnum = 0 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns) + var Fluid_bounds = Fluid.bounds + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + METRIC.InitializeMetric(Fluid, + Fluid_bounds, + xBnum, Npx, + yBnum, Npy, + zBnum, Npz) + + end + checkMetric(Fluid) + + __fence(__execution, __block) + + C.printf("metricTest_Periodic: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "metricTest_Periodic.o", "object") diff --git a/unitTests/metricTest/metricTest_Staggered.rg b/unitTests/metricTest/metricTest_Staggered.rg new file mode 100644 index 0000000..757a923 --- /dev/null +++ b/unitTests/metricTest/metricTest_Staggered.rg @@ -0,0 +1,1266 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local sqrt = regentlib.sqrt(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' +local CONST = require "prometeo_const" + +-- Stencil indices +local Stencil1 = CONST.Stencil1 +local Stencil2 = CONST.Stencil2 +local Stencil3 = CONST.Stencil3 +local Stencil4 = CONST.Stencil4 +local nStencils = CONST.nStencils + +local struct Fluid_columns { + -- Grid point + centerCoordinates : double[3]; + cellWidth : double[3]; + -- Face reconstruction operators [c-2, ..., c+3] + reconXFacePlus : double[nStencils*6]; + reconYFacePlus : double[nStencils*6]; + reconZFacePlus : double[nStencils*6]; + reconXFaceMinus : double[nStencils*6]; + reconYFaceMinus : double[nStencils*6]; + reconZFaceMinus : double[nStencils*6]; + -- Blending coefficients to obtain sixth order reconstruction + TENOCoeffsXPlus : double[nStencils]; + TENOCoeffsYPlus : double[nStencils]; + TENOCoeffsZPlus : double[nStencils]; + TENOCoeffsXMinus : double[nStencils]; + TENOCoeffsYMinus : double[nStencils]; + TENOCoeffsZMinus : double[nStencils]; + -- Flags for modified reconstruction on BCs + BCStencilX : bool; + BCStencilY : bool; + BCStencilZ : bool; + -- Face interpolation operator [c, c+1] + interpXFace : double[2]; + interpYFace : double[2]; + interpZFace : double[2]; + -- Face derivative operator [c+1 - c] + derivXFace : double; + derivYFace : double; + derivZFace : double; + -- Cell center gradient operator [c - c-1, c+1 - c] + gradX : double[2]; + gradY : double[2]; + gradZ : double[2]; +} + +--External modules +local MACRO = require "prometeo_macro" +local GRID = (require 'prometeo_grid')(SCHEMA, Fluid_columns) +local METRIC = (require 'prometeo_metric')(SCHEMA, Fluid_columns) + +-- Test parameters +local Npx = 32 +local Npy = 32 +local Npz = 32 +local Nx = 2 +local Ny = 2 +local Nz = 2 +local xO = 0.0 +local yO = 0.0 +local zO = 0.0 +local xW = 1.0 +local yW = 1.0 +local zW = 1.0 + +function checkInternal(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Internal Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == false, ["metricTest: error in Internal Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in Internal Metric on " .. grad]) + end +end + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid) +do + fill(Fluid.centerCoordinates, array(0.0, 0.0, 0.0)) + fill(Fluid.cellWidth, array(0.0, 0.0, 0.0)) + fill(Fluid.reconXFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFacePlus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconXFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconYFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.reconZFaceMinus, [UTIL.mkArrayConstant(nStencils*6, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZPlus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsXMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsYMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.TENOCoeffsZMinus, [UTIL.mkArrayConstant(nStencils, rexpr 0.0 end)]) + fill(Fluid.BCStencilX, false) + fill(Fluid.BCStencilY, false) + fill(Fluid.BCStencilZ, false) + fill(Fluid.interpXFace, array(0.0, 0.0)) + fill(Fluid.interpYFace, array(0.0, 0.0)) + fill(Fluid.interpZFace, array(0.0, 0.0)) + fill(Fluid.derivXFace, 0.0) + fill(Fluid.derivYFace, 0.0) + fill(Fluid.derivZFace, 0.0) + fill(Fluid.gradX, array(0.0, 0.0)) + fill(Fluid.gradY, array(0.0, 0.0)) + fill(Fluid.gradZ, array(0.0, 0.0)) +end + +local function checkLeft(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in Left Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in Left Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs(r[c].[interp][0] - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. interp]) + regentlib.assert(fabs(r[c].[interp][1] ) < 1e-8, ["metricTest: error in Left Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]*0.5) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0] ) ) < 1e-8, ["metricTest: error in Left Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*0.5) - 1.0) < 1e-3, ["metricTest: error in Left Metric on " .. grad]) + end +end + +local function checkLeftPlusOne(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-1.0 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/( 2.0 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2] ) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(7.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(8.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4] ) ) < 1e-8, ["metricTest: error in LeftPlusOne Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in LeftPlusOne Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir] ) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusOne Metric on " .. grad]) + end +end + +local function checkLeftPlusTwo(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 1.0 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-2.0 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/( 2.0 )) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 3.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-7.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(11.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 2.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in LeftPlusTwo Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/4.7000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/2.7000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/1.0000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/1.6000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/3.9000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/2.7000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/4.0000e-02) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/3.0000e-01) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in LeftPlusTwo Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in LeftPlusTwo Metric on " .. grad]) + end +end + +local function checkRightMinusThree(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 2.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(11.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-7.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 3.0/9.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/( 2.0 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-2.0 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 1.0 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusThree Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/3.9000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/2.7000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/4.0000e-02) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/3.0000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/4.7000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/2.7000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/1.0000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/1.6000e-01) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in RightMinusThree Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusThree Metric on " .. grad]) + end +end + +local function checkRightMinusTwo(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2] ) ) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3] ) - 1.0) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/( 2.0 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-1.0 )) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(7.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(8.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/16.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(2.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3] ) ) < 1e-8, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(1.0/4.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in RightMinusTwo Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusTwo Metric on " .. grad]) + end +end + +local function checkRightMinusOne(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil2*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil3*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + regentlib.assert(fabs(r[c].[reconPlus][Stencil4*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+1] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+2] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+3] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+4] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + regentlib.assert(fabs(r[c].[reconMinus][Stencil1*6+5] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == true, ["metricTest: error in RightMinusOne Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs(r[c].[interp][0] ) < 1e-8, ["metricTest: error in RightMinusOne Metric on " .. interp]) + regentlib.assert(fabs(r[c].[interp][1] - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]*0.5) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*2.0) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1]*r[c].cellWidth[dir] ) - 1.0) < 1e-3, ["metricTest: error in RightMinusOne Metric on " .. grad]) + end +end + +local function checkRight(r, c, sdir) + local dir + local reconPlus + local reconMinus + local TENOCoeffsPlus + local TENOCoeffsMinus + local BCStencil + local interp + local deriv + local grad + if sdir == "x" then + dir = 0 + reconPlus = "reconXFacePlus" + reconMinus = "reconXFaceMinus" + TENOCoeffsPlus = "TENOCoeffsXPlus" + TENOCoeffsMinus = "TENOCoeffsXMinus" + BCStencil = "BCStencilX" + interp = "interpXFace" + deriv = "derivXFace" + grad = "gradX" + elseif sdir == "y" then + dir = 1 + reconPlus = "reconYFacePlus" + reconMinus = "reconYFaceMinus" + TENOCoeffsPlus = "TENOCoeffsYPlus" + TENOCoeffsMinus = "TENOCoeffsYMinus" + BCStencil = "BCStencilY" + interp = "interpYFace" + deriv = "derivYFace" + grad = "gradY" + elseif sdir == "z" then + dir = 2 + reconPlus = "reconZFacePlus" + reconMinus = "reconZFaceMinus" + TENOCoeffsPlus = "TENOCoeffsZPlus" + TENOCoeffsMinus = "TENOCoeffsZMinus" + BCStencil = "BCStencilZ" + interp = "interpZFace" + deriv = "derivZFace" + grad = "gradZ" + end + return rquote + -- Face reconstruction operators + -- Plus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+0]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+1]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+2]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+3] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil3*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+2]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+3]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+4]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + regentlib.assert(fabs((r[c].[reconPlus][Stencil4*6+5]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconPlus]) + -- Minus side + -- Stencil1 + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+2]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+3]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+4]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil1*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil2 + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+1]/(-1.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+2]/( 5.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+3]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil2*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil3 + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+0] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+2] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+3]/(11.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+4]/(-7.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil3*6+5]/( 2.0/6.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + -- Stencil4 + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+0]/( 1.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+1]/(-5.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+2]/(13.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+3]/( 3.0/12.0))- 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+4] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + regentlib.assert(fabs((r[c].[reconMinus][Stencil4*6+5] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. reconMinus]) + -- TENO blending coefficients + -- Plus side + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + regentlib.assert(fabs((r[c].[TENOCoeffsPlus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsPlus]) + -- Minus side + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil1]/(9.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil2]/(6.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil3]/(1.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + regentlib.assert(fabs((r[c].[TENOCoeffsMinus][Stencil4]/(4.0/20.0)) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. TENOCoeffsMinus]) + -- BC flag + regentlib.assert(r[c].[BCStencil] == false, ["metricTest: error in Right Metric on " .. BCStencil]) + -- Face interpolation operator + regentlib.assert(fabs((r[c].[interp][0]*2.0) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. interp]) + regentlib.assert(fabs((r[c].[interp][1]*2.0) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. interp]) + -- Face derivative operator + regentlib.assert(fabs((r[c].[deriv]*r[c].cellWidth[dir]) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. deriv]) + -- Gradient operator + regentlib.assert(fabs((r[c].[grad][0]*r[c].cellWidth[dir]*0.5) - 1.0) < 1e-3, ["metricTest: error in Right Metric on " .. grad]) + regentlib.assert(fabs((r[c].[grad][1] ) ) < 1e-8, ["metricTest: error in Right Metric on " .. grad]) + end +end + +__demand(__inline) +task checkMetric(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.centerCoordinates), + reads(Fluid.cellWidth), + reads(Fluid.{reconXFacePlus, reconXFaceMinus}), + reads(Fluid.{reconYFacePlus, reconYFaceMinus}), + reads(Fluid.{reconZFacePlus, reconZFaceMinus}), + reads(Fluid.{TENOCoeffsXPlus, TENOCoeffsXMinus}), + reads(Fluid.{TENOCoeffsYPlus, TENOCoeffsYMinus}), + reads(Fluid.{TENOCoeffsZPlus, TENOCoeffsZMinus}), + reads(Fluid.{BCStencilX, BCStencilY, BCStencilZ}), + reads(Fluid.{interpXFace, interpYFace, interpZFace}), + reads(Fluid.{ derivXFace, derivYFace, derivZFace}), + reads(Fluid.{ gradX, gradY, gradZ}) +do + for c in Fluid do + -- Check x-direction + if c.x == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == 2 then + [checkLeftPlusTwo(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx-2 then + [checkRightMinusThree(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "x")]; + elseif c.x == Npx+1 then + [checkRight(rexpr Fluid end, rexpr c end, "x")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "x")]; + end + -- Check y-direction + if c.y == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == 2 then + [checkLeftPlusTwo(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy-2 then + [checkRightMinusThree(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "y")]; + elseif c.y == Npy+1 then + [checkRight(rexpr Fluid end, rexpr c end, "y")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "y")]; + end + -- Check z-direction + if c.z == 0 then + [checkLeft(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == 1 then + [checkLeftPlusOne(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == 2 then + [checkLeftPlusTwo(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz-2 then + [checkRightMinusThree(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz-1 then + [checkRightMinusTwo(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz then + [checkRightMinusOne(rexpr Fluid end, rexpr c end, "z")]; + elseif c.z == Npz+1 then + [checkRight(rexpr Fluid end, rexpr c end, "z")]; + else + [checkInternal(rexpr Fluid end, rexpr c end, "z")]; + end + end +end + +task main() + + C.printf("metricTest_Staggered: run...") + + -- No ghost cells + var xBnum = 1 + var yBnum = 1 + var zBnum = 1 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns); + var Fluid_bounds = Fluid.bounds + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + __demand(__index_launch) + for c in tiles do + GRID.InitializeGhostGeometry(p_Fluid[c], + SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, SCHEMA.GridType_Uniform, + 1.0, 1.0, 1.0, + xBnum, Npx, xO, xW, + yBnum, Npy, yO, yW, + zBnum, Npz, zO, zW) + end + + METRIC.InitializeMetric(Fluid, + Fluid_bounds, + xBnum, Npx, + yBnum, Npy, + zBnum, Npz); + + -- Enforce BCs on the metric + [METRIC.mkCorrectGhostMetric("x")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_Dirichlet, SCHEMA.FlowBC_Dirichlet, + xBnum, Npx); + [METRIC.mkCorrectGhostMetric("y")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_Dirichlet, SCHEMA.FlowBC_Dirichlet, + yBnum, Npy); + [METRIC.mkCorrectGhostMetric("z")](Fluid, + Fluid_bounds, + SCHEMA.FlowBC_Dirichlet, SCHEMA.FlowBC_Dirichlet, + zBnum, Npz); + + end + checkMetric(Fluid) + + __fence(__execution, __block) + + C.printf("metricTest_Staggered: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "metricTest_Staggered.o", "object") diff --git a/unitTests/mixTest/Makefile b/unitTests/mixTest/Makefile new file mode 100644 index 0000000..b5dbbbd --- /dev/null +++ b/unitTests/mixTest/Makefile @@ -0,0 +1,88 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MIXS= $(HTR_DIR)/src/Species.rg \ + $(HTR_DIR)/src/Reaction.rg \ + $(HTR_DIR)/src/ConstPropMix.rg \ + $(HTR_DIR)/src/AirMix.rg + +default: mixTest.exec + +clean: + $(RM) *.exec *.o + +mixTest.exec: mixTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +mixTest.o: mixTest.rg $(HTR_DIR)/src/config_schema.h $(MIXS) + $(REGENT) mixTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + diff --git a/unitTests/mixTest/mixTest.rg b/unitTests/mixTest/mixTest.rg new file mode 100644 index 0000000..185d7ee --- /dev/null +++ b/unitTests/mixTest/mixTest.rg @@ -0,0 +1,228 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local sqrt = regentlib.sqrt(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local Config = SCHEMA.Config + +function mktestMixture(name) + local testMixture + + local config = regentlib.newsymbol() + + local T = 750.0 + local P = 101325.0 + + local MIX + local ENames + local EYi + local EXi + local EMixW + local Erho + local Ecp + local Eh + local Ehsp + local EWi + local Ee + local Emu + local Elam + local Egamma + local Esos + local Edif + local Eprod + local Edpde + local Edpdrho + + if (name == "ConstPropMix") then + local R = 287.15 + local Pr = 0.71 + MIX = (require 'ConstPropMix')(SCHEMA) + ENames = rexpr array("MIX") end + EYi = rexpr array( 1.0 ) end + EXi = rexpr array( 1.0 ) end + EMixW = rexpr 8.3144598/[R] end + Erho = rexpr [P]/([R]*[T]) end + Ecp = rexpr 1.005025e+03 end + Eh = rexpr [Ecp]*[T] end + Ehsp = rexpr array([Ecp]*[T]) end + EWi = rexpr array([EMixW]) end + Ee = rexpr Eh - [P]/[Erho] end + Emu = rexpr 5.000000e-03 end + Elam = rexpr [Ecp]*[Emu]/[Pr] end + Egamma = rexpr 1.4 end + Esos = rexpr sqrt([Egamma]*[R]*[T]) end + Edif = rexpr array( 0.0e0 ) end + Eprod = rexpr array( 0.0e0 ) end + Edpde = rexpr [Erho]*([Egamma] - 1.0) end + Edpdrho = rexpr array( [R]*[T] ) end + elseif (name == "AirMix") then + MIX = (require 'AirMix')(SCHEMA) + local R = 8.3144598 + ENames = rexpr array( "N2", "O2", "NO", "N", "O") end + EYi = rexpr array( 0.2, 0.2, 0.2, 0.2, 0.2) end + EXi = rexpr array( 1.524403e-01, 1.334541e-01, 1.423168e-01, 3.048806e-01, 2.669082e-01) end + EMixW = rexpr 2.135186e-02 end + Erho = rexpr [P]*[EMixW]/([R]*[T]) end + Ecp = rexpr 1.206133e+03 end + Eh = rexpr 1.100436e+07 end + Ehsp = rexpr array( 4.812927e+05, 4.425045e+05, 3.505703e+06, 3.441706e+07, 1.617526e+07) end + EWi = rexpr array( 2*14.0067e-3, 2*15.9994e-3, 30.00610e-03, 14.0067e-03, 15.9994e-03) end + Ee = rexpr Eh - [P]/[Erho] end + Emu = rexpr 3.723077e-05 end + Elam = rexpr 5.927382e-02 end + Egamma = rexpr 1.476782e+00 end + Esos = rexpr 6.567317e+02 end + Edif = rexpr array( 1.192983e-04, 1.174019e-04, 1.162986e-04, 1.820668e-04, 1.882347e-04) end + Eprod = rexpr array( 3.413124e+07, 2.664566e+04,-3.578332e+07,-1.742776e+07, 1.905320e+07) end + Edpde = rexpr [Erho]*([Egamma] - 1.0) end + Edpdrho = rexpr array( 5.206698e+06, 5.184248e+06, 3.742883e+06,-1.064452e+07,-2.029053e+06) end + else + error "Unknown mixture" + end + + __demand(__inline) + task testMixture(config : Config) + + -- Init the mixture + var Mix = MIX.InitMixture(config) + + -- check GetSpeciesNames + for i = 0, Mix.nSpec do + regentlib.assert(C.strcmp([ENames][i], MIX.GetSpeciesNames(Mix)[i]) == 0, ["mixTest: ERROR in GetSpeciesNames of " .. name]) + end + + -- check GetMolarWeightFromYi + var MixW = MIX.GetMolarWeightFromYi([EYi], Mix) + regentlib.assert(fabs((MixW/([EMixW])) - 1.0) < 1e-3, ["mixTest: ERROR in GetMolarWeightFromYi of " .. name]) + + -- check GetMolarFractions + var Xi = MIX.GetMolarFractions(MixW, [EYi], Mix) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((Xi[i]/([EXi][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetMolarFractions of " .. name]) + end + + -- check GetMolarWeightFromXi + var MixW2 = MIX.GetMolarWeightFromXi(Xi, Mix) + regentlib.assert(fabs((MixW2/MixW) - 1.0) < 1e-3, ["mixTest: ERROR in GetMolarWeightFromXi of " .. name]) + + -- check GetMassFractions + var Yi = MIX.GetMassFractions(MixW, Xi, Mix) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((Yi[i]/([EYi][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetMassFractions of " .. name]) + end + + -- check GetRho + var rho = MIX.GetRho([P], [T], MixW, Mix) + regentlib.assert(fabs((rho/([Erho])) - 1.0) < 1e-3, ["mixTest: ERROR in GetRho of " .. name]) + + + -- check GetRhoYiFromYi + var rhoYi = MIX.GetRhoYiFromYi(rho, Yi) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((rhoYi[i]/([Erho]*[EYi][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetRhoYiFromYi of " .. name]) + end + + -- check GetYi + var Yi2 = MIX.GetYi(rho, rhoYi) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((Yi2[i]/([EYi][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetYi of " .. name]) + end + + -- check GetHeatCapacity + var cp = MIX.GetHeatCapacity([T], Yi, Mix) + regentlib.assert(fabs((cp/([Ecp])) - 1.0) < 1e-3, ["mixTest: ERROR in GetHeatCapacity of " .. name]) + + -- check GetEnthalpy + var h = MIX.GetEnthalpy([T], Yi, Mix) + regentlib.assert(fabs((h/([Eh])) - 1.0) < 1e-3, ["mixTest: ERROR in GetEnthalpy of " .. name]) + + -- check GetSpeciesEnthalpy + for i = 0, Mix.nSpec do + var hsp = MIX.GetSpeciesEnthalpy(i, [T], Mix) + regentlib.assert(fabs((hsp/([Ehsp][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetEnthalpy of " .. name]) + end + + -- check GetSpeciesMolarWeight + for i = 0, Mix.nSpec do + var W = MIX.GetSpeciesMolarWeight(i, Mix) + regentlib.assert(fabs((W/([EWi][i])) - 1.0) < 1e-3, ["mixTest: ERROR in GetSpeciesMolarWeight of " .. name]) + end + + -- check GetInternalEnergy + var e = MIX.GetInternalEnergy([T], Yi, Mix) + regentlib.assert(fabs((e/([Ee])) - 1.0) < 1e-3, ["mixTest: ERROR in GetInternalEnergy of " .. name]) + + -- check GetTFromInternalEnergy + var T1 = MIX.GetTFromInternalEnergy(e, [T]+100.0, Yi, Mix) + regentlib.assert(fabs((T1/([T])) - 1.0) < 1e-3, ["mixTest: ERROR in GetTFromInternalEnergy of " .. name]) + + -- check isValidInternalEnergy + regentlib.assert(MIX.isValidInternalEnergy(e , Yi, Mix) == true, ["mixTest: ERROR in isValidInternalEnergy of " .. name]) + regentlib.assert(MIX.isValidInternalEnergy(0.0, Yi, Mix) == false, ["mixTest: ERROR in isValidInternalEnergy of " .. name]) + + -- check GetTFromRhoAndP + regentlib.assert(fabs((MIX.GetTFromRhoAndP(rho, MixW, P)/([T])) - 1.0) < 1e-3, ["mixTest: ERROR in GetTFromRhoAndP of " .. name]) + + -- check GetPFromRhoAndT + regentlib.assert(fabs((MIX.GetPFromRhoAndT(rho, MixW, T)/([P])) - 1.0) < 1e-3, ["mixTest: ERROR in GetPFromRhoAndT of " .. name]) + + -- check GetViscosity + regentlib.assert(fabs((MIX.GetViscosity(T, Xi, Mix)/([Emu])) - 1.0) < 1e-3, ["mixTest: ERROR in GetViscosity of " .. name]) + + -- check GetHeatConductivity + regentlib.assert(fabs((MIX.GetHeatConductivity(T, Xi, Mix)/([Elam])) - 1.0) < 1e-3, ["mixTest: ERROR in GetHeatConductivity of " .. name]) + + -- check GetGamma + var gamma = MIX.GetGamma(T, MixW, Yi, Mix) + regentlib.assert(fabs((gamma/([Egamma])) - 1.0) < 1e-3, ["mixTest: ERROR in GetGamma of " .. name]) + + -- check GetSpeedOfSound + regentlib.assert(fabs((MIX.GetSpeedOfSound(T, gamma, MixW, Mix)/([Esos])) - 1.0) < 1e-3, ["mixTest: ERROR in GetSpeedOfSound of " .. name]) + + -- check GetDiffusivity + var dif = MIX.GetDiffusivity([P], [T], MixW, Xi, Mix) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((dif[i] - [Edif][i])/([Edif][i] + 1e-60)) < 1e-3, ["mixTest: ERROR in GetDiffusivity of " .. name]) + end + + -- check GetMolarFractions + var prod = MIX.GetProductionRates(rho, [P], [T], Yi, Mix) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((prod[i] - [Eprod][i])/([Eprod][i] + 1e-60)) < 1e-3, ["mixTest: ERROR in GetProductionRates of " .. name]) + end + + -- check Getdpdrhoi + regentlib.assert(fabs((MIX.Getdpde(rho, gamma, Mix)/([Edpde])) - 1.0) < 1e-3, ["mixTest: ERROR in Getdpde of " .. name]) + + -- check Getdpdrhoi + var dpdrhoi = MIX.Getdpdrhoi(gamma, [T], Yi, Mix) + for i = 0, Mix.nSpec do + regentlib.assert(fabs((dpdrhoi[i] - [Edpdrho][i])/([Edpdrho][i] + 1e-60)) < 1e-3, ["mixTest: ERROR in Getdpdrhoi of " .. name]) + end + + end + return testMixture +end + +task main() + var config : Config + SCHEMA.parse_Config(&config, "test.json"); + + -- Test ConstPropMix + [mktestMixture("ConstPropMix")](config); + + -- Test AirMix + [mktestMixture("AirMix")](config); + + C.printf("mixTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "mixTest.o", "object") diff --git a/unitTests/mixTest/test.json b/unitTests/mixTest/test.json new file mode 100644 index 0000000..cf31117 --- /dev/null +++ b/unitTests/mixTest/test.json @@ -0,0 +1,81 @@ +{ + "Mapping" : { + "tiles" : [1,2,3], + "tilesPerRank" : [1,2,3], + "sampleId" : -1, + "outDir" : "", + "wallTime" : 10000 + }, + + "Grid" : { + "xNum" : 400, + "yNum" : 100, + "zNum" : 1, + "origin" : [0.0, 4.0, 8.0], + "xWidth" : 1.0, + "yWidth" : 0.5, + "zWidth" : 0.1, + "xType" : "TanhMinus", + "yType" : "TanhMinus", + "zType" : "Uniform", + "xStretching" : 0.9, + "yStretching" : 0.9, + "zStretching" : 1.0 + }, + + "Integrator" : { + "startIter" : 0, + "startTime" : 0.0, + "resetTime" : false, + "maxIter" : 200000, + "maxTime" : 20.0, + "cfl" : 0.9, + "fixedDeltaTime" : 4.0e-3, + "implicitChemistry" : false + }, + + "BC" : { + "xBCLeft" : { "type" : "Periodic" }, + "xBCRight" : { "type" : "Periodic" }, + "yBCLeft" : { "type" : "Periodic" }, + "yBCRight" : { "type" : "Periodic" }, + "zBCLeft" : { "type" : "Periodic" }, + "zBCRight" : { "type" : "Periodic" } + }, + + "Flow" : { + "mixture": "ConstPropMix", + "gasConstant" : 287.15, + "gamma" : 1.4, + "prandtl" : 0.71, + "viscosityModel" : { + "type" : "Constant", + "Visc" : 5.0e-3 + }, + "initCase" : "Uniform", + "restartDir" : "restartDir", + "initParams" : [1.01325e5, 300.0, 10.0, 20.0, 30.0], + "resetMixture" : false, + "initMixture" : { + "Species" : [{"Name" : "Mix", "MolarFrac" : 1.0 }] + }, + "bodyForce" : [1.0, 2.0, 3.0], + "turbForcing" : { + "type" : "CHANNEL", + "Forcing" : 1000.0, + "RhoUbulk" : 20.0 + + } + }, + + "IO" : { + "wrtRestart" : true, + "restartEveryTimeSteps" : 10000, + "probes" : [], + "AveragesSamplingInterval": 10, + "ResetAverages": false, + "YZAverages": [], + "XZAverages": [], + "XYAverages": [] + } +} diff --git a/unitTests/variablesTest/Makefile b/unitTests/variablesTest/Makefile new file mode 100644 index 0000000..37291c7 --- /dev/null +++ b/unitTests/variablesTest/Makefile @@ -0,0 +1,91 @@ +# Required paths +ifndef LEGION_DIR + $(error LEGION_DIR is not set) +endif +ifndef HTR_DIR + $(error HTR_DIR is not set) +endif + +# OS-specific options +ifeq ($(shell uname),Darwin) + DYNLINK_PATH := DYLD_LIBRARY_PATH +else + DYNLINK_PATH := LD_LIBRARY_PATH +endif + +# CUDA options +USE_CUDA ?= 1 + +# HDF options +export USE_HDF ?= 1 +export HDF_HEADER ?= hdf5.h +HDF_LIBNAME ?= hdf5 + +# C compiler options +CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent +CXXFLAGS += -std=c++11 -O3 -Wall -Werror -fno-strict-aliasing -I$(LEGION_DIR)/runtime -I$(LEGION_DIR)/bindings/regent + +# Regent options +export TERRA_PATH := ?.rg;$(HTR_DIR)/src/?.rg +export INCLUDE_PATH := . +ifdef HDF_ROOT + export INCLUDE_PATH := $(INCLUDE_PATH);$(HDF_ROOT)/include + export $(DYNLINK_PATH) := $($(DYNLINK_PATH)):$(HDF_ROOT)/lib +endif +REGENT := $(LEGION_DIR)/language/regent.py +REGENT_FLAGS := -fflow 0 -finner 1 -fbounds-checks 1 +ifeq ($(USE_CUDA), 1) + REGENT_FLAGS += -fcuda 1 -fcuda-offline 1 +else + REGENT_FLAGS += -fcuda 0 +endif +ifeq ($(USE_OPENMP), 1) + REGENT_FLAGS += -fopenmp 1 +else + REGENT_FLAGS += -fopenmp 0 +endif + +# Link flags +LINK_FLAGS += -L$(LEGION_DIR)/bindings/regent -lregent +ifdef HDF_ROOT + LINK_FLAGS += -L$(HDF_ROOT)/lib +endif +ifeq ($(USE_HDF), 1) + LINK_FLAGS += -l$(HDF_LIBNAME) +endif +LINK_FLAGS += -lm + +ifeq ($(DEBUG), 1) + REGENT_FLAGS += -g + CFLAGS += -g + CXXFLAGS += -g + LINK_FLAGS += -g +endif + +.PHONY: default all clean + +MODULES= $(HTR_DIR)/src/AirMix.rg \ + $(HTR_DIR)/src/prometeo_const.rg \ + $(HTR_DIR)/src/prometeo_macro.rg \ + $(HTR_DIR)/src/prometeo_variables.rg + +default: variablesTest.exec + +clean: + $(RM) *.exec *.o + +variablesTest.exec: variablesTest.o $(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/json.o + $(CXX) -o $@ $^ $(LINK_FLAGS) + +variablesTest.o: variablesTest.rg $(HTR_DIR)/src/config_schema.h $(HTR_DIR)/src/util-desugared.rg $(MODULES) + $(REGENT) variablesTest.rg $(REGENT_FLAGS) + +$(HTR_DIR)/src/config_schema.o $(HTR_DIR)/src/config_schema.h: $(HTR_DIR)/src/process_schema.rg $(HTR_DIR)/src/config_schema.lua + make -C $(HTR_DIR)/src config_schema.o + +json.o json.h: $(HTR_DIR)/src/json.c $(HTR_DIR)/src/json.h + make -C $(HTR_DIR)/src json.o + +$(HTR_DIR)/src/util-desugared.rg: $(HTR_DIR)/src/util.rg + make -C $(HTR_DIR)/src util-desugared.rg + diff --git a/unitTests/variablesTest/variablesTest.rg b/unitTests/variablesTest/variablesTest.rg new file mode 100644 index 0000000..b577cca --- /dev/null +++ b/unitTests/variablesTest/variablesTest.rg @@ -0,0 +1,274 @@ +import "regent" +------------------------------------------------------------------------------- +-- IMPORTS +------------------------------------------------------------------------------- + +local C = regentlib.c +local fabs = regentlib.fabs(double) +local SCHEMA = terralib.includec("../../src/config_schema.h") +local UTIL = require 'util-desugared' + +local Config = SCHEMA.Config + +local CONST = require "prometeo_const" +local MACRO = require "prometeo_macro" +local MIX = (require "AirMix")(SCHEMA) +local nSpec = MIX.nSpec +local nEq = CONST.GetnEq(MIX) -- Total number of unknowns for the implicit solver + +local Primitives = CONST.Primitives +local Properties = CONST.Properties + +local struct Fluid_columns { + -- Cell center gradient operator [c - c-1, c+1 - c] + gradX : double[2]; + gradY : double[2]; + gradZ : double[2]; + -- Primitive variables + pressure : double; + temperature : double; + MolarFracs : double[nSpec]; + velocity : double[3]; + -- Properties + rho : double; + mu : double; + lam : double; + Di : double[nSpec]; + SoS : double; + -- Gradients + velocityGradientX : double[3]; + velocityGradientY : double[3]; + velocityGradientZ : double[3]; + temperatureGradient : double[3]; + -- Conserved varaibles + Conserved : double[nEq]; +} + +--External modules +local VARS = (require 'prometeo_variables')(SCHEMA, MIX, Fluid_columns) + +-- Test parameters +local Npx = 16 +local Npy = 16 +local Npz = 16 +local Nx = 2 +local Ny = 2 +local Nz = 2 + +--local R = rexpr 8.3144598 end +local P = rexpr 101325.0 end +local T = rexpr 5000.0 end +local Xi = rexpr array(0.4, 0.2, 0.15, 0.15, 0.1) end +local v = rexpr array(1.0, 2.0, 3.0) end +local Tres = rexpr 500.0 end + +-- Expected properties +local eRho = rexpr 6.2899871101668e-02 end +local eMu = rexpr 1.2424467023580e-04 end +local eLam = rexpr 2.2727742147267e-01 end +local eDi = rexpr array(2.5146873480781e-03, 2.4389311883618e-03, 2.4550965167542e-03, 3.6168277168130e-03, 3.9165634179846e-03) end +local eSoS = rexpr 1.4518705966651e+03 end + +-- Expected conserved variables +local eConserved = rexpr array(2.7311049167620e-02, 1.5598263689963e-02, 1.0970170602665e-02, 5.1208217189288e-03, 3.8995659224908e-03, 6.2899871101668e-02, 1.2579974220334e-01, 1.8869961330500e-01, 5.4092397631210e+05) end + +__demand(__inline) +task InitializeCell(Fluid : region(ispace(int3d), Fluid_columns)) +where + writes(Fluid) +do + fill(Fluid.gradX, array(0.0, 0.0)) + fill(Fluid.gradY, array(0.0, 0.0)) + fill(Fluid.gradZ, array(0.0, 0.0)) + fill(Fluid.pressure, [P]) + fill(Fluid.temperature, [T]) + fill(Fluid.MolarFracs, [Xi]) + fill(Fluid.velocity, [v]) + fill(Fluid.rho, 0.0) + fill(Fluid.mu , 0.0) + fill(Fluid.lam, 0.0) + fill(Fluid.Di , [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Fluid.SoS, 0.0) + fill(Fluid.velocityGradientX, array(0.0, 0.0, 0.0)) + fill(Fluid.velocityGradientY, array(0.0, 0.0, 0.0)) + fill(Fluid.velocityGradientZ, array(0.0, 0.0, 0.0)) + fill(Fluid.temperatureGradient, array(0.0, 0.0, 0.0)) + fill(Fluid.Conserved, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) +end + +__demand(__inline) +task CheckUpdatePropertiesFromPrimitive(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.[Properties]) +do + for c in Fluid do + regentlib.assert(fabs((Fluid[c].rho/[eRho]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePropertiesFromPrimitive") + regentlib.assert(fabs((Fluid[c].mu /[eMu ]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePropertiesFromPrimitive") + regentlib.assert(fabs((Fluid[c].lam/[eLam]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePropertiesFromPrimitive") + for i=0, nSpec do + regentlib.assert(fabs((Fluid[c].Di[i]/[eDi][i]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePropertiesFromPrimitive") + end + regentlib.assert(fabs((Fluid[c].SoS/[eSoS]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePropertiesFromPrimitive") + end +end + +__demand(__inline) +task CheckUpdateConservedFromPrimitive(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.Conserved) +do + for c in Fluid do + var interior = MACRO.in_interior(c, 1, Npx, 1, Npy, 1, Npz) + if interior then + for i=0, nEq do + regentlib.assert(fabs((Fluid[c].Conserved[i]/[eConserved][i]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdateConservedFromPrimitive") + end + else + for i=0, nEq do + regentlib.assert(Fluid[c].Conserved[i] == 0.0, "variablesTest: ERROR in UpdateConservedFromPrimitive") + end + end + end +end + +__demand(__inline) +task CheckUpdateGhostConservedFromPrimitive(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.Conserved) +do + for c in Fluid do + var interior = MACRO.in_interior(c, 1, Npx, 1, Npy, 1, Npz) + if interior then + for i=0, nEq do + regentlib.assert(Fluid[c].Conserved[i] == 0.0, "variablesTest: ERROR in UpdateGhostConservedFromPrimitive") + end + else + for i=0, nEq do + regentlib.assert(fabs((Fluid[c].Conserved[i]/[eConserved][i]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdateGhostConservedFromPrimitive") + end + end + end +end + +__demand(__inline) +task CheckUpdatePrimitiveFromConserved(Fluid : region(ispace(int3d), Fluid_columns)) +where + reads(Fluid.[Primitives]) +do + for c in Fluid do + var interior = MACRO.in_interior(c, 1, Npx, 1, Npy, 1, Npz) + if interior then + regentlib.assert(fabs((Fluid[c].pressure/[P]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + regentlib.assert(fabs((Fluid[c].temperature/[T]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + for i=0, nSpec do + regentlib.assert(fabs((Fluid[c].MolarFracs[i]/[Xi][i]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + end + for i=0, 3 do + regentlib.assert(fabs((Fluid[c].velocity[i]/[v][i]) - 1.0) < 1e-8, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + end + else + regentlib.assert(Fluid[c].pressure == 0.0, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + regentlib.assert(Fluid[c].temperature == [Tres], "variablesTest: ERROR in UpdatePrimitiveFromConserved") + for i=0, nSpec do + regentlib.assert(Fluid[c].MolarFracs[i] == 0.0, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + end + for i=0, 3 do + regentlib.assert(Fluid[c].velocity[i] == 0.0, "variablesTest: ERROR in UpdatePrimitiveFromConserved") + end + end + end +end + + +task main() + -- Init the mixture + var config : Config + var Mix = MIX.InitMixture(config) + + -- Define the domain + var xBnum = 1 + var yBnum = 1 + var zBnum = 1 + + -- Define the domain + var is_Fluid = ispace(int3d, {x = Npx + 2*xBnum, + y = Npy + 2*yBnum, + z = Npz + 2*zBnum}) + var Fluid = region(is_Fluid, Fluid_columns); + + -- Partitioning domain + var tiles = ispace(int3d, {Nx, Ny, Nz}) + + -- Fluid Partitioning + var p_Fluid = + [UTIL.mkPartitionByTile(int3d, int3d, Fluid_columns, "p_All")] + (Fluid, tiles, int3d{xBnum,yBnum,zBnum}, int3d{0,0,0}) + + var Fluid_regions = + [UTIL.mkPartitionIsInteriorOrGhost(int3d, Fluid_columns, "Fluid_regions")] + (Fluid, int3d{xBnum,yBnum,zBnum}) + + -- Interior points + var p_Interior = static_cast(partition(disjoint, Fluid, tiles), cross_product(Fluid_regions, p_Fluid)[0]) + + + -- All ghost points + var p_AllGhost = p_Fluid - p_Interior + + __parallelize_with + tiles, + disjoint(p_Fluid), + complete(p_Fluid, Fluid) + do + + InitializeCell(Fluid) + + -- Test UpdatePropertiesFromPrimitive + __demand(__index_launch) + for c in tiles do + VARS.UpdatePropertiesFromPrimitive(p_Fluid[c], p_Fluid[c], Mix) + end + + CheckUpdatePropertiesFromPrimitive(Fluid) + + -- Test UpdateConservedFromPrimitive for ghosts + __demand(__index_launch) + for c in tiles do + VARS.UpdateConservedFromPrimitive(p_Fluid[c], p_AllGhost[c], Mix) + end + + CheckUpdateGhostConservedFromPrimitive(Fluid) + + -- Test UpdateConservedFromPrimitive for internal + fill(Fluid.Conserved, [UTIL.mkArrayConstant(nEq, rexpr 0.0 end)]) + __demand(__index_launch) + for c in tiles do + VARS.UpdateConservedFromPrimitive(p_Fluid[c], p_Interior[c], Mix) + end + + CheckUpdateConservedFromPrimitive(Fluid) + + -- Test UpdatePrimitiveFromConserved + fill(Fluid.pressure, 0.0) + fill(Fluid.temperature, [Tres]) + fill(Fluid.MolarFracs, [UTIL.mkArrayConstant(nSpec, rexpr 0.0 end)]) + fill(Fluid.velocity, array(0.0, 0.0, 0.0)) + __demand(__index_launch) + for c in tiles do + VARS.UpdatePrimitiveFromConserved(p_Fluid[c], p_Interior[c], Mix) + end + + CheckUpdatePrimitiveFromConserved(Fluid) + + end + + __fence(__execution, __block) + + C.printf("variablesTest: TEST OK!\n") +end + +------------------------------------------------------------------------------- +-- COMPILATION CALL +------------------------------------------------------------------------------- + +regentlib.saveobj(main, "variablesTest.o", "object")