# Step-by-step tutorial for Session 3 CFD Master Class

**URL:** <https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711>\
**Category:** CFD Master Class\
**Created:** [October 10, 2016, 8:50am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711 "2016-10-10T08:50:21Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon35769789](https://www.simscale.com/forum/letter_avatar/anon35769789/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon35769789](https://www.simscale.com/forum/u/anon35769789)\
**Post date:** [October 10, 2016, 8:50am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/1 "2016-10-10T08:50:21Z")

</div>

## Recording

[![](https://www.simscale.com/forum/uploads/default/original/3X/7/e/7e85efe4888104db7e206d22d6b5a70408c43925.jpeg "CFD Master Class: Multiphase Flow Systems") ](https://www.youtube.com/watch?v=kErRdJT-jQc)

## Exercise

In this exercise we will examine how the Courant number affects the stability and simulation time. A high Courant number speeds up the simulation convergence but can lead to instability. For this reason, the Courant number is restricted below 1 and in some cases an even lower Courant number is required. A lower Courant number corresponds to a smaller time step size and hence more computations, but enhances stability.

The task is to run simulations at different Courant numbers and examine the effects on the convergence speed and stability.

We will be doing a multiphase simulation for this task. Note that these simulations are transient in nature and will take longer to converge. Thus for these types of simulations, selecting the right Courant number is very crucial.

## Step-by-Step Instructions

- For this project we will use a simple geometry which can be [imported using this link](https://www.simscale.com/workbench?publiclink=4982767c-eea9-425c-a940-7303435ee5bb).

- We will examine the waterfall in an open channel with the water entering from one side of the domain and falling into the water reservoir at the bottom of the domain.

## Meshing

- Make sure that the geometry item is selected in the Project Tree and press **New Mesh** to create a new mesh setup for the geometry.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/e/eefb04bea590537b5a41a505e5f2a5b41190b636.png)

- We will make a fine mesh for this geometry by using the manual Hex-Dominant meshing algorithm. Move to the **Hex-dominant parametric (only CFD)** in the mesh setup, set the number of cells in the x,y,z directions to **108, 22, and 43** respectively and set the number of cores to **4** for this job.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/7/7cd46a670fa80478d86de4a7482669929ff121e2.png)

- Now move to the **\_BaseMeshBox** in the mesh tree and set the dimensions for the bounding box as shown in the image below.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/a/ad341cd3dd35c6d6e2cabdfd8093774339ab0a48.png)

- Next go to the **MaterialPoint** item in the Project Tree and set the coordinates to **(2,1,1)**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/e/e5c19eff18ad7131657630bbd1e97b6706f5c3db.png)

- We want to make mesh refinements as well. To do this, we will create a Cartesian box. Go to the **Geometry Primitives** item, press **New** and select **Cartesian Box.**

 ![](https://www.simscale.com/forum/uploads/default/original/2X/c/cb0f82de7fc7dff2471baa118a1c8437009582d7.png)

- Set the dimensions of the box as shown in the image below.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/0b7b1f6d7a8b6d81cc857b2b10fce56f8d08b70c.png)

- Now to add mesh refinements, move to the **Mesh Refinements** in the meshing tree and press **New.**

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/009796ef34acff74dd00083946c3eba02b944002.png)

- Rename the mesh refinement to “SurfaceRefinement”, change the refinement type to **Surface Refinement** , set the refinement levels to 0 and 1, and then **Save** the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/8/8aad3e3fbd295405f44c42ccbfed055dabce3be2.png)

- Similarly add another mesh refinement and name it "RegionRefinement, change the type to **Region Refinement**. Set the refinement level and assign the refinement to your **Cartesian Box** geometry primitive. **Save** the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/2/23ffdb028d9f456ba4f6eec4f74171c75b4c1282.png)

- Finally move back to **Operation 1** in the Project Tree and press **Start** to start the meshing.

## Simulation

- Once the mesh is finished (please note that this can take some time), move to the **Simulation Designer** tab and press **New** to start new simulation setup.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/948b29275c567588ef990e1b626eb38f64c38cdd.png)

- In the middle column select **Fluid dynamics** and **Multiphase** for the Analysis Type. Make sure in the properties that local time stepping is turned **off** and that the **Laminar/Transient** model is selected. Once saved the Project Tree will expand in the left column.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/f/fc13c74623ff44679fb5d458dae755e7a25174ab.png)

- Go to the **Domain** item in the Project Tree and assign the mesh. **Save** the selection. For this simulation we will use the **waterfall mesh** domain that we just created.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/a/af83ccd116bea8956276f58c0cb10189664691be.png)

