Hello everyone.
Welcome back to the CFD using Openfoam beginner to intermediate course.
This is the class two and in this class we will be seeing some geometry and mesh generation using a
tool called block mesh.
Then setting up boundary and initial conditions.
And then we will also see how to use solvers and run the simulation in Openfoam.
After doing that, we will be using Paraview as the post-processing tool and we will be seeing the results
first.
What is block mesh?
Block mesh is a mesh generation tool which comes with the installation of Openfoam.
It uses a dictionary file to call block mesh dict to define simple geometries and create structured
meshes.
The role of block machine openfoam is that it is used to create initial computational meshes.
It can be highly structured, suitable for simple geometries like square, rectangle, channel or cube,
cuboid or a flow over a cylinder or a wedge.
These kind of things can be easily done using block mesh.
Even.
It can handle complicated mesh like structured mesh around an airfoil.
But for that, we have other tools which might be very efficient in terms of time than block mesh.
So the effort versus, uh, accuracy comes better in other software for a complex mesh.
But block mesh is very efficient for a simple mesh.
So the main key sections of block mesh dict is like vertices will be there.
We have to define the vertices on a 3D space which we are going to use.
Then using those vertices we will be defining boxes or a hexahedral box, meaning it will have six faces,
more like a cube or a cuboid.
Then we will be defining edges if we want specialized curves.
So if there is a two point and we can join the two lines two points using a line.
But if we want to join it using an arc, we can introduce a third point and define that point as a path.
So that can be done using the edge feature.
And then comes the boundary.
So this boundary will define the type of patch, whether it is an inlet or outlet, or empty patch or
wall patch, or if it is symmetric.
We can do those things in the boundary.
But let's say we have two blocks and two blocks share one common face, but we don't want it to be like
a wall.
What we do, we just merge the patch so that those two blocks behave like a single block.
So that is where the mesh merge patch pairs come into play.
So we will be seeing all these practically when seeing the blog mesh dict file as an example.
For the first thing, we will be creating simple geometries like a 2D square cavity.
We will be defining eight vertices, and we will use those eight vertices to create a single block.
And we will be defining boundary condition.
And we will see how the meshes in the next example will be.
We will be doing a 3D rectangular channel where we will be setting boundary condition like inlet, outlet
and wall, same eight vertices, and we'll be creating a block.
So we will first see this and then proceed further.
Now I have my terminal open.
I'm already in the folder for class two.
And we have the first case which is square cavity mesh.
So I will go inside that.
Okay.
Inside this we can see that we have constant uh para dot form and system.
We do not have zero.
So zero is supposed to contain the boundary condition or boundary files.
But we are not having that file here, that folder here because we are not interested in in running
the case, we are just interested in doing the mesh using block mesh data.
So block mesh dict exists inside system folders.
Let me show you.
So this is the case which we are going to use.
And under system folder we will be having the block mesh dict.
We will view what is there inside.
Okay.
Now we have eight vertices as you can see.
So each one corresponds to x, y and z.
But before that we have something called scale.
So what is this scale.
Usually everything in openfoam is an Si unit, meaning whatever vertices we define it is in metres.
So if it is like zero comma, zero comma zero, it is a point, and the next point is one comma zero
comma zero.
It means that this is one metre away from zero comma zero comma zero in x axis.
But if we don't want to work with meters, what do we do?
We just define it as 0.001.
If we want to work with millimeters just 0.01 if we want to work with centimeters.
But if you want to work on a kilometer scale, then you can obviously choose 1000.
If you are doing something like an entire aeroplane with a large amount of, uh, mesh, then you can
choose kilometer scale if you want, but usually scale one, which is meters is fine.
Now let's see what are these vertices.
To explain that, I will just open paint, uh, so that I can explain you physically.
So this is 000.
So let's assume we have a coordinate system.
And let's say this is x.
This is y and this is Z.
Okay.
Now we will be doing one by one.
This is like a an array okay.
Uh openfoam is written in C plus plus.
So everything starts from zero.
So this element in the array starts from zero.
So let's keep it like this is the zeroth point okay.
And we have one comma zero comma zero which is like one meter displaced in the direction of x.
So this will be our point one.
And then we have one comma one comma zero which would be around here.
And this is our point two.
And then we have zero comma one comma zero which will be around here.
So this will be our point three.
Now these four points can form a face a simple 2D face.
Well Openfoam can't really work with 2D structures, but with these four points we can only make a 2D
face.
Now we have got a face, but if you see the other four, the values in the x and y are same, like if
it is zero, one, two, three, then four, five, six, seven have the a corresponding like zero and
four have the same x and y, but the z is different.
And if you see two and five, the x and y is same.
But the z is changing.
What it essentially means is that we are just displacing this entire face or copying the entire face
and putting it at some distance in the Z direction.
Let's say this will be our fourth point.
This will be our fifth point corresponding to one.
This will be our sixth point, and this will be our seventh point.
So what this essentially does is that we have got another face.
Yeah.
Now we have two faces, but it is not yet connected in the Z direction, so we don't have a block.
Right.
So that's where this section comes in.
We are defining it in the name hex because it is a hexahedral block.
And then we are giving the numbers.
So these numbers are the index of these vertices.
So if you had noticed something when I was writing this, I was doing it in counterclockwise because
zero one, two three is in counter-clockwise.
Then 4567 is also counterclockwise.
This is a notion that we have to follow in openfoam.
And also when we are finished doing those the first four points, the next point has to correspond with
the zeroth point.
So that is how it works.
Only then it can make the association.
Okay.
Now we have created the two faces and we are defining 01230123.
And we have 456764567.
So we are defining it as a single block.
Now this will connect these points and make it as a block.
Okay.
The next command which we are seeing here is three points or three values.
This is x, this is y and this is z.
So what it means is that we are subdividing the x direction face in the value of 20.
And we are subdividing y by 20.
And we are just keeping one cell in z Z direction.
So after subdivision, the X direction will be getting subdivided 20 times and it will be carried over
throughout the mesh, not just one phase, it will be carried over throughout the mesh.
We will also see this visually and y is also done simple grading.
We will not look at that right now.
Let's uh, assume that it is one, one one as of now.
Most commonly, we will be using one, one one only.
So we will just see up to here, run the block mesh and we will see.
So what I am going to do is I will comment this entire boundary.
We will pretend that this doesn't exist.
Like I have commented this meaning it doesn't exist in the code.
So we are just going to run this.
I will go here and whenever you are running anything in Openfoam, make sure you are in the right working
directory.
So what is working directory mean when you are in a location like in this case I am at one square cavity
mesh and if I type ls I have to see the constant system folders.
Only then we are in the right, uh, location.
Let's say I am inside system because this is where block mesh resides.
Right?
But I should not be doing this.
If I go into system and do block mesh, it will throw an error.
It is not going to work.
So I will go back one directory.
Now I will type ls.
Now we can see constant and system.
So this is the location where we have to execute all our open form commands.
We have to remember this throughout the usage of open form.
Now the command to execute block mesh is just block mesh.
Notice that M is capital.
I will hit enter.
Now you can see that we have 400 cells because we have 20 by 20 and we have many faces.
And the bounding box is like 000 which is the minimum value.
and this is the maximum value of the cube, which is one one, minus one 0.1.
And we have only default faces as all patch.
So we will visualize it to visualize.
As I have explained in the previous class, we will do touch space dot form to create a paraview file.
Then we can go in here.
Double click this.
Wait for it to load.
Click apply.
Then we will have a block.
You see it is a block.
But how do we view the mesh?
We will go here.
Click on surface with edges.
Now you can see the blocks okay.
Uh, if you scroll down on the left panel you can see something called Data Access Grid.
I will turn on.
You can see the x axis ranges from 0 to 1.
Y is also ranging from 0 to 1, and z direction is from 0 to 0.1.
Exactly what we wanted to do.
So if I click this button, it will snap to the z axis normal plane.
Okay now we have this.
So we will see what the 20 by 20 actually did.
Okay.
Now let's say I have only one one in x and y direction.
Uh, now after changing, I will hit control S to save the file.
I will run block mesh again so it will get updated.
I will go to paraview and make sure that you are selected para dot form and click on refresh.
Try to move something like in para view.
Your left mouse will be used to rotate it.
Right mouse button can be used to scale up and scale down.
Middle mouse can be used to move things.
Mouse is highly recommended whenever you are working with any geometry, so get a mouse.
Okay, now I am zooming by scrolling the mouse wheel.
Okay, now you can see even though I am in surface with edges, we are seeing only one cell in this
because we have not divided into anything.
Now let's say I am just dividing this by five five.
I will save the file run block mesh command.
Go to paraview.
Refresh it.
Now you can see we have five on the x axis and five on the y axis.
Now I just want to go back to 20 by 20 let's say okay I will save it.
and run the block mesh refresh.
And you can see we have 20 by 20.
But since I gave one as the value in z direction, we have only one cell in the z direction.
It is because we are trying to make a 2D uh square cavity case.
So we are keeping is it as one.
So because in openfoam there is nothing as pure 2D, Everything has to be 2D.
But what we will do is we will set the front plane and back plane as empty patch, so it will behave
like a 2D case.
Okay, now we have the mesh.
How to define the boundary names like everything is a default patch here.
How do I know?
On the left panel if you see if you click here, I will deselect internal mesh and select on the default
faces click apply.
You see everything is default phase.
Now this is where we will be getting the name of the patches.
Now I will go back to internal mesh as of now okay.
In the block mesh dict file I have typed this so let's see what each of them says.
I will just comment out moving wall.
Save it.
I will go back to the paint.
Now you see, I have given a name.
Moving wall and the curly braces.
Within that I have typed type as wall.
So this is going to behave like a wall.
And this name can be anything.
I just chose moving wall um, in this case.
But it can be anything like a top wall or something.
Then the type is wall and I have to define the faces.
You can see we have four numbers here three, seven, six and two.
So what it is it is three, seven, six and two which is the top face here.
So you can notice that this is also an anticlockwise direction 3762.
We always have to follow this.
Otherwise it will say the face is outward.
It is facing outwards.
So what we are trying to follow is right hand thumb rule.
Assume that this is a hand okay, so whenever you are curling your fingers, the outward normal should
be facing outside.
Your thumb has to face outside.
So we are curling it that side.
So it is facing outside.
You can try it.
It is right hand thumb rule okay.
Now I will save this file.
I'll go here.
Run block mesh.
Now you can see that we have one more patch called moving wall.
Apart from default face I'll go to Paraview refresh.
You can see this just popped up.
We have a moving wall now.
I will select that.
Deselect everything and you can see this is the moving wall.
Very nice.
We just created or given a name to a wall or a patch.
Okay, now similarly I will remove comment for fixed walls.
Fixed walls are also walls.
As you can see I have defined three phases here.
One is 0473 which is 0473, which is this phase.
If you see from that side then that is still anticlockwise.
Then we have two six, five one and then 51540.
So we have defined all these faces as fixed walls.
I will save the file run block mesh.
Now you can see we also got fixed walls.
Now I'll go here refresh.
I will select the fixed walls alone.
Deselect everything you can see.
This is the fixed wall.
Okay, this is annoying.
I will remove the date axis grid.
Okay.
we have the fixed servers.
Now I will select both fixed walls and default faces.
We are seeing everything.
I will select fixed walls and moving wall.
Yeah, these are the walls.
Now we are missing front and back.
Right.
So you can see that only those two are left in the default patch.
Only these two are left without name.
So what we are going to do is we will select those two faces and put it into front and back, and we
are defining it as empty.
Whenever you are working with 2D, the front and back has to be empty.
Only then this will behave like a 2D case.
And here also I have put two face values.
I will save the file run block mesh just like you expected And refresh.
Now you can see we don't have anything in default phases.
We are seeing nothing.
I will remove default phases.
Check.
Fixed walls.
We have fixed walls, we have moving walls and we have front and back.
Yes, we have created the entire mesh.
Now if you want to refine it, it's very simple.
Just go here and maybe put 50 by 50.
Save the file.
Run block mesh.
Give refresh.
Yeah.
You have a finer mesh.
So this is all that you have to do to create a 2D mesh.
If it is a simple square like this can be done if you want to do something like a flow, uh, on a flat
plate, then you can do these things, but you need an inlet and outlet.
You just have to change this as inlet and this as outlet, which we will be seeing in the next case.
So I hope you understood what we did here.
Now we will see about simple grading.
So simple grading is like a gradient for the mesh.
Uh, let's say this is one now in the x direction I will change it to 0.1 and you will see how the effect
changes.
Sorry I didn't run the block mesh.
You see, everything is biased towards the right.
Still, the count is same.
It is 50 by 50, but it is a gradient towards one surface.
It is because we have given it as 0.1, which means this is 0.1 times finer than whatever is here.
So it will do that simple uniform grading.
So this will be efficient when you are doing some inflation layer.
Or if you want to, uh, create some boundary layer thickness then this could be useful.
And if I do -0.1.
Then I will get it towards this side okay.
And this can be done for y direction also I'll do Do 0.1 run block mesh and refresh.
Yeah, we have got it.
So to reset everything, all you have to do is put the values to default one, one one, save the file,
run block, mesh and refresh.
That's it.
So we have got the entire mesh.
This is nice.
Okay we are done with this.
Now we will see what we have in the second tutorial, which is rectangular channel.
Um, okay.
In the system folder we have block mesh dict and I have defined eight vertices.
You can pause the video and ponder how these vertices make a block.
Again I have made this, but now you can see there is a slight difference.
We are working with 3D so we don't have front and back and walls is defined as wall, but the inlet
and outlet is defined as patch because in patches we can give values like inlet and outlet.
That is what this makes.
For inlet I have chose the left face.
For outlet it is the right face and everything else is a wall.
This is a 3D case in x direction.
I chose 100 y ten and is it also ten?
No grading okay, and I have chose the scale as 0.1 and I'll save this file.
I'll go to this location which is the second folder rectangular channel mesh.
Okay.
Now I am in the right directory.
I know because I am seeing constant and system and I do list which is list.
Okay.
List is list will listing all the folder.
Now I can type block mesh.
Okay.
And, uh, I have already created the preview file, so I'll double click and open it.
Gonna apply.
So this is the geometry I'll go to surface with edges.
You can see the entire geometry.
Now I can click on inlet.
This is the inlet.
This is the outlet.
And these are the walls.
So you get the point.
How block mesh works.
And once we have the inlet and outlet we can set up a case.
But you might be wondering where are these files getting saved.
Right.
So we will see where it is getting saved.
It is under constant folder.
Generally constant folder has other files also like properties of the fluid or material.
But I have deleted these files because we are just interested in mesh.
Under this we have a folder called poly mesh.
This is where all the mesh information is stored.
Regardless of what mesh you are using, be it block mesh or snappy hex mesh, or if you are importing
mesh from Ansys or Fluent or Mesh or whatever it is, once it is in open form understandable format,
it will be under poly mesh.
Here you will be able to see five files.
These are points which make the mesh and these are the owner which is like a patch.
And the relation.
These are neighbors.
Other.
Another relation and faces.
If you are interested in seeing what is there inside, it is just pure numbers.
Okay, same with this.
You see everything is just number and for owner again it is just numbers, points also obviously numbers.
But we are not interested in those.
We are just interested in boundary.
Okay I will go inside the boundary file.
And now you can see it makes sense.
Right.
We have three patches.
One is inlet, the other is outlet and the other is wall.
So suppose you made the mesh.
Now you don't want to generate block mesh from scratch again.
Because sometimes when the mesh count is too high like a million, then it can take a bit of time to
generate the mesh.
It won't happen quickly.
In that case, you don't want to change just the patch names and run the block mesh again.
All you can do is you can go here and change whatever you want.
Let's say, uh, I don't want this as outlet.
I just want this as, uh, outflow.
Okay?
I'm just changing the name.
Then I can do it.
I'll save the file and it will be appearing there also.
You see, we have outflow.
So this is the outflow.
Uh Paraview has some trouble when we are removing names.
As you can see, this outlet actually doesn't have anything.
Once you open and close, it will be fine.
Now we have the outflow and that is the outlet now.
So that is how you can change the name.
Now I will change this back to outlet.
Save the file and refresh.
See now nothing is there in outflow.
We have it in outlet.
That is what this boundary can do.
Also you can change the patch type like if you don't want this outlet as a patch.
If you want it as um, empty.
Let's say it's not usually how physics works, but let's say that you want to change some patch to empty.
Then you can just change this to empty and it will go to empty.
Okay.
And now we also see something called group walls.
So if we have multiple walls, let's say walls one, walls two, walls three and multiple groups of
walls, then we are just selecting group walls and click on apply.
And we will be seeing all the walls.
So this is also one nice feature in Paraview.
Okay we are done with the second tutorial also.
Now the third is we are going to see curves.
Okay, it's a bend pipe.
I'll jump back to the PPT.
Now introduction to arcs.
So what are arcs?
When I was explaining edges, I mentioned that we can not just join two points through a line, we can
join it through a curve by defining a third point.
That is what the ARX function does.
So we will be doing that ARX in this okay.
So in any rectangular channel you can create a circular outflow or opening.
So that could be done.
Or you can create an entirely circular pipe that is also possible.
So this is the syntax the edges.
You can see we have arc v1 v2 p x p y p z.
So what is v1 v2.
When we were defining the block mesh we have these points four seven, three, two, six, one and so
on.
If I want to create a create an arc between 4 and 5.
So I just have to give these two as the v1 and v2.
Here v one and v two will be four and five.
Now what is p x p y p z.
This is the third point.
So how we usually do is the center of this point.
This will act as the p y p z.
So you can basically choose the third point and it will work.
So how do you actually know what is the third point's coordinate.
Uh, it comes by simple calculation on uh like a geometry.
Right?
We have we know the center of something, and, uh, we know the angle at which this is subtended.
If you want to say you want to create a point here, then you know what is the angle from the normal,
then you can just calculate it, calculate the x and y based on the sine theta and cos theta.
This is just, uh, normal geometrical calculation.
You can do that and select the points.
Okay.
This will be the syntax and we can create an arc.
Now we will see how it is done through a tutorial I'll go to the third bend pipe.
As you can see uh we have the block mesh here okay.
So now let's say that we don't have these two arcs.
Okay.
I have commented it out and I'll go to the location.
I will run sorry.
Block mesh.
Okay.
I will load the mesh.
See?
Now we have a pure rectangle.
Nothing fancy.
We can see surface with edges.
Yeah, we have an inlet.
We have an outlet and we have walls.
Okay, we have everything.
Okay.
Now let's say I want to join two points and create an arc.
So how do I do it?
We will just create one arc and see how it works.
Usually it looks messy.
Arcs are not very efficient in openfoam.
Maybe sometimes it is efficient, sometimes it is not.
Okay, I have just given refresh and you can see it has created an arc here.
Okay, so it just created an arc because we defined it.
It is between 1 and 2.
And I have just created uh, defined a third point and it is creating mesh.
Okay.
So this is how it works.
Now if I want to do it for this phase also, then I will uncomment this save the file, run block mesh
and refresh it again.
You can see now if you really want to see the coordinates matching.
Okay.
Now if you see this point it is zero point in x axis.
It is one.
You can see that it is 0 to 1.
So in x axis it is one and y axis it is 0.5 z axis it is around 1.5.
See that is what we have defined it here.
So it is 10.5 and 1.5.
Now let's say I just want to push it to one this year, not 1.5.
It changed it.
Uh and running the block it is throwing an error because it's not matching well.
So there is it.
This is not fully functional.
So we might have to be very cautious while doing this.
Okay.
So I just defined it and it works fine.
So I will just stick on to it.
But if you want to play with the values, you can definitely do.
And I also have a tutorial on YouTube, uh, in the channel code dynamics where I have done flow over
a cylinder mesh just using block mesh.
So there I have clearly explained on how to calculate the third point, the point where it will create
a curve.
Using Python, the basic mathematical formula, we can evaluate that.
So you can check that video if possible I will drop that in the resources.
Okay.
If I start explaining that this will become a very very long video like 1.5 hours video.
Okay.
Now we have the mesh.
So this is how we are creating Arcs.
Okay.
Now we will go to the next topic.
So we saw all of these how to do run a block mesh.
It is through the command block mesh and usually it is stored in the poly mesh folder.
Okay.
In CFD whenever we are working we will be defining the boundary conditions.
Let's say the inlet velocity at zeroth time step is one meters per second or 0.1m/s.
So this is what is called as boundary condition.
And it will be applied for all the phases.
Let's say in wall it is a no slip condition which means velocity is zero.
It is a fixed value at the outlet.
The pressure will be zero and for velocity it will be zero gradient.
So what is zero gradient?
We have to understand the types of boundary condition.
When you take the regular theoretical CFD course we you would have come across something called the
Dirichlet boundary condition and the von Neumann boundary condition.
So what it actually means is that, uh, the Dirichlet condition, the values are fixed, it doesn't
change or it is not a gradient kind of thing, it is just a fixed value.
It is a specific value.
But if you take Neumann condition, it is a zero gradient or some gradient.
It is a flow which is defined in terms of gradients.
Okay.
So if you want to get into the math you can check the lectures which will talk about it.
But we are just focusing on how to implement those in Openfoam.
So we will see that.
And there is also something called symmetric.
Let's say there is flow over a cylinder, but you don't want to simulate the entire cylinder because
it will be computationally expensive.
If it is laminar, it is going to be symmetric about the center axis, right?
We don't have to do it completely.
So in that case you can do symmetric boundary condition and only simulate flow over half cylinder.
And it all directly applies to the other half.
Also you can do the mirroring and post-processing.
So that is where symmetry boundary condition comes.
And cyclic and periodic boundary conditions are something like.
The outflow can be connected back to the inlet, and whatever values is getting out of the outflow will
be connected back to the inlet.
So it is like repeating geometries.
That's why it is called periodic boundary condition.
And obviously wall will have no slip or slip condition depending on the physics you are working with
and setting the boundary conditions will always happen in the zero folder.
So just like how we had constant and system, we have another folder called zero.
We will be seeing from now on because for the previous videos we did not want the boundary condition
to be confusing.
So we I did not add it.
Now we will be seeing the zero file also.
So each file will have or the each time step in the zeroth condition zeroth folder is just zeroth time
step.
It will have velocity, pressure, uh, temperature pressure minus the hydrostatic forces.
Uh, and there are other turbulence models like k epsilon, nu T omega and so on.
So these files contain the boundary condition for the entire case.
But usually it is mandatory to only to have velocity and pressure.
Depending on physics we will have other mandatory files.
Okay.
Now now for the very simpler case, we will have only velocity and pressure.
No turbulence.
It will be a laminar case.
So this condition will be defined under a section called boundary field which looks something like this.
For an example we have the velocity file.
And under velocity file we will have the function called boundary field.
It is having three conditions like inlet, outlet and wall.
This is what we had in the mesh also.
So this inlet is having type fixed value and the value is one meter per second.
Since it is a unit, this is one meter per second.
And in the x direction in the outlet is zero gradient, which means the solver will calculate the values
for you.
Initially it is just zero in gradients it is a Neumann type boundary condition.
Then the solver will calculate what should be the outlet based on the inlet.
The walls is no slip, so Openfoam offers you this guy a nice keyword no slip to, uh, type that the
velocity will be zero.
But if you don't want to use that, you can't do type fixed value and check the value to uniform 000.
So that is also meaning essentially the same.
And if you take the pressure for the same case, the inlet will be zero gradient because velocity and
pressure are coupled.
It's related, so we should not over define it.
So we will set the inlet as zero gradient.
Because we already defined the inlet as value and the outlet, we will set a specific value for pressure
because we ask the solver to calculate the outflow for velocity.
So we have to give some condition which will be given to the pressure.
And walls will also be zero gradient.
So the solver will calculate the pressure on walls.
Okay.
So we will see, uh, how these things work.
Okay I'll go to the next folder which is a lid driven cavity case.
We have zero constant and system under system we have the block mesh file.
We will just run the mesh and we will see how it looks.
It is throwing an error.
Let's see what happened in the block mesh.
Okay, I have some keywords here.
I should remove it.
I will save the file.
Yes, it is running fine now.
So that was a typo mistake.
Now we can see the mesh.
So this is the mesh we have.
This will be fixed walls.
And this is a moving wall.
Front and back will be empty because, uh, it is a 2D case.
If you just want to see all the empty patches, you can select this and you can see all the empty patches.
So front and back is empty.
Now, what we are trying to do is we are trying to simulate a case, a 2D case where the upper wall
is moving towards the right and other walls are fixed.
So it is going to create a recirculation region inside this domain.
And that is what we are trying to observe.
Okay Okay.
Now we will see.
Uh, it it has created the poly mesh.
Now we will get introduced to the zero files.
Now we have u and p which means velocity and pressure.
I will open the velocity file.
You can see the dimensions are zero one minus one 000.
And don't worry about these errors.
If you are uh ID shows it.
It doesn't matter as long as the syntax is fine.
Uh, we have the moving wall, which is moving at one meter per second in X direction.
We have fixed walls, which is obviously no slip print and back is empty.
Okay.
So this is like a syntax this names has to mandatorily match with these.
Only then it will get uh applied if you make even slight mistake like putting small w W instead of capital
W, it's going to be a problem.
Then we will see the pressure file.
So in pressure for walls we have defined zero gradient.
And front and back is always empty.
So we have given empty.
You can calculate the dimension.
This is m l t.
And the other values also go on like temperature and all.
But we are not interested in that as of now.
Just do m l t and you can know what the dimension of this file is.
Okay.
Now we have done the initial conditions, but now we also have to set the turbulence model.
Right.
So for this cavity case we are using something called ICO form.
So ICO form is a solver in Openfoam, which is transient in nature and it is incompressible, but it
cannot handle turbulence.
It is purely laminar.
It can work only in laminar regions.
Okay.
So for that we have a file called transport properties.
Always transport properties will define the values of the kinematic viscosity of the fluid which is
used.
So to change the fluid.
We don't have the facility to choose a fluid by name, unlike commercial software like Ansys.
Instead, what we will do is we will define the kinematic viscosity of the fluid and it will calculate
whatever is necessary.
And since Ecco foam doesn't work with turbulence, we don't have a file here called turbulence properties.
Otherwise we will be having turbulence properties also in Ecco form Without said it is always laminar
so we are not going to set any turbulence.
You can find the polymesh which has all the mesh details.
Okay, now we are not interested in learning these three things just yet.
We will be seeing uh, it quickly, but for now we will see what we are going to do with this Iko form
case.
We are trying to do something called lid driven cavity.
We are going to, uh, move a lid on top and we will be seeing what is the recirculation region inside.
Okay.
Now we will run it.
So we will be using eco foam solver as I said.
Now I will go into control duct.
And this is the file which controls all the running parameters simulation parameters.
So the application is eco foam which is the solver is eco foam.
icofom.
And the simulation has to start from start time.
So in this case the start time is zero.
So it will start from zero.
Suppose if we run till some time let's say 0.5 seconds and we want to continue from there, then we
can use this command latest time.
But in this case the latest time happens to be zero.
So this can be latest time need not be start time.
Then we are setting the start time as zero.
So if we are using start time then this will be essential.
Otherwise you can leave it then stop.
It will be end time and we will define the end time.
In this case I have chosen 0.5 seconds.
Let it be the delta T, which is the, uh time step.
We will be using 0.005.
So I have checked the stability criteria and came up with this time step.
In most cases you have to check it and there is also adaptive time stepping in openfoam, which we will
learn later to set up certain cases where we can do adaptive time stepping based on the current number
or kfl number.
If you know by that name, okay.
And right interval is 20, which means for every 20 time steps a file will be written, the time step
file will be written.
and, uh, perjury will remove older files.
Let's say if I give purge right five, then it will keep only latest five times.
This will be useful in case of steady state scenarios, but now it is not useful if all the details
are going through your head, don't worry, you will catch up.
It is just the first tutorial.
Okay, so you don't have to worry about these things as of now Pretty much all the time.
We'll let it be default.
Okay.
And the FPV schemes and FPV solution contain all the details related to what numerical method you will
be using to solve each of the equation.
So we are not going to go into that.
It will be an advanced course, so we are just leaving it as default.
We are using a Piso solver.
So Piso is an algorithm which is what the ICO form uses.
So we will stick with that.
And I'll go here.
So we have the mesh.
We set up the boundary conditions and initial condition.
Now I will initiate echo form by the command I echo form.
I'll hit enter.
Now the simulation is over.
So you you could see that we have 0.10.2.
So on till 0.5.
I will open the paraview from scratch again.
Usually refresh doesn't work in this kind of things.
I'll apply you.
The colors might be different for you.
If you want to change the color, you can scroll down on the left panel.
You can click on the color map.
It will get.
This might be your color map as of now, but I like to keep this pressure in this color map.
If you want to set this as your default, you can set it and click this button.
Okay?
If you want to choose any other color maps, you are free to do so.
I personally prefer this for, uh, pressure.
So this is the pressure at 0.1 seconds.
Now, if I play, this doesn't pretty much change for till 0.5.
It is being constant, so if I want to view velocity I will go here choose velocity.
And uh, as you can see the velocity changes something like this.
Okay.
So we are not seeing pretty much any change in here, even though the time step is from 0.1 to 0.5.
It is because we have a very coarse mesh.
Let's see.
It's a very very coarse.
And also we are not trying to do a lid driven cavity case.
As such we are just learning the boundary condition.
So this is fine because essentially we might need smaller time steps with a finer grid.
But for now you understood the point on how to set up the boundary condition, the u and p file.
So I will close this, uh, and we have one last tutorial.
Pipe flow.
So the pipe flow, we will be setting the initial fixed value for velocity pressure.
And we will also do, uh, no slip for the walls.
And then we will set up the initial velocity and pressure for boundary conditions.
Then let's see okay.
Now for uh pipe flow we already have a block mesh dict which comes along with this, but this is pretty
crazy, right?
This is advanced thing.
We will see how to create a pipe mesh very simply using snappy mesh.
Without all these values, it will be very simple.
Uh, we will be seeing in forthcoming weeks, but for now, we will be just using, uh, existing block
mesh.
I took this from the tutorials folder, so we will just create block mesh using this.
Now I'll clear this.
Now we will go to the last case which is pipe flow.
I'm in the right directory now I will do block mesh.
The mesh is generated I will view it in paraview.
So we have a pipe case.
Okay.
So this is more like a symmetry blend case.
Like this is your symmetry plane.
Okay.
So we are not interested in understanding what this case physically means.
We are just interested in setting up the boundary conditions.
That's what this tutorial is about.
As you can see we have inlet front back walls, lower wall and wall, startup outlet, upper wall and
so many things here.
So if you go to the zero file in the U file you can see the boundary condition for everything.
Now you might be wondering what is this.
So this is just C plus plus way of telling that this condition applies to both lower wall startup and
upper wall startup.
Same for this okay, so we are doing an inlet of 0.01 the x direction.
This internal field is like the internal scalar field which will be set.
And uh this is only minus eight.
We did not want to set it to zero.
So it is in a pretty low value.
This is the velocity file.
You can pause the video and ponder on what is actually set.
Okay the Dirichlet and Neumann condition then.
Then.
Similarly for pressure we have this.
So you can see that this is set to symmetry plane because they want a symmetry over this plane.
So that's why it is set to symmetry.
Again you can pause and ponder.
You can change values and try on your own.
So this is what we are essentially doing in boundary file.
All I wanted to say is we have to set boundary condition for all the files, unless, unlike commercial
software where you will set only for inlet and it will automatically choose what will be there for pressure
and for the inlet.
So it's not like that in Openfoam you have to define everything.
Okay, we have only U and P and we will see what type of solver we are using.
Again, it's uh incompressible solver.
It's called simple form.
So simple means Semi-implicit method for pressure linked equations.
You would have come across this in your, uh, theoretical CFD course.
So that is what we are going to use.
Simple algorithm.
It is a steady state solver and it is incompressible.
So we will be running this case and we will be running till 200th time step.
Okay.
The start time is zero and the end time is 2000.
We will run this.
I will go here and type simple form.
Notice that F is capital.
I'll hit enter.
It will take a bit of time before it is converged and we will wait for it to converge.
Then I'll get back to you.
Okay, now the simulation is over.
But why did not it go to 2000?
Right.
We set the end time as 2000, but it did not because the solution converged.
Before 2000, it converged at one for two two iterations itself.
So the convergence criteria and everything is set in the FP scheme and FP solution, not in F scheme.
In FP solutions you can see the residual control and uh, how many iterations it has to run for each
thing.
And what is the characters?
That is the number of iterations and what type of solver you want to use?
What is the tolerance for that?
Everything can be set here.
Uh, so that is how it is choosing the convergence criteria.
And it has converged.
Now if you go here you can see only five files, right.
If you go to the control date, you can see that the right right interval is 100.
So we should have been getting files for every 100 iteration.
But we did not because the purge rate is five, which means it will keep only the latest five files.
But for steady state all we care is just one for double two, because that is the solution where it
got converged.
So we are not interested in other files.
We can safely delete those if you want.
Now I will just open paraview.
Click on apply.
You see we have the pressure and we have the velocity.
But this is at 1100.
We have to go to the last time step.
Either you can select it manually or click on this button and it will take you to the last time step.
As you can see this simulation converged.
This is the pressure or sorry velocity.
And this is your pressure.
Always make sure to visualize the cell data so that it will be smooth if you do.
Uh, sorry.
Point data always point data.
If you choose the cell data it will be squared like this.
So always choose point data.
Okay.
So we now know how to do simple form and how to set up the boundary condition.
But as I was saying we also have to define turbulence properties because simple form can handle turbulence.
So what I did here is I just set the simulation type to laminar.
If we are working with any turbulence model, then we will be defining it here.
Like if it is rans, we will be defining what is the Rans model.
If it is less, we will be defining that as well.
But we'll be seeing that in the upcoming weeks for now.
Uh, we have just run a laminar case for, uh, two solvers, ACO form and simple form, and we have
set the boundary condition generated mesh.
I think that is pretty good for this week.
Okay.
And now we also know how control dict works.
Okay.
So ACO form as I said it is an incompressible laminar flow for Newtonian fluids.
It can't handle turbulence.
It solves unsteady Navier-Stokes equation, which is also the transient one or also known as uh.
Yeah.
Unsteady or transient.
That's it.
And for the case setup, all we need is velocity pressure and transport properties.
And, uh, we will be giving the kinematic viscosity in the transport properties file.
Then for running Iko form, the list of commands is.
First we have to do block mesh and then I go home.
And simple form is a steady state solver for incompressible fluids.
It can handle turbulence and it is for uh laminar flows.
Also, it can work both for laminar and turbulence and it solves the steady state Navier-Stokes equation
using this simple algorithm, which is Semi-implicit method for pressure linked equations.
If you want to know the math of it, you can check the documentation or any standard textbook like Versteeg
Malalasekera.
And for simple form the k setup, we need the velocity pressure if it is a laminar case.
Otherwise we will also have the turbulence files which we are not carrying as of now.
And we have to define the transport properties where we will be defining the fluid properties.
And also, as I said, we have the turbulence properties where we have given laminar okay.
For mesh generation.
The command which we used is block mesh to generate the computational domain.
And we set the initial and boundary condition using the zero folder and the files under zero folder
for physical properties like kinematic viscosity.
We use the transport properties and for turbulence we use turbulence properties file.
For control parameters we use control dict if we scheme and if we solution under the system folder.
And for running the simulation we will be using the respective solver and we post-processed with Paraview.
Okay.
So these are just some introduction to Paraview.
This is exactly what I said in the tutorials.
If you want to go through the PPT then you can, uh, ponder over it.
Okay, so if you have any doubts, you can, uh, contact me or there is a big community, as I always
say, there is a huge community online for CFD using Openfoam.
Someone has already faced the issue that you are facing right now, so most probably you will get any
solution.
So by searching yourself online, you will be coming across other problems which other people faced.
So by uh, looking at those problems, if you face it later in the future, you will be able to resolve
it without looking up.
So that's the advantage.
Instead of directly asking someone what the solution could be.
So thank you for watching this video.
See you in the next class.