Hello everyone.
Welcome back to the CFD using Openfoam Beginner to Intermediate course.
In this class we will be seeing the types of boundary conditions, practical implementation, examples
of those boundary condition turbulence modeling, introduction and setting up and running some Rans
simulation.
So what are the types of boundary condition?
As we already saw we have two.
One is Dirichlet boundary condition and the other is Neumann boundary condition.
To do a Dirichlet condition we will be defining a fixed value.
So it specifies a fixed value for a variable at the boundary.
The example is like inlet velocity in a pipe.
The application will be used when the exact value of the variable is known at the boundary.
The open form keyword to do this is fixed value.
Notice that the v is capital because it's the second word.
I took a velocity file.
For example.
In this we will be specifying the inlet as a velocity.
So here I have done inlet as a function.
This will be defining in the u file.
So the type will be fixed value.
The value will be uniform 100 which means it is one meters per second in x direction.
If you want it in the negative x direction, you can just mention it minus one and it will be, uh,
directed in the opposite direction if you see Neumann boundary condition, it is a fixed gradient.
So it specifies a fixed gradient or rate of change for a variable at the boundary.
The example is heat flux at the surface of the wall or a heated wall.
The application is.
It is used when the derivative of the variable is known at the boundary.
So the open form keyword is zero gradient.
It is not constrained to using zero gradient, but it is the most commonly used.
You can also define other types of gradients with specific values if you want, so that is also possible.
Here I have say taken the same velocity file, but here we will be defining the outlet.
So this outlet is set to type zero gradient because we do not know what is the value at the outlet because
we define at the inlet.
So we won't give at the outlet.
The solver will calculate it for us.
Instead, we will be defining maybe zero pressure at the outlet.
Then we have symmetric boundary condition.
It assumes no flux across the boundary.
The center line of a symmetric flow problem is one such example.
The application is used to reduce computational effort by exploiting the symmetry in the problem.
The openfoam keyword is using just symmetry plane, so it is mostly useful in cases like a nozzle instead
of doing entire 3D.
Even if you take a 2D section, you are still going to see the flow.
But even in a 2D, you don't have to simulate both the top half and the bottom half.
Just simulating the top half is enough because it is going to be symmetric along the center axis.
So you can define the center axis face as symmetry plane and it would still work.
Then we have the periodic boundary condition, which is also known as cyclic.
It assumes the solution repeats itself in a periodic manner, which means the flow in a periodic array
of obstacles can be modeled in such a way that the outlet of the pipe or outlet of the flow domain can
be given as the input back.
So when we are getting a value at the outlet, we can give it as the inlet as well.
So that is what the cyclic says.
So the application is it is used in simulations of a repetitive structures or flow.
And if you have only a small section of pipe, but if you want to consider it as an infinite length,
then you can do the outlet are given to the inlet thing.
So it is mostly periodic or cyclic, and it can be considered as an infinite pipe.
The openfoam keyword is just cyclic, so we have two things.
So one is periodic one and periodic two.
So if you see both has the type cyclic.
But the neighborhood patch corresponds to the opposite of the one.
If you see the periodic one we have neighbor patches periodic two and periodic two has the neighbor
patches periodic one.
This is how we are defining the coupling of both those patches.
and it will be coupled so that one of the output value is given to the input of other value.
The practical implementation example is what we are going to see now.
We have a backward facing step of a 2D.
So if you haven't watched the meshing tutorial already, please check out this YouTube link of my YouTube
channel where I have step by step explained how to prepare the mesh for this.
We will set up both laminar and turbulent case.
For this problem we will use incompressible state solver which is simple form.
So now we will see how to do the laminar case.
This is the geometry which we are using.
It has inlet outlet fixed walls and front and back.
If you see the front end back is set to empty because we are treating it as 2D case.
Then we have the velocity.
The velocity.
We have used Dirichlet boundary condition, where we are defining the uniform velocity as 1D minus three,
which is ten power minus three in the x direction.
Of course, meters per second.
And the outlet is zero gradient.
If you see correspondingly for the pressure, we are not defining the inlet because we already defined
it in the velocity.
So we are defining it as zero gradient in the inlet.
And for the outlet we are setting zero pressure.
So it is also in a unit.
So we will be defining fixed value and the value is uniform zero.
And for fixed walls for velocity it is no slip.
It is just nice way of saying that the fixed value is zero.
Notice that the s is capital and for pressure we are saying zero gradient.
So zero gradient is the way to tell the solver that you have to calculate it for me, and I do not know
it already on front and back is obviously empty because we are doing a 2D case.
If you see the transport properties, we are using a Newtonian model with the kinematic viscosity of
1.56 into ten power minus five, and the simulation type is laminar for this tutorial and in the control
dict, the application is simple form start time is zero and we will be stopping at 2000.
That's the maximum number of iterations.
But if the solution converges faster, we will not go till 2000.
That's how steady state cases work.
So these are the results which we are expecting out of the tutorial.
So now I will jump to the terminal.
Okay so this is the case where we will be working on.
So I will open that location by doing the command explorer dot x space dot.
So this is exactly the case which I showed you.
All the case files belong to this.
Now we are going to run the block mesh.
So I ran the block mesh.
And then the next command is simple form.
Now I will let the simulation run and let it converge.
And we will wait for it.
Okay, now the simulation has converged at 483 iterations.
As you can see, since it converged, it did not bother to go till, uh, 2000 iterations.
Now we can visualize the results.
I'll open the paraview file.
I'll click on apply.
Okay, now we have got the pressure.
But since we are interested only in the last time step where it converged, we will press this and go
to the last time step which is 483.
I'll press on this to set the value to the, uh, range, which is visible here, and we can visualize
the pressure.
As you can see, uh, we are getting a good, steady state over here.
Okay.
Now, the most important, uh, result, which we are seeing in our backward facing step is the reattachment
length and the recirculation region.
So we will see how to visualize the recirculation region by plotting streamlines.
So I will press on this which will plot the streamlines.
Click on apply.
Initially it will show only the pressure colors.
You can change it to velocity colors.
Now if you want to hide the line you can press on this.
It will hide the line.
You can see that there is a recirculation region under Reattachment point for this.
But this tutorial is not about calculating the calculating the reattachment point, so I am not going
to touch upon that.
If you think like this are too many number of stream lines, then you can probably reduce it like this
is a good number.
We are able to see distinct lines here.
So this is how we will be plotting stream lines.
And uh, if you just want to see how it looks without the stream lines, then you can go here, hide
this.
And this is your result.
So that's it about the laminar case.
Now we will see the turbulent case.
So what is turbulence.
The characteristics of a turbulent flow are irregularity diffusivity and high Reynolds number.
The importance of turbulence in engineering is that it is an important aspect to consider, as it plays
a crucial role in fields like fluid mechanical system, aeronautical engineering, and environmental
engineering.
Also weather and HVAC.
The turbulence model overview is mostly these.
We are mostly interested in only three types of turbulence modeling.
One is direct numerical simulation, where we will be solving the entire Navier-Stokes equation without
any modeling.
It is computationally expensive and not feasible for higher Reynolds number.
Then we have large eddy simulations which will resolve large scale turbulence structures while modeling
smaller scales, and it is suitable for unsteady flows with moderate computational cost.
Then we have Reynolds averaged Navier-Stokes, popularly known as Rans, or in Openfoam terms, it's
RA ra as it solves the time averaged equation of motion with turbulence effects modeled widely used
due to its balance between accuracy and computational cost.
So this is the introduction to turbulence modeling.
We will be using Rans throughout this course.
In trance there are mostly three main uh models.
One is known as k epsilon where it is a two equation model where it is, uh modeled based on turbulence
kinetic energy, which is k, and the dissipation rate epsilon.
It is suitable for general purpose applications.
Then we have the most popular one, which is the k omega SST model.
It is also a two equation model based on turbulence, kinetic energy and specific dissipation rate,
which is omega.
Commonly used in external aerodynamics and turbomachinery where the walls need to be modeled so SST
is shear stress transport model.
So we will be modeling shear stress better in this.
Then we have the Spalart-allmaras model, which is a one equation model designed specifically for aerospace
application to predict boundary layer behavior and aerodynamic performance.
It is mostly used in external aerodynamics for airfoil wings and aircraft.
So now we will be seeing backward facing step 2D turbulent case tutorial.
So I'll go here.
I will, uh, enter the second tutorial.
I'll clear this.
Okay.
Now we are going to see the boundary files again.
The boundary is going to remain in the same.
The mesh is the same.
And for velocity we have given 0.05m/s.
It's quite high from what we used already.
Then we have the K, which is, uh, turbulent kinetic energy for inlet.
We are giving a fixed value and value.
We are giving a reference value which is uniform 1.09 into ten power minus three.
It is a 0.061 percentage.
If you want to know how to calculate k omega and epsilon, there is a beautiful documentation from Openfoam.
You can check that out.
So they have given all the standard formula to calculate it, which you will be using as the initial
condition.
And for fixed walls we are using k q r wall function and again the value is referenced to internal field.
Front and back is again empty.
Then for new T we are giving the inlet as zero outlet, also as zero fixed walls as new two blended
wall function, which is a function.
And if you want to know more about these functions, you really have to check the documentation because
there are a lot of function.
We can't just explain all the function in the videos.
So uh, we have the front and back HMD.
So new T is just turbulent kinematic viscosity.
Then uh, the next thing is we are having the omega here.
So sorry the PPT has went backside.
So it is omega and we have given it a pretty big value.
So there is a reason since we want it to converge to a right value, we are giving it a very big value
and it will correct it to the correct value.
So we are trying to give a very big value and asking the solver to correct it for us.
And uh, if you notice in new T we are giving it calculated.
So that is also same.
We are setting it as zero, a very low value and asking the solver to calculate it for us.
So that's what happening.
And in the control dict it is going to remind the same.
And this is what we are uh expecting out of the simulation.
Okay.
Now I will run block mesh.
It is done.
Now I will run simple form.
Let's wait for the simulation to end.
Now the simulation has converged at 1378 iterations.
Now we can visualize it using Paraview.
Okay, we have got the pressure.
And we have also got the velocity.
Now, if you want to plot the streamlines, of course you can do it here.
I'll change it to 250.
Click on apply.
Now you see we have got many recirculation regions.
So this is what turbulence does to the flow domain.
Okay.
Now we have done the simulation.
If you have any questions please feel free to contact me.
And if you want to check the boundary conditions or types of boundary for each of the turbulence values
like k, epsilon and omega, you can check the documentation and set it up.
There are many tutorial cases which you can refer to and try it on your own.