Commit c700ad8c authored by laura.pfeiffer's avatar laura.pfeiffer
Browse files

added Horeka Run script for Biventricle

parent a32ff46e
import os
dataPath='../../data/BiVentricle'
def checkIfFolderExists(path):
if not os.path.exists(path):
os.makedirs(path)
def getModelByName(name):
model =''
if name =='LI':
model = 'LinearImplicit'
elif name =='SI':
model='SemiImplicit'
elif name =='IE':
model ='ImplictEuler'
else:
model = 'Splitting'
return model
def getSplittingMethodByName(name):
if name[0]=='S':
return 'Strang'
elif name[0]=='B':
return 'Stein'
else:
return 'Godunov'
def Standard():
block=''
block +='#!/bin/bash\n'
block += '#SBATCH --partition=cpuonly\n'
block += '#SBATCH --account=hk-project-ipfem\n'
block += '#SBATCH --export=ALL,EXECUTABLE=./Elphy-M++\n'
block += '#SBATCH --mail-type=ALL\n'
block += '#SBATCH --mail-user=laura.lindner2@kit.edu\n'
return block
def Jobname(name):#name could be SIl3j4
return '#SBATCH --job-name='+name +'\n'
def Nodes(n):
return '#SBATCH --nodes='+str(n)+'\n'
def Tasks(n):
return '#SBATCH --ntasks-per-node='+str(n)+'\n'
def Time(h,m):
if m==0:
return '#SBATCH --time='+str(h)+':00:00\n'
elif m<10:
return '#SBATCH --time='+str(h)+':0'+str(m)+':00\n'
else:
return '#SBATCH --time='+str(h)+':'+str(m)+':00\n'
def Start(args):
block=''
block += 'mpirun ${MPIRUN_OPTIONS} Elphy-M++ BiVentricleTest/start'
for a in args:
block += ' '+a+'='+str(args[a])
block+='\n'
return block
def decideTime(level,j):
h=0
m=0
if level <=3:
m =2**(j+1)
if m>60:
h=int(m/60)
m=m%60
elif level == 4:
if j<=2:
h=1
elif j ==3:
h=2
elif j ==4:
h=4
elif j==5:
h=8
elif j==6:
h=16
else:
print('no time for j='+str(j)+' defined')
elif level==5:
h=2**j +2
else:
print('no level time defined')
#print(h,m)
return(4*h,4*m)
def modifyJobskript(name,j,sdt,args,add=0):
level=args['ElphyLevel']
filename =name+'l'+str(level)+'Job'
(h,m)=decideTime(level,j)
with open(filename, 'w') as output_file:
output_file.write(Standard())
output_file.write(Nodes(2**(level+add)))
output_file.write(Tasks(64))
output_file.write(Time(h,m))
output_file.write(Jobname(name+'l'+str(args['ElphyLevel'])+'j'+str(j)))
output_file.write('module load compiler/gnu/8 mpi/openmpi/4.1\n')
output_file.write('export MPIRUN_OPTIONS="--bind-to core --map-by core -report-bindings"\n')
output_file.write('echo "${executable} running on ${SLURM_NTASKS_PER_NODE} tasks per node with ${SLURM_NNODES} nodes"\n')
args.update({'DeltaTime':sdt*2**(-j)})
output_file.write(Start(args))
output_file.write(moveActivation(level,j,name))
return name+'l'+str(args['ElphyLevel'])+'Job'
def moveActivation(l,j,alg):
block =''
block+='mv data/vtu/ActivationTime.vtu ../../data/BiVentricle/'+str(alg)+'0001/' +'AT_l'+str(l)+'j'+str(j)
block+='\n'
return block
def startJobs(lL,tL,nL,testname,added=None):
sdt=0.0001
arguments={}
for alg in nL:
if added!=None:
if 'ElphyModel' in added:
model =added['ElphyModel']
else:
model =getModelByName(alg)
else:
model =getModelByName(alg)
arguments.update({'ElphyModel':model})
checkIfFolderExists(dataPath+alg+'0001SAT/'+testname+'/')
if model =='Splitting':
arguments.update({'ElphySplittingMethod':getSplittingMethodByName(alg)})
for l in lL:
arguments.update({'ElphyLevel':l})
for j in tL:
logname=dataPath+alg+'0001SAT/'+testname+'/log_l'+str(l)+'j'+str(j)+'m1'
arguments.update({'logfile':logname})
if added!=None:
arguments.update(added)
if model == 'ImplictEuler':
jobname =modifyJobskript(alg,j,sdt,arguments,1)
else:
jobname =modifyJobskript(alg,j,sdt,arguments)
#print(jobname)
#os.system('sbatch '+ jobname)
def startSI():
lL=[0]
tL=[0]
nL=['SI']
startJobs(lL,tL,nL,'')
if __name__=="__main__":
startSI()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment