Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 48 additions & 20 deletions easybuild/easyblocks/o/openfoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,13 @@ def sanity_check_step(self):
# only for recent (>= v6.0) versions of openfoam.org variant
if self.is_dot_org and self.looseversion >= LooseVersion('6'):
openfoamdir_path = os.path.join(self.installdir, self.openfoamdir)
motorbike_path = os.path.join(openfoamdir_path, 'tutorials', 'incompressible', 'simpleFoam', 'motorBike')
if self.looseversion <= LooseVersion('10'):
motorbike_path = os.path.join(
openfoamdir_path, 'tutorials', 'incompressible', 'simpleFoam', 'motorBike'
)
else:
motorbike_path = os.path.join(openfoamdir_path, 'tutorials', 'incompressibleFluid',
'motorBike', 'motorBike')
if os.path.exists(motorbike_path):
test_dir = tempfile.mkdtemp()

Expand All @@ -504,27 +510,49 @@ def sanity_check_step(self):
else:
geom_target_dir = 'triSurface'

if self.looseversion <= LooseVersion('10'):
cmds = [
"cp -a %s %s" % (motorbike_path, test_dir),
# Make sure the tmpdir for tests ir writeable if read-only-installdir is used
"chmod -R +w %s" % test_dir,
"cd %s" % os.path.join(test_dir, os.path.basename(motorbike_path)),
"source $FOAM_BASH",
". $WM_PROJECT_DIR/bin/tools/RunFunctions",
"cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir,
"runApplication surfaceFeatures",
"runApplication blockMesh",
"runApplication decomposePar -copyZero",
"runParallel snappyHexMesh -overwrite",
"runParallel patchSummary",
"runParallel potentialFoam",
"runParallel simpleFoam",
"runApplication reconstructParMesh -constant",
"runApplication reconstructPar -latestTime",
"cd %s" % self.builddir,
"rm -r %s" % test_dir,
]
# v11 and above run the motorBike example differently
else:
cmds = [
"cp -a %s %s" % (motorbike_path, test_dir),
"cd %s" % os.path.join(test_dir, os.path.basename(motorbike_path)),
"source $FOAM_BASH",
". $WM_PROJECT_DIR/bin/tools/RunFunctions",
"cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir,
"runApplication surfaceFeatures",
"runApplication blockMesh",
"runApplication decomposePar -copyZero",
"runParallel snappyHexMesh -overwrite",
"runParallel patchSummary",
"runParallel potentialFoam",
"runParallel simpleFoam",
"runApplication reconstructParMesh -constant",
"runApplication reconstructPar -latestTime",
"cd %s" % self.builddir,
"rm -r %s" % test_dir,
"cp -a %s %s" % (motorbike_path, test_dir),
# Make sure the tmpdir for tests ir writeable if read-only-installdir is used
"chmod -R +w %s" % os.path.join(test_dir, os.path.basename(motorbike_path)),
"cd %s" % os.path.join(test_dir, os.path.basename(motorbike_path)),
"source $FOAM_BASH",
". $WM_PROJECT_DIR/bin/tools/RunFunctions",
"cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/%s/" % geom_target_dir,
"runApplication blockMesh",
"runApplication decomposePar -copyZero",
"find . -type f -iname '*level*' -exec rm {} \\;",
"runParallel renumberMesh -overwrite",
"runParallel potentialFoam -initialiseUBCs",
"runParallel simpleFoam",
"cd %s" % self.builddir,
"rm -r %s" % test_dir,
]
# all commands need to be run in a single shell command,
# because sourcing $FOAM_BASH sets up environment
custom_commands.append(' && '.join(cmds))
# all commands need to be run in a single shell command,
# because sourcing $FOAM_BASH sets up environment
custom_commands.append(' && '.join(cmds))

super(EB_OpenFOAM, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands)

Expand Down