Design of Experiment with OpenFOAM

Published by rupole1185 on

A design of experiment is a methodology of authomatically execute multiple analysis to verify, for instance, the influence of boundary conditions to a CFD case. Thanks to cloudHPCexec, a linux tool which you can install as a normal .deb package, this is possible and easy to do. Let’s discover how!

Everything starts by generating a correct setup for your snappy mesh generation. We are now going to refer to a popular openFoam testcase: motorBike.

Once you are happy with your settings, execute your simulation on the cloud by typing the following command:

cloudHPCexec -batch 8 highmem snappyHexMesh-of8 MOTOR-MESH

This command executes a 8 vCPU machines with RAM type highmem (8 GB per vCPU) using snappyHexMesh for OpenFOAM v8. MOTOR-MESH is instead the name of the folder once uploaded on the cloudHPC website. The execution of this command returns the ID of the simulation which runs on the cloudHPC.

If you are generating a bash script file, at this point you have to wait for the mesh to be completed before actually moving on with the CFD execution. Our tool provides a -wait command which puts on hold the script execution until a certain analysis/simulation is in RUNNING, as showed in the following image.

Launching openFoam solver

Before entering the details on the openFOAM execution, we recommend you to check the recommended settings for controlDict and decomposeParDict.

To execute one openFOAM solver, exactly like we made for the snappyHexMesh execution, we again type the cloudHPCexec command:

cloudHPCexec -batch 16 highcore openFoam-of8 MOTOR-CFD-20 MOTOR-MESH

Compared to previous execution a few things have changed:

  • highcore. This is a multi-core only instance which is always recommended for openFOAM solvers
  • MOTOR-CFD-20. This is the folder name on the cloudHPC storage
  • Since we generated the mesh on the cloudHPC, we want to copy the mesh from the previous snappyHexMesh execution. For this we specify MOTOR-MESH as the folder from which the system is going to copy the openFoam mesh.

Updating BC and re-launching the solver

Now that one openFoam case is running, we might want to run a proper DOE – Design of experiment: we update the boundary conditions and, using the same snappyHexMesh we run a new case. To do so, we can update our boundary conditions which are specified in 0.org/include/initialConditions for the U variable.

In this file a flowVelocity variable defines the inlet velocity vector of (20 0 0).

OpenFoam provides a great tool to update variables in files: foamDictionary. With this the command becomes:

foamDictionary 0.org/include/initialConditions -entry flowVelocity -set "(10 0 0)"

This command modifies the variable flowVelocity in file 0.org/include/initialConditions and sets its value to (10 0 0). You can easily adapt this configuration to match your DOE.

It is now time to execute this new case with the modified velocity. We retype the same command as in the first openFoam execution and we just modify the folder name on the cloud to MOTOR-CFD-10.

We now have two running cases on the cloud with the two boundary conditions. Just a matter of execution time to get two results in the time required to compute one!

Bash scripting

The generation of a bash script which automatically executes all the abovewritten operations is easy. Just generate a text file in which you copy, one after the other, all the commands defined above and make it executable by typing:

chmod ugo+x file_name.sh

CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: cloudHPCOpenFOAM

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *