Skip to content

OpenFOAM Lid driven cavity test case - #243

Merged
casparvl merged 37 commits into
EESSI:mainfrom
satishskamath:openfoam
Jun 12, 2025
Merged

casparvl merged 37 commits into
EESSI:mainfrom
satishskamath:openfoam

Conversation

@satishskamath

@satishskamath satishskamath commented Feb 25, 2025 •

Copy link
Copy Markdown
Collaborator

Todos:

  • Creating a basic ReFrame test case from the slurm batch file.

@casparvl
casparvl marked this pull request as draft March 13, 2025 12:10
@satishskamath

Copy link
Copy Markdown
Collaborator Author

@casparvl @laraPPr and @smoors this PR is open for testing on the systems, right now. I am still fixing formatting and trying to satisfy the linter but I think more or less the test is done.

@satishskamath satishskamath changed the title OpenFOAM Lid driven cavity test case [WIP] OpenFOAM Lid driven cavity test case [WIP/Open for testing] May 14, 2025
@satishskamath

satishskamath commented May 15, 2025 •

Copy link
Copy Markdown
Collaborator Author

Btw the linter does not recognise reframe pipeline hooks:

./eessi/testsuite/tests/apps/openfoam/openfoam.py:104:6: F821 undefined name 'deferrable'

Have any of you encountered this before? @smoors , @laraPPr , @casparvl ?

Satish Kamath added 7 commits May 15, 2025 16:03
"\" in a string leads to extra space between the characters in the
string.
Correct way of doing it:
```
my_string = "The quick brown dog " \
            "jumped over the lazy fox"
```
@satishskamath

Copy link
Copy Markdown
Collaborator Author
[satishk@tcn3 projects]$ reframe -C eessi_reframe/settings_example.py -c test-suite/eessi/testsuite/tests/apps/openfoam/openfoam.py    --system="snellius_eessi:cpu_rome" --run
[ReFrame Setup]
  version:           4.6.1
  command:           '/home/satishk/.local/easybuild/RHEL8/2023/software/ReFrame/4.6.1/bin/reframe -C eessi_reframe/settings_example.py -c test-suite/eessi/testsuite/tests/apps/openfoam/openfoam.py --system=snellius_eessi:cpu_rome --run'
  launched by:       [email protected]
  working directory: '/gpfs/home5/satishk/projects'
  settings files:    '<builtin>', 'eessi_reframe/settings_example.py'
  check search path: '/gpfs/home5/satishk/projects/test-suite/eessi/testsuite/tests/apps/openfoam/openfoam.py'
  stage directory:   '/scratch-shared/satishk/reframe_output/staging'
  output directory:  '/gpfs/home5/satishk/projects/output'
  log files:         '/gpfs/home5/satishk/projects/reframe.log'

[==========] Running 4 check(s)
[==========] Started on Fri May 16 11:24:32 2025+0200

[----------] start processing checks
[ RUN      ] EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=16_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /2f8f29fc @snellius_eessi:cpu_rome+default
[ RUN      ] EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=8_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /0e2a6d3a @snellius_eessi:cpu_rome+default
[ RUN      ] EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=4_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /e79508b8 @snellius_eessi:cpu_rome+default
[ RUN      ] EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=2_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /827f27ca @snellius_eessi:cpu_rome+default
[       OK ] (1/4) EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=2_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /827f27ca @snellius_eessi:cpu_rome+default
P: perf: 1.0 s/timestep (r:0, l:None, u:None)
[       OK ] (2/4) EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=4_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /e79508b8 @snellius_eessi:cpu_rome+default
P: perf: 0.8666666666666667 s/timestep (r:0, l:None, u:None)
[       OK ] (3/4) EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=16_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /2f8f29fc @snellius_eessi:cpu_rome+default
P: perf: 1.0666666666666667 s/timestep (r:0, l:None, u:None)
[       OK ] (4/4) EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=8_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /0e2a6d3a @snellius_eessi:cpu_rome+default
P: perf: 0.4666666666666667 s/timestep (r:0, l:None, u:None)
[----------] all spawned checks have finished

[  PASSED  ] Ran 4/4 test case(s) from 4 check(s) (0 failure(s), 0 skipped, 0 aborted)
[==========] Finished on Fri May 16 12:08:58 2025+0200
Log file(s) saved in '/gpfs/home5/satishk/projects/reframe.log'

Test on rome nodes Snellius.

@smoors

smoors commented May 23, 2025

Copy link
Copy Markdown
Collaborator

@satishskamath the cavity3D directory is not staged.
you should move it into a src directory (or another one and set sourcesdir).

@satishskamath

Copy link
Copy Markdown
Collaborator Author

@smoors and @laraPPr I moved it now to the src directory. In my local tree I had it, but I think I forgot to move the folder in a commit, that is why it was not reflected here. Can both of you try again? Thanks.

@smoors

smoors commented May 25, 2025

Copy link
Copy Markdown
Collaborator

it works now in hydra:

[==========] Running 1 check(s)
[==========] Started on Sat May 24 23:00:40 2025+0200

[----------] start processing checks
[ RUN      ] EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=2_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /827f27ca @hydra:skylake+default                       
[       OK ] (1/1) EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=2_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /827f27ca @hydra:skylake+default                 
P: perf: 5.066666666666666 s/timestep (r:0, l:None, u:None)
==> setup: 0.092s compile: 0.010s run: 473.478s sanity: 0.073s performance: 0.003s total: 473.591s                                                                          
[----------] all spawned checks have finished

[  PASSED  ] Ran 1/1 test case(s) from 1 check(s) (0 failure(s), 0 skipped, 0 aborted)                                                                                      
[==========] Finished on Sat May 24 23:08:34 2025+0200

=============================================================================================================================================================================
PERFORMANCE REPORT
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[EESSI_OPENFOAM_LID_DRIVEN_CAVITY %scale=2_nodes %device_type=cpu %module_name=OpenFOAM/v2312-foss-2023a /827f27ca @hydra:skylake:default]                                  
  num_tasks_per_node: 40
  num_tasks: 80
  num_cpus_per_task: 1
  performance:
    - perf: 5.066666666666666 s/timestep (r: 0 s/timestep l: -inf% u: +inf%)

@satishskamath

Copy link
Copy Markdown
Collaborator Author

@laraPPr did it work for you?

@laraPPr

laraPPr commented May 27, 2025

Copy link
Copy Markdown
Collaborator

Haven't tried yet but i suspect the launcher will pop-up as a problem. Will try to test it tomorrow.