- To create the reservoir of water, move to the **Geometry Primitives** in the Project Tree and add a new “Cartesian Box”. Rename the box to “Reservoir” and set the dimensions of the box to the values shown in the image below.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/2/27907be145c5a0c8fb9ac05411c36b836856e881.png)

 ![](https://www.simscale.com/forum/uploads/default/original/2X/d/d44aca9638b5311b0280d2725f0379d32d4039d1.png)

- Now move to the item called **Topological Entity Sets** , select the inlet face as shown in the image and press **+New from selection**. Rename this selection to ''inlet".

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/03169fc0e9cfe50b504331eeb1d1fae2d17cf75d.png)

- Similarly select the outlet face as shown in the image below and make a new set. Rename it to “outlet”.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/9649ca1b9fe10c2a79a0dd8a301f11b600c42eff.png)

- Finally select the remaining faces and make a new set called “walls”.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/9b6fac05645c4a168c1ceffb55e5280111f40976.png)

- Now move to the **Model** item in the Project Tree and set the value for gravity to =9.81 m/s2 for the z value.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/c/c11d3e949cbd9acea1022c6a084ca73372502327.png)

- To assign materials to the domain, move to the Materials and click **New**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/e/e65cb04d0e9b8a3075d8f880dcb58597e8a5c85a.png)

- Click **Import from material library**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/e/e46182164395c505e76575b90224d12ba78d2fd6.png)

- From the library options, select and save **Air**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/d/d9b297d8eb16ca45dfcf2601c06ba41d38ac4c29.png)

- Finally change the **Associated phase** to “Phase 0” and assign it to the entire volume region0

 ![](https://www.simscale.com/forum/uploads/default/original/2X/a/ae608d64f02c9f82b36c7b18d1811d26d7d7991c.png)

- Similarly add another material, this time **Water**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/a/a754b31f74e246b86babcfafcea0b1606946f544.png)

- Change the **Associated phase** to “Phase 1” and assign it to the entire volume region0

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/9088d4e599436a9c0c833eb798ce3b540e7a2331.png)

- Now move to the **Phase fraction** in initial conditions, change the type to **Subdomain-based** and set the “Default phase fraction value” to 0. Press **Save** to save the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/7/74c95deb07f2c476859525622e8889cb42ac032b.png)

- Once saved, press **New** to add the subdomain. Here set the parameters accordingly, select the “Reservoir” and save the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/94b5404720d03056ce38ad2c24651f9394dc14d0.png)

- The next step is to add the boundary conditions. Move to the **Boundary conditions** item in the Project Tree and press **New** to add a new boundary condition.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/062e51d49b065ae75634b0ce6ed3d182796b0a18.png)

- Rename the boundary condition to “Inlet”, set the Type to **Velocity Inlet** with an x value velocity of 2 m/s, set the phase fraction to 1 and assign it to the “inlet” face. Press **Save** to save the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/b/bae565911f35e179a0832f4ab67f76adce258b79.png)

- Add another boundary condition for the outlet and rename it to “Outlet”. Set the Type to **Custom** with a **pressure-inlet outlet velocity** and **Total pressure.** Then set the phase fraction to **Inlet-outlet** and assign it to the “outlet” face. Press **Save** to save the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/9167c14358663f813f821830773acea7bafe688f.png)

- Add the last boundary condition for the walls as shown in the image.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/90c55d0f76ccded9b365ed72e8164fc97e038473.png)

- Now move to the **Numerics** and set the essential parameters as shown in the images below. Press **Save** to save the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/0af1ca2d30f9876cbb707dd8d7bfce1a5c52c28e.png)

 ![](https://www.simscale.com/forum/uploads/default/original/2X/3/36c71372fcbb46ddbfd873c67065b31eced194a5.png)

- Move to the **Simulation control** and set the parameters accordingly. We will run this simulation for 3.5 seconds. **Save** the selection.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/a/a05c9ca0212c3b6162fd02fe787ca10023d53cd7.png)

 ![](https://www.simscale.com/forum/uploads/default/original/2X/9/99aa4392e335e1531d8f816f4939894fe602c626.png)

- Then move to the **Simulation Runs** item in the Project Tree and press **New** to create a new simulation run. Once new run is created press **Start** to start the simulation run.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/2/20b2a42791d0dc1667d69e3e1f056ae60508508a.png)

## Post-processing

- Once the simulation is complete, move to the **Post-Processor** tab.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/8/892d6d7abac19287c114f68f4118e7df1730fd00.png)

- Load the solution fields to the viewer by clicking on the **Solution fields** item in the project tree.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/4/41cd1dbbd78a8fee6176ffccbfb99360e345db57.png)

- Once solution is loaded change the **Opacity** of the domain and **Apply** the changes. Now change the shown field to **Solid color**. This way we are only plotting the domain.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/0/0a3fe7f4f67777f31bfc5309cea13a2c0d5858af.png)

- Next add a filter to visualize the air water interface. Click on the **Add filter** button and select **Contour**.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/3/3f898dd43c6000b3b6bd4c221894b221570c7c90.png)

- Set the parameters as shown in the image. Apply the changes and change the plotted field to **U** in order to visualize the velocity at interface.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/c/c3ab4b27a2dae5edd14c3f2bae8e49294fe0711a.png)

- Click on the eye sign next to the “Run 1” item to show the domain.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/7/7042e40e9482b21e01928a602ac7a4245aeaccfa.png)

- Now your task is to examine how changing the Courant numbers and time step affects the convergence speed and stability of the simulation. Create a table to track your findings.

- Please create additional simulation runs for following time steps/Courant numbers:

 ![](https://www.simscale.com/forum/uploads/default/original/2X/6/6c6f42a0f7524010b51e1e7f2f649a02ae933ac4.png)

---

<div class="post-metadata">

**Author:** ![anon35769789](https://www.simscale.com/forum/letter_avatar/anon35769789/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon35769789](https://www.simscale.com/forum/u/anon35769789)\
**Post date:** [October 10, 2016, 8:50am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/2 "2016-10-10T08:50:31Z")

</div>



---

<div class="post-metadata">

**Author:** ![anon67859130](https://www.simscale.com/forum/letter_avatar/anon67859130/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon67859130](https://www.simscale.com/forum/u/anon67859130)\
**Post date:** [October 14, 2016, 3:12pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/3 "2016-10-14T15:12:25Z")

</div>



---

<div class="post-metadata">

**Author:** ![hiuluom](https://www.simscale.com/forum/user_avatar/www.simscale.com/hiuluom/32/36369_2.png) [@hiuluom](https://www.simscale.com/forum/u/hiuluom)\
**Post date:** [October 15, 2016, 4:21pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/4 "2016-10-15T16:21:52Z")

</div>

Hi Mafi,  
I would like to ask some question that is how to determine level refinement for region corresponding CFL?  
and is it the smallest size Dx in domain used to compute CFL?

---

<div class="post-metadata">

**Author:** ![OTCristian](https://www.simscale.com/forum/letter_avatar/otcristian/32/5_5575768a8748004e209b776fc1b2916d.png) [@OTCristian](https://www.simscale.com/forum/u/OTCristian)\
**Post date:** [October 16, 2016, 4:36pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/5 "2016-10-16T16:36:29Z")

</div>

Hello.

The Courant number (CFL) exceeded the limit of 1. You may experience either instability or bad temporal accuracy. It is recommended to keep the CFL number below 0.7. In order to achieve this you need to decrease the time step.

I keep on getting this error message and the simulation cancels itself.

---

<div class="post-metadata">

**Author:** ![mlarreta](https://www.simscale.com/forum/user_avatar/www.simscale.com/mlarreta/32/3847_2.png) [@mlarreta](https://www.simscale.com/forum/u/mlarreta)\
**Post date:** [October 17, 2016, 2:28am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/6 "2016-10-17T02:28:22Z")

</div>

Hi @OTCristian,

I reviewed your project and seems like you have a finer mesh than the instructions, my mesh is around 1 million of 3D elements and yours is around 8 millions, this is causing the simulation to terminate because it’s exceeding the time of execution (15,000 sec or 250 min), the simulation is canceled at 256 min.

I can see that you used level 3 for the region refinement instead of 2, try to do a new mesh, this should resolve the cancellation issue, the courant number warning will appear again.

---

<div class="post-metadata">

**Author:** ![OTCristian](https://www.simscale.com/forum/letter_avatar/otcristian/32/5_5575768a8748004e209b776fc1b2916d.png) [@OTCristian](https://www.simscale.com/forum/u/OTCristian)\
**Post date:** [October 17, 2016, 11:25am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/8 "2016-10-17T11:25:20Z")

</div>

Yes, I do use a finer mesh. So that’s should be the problem, using level 3 region refinement instead of 2. I was trying to obtain a more refined result. I`ll change the refinement and get back with an answer.

---

<div class="post-metadata">

**Author:** ![mlarreta](https://www.simscale.com/forum/user_avatar/www.simscale.com/mlarreta/32/3847_2.png) [@mlarreta](https://www.simscale.com/forum/u/mlarreta)\
**Post date:** [October 17, 2016, 3:15pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/9 "2016-10-17T15:15:16Z")

</div>

I can see what you mean @OTCristian , in that case for the finer mesh you can increase the Maximum runtime [s] in order to give it more time to solve all the equations.

---

<div class="post-metadata">

**Author:** ![ayousry](https://www.simscale.com/forum/letter_avatar/ayousry/32/5_5575768a8748004e209b776fc1b2916d.png) [@ayousry](https://www.simscale.com/forum/u/ayousry)\
**Post date:** [October 20, 2016, 11:40pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/11 "2016-10-20T23:40:24Z")

</div>

Hi  
I have the same problem (The Courant number (CFL) exceeded the limit of 1.)

---

<div class="post-metadata">

**Author:** ![hiuluom](https://www.simscale.com/forum/user_avatar/www.simscale.com/hiuluom/32/36369_2.png) [@hiuluom](https://www.simscale.com/forum/u/hiuluom)\
**Post date:** [October 21, 2016, 8:44am UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/12 "2016-10-21T08:44:35Z")

</div>

You should set small time step less than max time step for CFL 1.0.

---

<div class="post-metadata">

**Author:** ![oscarcorripio](https://www.simscale.com/forum/user_avatar/www.simscale.com/oscarcorripio/32/6518_2.png) [@oscarcorripio](https://www.simscale.com/forum/u/oscarcorripio)\
**Post date:** [October 21, 2016, 1:41pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/13 "2016-10-21T13:41:46Z")

</div>

Hey, the problem is that your simulation times out just like @mlarreta mentioned. If you look carefully at the simulation control picture you will see that @anon35769789 also changed the Maximum runtime to 15000. Otherways you get that error message that you mention. Once you fix this you can use the CFL and time steps exactly as listed on the table.

---

<div class="post-metadata">

**Author:** ![mlarreta](https://www.simscale.com/forum/user_avatar/www.simscale.com/mlarreta/32/3847_2.png) [@mlarreta](https://www.simscale.com/forum/u/mlarreta)\
**Post date:** [October 21, 2016, 2:30pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/14 "2016-10-21T14:30:36Z")

</div>

Hi @ayousry,

I reviewed you project, all the runs are 100% complete, and you are still getting the courant number error as you mentioned, I have the same error for all the run configurations.

You can try this, I used a CFL number of 0.2 with a time step of 0.0035, it took more time but the warning didn’t show up, you can calculate your own CFL with the formula, this is from the video of the session 😀.

 ![](https://www.simscale.com/forum/uploads/default/original/2X/5/50c75a5e13102f324ea77b2908c68b14ae43d70b.jpg)

---

<div class="post-metadata">

**Author:** ![DaleKramer](https://www.simscale.com/forum/user_avatar/www.simscale.com/dalekramer/32/20201_2.png) [@DaleKramer](https://www.simscale.com/forum/u/DaleKramer)\
**Post date:** [August 16, 2018, 5:48pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/15 "2018-08-16T17:48:18Z")

</div>

@anon35769789

And yet another great and timeless workshop 🙂

> [@anon35769789](#):
>
> Please create additional simulation runs for following time steps/Courant numbers:

Any chance of you publishing the execution times and a summary of the result differences for this homework now that due date has long gone 😉

Thanks,  
Dale

---

<div class="post-metadata">

**Author:** ![jousefm](https://www.simscale.com/forum/user_avatar/www.simscale.com/jousefm/32/34908_2.png) [@jousefm](https://www.simscale.com/forum/u/jousefm)\
**Post date:** [August 16, 2018, 8:16pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/16 "2018-08-16T20:16:35Z")

</div>

Hi Dale (@DaleKramer )!

Usually this has to be elaborated by the user when handing in the homework 😉 But creating a plot showing the execution time over CFL for instance would be a nice “add-on” inside the homework documentation indeed.

Best,

Jousef

---

<div class="post-metadata">

**Author:** ![DaleKramer](https://www.simscale.com/forum/user_avatar/www.simscale.com/dalekramer/32/20201_2.png) [@DaleKramer](https://www.simscale.com/forum/u/DaleKramer)\
**Post date:** [August 16, 2018, 8:34pm UTC](https://www.simscale.com/forum/t/step-by-step-tutorial-for-session-3-cfd-master-class/45711/17 "2018-08-16T20:34:01Z")

</div>

> [@jousefm](#):
>
> Usually this has to be elaborated by the user when handing in the homework

But homework due date is long gone and I think that the results are historically and educationally valuable and which should be published 🙂

Dale
