creams: use python script to generate the input

This commit is contained in:
Rodrigo Arias 2021-05-03 11:10:19 +02:00
parent 6937ffcfe9
commit 3892167e7d
2 changed files with 72 additions and 13 deletions

49
garlic/apps/creams/gen_grid.py Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description="Generate a grid.dat input file for CREAMS")
parser.add_argument('--npx', type=int, help='number of processes in X', default=1)
parser.add_argument('--npy', type=int, help='number of processes in Y', default=1)
parser.add_argument('--npz', type=int, help='number of processes in Z', default=32)
parser.add_argument('--grain', type=int, help='granularity', default=9)
parser.add_argument('--nx', type=int, help='number of points in X', default=20)
parser.add_argument('--ny', type=int, help='number of points in Y', default=20)
parser.add_argument('--nz', type=int, help='number of points in Z', default=7000)
parser.add_argument('--dx', type=float, help='grid spacing in X', default=0.0025062657)
parser.add_argument('--dy', type=float, help='grid spacing in Y', default=0.0025062657)
parser.add_argument('--dz', type=float, help='grid spacing in Z', default=0.0025062657)
args = parser.parse_args()
grain_str = "%d %d" % (args.grain, args.grain)
boundary = "extrapolation"
# Print
print(' %-49d number of processes in x-direction (0 if automatic)' % args.npx)
print(' %-49d number of processes in y-direction (0 if automatic)' % args.npy)
print(' %-49d number of processes in z-direction (0 if automatic)' % args.npz)
print(' ')
print(' %-49s subdomain granularity' % grain_str)
print(' ')
print(' %-49s -x boundary' % boundary)
print(' %-49s +x boundary' % boundary)
print(' %-49s -y boundary' % boundary)
print(' %-49s +y boundary' % boundary)
print(' %-49s -z boundary' % boundary)
print(' %-49s +z boundary' % boundary)
print(' ')
print(' x-direction')
for i in range(args.nx):
print("%.9e" % (i * args.dx))
print(' ')
print(' y-direction')
for i in range(args.ny):
print("%.9e" % (i * args.dy))
print(' ')
print(' z-direction')
for i in range(args.nz):
print("%.9e" % (i * args.dz))
print(' ')
print(' END')

View File

@ -1,7 +1,13 @@
{ {
stdenv stdenv
, granul ? 0 , python3
, nprocz ? 0 , granul ? 9
, nprocx ? 1
, nprocy ? 1
, nprocz ? 1
, nx ? 20
, ny ? 20
, nz ? 7000
, gitBranch ? "garlic/mpi+send+seq" , gitBranch ? "garlic/mpi+send+seq"
, gitCommit ? null , gitCommit ? null
, garlicTools , garlicTools
@ -13,26 +19,30 @@ let
inherit gitCommit gitBranch; inherit gitCommit gitBranch;
gitTable = import ./git-table.nix; gitTable = import ./git-table.nix;
}; };
gen = ./gen_grid.py;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "creams-input"; name = "creams-input";
buildInputs = [ python3 ];
inherit (gitSource) src gitBranch gitCommit; inherit (gitSource) src gitBranch gitCommit;
phases = [ "unpackPhase" "patchPhase" "installPhase" ]; phases = [ "unpackPhase" "installPhase" ];
patchPhase = ''
patchShebangs SodTubeBenchmark/gridScript.sh
'';
installPhase = '' installPhase = ''
pushd SodTubeBenchmark
./gridScript.sh 0 0 ${toString nprocz} ${toString granul}
popd
mkdir -p $out mkdir -p $out
cp -a SodTubeBenchmark $out/ cp -a SodTubeBenchmark $out/
'';
hardeningDisable = [ "all" ]; python3 ${gen} \
--npx ${toString nprocx} \
--npy ${toString nprocy} \
--npz ${toString nprocz} \
--grain ${toString granul} \
--nx ${toString nx} \
--ny ${toString ny} \
--nz ${toString nz} \
> $out/SodTubeBenchmark/grid.dat
'';
} }