def check_launcher_options(self):
if (self.job.launcher.command(self.job)[0] == 'mpirun'):
self.launcher_command = self.job.launcher.command(self.job)
self.launcher_command[-1] = str(self.num_tasks_per_node * self.num_nodes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@satishskamath Can you add some comments here to explain why this is necessary when mpirun is used as launcher, since we don't need to do this at all for other tests?

@satishskamath satishskamath Jun 5, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel this is to prepare the mpirun -np <number of tasks> command before attaching it to the executables specified in the pre-run commands.
With srun this is not required because the number of tasks per node and number of nodes are already defined in the jobscript, those options are sufficient.

Regarding this not being done in other tests, following is the explanation:

  • This is what a correct job script with mpirun looks like:
#!/bin/bash
#SBATCH --job-name="rfm_EESSI_OPENFOAM_LID_DRIVEN_CAVITY_827f27ca"
#SBATCH --ntasks=384
#SBATCH --ntasks-per-node=192
#SBATCH --cpus-per-task=1
#SBATCH --output=rfm_job.out
#SBATCH --error=rfm_job.err
#SBATCH --time=1:0:0
#SBATCH -p genoa
#SBATCH --export=None
#SBATCH --mem=328124M
module load 2023
module load OpenFOAM/v2312-foss-2023a
export OMP_NUM_THREADS=1
export I_MPI_PIN_CELL=core
export I_MPI_PIN_DOMAIN=1:compact
export OMPI_MCA_rmaps_base_mapping_policy=slot:PE=1
cd ./cavity3D/8M/fixedTol
source $FOAM_BASH
foamDictionary -entry numberOfSubdomains -set 384 system/decomposeParDict
blockMesh 2>&1 | tee log.blockMesh
mpirun -np 384 redistributePar -decompose -parallel 2>&1 | tee log.decompose
mpirun -np 384 renumberMesh -parallel -overwrite 2>&1 | tee log.renumberMesh
mpirun -np 384 icoFoam -parallel 2>&1 | tee log.icofoam
echo "EESSI_CVMFS_REPO: $EESSI_CVMFS_REPO"
echo "EESSI_SOFTWARE_SUBDIR: $EESSI_SOFTWARE_SUBDIR"
echo "FULL_MODULEPATH: $(module --location show OpenFOAM/v2312-foss-2023a)"

Executables such as redistributePar and renumberMesh need the correct number of MPI tasks and are a part of prerun commands, and if I print the launcher command even after the setup phase, I get this:

['mpirun', '-np', '1']

Here you can see that the number of processors is still 1.
As far as I know, there are no other tests where the prerun commands require the launcher and the correct number of total MPI tasks.

For srun it does not matter, because a correct jobscript looks like this:

#!/bin/bash
#SBATCH --job-name="rfm_EESSI_OPENFOAM_LID_DRIVEN_CAVITY_827f27ca"
#SBATCH --ntasks=384
#SBATCH --ntasks-per-node=192
#SBATCH --cpus-per-task=1
#SBATCH --output=rfm_job.out
#SBATCH --error=rfm_job.err
#SBATCH --time=1:0:0
#SBATCH -p genoa
#SBATCH --export=None
#SBATCH --mem=328124M
module load 2023
module load OpenFOAM/v2312-foss-2023a
export OMP_NUM_THREADS=1
export I_MPI_PIN_CELL=core
export I_MPI_PIN_DOMAIN=1:compact
export OMPI_MCA_rmaps_base_mapping_policy=slot:PE=1
cd ./cavity3D/8M/fixedTol
source $FOAM_BASH
foamDictionary -entry numberOfSubdomains -set 384 system/decomposeParDict
blockMesh 2>&1 | tee log.blockMesh
srun redistributePar -decompose -parallel 2>&1 | tee log.decompose
srun renumberMesh -parallel -overwrite 2>&1 | tee log.renumberMesh
srun icoFoam -parallel 2>&1 | tee log.icofoam
echo "EESSI_CVMFS_REPO: $EESSI_CVMFS_REPO"
echo "EESSI_SOFTWARE_SUBDIR: $EESSI_SOFTWARE_SUBDIR"
echo "FULL_MODULEPATH: $(module --location show OpenFOAM/v2312-foss-2023a)"

I do not have to specify the correct number of MPI tasks inline for the prerun commands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for clarifying.

Can you add a comment to briefly clarify why this "hack" is needed?
It's essentially because the launcher command is not fully "configured" yet, and still uses 1 as default value for number of ranks...

Is there any way in which we can prevent having to use this hack?
There's no way to run more a series of commands rather than just a single command, which are all launched correctly via the launcher?
Because that's what we really need here, I'd say...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, a comment here to state why this is needed will be helpful in the future. I'd make sure it states two things:

  1. a typical OpenFOAM job would contain multiple mpirun's
  2. We had trouble using ReFrame fixtures to separate these over multiple jobs, because we couldn't get it to work together with the mixin class.

@boegel

boegel commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

@laraPPr As discussed, for this test to work for us, we need to make sure that the following also happens in the generated job script:

  • export OMPI_MCA_orte_keep_fqdn_hostnames=1 => this is required on our system, mpirun must use fully-qualified hostnames (FQDN);

  • unset SLURM_EXPORT_ENV => this is required because:

    • our config for Hortense specifies that --export=NONE must be used with sbatch (that's required to avoid that the environment set by our cluster modules gets passed down into the submitted job);
    • this results in $SLURM_EXPORT_ENV being set in the job environment, which in turns causes trouble when mpirun calls srun under the covers, since it results in $PATH and $LD_LIBRARY_PATH not being passed down to the MPI ranks, and then orted can't be found (resulting in "An ORTE daemon has unexpectedly failed after launch and before communicating back to mpirun");

Both of these can be added to prepare_cmds for the Hortense partitions in the ReFrame configuration file, and OMPI_MCA_orte_keep_fqdn_hostnames can probably also be set by env_vars in the ReFrame configuration file.

When using mympirun as launcher (and not the fake mpirun wrapper), both of these are done automatically, see also hpcugent/vsc-mympirun#143

@boegel

boegel commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

@satishskamath Do we really need to ship the whole cavity3D along with the test?

Can't that be copied from the OpenFOAM installation or something in the test itself?

@satishskamath

satishskamath commented Jun 5, 2025 •

Copy link
Copy Markdown
Collaborator Author

@satishskamath Do we really need to ship the whole cavity3D along with the test?

Can't that be copied from the OpenFOAM installation or something in the test itself?

@boegel
Actually I should specify this in the test itself if I have not already. This is taken from the ExaFOAM project:
https://develop.openfoam.com/committees/hpc/-/tree/develop/incompressible/icoFoam/cavity3D
I know that a 2D version is shipped with OpenFOAM but not sure about a 3D version, I could not find it.
If we know that the link will stay there forever, we can clone the repo, but I was not sure if it will stay there forever. :)

Also, there are two other mesh sizes in that folder which I would like to use for further PRs, that is the reason I need the complete directory tree.

@laraPPr

laraPPr commented Jun 6, 2025

Copy link
Copy Markdown
Collaborator

Am now testing with the new hortense config, #266. Has already passed the 2_nodes tests

@satishskamath

Copy link
Copy Markdown
Collaborator Author

@laraPPr did rest of the tests pass?

Comment thread config/surf_snellius.py Resolved
Comment thread config/surf_snellius.py Resolved
Satish Kamath added 4 commits June 12, 2025 11:24
[x] DONE: drop down to quarter node, and add a 'skip-if' in case there's <8 cores.
[x] DONE: add the comment in the code about the multiple invocations of mpirun
@casparvl
casparvl marked this pull request as ready for review June 12, 2025 13:30

@casparvl casparvl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, tested on Snellius and Vega, Lara seems to have at least tested some scales on Hortense. Going in! Thanks @satishskamath

@casparvl
casparvl merged commit 66d8537 into EESSI:main Jun 12, 2025
@smoors smoors changed the title OpenFOAM Lid driven cavity test case [WIP/Open for testing] OpenFOAM Lid driven cavity test case Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants