Transcripts
1. Course Content: Hello, everyone.
Welcome to the CFD using Open Form beginner
to intermediate course. In this video, we will be looking through the
course content. I have split the entire course into ten separate sections, and we will see what will
be covered in each section. So in the class one, we will be seeing some introduction
to open form, how to install it, and how
to set up the software. And we will also be seeing some basic file structure
on how open form is built and basic
commands which will be useful in running
open foam simulations. We will just see the basic
commands in the first class. We will be learning
more commands as the course progresses. But these basic commands will be essential
to get started. In the class two, we will
be seeing how to prepare a geometry and generate mesh
with a tool called Blockmsh. We will be seeing how to set up the boundary and
initial condition for a case in open foam. We will also look
through some solvers and how to run simulation
using open foam. After running the simulation, we will be using a tool called paraview to post
process the results. In the class three, we will
be doing Snappy hex mesh. So we'll be using Blokmsh as a dependent tool
for snappy x mesh. We will get introduced
to Snappy hex mesh, and we will be creating
complex measures using it. We will also learn how to use the check mesh command to
check quality of the meshes. In the class four, we will get introduced to
incompressible, compressible and
multiphase solvers. So we will go through
the basics of everything and look
at some examples. After looking at that,
we will be running a lead driven cavity case. This will be a
hands on tutorial, and we will also introduce the case study of
lead driven cavity. In the Section five, we will be seeing the types of boundary condition and how to implement them in open form, how to do a turbulence
modeling in open form, and we will get the
introduction of it. And after that, we
will be setting up and running our own
ran simulation, which is Renault's average
vistok simulation. We will be looking at how K Epsilin turbulence
model is made, how K Omega SST model is made, or how to run a
simple laminarchs. So we will be seeing all
those then in the class six, we will be running some
transient solvers simulation. We would have run
transient cases even before that even the lead driven cavity is
a transient case, but still we will
be running more in depth analyzed cases
for transient solvers. We will set up from scratch
and we will run it. And we will also look at how to decompose any case and
run it in parallel, so this simulation runs faster. So open foam comes with
the installation of MPI. So we will be using MPI to
do the parallel processing. We will also look at how to make a mesh using Snapeg
mesh, but in parallel. In the class seven, we
will get introduced to refinement box
in Snappy X mesh, which will be a slightly
advanced feature where we can define area locally
in Snappy XMsh. And we will also get
two hands on tutorials, one on external aerodynamics for the classic CopenFm
motorbike case, and we will be doing plotting of force
coefficients using GNU plot, and the other is exporting the post process data to Excel and how to
plot from Excel. In the class A, we will be importing ANC's workbench mesh, as well as *** fluent
mesh, both are different. We will be importing both, and we will use the workbench mesh to run one of the simulation for
flu over a cylinder, and we will do a handsome
tutorial on that. For the class nine, we will
be seeing how to set up an automation file called
All run and all plane file. AlternFle will enable
the user to run the simulation with series of commands without
doing it manually. We can set up the
AlternFle If you want to change any boundary condition
or initial condition, you can change that,
and you don't have to run each and every
command one by one. You can just initiate
the automation AlternFle and it will run it in
series, and it can do. Series in the sense, it
will do step by step. It can also do
parallel processing. Then the all clean file will
be used to clean the case just in case if you want to run this case from scratch again, but you don't want to
delete every time step, every mesh generated manually, you can use the all clean
file and clean the case, get it back to the
default setup, and you can run from scratch. In the class ten, we will get introduced to multiphase
flow simulation. This will be a basic
introduction and some modeling approaches and practical consideration
using open foam, setting up any multiphase
case using open foam. Then we will be
having one hands on tutorial on the
demonstration of dam brease. Usually, dam break
case is two phase, but we will be doing four phase using multiphase euler
foam in open form. So this is all that we will
be covering in this course. Looking forward to seeing
in the class. Thank you.
2. Introduction to OpenFOAM, Installation and Basic Commands: Hello, everyone.
Welcome to the CFD using open Foam beignet
to intermediate course. This will be the first class. In this class, we'll be looking at the introduction
to open foam, installation and setup
of the software, basic file structure
and basic commands, which is used in open form. First, what is open form? Open form stands for open field operation
and manipulation. It is an open source software used for computational
fluid dynamics, commonly known as CFD. It is designed for solving
continuum mechanics problem, including fluid flow, heat transfer, and
chemical reactions. Initially, it was developed by OpenCf delimited, a company, a division of the ESI group, first released in the year 2004. Since then continuously
enhanced and maintained by the Open form Foundation and
an active user community. So we generally say.com
and.org version, or it is also known as foundation
and Community version. So in this course, we'll be
using the community version, which is the ESI version. So what happens is the ORG
or foundation version, they release in the
format of version one, version two, and the
latest one is Version 11. So it is mostly
like nine, ten, 11. And when this course
is published, the latest is 11. But ESI they do it in a
slightly different format. So they release two
versions every year. One in the month of June and one in the month of December. So you see the latest
version which is released as of this course
recording is 2312. So Version 2312, what it means is it is released
in the year 23, is 2023, and the 12 means the 12th month of the
year, which is December. So the previous release
was version 2306. So it was in the June, so 2306. And previous to that,
it is obviously 221, two, and it goes on. And as of this course, it is recorded in June 2024, so we are expecting 20 406 soon. We will be using 23
12 for this course. Features and capabilities
of open foam. Wide range of solva is present for compile compressible
flow solvers. You also have solves
for multiphase, heat transfer, combustion, chemical reaction,
and everything. It is also highly customizable. Since it is an open
source software, you can modify, create
your own custom solware, edit the source code. You can play around the
coding as much as you want, and there is no restriction, and it is absolutely free. Also, there are
extensive libraries for physical models
and numerical methods. Even if it is not coming
in the installation, you can download it
from external websites, contributors from Github. It is called Foam
extent version. You can write your own
solvers if you need, or you can use
solvers written by other people in
terms of open form. So it is highly customizable. And its pre processing and post processing utilities are highly powerful like the tools
for mesh generation and manipulation comes
within the installation. And data analysis and
visualization tools can be done using a software called paraview which is
also open source, and it comes along with the
installation of open foam. And we can also do
complex geometries and dynamic meshing where the mesh moves with respect to time. So it is also possible
in open form. It supports structured as
well as unstructured meses, capable of handling
moving boundaries and mesh deformation and also rotating measures in many cases. So we will see how to do
the installation and setup. For installation, we need WSL, which is called Windows
Subsystem Linux. Open foam works only in Linux system and not
in Windows system, but that doesn't
mean we have to get a computer which is
entirely voted with Linux. That is why we have
something called WSL or Windows Subsystem Linux, where we get the
terminal window of the Linux inside Windows so that we can use a Linux
subsystem within the Windows. So to install that, all you have to do is open
your command prompt, run as administrator or you can also open your
Power Shell and run this command WSL hyphen
install space hyphen D, where D means the
distribution version. And space you can type Ubuntu with capital U, hyphen 22.04. So what this will do is it will install the Windows
Subsystem Linux, along with the Ubuntu version
of Linux, which is 22.04. Along with the
installation, and you will get Ubuntu inside your system. But if you know how to do a second second OAS
inside your system, then you are free to
do a Linux bootup. Or if you have a spare
laptop and you can afford to remove Windows OAS and put in Linux completely,
you can also do that. So once you enter
this command and hit Enter, the process will start. Now, wait for the
process to finish. Since I have already
installed it, uh, I'm not install it again, so you can just
run this command. Now, after it is over, it will prompt you
to restart your PC. Now, restart your PC and wait. So you just do the
next slide also. Watch the next slide and
then do this process. That's what I recommend.
After restarting, a window named Ubuntu will open. Wait till it asks you to enter your username
and password. So this user name
and password will be your login details for
your Linux system, which is in Windows subsystem. If the Ubento terminal
doesn't open automatically, you can also open
from the search Bar. You can just open
your search Bar and search for Ubuntu and a
terminal window can be open. Note, when you're
typing user name, you can see the user name, but when you are
typing the password, the password won't be visible. So you might be wondering, I'm typing something, but it is not visible on the screen. It won't even show the stars, like how we generally do. When we type a password,
it will show stars. But in this case, it won't show. So instead, what it will do is it will
keep a blank space. So when you are
typing the password, type it very carefully. I need not be very
highly secure. It is just for a small
security purpose. It's not going to affect your overall security of a system. So keep it as
simple as possible. It need not involve anything like numbers,
special characters. There is nothing
mandatory like that. You can keep it as
simple as you want. So make sure you are typing it very carefully
and hit Enter. Then the installation
will be done for Ubuntu. Now, there is a quick tip. Since we are talking
about installation, now I would recommend
you to either install Notepad plus place or
Visual Studio code. Since open foam is open source, we will be modifying the
codes to run the simulation. There is no specific graphical user interface or GI for this. Any notepad word or any text editor for that
matter would work just fine. But some specialized IDs can make your work
easier and comfortable. I recommend you to install either Notepad plus
plus or VS code. I would personally use VSCode because it has amazing
user interface, and it will help me with
autofill sometimes. So if you want to follow along, same as mine, you
can go with VS code. But if you just want to settle down with
Notepad Plus Bliz, it's your personal preference. Okay, now we have the WSL. If you faced any issues, please do contact me, or you can search on the web. There is various resources to help you on how to install
WSL. It will be very easy. Now we will do the
installation and setup of Open Form Version 2312. In my system, I already
have the 2212 version. But now I want to install
the 2312 version. So I will do that along with you so that you
can also follow along. So for that, we have
to visit the website, HTTPS, and so on what
is there on the screen. You can also simply search
Open Form Install 2312. The first link
will do just fine. So what we have to do
is we have to open our WSL terminal or it is
also the Open to terminal. So I will tell you two methods. One is, click on
your Windows button or open the search bar
and search for bent. This thing will appear. You can hit Enter and it
will open a terminal. Just wait for it to load. Now it is loaded. This
is also fine, okay? But if it is not opening
or if it is throwing any, there is another method. You can press Windows k plus R, and this run window will open. You can type in
WL and hit Enter. Now this will open. Even
if this doesn't work, you can do the Windows
plus R, type in CMD. This will open your command
prompt or you can also search Command Prompt from
here and open it. No problem. You don't have to run
it as administrator. Just normal command
Crampt is fine. And then you can type
WSL and head Enter. Now, this will load
the WSL for you. Okay, now I got the
WSL. How do I know? I have the lab, my username
at the device name, and we will see
something like slash M&T slash the directory of this. So this is what we
call the directory. The location from the base where we are working
is called directory. I will use this word very often. If you are comfortable with terminal, you would
already know this. So the first command which
you'll be knowing is clear. So you type clear, hit Enter, it will
clear it. Okay? Now what we are
going to do is Um, we are going to type
in these commands, and we are going to run it. It will install the open form, but you can also go to
the website which I just mentioned and you can copy
paste this entire code. But I'm going to type this out. Now, what I'm going to
do is I will type CD. Now, you don't have to
understand what I'm doing or what these
commands mean, but CD is change directory, it will take me to
the home directory. Now we are in the home. Just after dollar if we don't see anything
that is the home. Again, I will clear it. Now
I will type this command, whatever is there on the screen. This curl space HTTPS dealt openfon.com slash AD Hyphen debian hyphenpo
dot SHPC Sidebar. I don't know what is that
space sudo space Bash. I'll hit Enter. Now it is
asking me for the password. So I will type the password, and it is running. This is the only place where we will be needing the
password we just set. So it is doing App get update, which is updating what
is available already, and it will see if there are
any updates for the system. So wait for some time. Make
sure your Internet is stable, only then it will
be done faster. Then we can do the
second command. So by the way, whatever is there after the
hash, it is not needed. It is just a command. Now we
can do the second command, which is pseudo apt get update. Now this is also going to
update whatever is done. So this is getting the update, and then we will install
whatever update is there. It will be done automatically.
You don't have to worry. Now, this is the command which will actually install open foam. T psudotigate, install Open
Foam 23 12 hyphen default. So there are many
methods to install. Default is going to install
everything that is there. Now, this is sensitive, so don't make anything capital. Everything is small
here. Hit Enter. Now it is going to ask you whether do you
want to continue? Now, you can just type Y. This is not as sensitive. You can type capital Y or
small Y, doesn't matter. Type Y and hit Enter and
keep your Internet stable. This is going to take a while, and it will install
open foam for you. Now let us wait until it is over, and I'll
get back to you. Now the installation is over. As you can see it is
asking us to do something. It is asking us to set
up open Foam through a command called source from BasrCFle dot space,
and this thing. This is what is going to tell the Linux to uh,
locate open foam. Whenever we are
calling open foam, it has to know where
open foam is installed. This is the location
where it is installed. So we have to source that.
It's called sourcing. Before that, we
will check whether open foam is installed
properly or not. So to do that, you can type in the next command
on this slide, which is open Foam 231,
two, and hit Enter. Now, if you see this, then your installation
is done well. Okay. Now, you have to see your user name dollar
and blinking thing. It will also say
open Form 2312 here. If it is saying that, then
your installation is great. If you're facing any
problem, do ask me, you can contact me
or there are again, various resources available on the Internet to sort out any issue which you are
getting an installation. Most probably someone
has got that before you. So you can always check it out. Now we are going to do
the sourcing thing. To come out of this terminal, you can click here and probably Control C or control D will
work for me, Control D works. So then I'm going to do
something called CD, okay, just to ensure that
I'm in the home directory. Now we are going to type
explorer dot espy dot. Don't miss the space dot
and hit Enter, okay? Now this window will
pop up where you will be able to see something
called dot bash rc, which is the file open form was talking about
dot bash RCFle. Open that. It will
ask for permission. You can open it using VS code. I'm using VS code to open it. Go all the way down
to the last line. Actually, you won't be seeing any of these, so just forget it. This will be your last line. This FI will be your last line, so don't mind any of these. Okay? Pretend that it
doesn't exist here. So what you are going
to do is you're going to copy paste this entire thing. I'm just going to
copy what to be code. And in the last line of your BRC file, you are
going to paste it. In your case, it will
be after the FI. Go to the new line and paste it. Now, you are going to do
something called source. Okay. So this will work for you. So what you have to do is
you have to type source, then you have to type
this, then save it. And then you can
open a new terminal. I will be preferring to use
Windows plusR and then Ws. See now you should not
get any errors here. If you are getting any error, it means that you are sourcing
has gone wrong somewhere. You can safely close
the previous terminal. It is fine. Now, only
the new terminal will work with the source. Okay? So if you have
done it perfectly, it will not show any error. Otherwise, it will
show some command that it is not
sourced or something. So I will also explain
what I have done here. Whenever you want some shortcut, let's say that I want to go to a specific area in my
PC, some directory. Now it is in C
slash US slash Jah. This is my home directory. This is the directory where
I'm at the terminal at. But if I want to go to
a specific directory, say, Udi open Foam course. So if I want to go there, then the command is
actually CD space than the location of the folder. Then if I just type that, let's say, I'm typing
specifically that. I'll go to my home directory. Now I'm typing Series
slash T slash, D slash open foam v221, two, uh UM open foam course. If I'm typing, you can see that I'm entering that location. But if I don't want to
do that, let's say, I'm going to use this
folder very often. Then what I can do is I'll create something called Allias. So if I want to
enter that location, all I have to do is enter the home directory
by typing in CD. Then I will type UDI hit enter, and it will take
me there directly. So it is an alias to
do specific commands. Now, if you have
multiple versions of open form or if you also want to do
something like this, then what you can
do is you can put this entire thing within
uh, single quotations. Then after the quotation
uses type a dot. So it has to be dot space, then the location
instead of source space. Then I'm going to
type Allis space. Then you can give
whatever word you want. I'm going to use
OF 2312 for this. Whenever I type OF 231, two, this file or this
location will be sourced. Let's say I want to use
open Form 2212 sometime. Then I can type OF
2212 in my terminal. Okay. Now, if I type that, then my terminal is
taking me to open from 2212 location
wherever it is installed. But if I want to work
with open From 2312, say, I will type open fom 231, two, now you see it is
taking me to open from 2312. So that is what we
are trying to do. That is what we are
trying to source here. If I type IF 2312, it will take it will
source it automatically. So it is not
available as of now. So I have to restart
and it will work. So this is what Alias does, this is what I have
done here as well. Now, this is what is going
to work here as well. So I hope you
understood till there. Now the next thing. Now we
have typed in CD clear, and we have also sourced this. So this is what we did till now. If you want to go through these slides,
you can go through. Now we are going to do something
called make directory. Okay? For this, I will
open a new terminal. Now I will source
Open Foam to 31, two, and I have sourced
open Foam 23 12, which is the new version
which I have just installed. So whenever you have
multiple versions, you might have to
source it manually. But if you just did the
source space UA USR, then you don't have
to do this line. You will find me doing this command throughout
this course very often. So you can choose to do it or
skip it whenever you want. What we are going
to do is create a directory MKDIR
space hyphen P, dollar foam underscore
run, and hit Enter. What this is going to do is just like how we created Alias. Open foam has its own method
of creating as that is this. Now, if I type just run, it will take me to a location, um, where it has created
a run directory. Usually, this is
the place where we will be doing all
the simulations. And this is generally is what is considered
as run directory. But I will suggest you
to do something else, which I will tell
in the next class, we will be creating our
own run directory. Okay? So this is what we had to do. Then what you can do is
instead of running just run, you can also run CD dollar
foam underscore run. Okay. Now, after that, open Foam offers us set of tutorials which we can copy
and use it whenever we want. Whenever we are working
with Open Foam, we don't set up
anything from scratch. We will copy paste
some of the tutorials and modify it to
cater our knees. So to do that, we have
to type in this command, and it is CP, hyphen R dollar Foam
underscore tutorials, slash IncompressibE. Slash simple form, make
sure that F is capital. It is case sensitive. So make sure everything is set properly. It's daily. Space, dot, and hit Enter. Okay? Now, previously
when I typed LS, we did not see
anything like here. But now when I type LS, you can see that we have
something called Pitch daily. This is what we just copied. So CP is copy command. Hyphen ar is copy recursively. So it means that
whatever file is there inside Pitch
Daily, copy that also. Now, we have copied that also. But now I will ask you
to do something like CP, hyphen R dollar foam
underscore two Ls space dot. Don't miss that dot. Then hit Enter. This is
going to take a while. Now, if you type LS, you can also see something
called tutorials. Now, this tutorials is a main folder, which
I was telling you. Like we have various
solvers here. We will be using these
tutorials to set up our cases. We won't set up it, set it up from scratch. We will just use this, okay? So we have created something
called the Pits daily here. This is the way to check whether your installation is
done properly or not. Now we are going to enter
the Pits daily folder. It is the command CD
space Pits daily, make sure that this is
capital. Hit Enter. Now if you want to see what is there inside, you can type LS. You have zero
constant and system. You don't have to worry what
these things mean as of now. Now, the command
which you have to run next is block mesh. So I'm just following
whatever is there in the PPT. Now, lock mesh, it enter, you have to see something
called end here. You don't have you should not
see any warning word here. It will be ending
smoothly with end. Then the next command is
simple form, Ht enter. Now, wait till this is over. It will take a bit of time,
but it will be over soon. Okay, now again, you are seeing something called.
Now this is over. What we have done
is we have just simulated a backward
facing stepcase, ok and we will be typing
something called Parafom. This is the way to do
the post processing. This might or might
not work for you. Like, I did not
work for me, right, because it might or might
not work for some people, so you don't have to
worry about that. So what we will be doing is we will be installing
something called paraview. So what is PARA V? PRA V is the open source data analysis
and visualization tool. It is developed by a
company called Kitware and various institutions
in collaboration. So the key features is it
handles a large data sets. It can be used for any sort
of scientific computation, not just open form and CFT. It has a interactive three
D visualization platform, and it is scriptable via Python. If you want to automate things or if you want to
make it customizable, you can do it using Python. And using para view, along with open foam, it is very powerful to
post process all our data. We can perform
operations like slicing, contour plots, team line, if you want to do a graph over specific line on the
geometry, you can do that. If you want to export the data within some cells in the
mesh, you can do that. It has a wide variety
of capabilities. So we are going to
install paraview so the method to do it is we'll
be going to this website, paravw.org, and you can
download the latest version. You can install the software in your Cedriv in the
default location. Now we are going
to do something. I will types. As you can see, we have zero hundred, 202 81. These are the time steps. Now we have to run
a command called Touch space para dot,
foam, hit Enter. Now, what this
essentially does is it created a file
called paradtFom. This is the paraview file. Now I have installed
paraview already. So what I'm going to
do is going to type explorer dot x space
dot, hit Enter. It will take me to the location where these files are existing. Now we will be seeing this. So just right click open
with choose another app. Then you can click on
Choose app on your PC. If you scroll down, you'll be able to
see this para view, wherever you have installed. So you will be able
to see Para view. This is my previous version. This is my new version, so I am double clicking
the new version. So whatever you have installed, you will be able to
see that double click. Inside Bin, if you
just scroll down, you'll be able to see Para
view an application file. See, this is an application
file, click on this, click on open and make
sure to give always. Now, this will load
as the case files. It will take a bit of
time for the first time. So once I click the
green apply here, you might be able to see something like this
in terms of geometry, but the colors
might be different. So the color map
might be different, but as long as it looks
similar, it is fine. So if you go here, you'll be able to choose
between velocity, pressure, okay, ESL and nut. We will be seeing these and how these got generated later. But for now, you are just going to check whether the installation
works fine or not. And this is the interface where we will be
changing the times. As you can see, we
have 100, 200 and 281, since this is a
steady state case, so we are interested only the last timestep
where it got converged. Okay? So this is
the pressure data. We have the velocity data. So if you click this button, it is going to take
all the data within this window and set the minimum and maximum to
the color map accordingly. So this is called rescale to visible data
range, I have selected that. This is what we have
just simulated. This is a backward
phasing step case. If I click here, it will run
me through the timestep, but this is a steady
state simulation, so it doesn't matter. Now I can close this. If I go back to the terminal, it will be just like
how we left it. Now we will see what is left. We have done this. You color might look something like this. I have changed the color
map for my preference. Now we will see what
is a file structure and basic commands in open form. So we have a case, case is the setup which we will be using
to run any simulation. So the case has three
different parts. One is time directories. Then there is a folder
called constant, which will store all
the constant values or properties related
to the simulation. And then we have a
folder called system, which will store all the
control related things, which is related
to the simulation. Under time directories
will be having zero. And after that, it will
progress as the timestep. If your timestep is 0.1, then after zero, you
will have 0.1, 0.20 0.3. If your time step is
0.001, then it'll be zero, 0.001, 0.002, and so on.
So you get the point. So all these zero files will have corresponding
velocity, pressure, temperature and pressure
minus the hydrostatic forces. So all these files
will be there. And in the constant
folder, generally, we have the mesh here, which is stored in the format
called polymesh. We will be having
a folder called polymesh under which we'll
be having the points, cell, phases, boundary details. After that, we will have
various properties like turbulence properties,
transport properties, which will have the fluids kinemtic viscous and
turbulence model. Turbulence properties will have the turbulence details
like whether it is laminar or Renault's average simulation
or whatever it is. Under system, we will be
having the control dit, which will be controlling the application which will
be using all the solve which we'll be using
any external function, use a defined function
to plot any data or if you want to change the timestep, start
time, end time, anything related to
simulation or setup, we'll be doing
through the control **** If we scheme
and if we solution correspond to the
numerical schemes which we'll be using
to generate the data. So we have various AFD
numerical schemes, and we will be setting up
those through those two files. Block mesh dicta is
a file which will be useful in
generating basic mesh. Snappy hex mesh can be used for generating
complex meshes. So these are the general
files under these folders, but usually there
will be more files, which is not generic, so we are not plotting
it in this chart. So some of the useful
commands are these, I will demonstrate
by typing it, okay? So first is L S, LS will do list. So it will list whatever, um, folder is there in that specific directory.
Let's say I want to. Then the second command is CD space the name of the folder. That is what I'm going
to do. CD space. Now here, I have open foam
as one of my folders. So if you want to autofill, you just type first one or
two letters and hit tab, it will autofill for you. Hit Enter. Now you can see
that I am inside open foam. Now if I want to go back, what I will do is I will
do cdspace dot dot. It will take me back.
Now for demonstration, I'll go back inside. Now, as you can see, I
have four folders here. Let's say I want to go
into the fourth file. Now it's asking me
to choose the one. I'm choosing it
and hitting Enter. Now under this, I have run. Now, let's say, if I want to
go back to the home again, either I can do
CD and hit Enter, it will always take
me to home or else if I want to do let's say I
am very further into this. Okay. Now, I just want
to go back two folders. I will do CD space
dot dot slash dot dot for coming out of two folders. And if I want to come
out of three folders, what I'll do is CD space dot dot slash dot
dot slash dot dot. It will take me back by
three folders, okay? I'll clear it. Now, touch is a command which
will create files. So generally we'll use it
to create paraviewFles. Let's say I have these three. I'll go back to my home. We have only open foam now. Okay. Now I will create the paraviewFle here,
touchpasParo dot fom. I'll hit Enter and
search what is there. You can see I have parotomFle. Okay. Now if you want to create this is for
creating a file. Now if you want to
create a folder, then you can use MKDIR, which basically means
make directory, and I can type in the folder
name. Let's say folder. Okay. Now when I type LS, you can see we have two folders, open form and folder,
which we just created. Now, if you want to enter
folder, yeah, I will enter. Now, let's say I want
to remove the folder, the folder which I just created. It is RM, hyphen R, then I'll type the
folder name, Enter. Now if I search, the
folder is not there. If I want to remove the
paravFle I'll just do RM, and it is also gone. So generally for folders, we will be using hyphen R, but, um, will not be using
it to delete files. Now, explorer dot x will generally open just your
Windows Explorer. Okay. But if we want to open it
in the specific location, let's say I'm inside open foam, here I am in version
two, two, one, two, and this I'm
under tutorials. Okay, I'm under
run. Okay? Now, if I see there is nothing inside, but I just want to
open this location. What I'm going to do is
explore dot Tx space dot. So that space dot means
open it in this location. So dot means this location. It's a second parametric input. I'll head enter,
and as you can see, it is exactly opening
that location. So that is how that
command is useful. So these are the basic commands which we will use very often. Apart from this, we are
not going to use much, which is related
to Linux directly. So these are Linux commands. We'll be using more commands, which is related to open foam, which we will learn as
the course progresses. So that's it for this video. If you have any questions, feel free to contact me. Um, there is a big open
form community online. If you have any doubts, first try to check it online. So you'll be learning more
than what you just need because you'll be seeing
problems from other people also. So you will learn more. Thank you. See you
in the next class.
3. Install OpenFOAM v2406 & WSL Ubuntu 24: Everyone. In this video, we are going to
see how to install open foam version
20 406 using WSL. So WSL is Windows
Subsystem Linux, where you can get
almost all the access of Linux system within
your Windows mission. So that is what we
are going to see. We are going to start from
the installation of WSL and get till the installation
of Open foam 20 406. And also, I have
an additional tip on how to set up
the open foam so that it does not
consume a lot of space in your hard disk or SSD. So usually WSL has this
problem where even after you delete certain files inside
the WSL architecture, it will not show us free
space in your hard disk. So we will see one method which will rectify that problem. So to install Open foam, you can visit this website, openfom.com. There
are two versions. I will suggest using this one. So once you go to openfom.com, you go to Downloads
here, press on Linux. Then this will open
up this window. So here you can press W plus open two and it will
open a new window. And these are the
commands that we have to run in a terminal, which is the Linux terminal
to install open four. So for that we
need a WSL, right. So we will see how
to install that. First, you can open
your command prompt in a regular fashion. Then you can choose any
drive that you want. If you want to use
your C drive only, you can just type all the commands which I'm
typing directly. But now, let us say that
I want to use my D drive. Then I will put D colon. Presenter and it
will take me there. It's up to you on which
drive you want to do it. I have multiple drives and I
don't want to put it in C, so I'm putting it in D. If you want to continue with
C, you can do it. In the command is, let
me zoom it up slightly. WSL space hyphen D, sorry, hyphen hyphen means
space hyphen D, space, bent, hyphen 24.04. Version 24.04 is
the latest version. So I'm installing that. If it asks for any
permission, you can give it, and it will take a bit of
time to install the WSL. So let us wait till it is over. Okay, now the installation
is happening. I'll give it the axis. Now after it has downloaded,
it is installing. Now let's wait till it installs. Okay, now the installation
has been done and it is saying the requested
operation is successful, but the changes will not be effective until the
system is rebooted. Generally, we will
have to reboot. But for some system, it might or might not
work without a reboot. Let us see whether it is
working without a reboot. If it's not working,
then we will reboot. So to check whether
it's working or not, just hit your search button, then search for Ubuntu, it is showing Ubuntu
24.04, press Enter. Okay. You can see that it
is giving me an error. This may take a few minutes and the WSL register
distribution failed and all. So for me, it did not
work without a reboot, so I'm going to
proceed and reboot. So once the reboot is done, then I will show you
what is the procedure. So now I will reboot. Okay, now my system has been rebooted. So what I'm going to do is
this search for Ubuntu. This might open
automatically or might not open automatically,
let it take some time. Then once the
installation is over, it will ask for user
name and password. Then we will do the setup. Because this is a
separate mischie inside your Windows mission. We have to give the
user name and password. Now it is asking
for a user name. So I'm just entering
a user name. Press Enter, then it
will ask for a password, but you have to be very careful while typing the password. Because when you type, usually when we type password anywhere, either it will show what we
are typing or it will show at least a star or
some symbol. Right. But here now it will
not show anything. You have to type
it very carefully, and it will ask for
a confirmation also. So now I'm going to type Enter and it will ask to
retype the password, so type it again carefully and make sure that
you are not giving any space special character while typing your
username or password. So it should not have
any special character or it should not have
any spaces in between. So once you do that,
this window will appear, and this is your WSL massin. So how will you know whether you are in WSL or in command prompt? So when you are in WSL, you will see that your user name at your device name
will appear here. But if you are on
your command prompt, then this will all
be white, right? And it will just say C uses HP, the atop name, all
that will come here. So here you will be
getting this green color and then it will be
followed by blue color. So all that will
be there, that is how you know that
you are in your WSL. Let me close this and
open a new bent terminal. Now we can start
installing our open foam. So the first method is just copy this,
go to your terminal, either right click
Right Mouse button or just press Control V. So mostly write
button will work, t button, press Enter. Now it is asking for
a password, right? We have to type it
very carefully. Have to remember the
password all the time. You should not forget it. Otherwise, you have to uninstall your WAL and reinstall it again. It's going to be a big problem. So always remember the password. Now it is saying the
repository setup. You can now install packages. So first, we have to update, get updates for the packages. So copy this right
click presenter. It will search for any
updates available. This might take a bit of time. So once that is done, we
are ready to install. So you just copy this entirely. Go here, right click. Use your left arrow button. To change this to 20 406 instead of 23 12,
then press Enter. Then it will ask
for a confirmation. Now it is asking or no, and it will consume one, two, four, six MB of
additional space. So I'll type Y, it enter. It doesn't matter whether
it is small Y or capital Y, don't have to worry about that. So once you press type Y, press Enter, just wait for
open foam to get installed. So once the installation
is done, I'll get back. Okay, now, the installation
of Open Foam is also done. But if you see that it is giving us some
instructions to do. So now let us do that. To do that, just type explorer
dot cspace dot, presenter. Okay. Then this window will open here you can see that you have a file
called dot BRC. Now, if this file is not there, this location is not there,
then in the terminal, you just type CD once, then you type the Explore
dot EXE and it will be fine. Okay. So now you can open this BRC file either in
VS code or in notepad, or if you have any other text
editor, anything is fine. So once you open it, go
to the last line, okay? Create one more
line after the FI, this should be the last line. Okay. Now here, you have to type this command that
is shown here, okay. I'm just going to type it out. You can also copy paste, but I generally like to type
it. So don't miss the dot. It starts with dot space
slash USR LIB Open Foam, Open Foam 20 406
slash ETC slash RC. So once you type that
without any mistakes, I hope I did not
make any mistakes. Save the file. Close this also, then open a new Ubuntu. Okay. Now you have to type the set of commands that
I'm telling you, MKDIR space hyphen P, dollar Foam underscore run. Notice that Foam underscore
run is capital, press Enter. Okay. Now what we are going to do is we
are going to create a location where you
can use your open foam. So you don't follow any
other YouTube tutorial, they will be using
the location where WSL is installed that
will cause problems. I will tell you this and you
follow this all the time. So go to drive any
drive, C or D or E, wherever you have space,
then create a new folder. Called Open foam. Here you can create
another new folder called version 20 406 recenter. I'm just doing this
because if you want to create any
other versions later, then you can have
it nicely there. Okay. Now what we
are going to do is going to open the same explorer dot ExCspagt in this location, open the BasharC Go to the last line and just
type out this command, AI as equal to opens colon, CD space, then you have
to type slash N T slash. Then you just go
to this location. If you are in C drive, then you have to type small
C. If you are in Drive, it's small D, form it's small D, slash, then this location. Okay? So it's open form, slash V two, four, 06, then close the single coach. Now here, we have to
give this a name. So I'm going to call
this OF 20 406. Okay? There is no space
between this and this and all. So just save this, close this bash C, open the sorry, close the
UbenT, open a new one. Okay. So whenever
you want to run any open form simulation,
just type this. It will take you to
this location. Okay? This is inside Windows. That is what this M&T means. So now let's test it. I'm going to create a
new file called file. You can see that it is appearing here instead of WSL location. We don't want this file, okay? So what I'm going to do now is I'm going to copy
all the tutorials. If you're familiar
with open foam, you will know that
all the people use the tutorials to
do anything we want. So the command here is
CP space hyphen ar, dollar foam underscore, tutorials space dot.
Don't miss the dot. So once you do that, the tutorial folder
will be copied here. If you're completely new to
open foam, just follow this. Trust me with the process. Don't worry what
this tutorial means. Why are we doing this and all? You will get ahold of it later. But for now, just copy the
tutorials folder here. And whenever you are following
any open Foam tutorial, open this location first type IF 06 in your Open two terminal, then you will be able to
get to this location. Once you get to this location, then you can do the tutorials
that they are telling you. In fact, we will create one
more folder where you will be able to copy
all the tutorials, create separate folder
for all the cases that you are running instead of putting everything
in the tutorials. We will also create that
once this copying is done. Once your tutorials folder
is completely copied, just create a new
folder called run. Then you can enter the folder
called run through this. Now, in fact, you can open
this location every time, when you open a new terminal, this will be
something like this. So once the terminal is open, just type OIF 20 406, and
it will take you there. Then you can enter
the run location. So this is where it is. Then you can run any
case that you want. So there is also another way. Let's say you are having
multiple folder inside run, then you have to navigate right. Instead of that,
you can just right click here, open and terminal. Any location, this
works for any location, open any location in Windows. There's right click
open and terminal. So once it is open
in the terminal, just type WSL, Enter, then it will open the
Ubuntu terminal here. Then you don't have to worry about opening the location
through your terminal. This will work all the time for any location. This is open. So that's it for the
installation of Open foam, then you can follow the other
tutorials in other videos. Make sure to like the
video if you liked it. If you have any doubts, you can come on
down in the video. Thank you.
4. blockMesh, icoFoam and Introduction to ParaView: Hello, everyone. Welcome back
to the CFD using open foam, 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 open form. After doing that,
we will be using Para Vew as the post
processing tool, and we will be
seeing the results. First, what is Blockmsh? Blockmsh is a mesh
generation tool which comes with the
installation of open foam. It uses a dictionary file called Blockmshdt to define
simple geometries and create structured measures. The role of Blockmhe
open form is that it is used to create initial
computational measures. It can be highly structured, suitable for simple geometries like square rectangle, channel, 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 is 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 Match dt is like
vertices will be there. We have to define the vertices on a three D space, which
we are going to use. Then using those vertices, we will be defining boxes or a hexahedlbx meaning it will have six faces more like
a cube or a cue boy. Then we will be defining edges if we want specialized curves. So if there is a two point, and we can join the 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 pace, 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 merged
patch pairs come into play. So we will be seeing
all these practically when seeing the block mesh
dit file as an example. For the first thing,
we'll be creating simple geometries like
two d 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. Then the next example
will be we will be doing a three D 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 pf dot form and
system. We do not have zero. 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 running the case. We are just interested in doing the mesh using block mesh dit. So block mesh dict exist
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 dit. 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
open form is a unit, meaning whatever vertices
we define, it is in meters. So if it is zero comma zero, comma zero, it is a point. And the next point is one
comma zero, comma zero. It means that this is 1 meter
away from zero comma zero, gama 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 1,000. If you are doing something
like an entire aeroplane with a large amount of 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'll just open paint 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 an array. Okay? Open form is
written in Z 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 zero point, okay? And we have one comma
zero comma zero, which is like 1 meter displaced
in the direction of X. So this will be our 0.1. And then we have one
comma one comma zero, which will be around here, and this is our 0.2. And then we have zero
comma one comma zero, which will be around here. So this will be our 0.3. Now, these four points
can form a phase, a simple two D phase. Well, open foam can't really
work with two D structures, but with these four points, we can only make a two d phase. Now we have got a phase. 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, corresponding 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 this is changing. What it essentially means is
that we are just displacing this entire pace 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 sunnth point. So what this essentially does is that we have got another phase. Yeah. Now we have two phases, 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 0123 isn't
counterclockwise, then 4567 is also
counterclockwise. This is a notion that we
have to follow in open form. And also, when we are finished doing the
first four points, the next point has to
correspond with the zero point. So that is how it works. Only then it can make
the association. Okay, now we have
created the two phases, and we are defining zero, one, two, three, which
is zero, one, two, three, and we have 4567, which is four, five, 67. So we are defining it
as a single block. Now, this will connect these points and
make it as a block. Okay. 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
phase in the value of 20, and we are subdividing Y by 20, and we are just keeping
one cell in 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 assume that it
is 111 as of now. Most commonly, we'll
be using 111 only. So we will just see up to here, run the block mesh,
and we will see. So what I'm 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 open form, make sure you are in the
right working directory. So what does working
directory mean? When you are in a
location, in this case, I'm 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 location. Let's say I am inside system because this is where
blockmsh 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'll go back one directory. Now I'll type LS, now we can
see constant and system. So this is the location
where we have to execute all our
open foam 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 zero, zero, zero, which is the minimum value, and this is the maximum
value of the cube, which is 11 -0.1. And we have only default
pass as all patch. So we will visualize
it to visualize, as I have explained in
the previous class, we will do touchspacpara.com
to create a para view 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? I will go here, click
on surface with edges. Now you can see
the blocks, okay? If you scroll down
on the left panel, you can see something called
dtaxisGrid a bit turn on. You can see the X
axis ranges 0-1, Y is also ranging 0-1, and Z direction is 0-0 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 Controls
to save the file. I will run BlockMsh again, so it will get updated. I will go to ParaView and
make sure that you are selected ParadotFm and click on Refresh. Try to
move something. Like in paravie, 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'm 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'm just
dividing this by five, five. I will save the file,
run block mesh command, go to Paav, 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 see. 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 two D square cavity case. So we are keeping as one. So because in open form, there is nothing as pure TD. Everything has to be TD. But what we will
do is we will set the front plane and back
plane as empty patch, so it will behave
like a two D 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, see
if you click here, Uh, I will deselect Internal mesh and select on the default phases. 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 dig
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 pate. A you see, I have given a name, moving wall a curly braces. Within that, I have
typed type as wall, so this is going to
behave like a wall. This name can be anything. I just chose moving wall, 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 in anticlockwise
direction. Three, seven, six, two. We
always have to follow this. Otherwise, it will say
the pace 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 root. 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 fees. 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. Just this phase. If you
see from that side, then that is still
anticlockwise. Then we have 2651,
and then 1540. We have defined all
these phases as fixed walls. I will
save the file. Run block mesh. Now you can see we also got fixer walls now. I'll go here, refresh. I will select the fixer waves
alone, deselect everything. You can see this
is the fixed wall. Okay. This is annoying. I will remove the
data access grid. Okay, we have the fixed walls. I will select both fixed
walls and default phases. We are seeing everything. I will select fixer
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 phases and put
it into front and back, and we are defining it as empty. Whenever you are
working with two D, the front and back
has to be empty. Only then this will
behave like a two D case. And here also, I have
put two phase 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 two D mesh if it
is a simple square. Like this can be
done if you want to do something like 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'll be seeing
in the next case. So I hope you understood
whatever we did here. Now we will see about
simple grading. So simple grading is like
a gradient for the mesh. 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 run the block mesh. You see everything is
biased towards the right. Still, the count is same. It is 50 50, but it is gradienting
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 create some
boundary layer thickness, then this could be useful. And if I do -0.1, then I will get it
towards this side. And this can be done
for Y direction also. I 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 lock mesh deck 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 three D, so we don't have front and back, and waltz 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 three D
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. 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'm seeing constant and system and I do LS, which is list, L S is list, we're listing all the folder. Now I can type Block mesh, okay? And I have already created
the Para view five, so I'll double
click and open it. On upline. 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 key. 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 polymsh. This is where all the mesh
information is stored, regardless of what
mesh you are using, be it block mesh or Snappy x mesh or if
you're inputting mesh from Mansis or fluent or
GMSH or whatever it is. Once it is in open form
understandable format, it will be under polymsh 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,
another relation and faces. If you are interested in
seeing what is there inside, it is just pure numbers. Okay? Same with this. I 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'll 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 at. So suppose you made the mesh, now you don't want to generate blood mesh from scratch again, because sometimes when the
mesh count is too high, like 1 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 I don't
want this as outlet. I just want this as outflow.
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. Paavw 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 Para view. Okay, we are done with
the second tutorial also. Now the third we are
going to see curves. It's a bend pipe. I'll
jump back to the PPT. Our 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
arcs function does. So we will be doing the
arcs 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. This is the syntax. The edges, you can see we have arc V one, V two, PX PY Ps. So what is V one Vt? 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 an arc 4-5, so I just have to give these
two as the V one and V two. Here, V one and V two
will be four and five. Oh, what is PXPYPt? This is the third point. So how we usually do is
the center of this point, this will act as the PXPYPz. So you can basically choose the third point
and it will work. So how do you actually know what is the third
point sordinate? It comes by simple
calculation on, like a geometry, right? We know the center of something, and we know 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 the X and Y based on the sine
Theta and cos Theta. This is just 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
bendpipe as you can see, we have the block mesh here. Okay. So now let's say that
we don't have these two arcs. 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. 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 open form. Maybe sometimes it is
efficient, sometimes it's not. Okay, I have just given refresh, and you can see it has
created an arc here. Okay? So I just created an
arc because we defined it. It is 1-2, and I have just
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 zero to one. 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 one, 0.5 and 1.5. Now, let's say I just
want to push it to one, the Z and not 1.5. I changed it, and running the block measure is
throwing an error because it's not matching well. So 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 onto it. But if you want to
play with the values, you can definitely do. And I also have a
tutorial on YouTube in the channel codynamics 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 one end
of 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 polymsh folder. Okay. In CFD, when
we are working, we'll be defining the
boundary conditions. Let's say the inlet velocity at zero times step
is one meters per second or 0.1 meters/second. So this is what is called
a boundary condition, and it will be applied
for all the phases. Let's say in all, 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 a regular theoretical CF
Dcurs you would have come across something called the
Dirichle boundary condition and for Neuman
boundary condition. So what it actually means is
that the Dirichle 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 low, which is defined
in terms of gradients. Okay? So if you want
to get into the math, you can the lectures, which we'll talk about
it, but we are just focusing on how to implement
those in open foam. 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 directly applies
to the other half also. You can do the mirroring
and post processing. So that is where symmetric
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 all
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 I did not add it. Now we will be seeing
the zero file also. So each file will have
or each time step. In the zero condition,
zero folder is just zero time step. It will have velocity,
pressure, temperature, pressure minus the
hydrostatic forces, and there are other turbulence
models like Epsll Nut, Omega, and so on. So these files contain the boundary condition
for the entire case, but usually it is mandatory only to have
lostian pressure. Depending on physics, we will
have other mandatory files. Okay? Now, for the
very simpler case, we will have only
Velostian pressure, no turbulence, it will
be a laminar case. So these conditions 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 all. This is what we had
in the mesh also. So this inlet is having
type fixed value, and the value is one
meters per second. Since it is SI unit, this is one meters per
second. In the X direction. 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 waltz is no slip. So open form offers
you this nice keyword, no slip to type that the
velocity will be zero. But if you don't
want to use that, you can do type fixed value and share the value to
uniform zero, zero, zero. 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 overdfine it. So we will say the
inlet as zero gradient because we already defined
the inlet as a value. And the outlet, we will set a specific value for
pressure because we ask the solvent to calculate
the outflow for velocity. So we have to give
some condition, which will be given
through the pressure. And walls will also
be zero gradients, so the solver will calculate
the pressure on walls. Okay. So we will see how
these things work, okay? I'll go to the next folder, which is a lead
driven cavity case. We have zero constant and system under system we have the
block mesh dig 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 dict. 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. 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 it is a toy case. If you just want to see
all the empty patches, you can select this and you can see all
the empty patches. Front and back is empty. What we are trying to do is we are trying to
simulate a case, a Toti 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 it
has created the polymesh. Now we will get introduced
to the zero files. Now we have U and P, which means veloc temperature. We'll open the velocity file. You can see the
dimensions are zero, one minus 100, zero, and don't worry about these
errors if your ID shows it. It doesn't matter as long
as this index is fine. We have the moving wall, which is moving at 1
meter/second in X direction. We have fixer walls, which is obviously no slip, front and back is empty. Okay? So this is like a syntax. This names has to mandatory
match with these. Only then it will get applied. If you make even
slight mistake like putting small 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 talglt the dimension. This is L, T, and the other values also go
on like temperature and all, but we are not interested
in that as of now. We'll just do MLT, and you can know what the
dimension of this file is. Okay. Okay. Now we have done
the initial conditions, but now we also have to set
the turbulence model, right? For this cavity case, we are using something
called cofoam. Co foam is a solver
in open form, which is transient in nature
and it is incompressible, but it can't handle turbulence. It is purely laminar. It can work only in
laminar regions. For that, we have a file
called transport properties. Always transport
properties will define the values of the
kyamatic 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 answers. Instead, what we
will do is we will define the yamatic viscosity of the fluid and it will
calculate whatever is necessary. And since Co 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 ICO foam without set
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 it quickly. But for now, we will see what we are going to do
with this CO foam case. We are trying to do something
called lid driven cavity. We are going to move a lid on top and we will be seeing what is the
recirculation reason inside. Okay? Now, we will run it. So we'll be using Co
foam sola as I said. Now I'll go into Control dict, and this is the
file which controls all the running parameters,
simulation parameters. So the application is ICO foam, which is the solva is Co foam. And the simulation has to
start from start time. So in this case, the start time is zero. So it'll
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
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 at 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 Time step, we will
be using 0.005. So I have checked the
stability criteria and came up with this timestep. In most cases, you
have to check it. And there is also adaptive
times stepping in open form, which we will learn
later to set up certain cases where we can do adaptive timestepping based on the Corn number or CFL number, if you know by that name. Ok and write interval is 20, which means for every 20 timesteps, a
file will be written. The file will be written. And perjurte will
remove older files. Let's say if I give
perjurte 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's 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 FV schemes and FV solution contain
all the details related to what numerical method you'll 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 PO solver. So PSO 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 the initial condition. Now I will initiate ICO foam by the command ICO foam.
I'll hit Enter. Now this simulation is over. So you could see
that we have 0.1, 0.2, so on until 0.5. I will open the Para
view from scratch again. Usually refresh doesn't work
in this kind of things. I'll apply. The colors
might be different for you. If you want to change the color, you can scroll down
on the left panel, can click on the color map. I 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, 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 pressure. So this is the pressure
at 0.1 seconds
5. How to create a tutorial: Hello, everyone.
In this tutorial, we will be seeing how to make a case from
open form tutorial. So open foam when
it is installed, it comes with a
set of tutorials. As we are working with
something which is open source, we don't have to build
everything from scratch. We will have some
examples and we can make our own case with those
examples as a base case. So in open form, those examples are commonly known as tutorials. So we will see how we can
take tutorial folders or case files and modify it for our own purpose and run
our own simulation. So to locate your
tutorial folder, all you have to do is first
source your open form. If you don't have
multiple versions, you can skip till now. So from now, it will
be very common. So you can be in any directory. Okay, so it doesn't matter. Now you can type CD, dollar,
foam underscore, tutorials. If you type this, you will go to the location where those
tutorial cases are there. Now you can type explored
dot xspacedt dn. Location will open.
If you see here, there is a lot of tutorials. The most common ones
are heat transfer incompressible and
compressible and multiphase in most cases. So if you see we have the
incompressible folder, if I go inside that, you will be able to
find all the solvers. These case files will be
separate for every solver. If these many solvers are there
for incompressible cases, the most popular
ones are ICO foam, pimple fam, and simple foam. If you go inside simple foam, again, you will find
a lot of tutorials. So these are the base tutorials through which you can
build your own case, having this as a reference. So we also have pimple
form where, again, it comes in terms of laminar, large Dsimulation or RAS model. So if I go inside laminar, we have these many tutorials, and if I go into LAs, we have some tutorials. If I go into RAs, which is Reynolds AvageNvtokes, we have these many
tutorials again. Okay. So if I go into ICO foam, again, we have these
many tutorials. Under cavity also, I have multiple different
cavity tutorials. Okay? So if you see, let's
take Co foam case. If I go here, I have zero
constant system folder. So under everything, we
will have the block mesh, decompose par, if
solution, everything. So if you see Co foam, it is always laminar, so we won't have the
turbulent properties files. So all you can do is
you can copy this and paste it wherever you
want and go to a terminal, navigate to that location, then you can run
your simulation. Okay? But if you are using
something like pimple foam, let's take RASKs because in
ICO foam, we saw the laminar. So if you take RASKs
and pimple foam, let's take very simple
thing like T junction. If you see here, we have got
zero constant and system. We have block MissF
solution and controlled it. All necessary files are there. It is a very simple case. If you go under constant, you will be able to find
turbulence properties. See? We have these
turbulence properties here. It is saying it is
using K Epsilon. We will be seeing a video on
how to model K Omega SST, but I will not touch upon Kepsilon or spallatalma
turbulence models. So instead, what you can do is you can refer to
tutorials like this. Okay, it uses Kpsilon. And if you go here in zero, you can find there
is Epsilon folder. K is there, new T is there. Also, you have new Tilda, which means you can also use
palate almas in this case. So these will be covered when we are seeing RAs
turbulence models. But as of now, I'm
just saying how to make use of those tutorials. Okay? Now, let's say, we have a simple
form and as usual, we have pitch daily case. Now when you are trying
to build upon a case, let's see what this
turbulence model is. Okay, they have K
aslent by default, so we are not going to change these tutorials
because if you are making any change to
the tutorial at all, you can't use it again, right. So what you will do is, you will copy this folder to some location
and then use it. So we will see how to do that. I'll go to some location. Okay. Now, let's
say mostly we will do all the things
in run directory, so you can run and it will
take you to the run directory. Now we will copy the
Pits daily case. So the commanders CP hyphen R dollar Foam
underscore tutorials. So this will point
to this folder. Now, under tutorials, we have to go inside
incompressible. I will go inside incompressible. Under incompressible,
we had to go into simple form, simple form. Then under that, we have its
daily, if I'm not wrong. Yes, we have Pitch daily, and we want to copy this
entire folder with the name. So just pace and dot, hit Enter. Okay, now we have copied
the folder. I will do LS. Now you can see we have Pitch daily and the tutorial folder. Now I will go
inside Pitch daily. And if you see, we have
the zero constant system, which means we
can't run the case. So for example, I
can do block mesh. Now I can run. Let
me track this. Simple form. And I can
do touch part form. And what I can do is I
will open this location. And as you can see, we have
all the case files here. This is the way which we will use to modify
any tutorials. Now, let's say you
want everything from the Pitti you want the
boundary names all same. So you want the mesh
inlet outlet upper wall over wall and front
and back one, and you want the same
KEL and everything. And even in constant, you want the turbulence
property to be the same or maybe different, but if you want the same thing. And if you just want to
make the mesh different, then you can copy this
case because it already has the method to implement
KSL and turbulence model. And pallet almas. So you can take this and
modify as you want it. Okay? So if you want
to change the mesh, you can do if you want to
change the control dig, you can do, if you
want to change the boundary files, you can do. Everything comes with
the template, right? So if you open the
velocity file, you can see it comes with the template of these
things with these headers, and you don't want to type
all of these from scratch. So always copy from a tutorial, which is as close as your case which are trying to set up and
you can modify it. I wouldn't copy a
pimple foam case to run a steady secase. So I can copy something
from pimple foam if I want to just run a transient case, and using terminal to copy using this command
is just one method. Say I have a folder, okay? Let's say I have this
folder and I'm just making something called run. Now I want to run the case here. What I will do is I can
go to incompressible. Now let's say I want to
run the cavity case, I'll go or better I will
take the elbow case. I'll copy the elbow, go
here, paste it here. You can use the Windows
Explorer if you are in Windows, and then you can run it. For example, I'll go
to that location. Now I am in the location
under which I have run, okay? So we have elbow here. Okay, now I can run
whatever is needed. So you don't worry
about the all run and all clean file here. We will learn about
that in later video. For now, we can see that
many things are there here. So you just want to run this
case, then you can load it. Then from the terminal,
you can run it. Now, I'm not going to run. So it was just for
demonstration. This is what you can do, always make a copy
and then do it. Don't change the
tutorial folders. That would be not
a good idea to do. So this tutorial is
all about looking at the tutorials folder and copying a case and
trying to simulate it. So I hope now you
understand how to use the tutorial folder. So if you see here,
we have a lot. For example, we have
the multiphase. Under multiphase, we
have a lot of solvers. All of these are solvers. And if you go into
compressible again, we have a lot of solvers. Under each solver, we
will have many tutorials. So you can watch over these tutorials and
once we understand what these all run
and clean files are, then you will also know what
are the set of commands which you have to run
to run the simulation. All the tutorials won't have block mesh and then
run a simple form. It all depends on
a lot of things. There are many uh, many manipulation of the case, like setting a field
in a multiphase case, just setting one part of the entire mesh to one
specific phase of the fluid. So these things are
there. For that, we'll be using something
called set fields dig and there is a topo set dig. So there are a lot of things. So when you are not sure
about how to run a case, that's where all run
file will help you. So we will look into that
later in the course. But for now, I just hope
you understood how to use the tutorials folder and the resources open form
oppose through it. Thank you. See you
in the next class.
6. snappyHexMesh and checkMesh: Hello, everyone.
Welcome back to the CFD using open foam course
beginss to intermediate. This is the third class. In this class, we'll be seeing how to use block mesh tool to generate further
complicated mesh using another tool
called Snappy Hmsh. So Snappy Hmsh is
dependent on block Msh, so we have to use Blockmsh in certain way to use it for
snappy H mesh that we will be looking and how to set up a snappy H mesh
and what actually snappy H meshes and how to create complex measures
using Snappy x mesh. Then we will look at a command called check mesh to check
the quality of WR mesh. Okay. So the block
mesh is used to create the background mesh in
case of snappy hex mesh. So what is background
mesh? We will look that. So the mesh must consist
purely of hexes. Like, we should have a
pure cube or pure cuboid, just like how we created the rectangular cavity
in the previous tutor. So the cell aspect
ratio should be approximately one that
is the ideal condition, so it is good to maintain that. And at least near the
surfaces at which the subsequent snapping
procedure is applied, which if you did
not understand now, you will understand later. But if you are good with
meshing in general, you'll understand
what snapping is. So near the areas where there will be snapping
towards the surface, we have to keep the cell
aspect ratio as one. And towards the convergence
of the snapping, if the procedure is slow, it could lead to the
possibility of failure, and we are not
wanting to do that. So we have to make sure that
the aspect ratio is one. And there must be at least
one interaction, sorry, intersection of a cell edge with the STL surface that is a mesh
of one cell will not work. So it has to intersect with some cell edges with
the STL surface. If everything till now
goes through your head, don't worry, you will
understand right when we get into
the presentation. Yeah. Okay. Now let's assume that we have
an teal surface. This car is the STL. We are interested in
simulating flow over a car. Okay? Now the gray area
is your fluid domain, and we have the tL surface. STL is basically surface
geometry. So we have it. You are interested in
mesh in the gray area, not the white area,
because we are interested in flow over the car. Okay, now the block mesh will
act as the background mesh, which will create the outer box, like you see this black box. The block mesh will
create these blocks and it will have some
subdivisions over there. It also contains
the boundary patch, such as inlet outlet and walls. Let's say that this patch has to be inlet and
this has to be outlet, then we will define that
in the block mesh itself. We are not going to do using
snappy hex mesh because snappy H mesh is going to
deal only with the surface. Okay. Then the block mesh will enclose the entire
tile and can act as the fluid domain if the mesh is required around the model
and inside the block mesh. So what this means is
that now we have created this black box is generated
enclosing the tL surface. So this block mesh has
created a fluid domain, which is the gray area, which encloses the tL surface. So this gray area is
the fluid domain. And this is essential, only if we want to make a mesh, which is outside
the til surface. But if this estel
surface is like a pipe, then it does not
have to be this big. It can just enclose the pipe and we can generate the
mesh inside the pipe. Then the tile will act as the enclosure, not
the block mesh. Okay. So only when the uh, mesh is required
outside the surface, then we need block mesh
bigger than the TL, and it will act as
the fluid domain. You will understand it
when we actually do it. Okay. Then the purpose of
Snappy hex mesh is that it is advanced mesh
generation tool for very complex geometry
like this aircraft. So this is generated
by Fozzy lab, which is at IIT Bombay.
I used to work there. So one of the researchers generated this mesh for the
Oki 30 M KI Mark I aircraft. So we were interested in simulating flow
over the aircraft. So this is just
the surface mesh. Actually, the mesh lies
in the fluid domain, but we can view
the surface mesh. Okay, that's what this image. The point is we can generate mesh for highly
complicated surfaces too. That's what I wanted to say. And the capabilities is it can
handle complex geometries. It can handle
refinement features, like if you want to
refine just one region, you can do that, and mesh quality improvement can be done through an I ratio process. Snappy H mesh workflow
is like follows. First, we will be importing the STL file into a folder
called Tri surface, which will reside under
constant directory. Like how we have polymsh adjacent to polymsh
we will create a new folder called
Tri surface and put the necessary STL
file inside that. Then we will be extracting
the surface feature using a feature called
surface feature extract or surface feature extract is the command to
extract the surfaces from the STL and save it
into dot E mesh file, which is open form
understandable. Then we will create
a castilated mesh. If you are good with meshing and the techniques used in it, you will understand what
castilated mesh is. And the snappy hex mesh will initially create
a castilated mesh. Using snapping and refinement. Then it will adjust the mesh to confirm the surface geometry
through further snapping. And then if you want layer addition, like boundary layers, five layers or six layers through layer
thickness for ileus, then you can add layers also. So that can also be
done in Snappy X mesh. So now we will see how
actually snappy X mesh works. Now the blocks which you are seeing is generated
by the block mesh. That is the background mesh. Then we have the car, which
is overlapping with the mesh, but we are interested in mesh outside the car, not
inside it, right. So this is the first scenario
where we have the setup. We have a block mesh,
and we have an STL file. Then the snappy hex mesh process will start to split the
cells near the surface. The feature edge is what
we say for the surface. So wherever there
is a feature edge, the snappy hex mesh
solve algorithm will split the cells to refine it so that we can
capture it accurately. It will do for all
the feature edges. So it will look
something like this. Okay? It has divided the blocks into smaller blocks
to capture the features. Then it will remove whatever is residing inside
the tile surface. We are not interested in that. We are interested only
in the mesh outside it. So it will remove or
dilate all the cells inside the tile surface. Then it will start
snapping to surfaces. As you can see, this
is not very good. The car wheel is circular, but we are getting
mesh inside also, and it's not very nice. So the process of snapping will start and it will
confirm the mesh, and it will snap to the surface, and it will not have anything outside or inside the surface. So it will be on the
surface exactly. So this is what snapping, uh, snapping does, and we will start adding mesh layers
wherever it is necessary. So we can control the mesh
layer where it is necessary. We can do. So this is the entire process of how
Snappy Hix mesh works. Now, for example, we will mesh a simple cylindrical pipe using pipe geometry
pipe dot STL. You will have the
STL file already in the resources so you can
download and use it. So first, we will set
up the file called surface feature extract date
because that is what is going to extract the
feature from STL and put it into dot EmsEmsh. That's what open
Form can understand. Okay, this is how the surface
feature extract looks. So I will open the
file itself so you can understand it better. Now, I am in the terminal. I will go to the class three. We have the pipe
external folder as the first tutorial,
so I will enter that. Okay, we have constant
para foam and system. We are not going to set
up the case, run it, so we don't have the
zero file now. Okay. Now, I will first
run the block mesh. Okay, we have the block mesh. Now to open this exact location, we can do this command explore dot TXCspace dot and head enter. It will open the exact location. You can see C three,
one by Pixon. I'll open the paraew file to view the mesh generated
by block mesh. Okay. Yeah. This is the
mesh we have, okay? This will act as the
background mesh. Now what we are going
to do is we are going to mesh up pipe. As I said, under
constant folder, we have tri surface, and we have pipe dot test
here, lclicono and apply. Now, you can see this is the pipe we are
going to work with. I put it in wire frames
so you can see it better. This is the background
mesh, and this is the pipe. Now we are interested in
meshing around the pipe. Please don't ask me
why we are doing it. We are just doing it
for learning purpose. So we're not going to
run any simulation. We are going to mesh
around the pipe. So by the block
mesh, we have inlet, outlet, upper and lower, and we also have front and back. This is what we have.
And I will close this. I will go system. Under this, we will be able to
find the surface which are extracdt. I will open that So you can see that we
have sourced pipe dot STL. So what is the location? By the way, you will not have
this file when you get it. So you will just have
polymsh and try surface. The polymesh will contain
the mesh from BlokMsh and the tr surface will
have only dot STL. Okay? So we have this STL, which we created using
any CAD software. I created using free
CAT I have put it here, so you'll get it
through the resources. So it is inside r surface. And notice that S is capital. Okay. Now we are sourcing
that name pipe dot STL. Extraction method is always
extract from surface. This include angle, we
are setting it to 150. If it is zero, it
will select no edge, and if it is 180, it will select all edge. So STL is basically
triangulated surface. So it also has edges. And we are giving 150 to be okay I will select
everything in a cylinder. For highly complex surveys, we might need 180 degrees. And subset features, we will set non edges as no and
open edges as, yes. It is always safe to
keep it in this setting. If you want to know
more about this, you can read the
documentation and you can explore nothing wrong, but I always like to keep non manifold edges as no
and open edges as yes. And you have to set
write OBJ as, yes. Okay. I will save this file. And the next command which
we have to do is Extract. Sorry. Surface feature extract. Notice that every other word has the first letter as
capital. A hit Enter. You should be seeing end
without any error or warning. Now, what this will do is
it will create this folder called Extended feature Edemsh and it has written
all these files. So this is what write OBJ does, and this is fine. Now we also have the pp dot
Extended feature EdmshFle, but you're not
interested in that. If you go to Tri surface, we pasted only dot
STL file here, but it also has dot E mesh file. That is what is
needed, actually. Okay. Now we are ready
to do snappy hex mesh. Okay? So snappy hex mesh. It has these three parameters
as the main thing. So cast mesh, it has to be true. Otherwise, you're not
going to get the mesh. Snap has to be true. Otherwise, you are not
going to get a smooth mesh. Add layers, it can
be true or false. It depends on what your
necessity is, okay? And by default, we will be giving pipe
dottyl in this case. If you are having
any other dot till, it has to match with the name
under tri surface folder. So you are giving it and the type will be
tri surface mesh. The name is pipe. This pipe under name, it is user defined. You can keep anything
that you want. Okay? It is not a syntax. You
can keep whatever you want. And feature will be given
through F pipe dot E mesh. This is what the surface
feature extract has generated, and we are setting it to level six for very
good refinement. It can be three, four,
five, six, anything, but generally three is okay
ish, six will be very good. You can also go above that. There is no limit, but
generally six is very fine and three is course
or a decent mesh. And the next thing is
refinement surfaces where we are selecting
this pipe, right? So this pipe is same as what you defined
in here, the name. So it has to match the pipe, and the level I have set it to five to six minimum and
maximum refinement level. So it will see how
the surfaces and it will choose whether to
do minimum or maximum. So it can be same also. Five,
five will also be given, 66 can also be given. And the patch info
will be type pipe, and in groups, it is pipe. So as we were seeing
in Para view, we have empty patch as
well as waltz patch. We can also do pipe. We can give our own group. If there are many pipes in the same case,
we can do pipes. Okay. This will be in
the patch in form. Then we have to give
location and mesh. So this is what is
most important. I will try to explain it
through visualization. So we have our block mesh here, and I will also load
the tri surface here. Our STL file. Yeah, we have it. Okay? So if I want the
mesh outside the surface, I have to choose a point
outside the surface, but it has to be
inside the block mesh. You can turn on
data access grade. And see what are the
points on X Y and Z. So the point if it
lies outside the pipe, but inside the block mesh, it will generate the block
mesh as the fluid domain. But if your point lies inside
the surface of the pipe, uh, then the mesh will
be inside the pipe. The second tutorial will
be on inside the pipe. So for now, we are
doing outside the pipe. So if you see the PPT, we are choosing 00.5 comma zero, which is around
in X, it is zero. Y is 0.5 and is it is zero. So zero, 0.5 and zero. It is slightly above the pipe. It is almost same on the
surface of the pipe, but it is outside the pipe. So it is going to generate the mesh outside the
pipe and nothing inside. So inside will be hollow. Okay. And the next feature
is add layer controls. If you set the
initial conditions to falls for add layers
in this region, then you don't have to set up anything under Ad layers
control function. But if you're
setting it to true, then you can add
the N phase layers. You have to choose the
name of the region, which in this case is pipe. So now we will run
Snappy x mesh so that commands to do it is
first we will do block mesh. Then the surface
feature extract, which two we have already done. Then we have to run the command Snappy x mesh, hyphen override. But before that, we will look at the actual file instead
of just screenshots. So it is under
snappy x mesh dict. If you go here, we have
the same file here. And we also have
these things called maximum local cells
set to 100,000. Maximum global cells
is set to 2 million. So these are limits. You can play over it, but pretty much you can leave
it default in most cases. And we have seen this. I have set level three because level six is going
to take a lot of time. Uh, that's why I said 23. But if you want to increase
six, then it's fine. Then for refinement levels, I said to three and four
because it will do it faster and resolve angles.
This is very important. Unlike surface which
are extracted, the more the angle, the better the capturing. But in this case, lesser the
angle, better the capturing. So it is to resolve
sharp angles. So usually 30 is fine. It's not good to go like
ten or five in general. So 30 is decent and we
have refinement regions. We will cover this
in a later tutogl. So this is not getting
used in our case, okay? So you can pretend that
this doesn't exist here. The location and
measure is also set. In the Snap controls, it has a lot of parameters, but pretty much you
can lay it default in um beginner level
or intermediate level. If you want to do very
fine level of meshing, then you can maybe
play with this. And add layer controls also
has this expansion ratio, final layer thickness,
minimum thickness, and at what parameters
it has to grow. So you can check these commands on what these parameters
are actually. So that is why these
commands exist. You can read and understand what each of these
parameters do, and you can play with
the values accordingly. Now we have something called
mesh quality controls. So it is including a file
called mesh quality dit, which is also in
the systems folder. You can always copy paste
this mesh quality dit. Mostly this is perfectly fine. You don't have to
change anything in this, so we are
going to leave it. After this, it can
be always default. You don't have to change it
pretty much most of the time. Now we will run
snappy eggs mesh. Okay. So the command is snappy, hex mesh, and always
do overwrite. It is not mandatory to do
this space hyphen overt, but what this will do is, since we are running
multiple iterations, right? So you can see here. We have refinement levels. So for each refinement level, it will try to write it
in a new timestep file. We're not interested
in doing that. So we are writing
the command overt, so it will override
the polymsh itself. So we will have consistent mesh under polymsh folder itself. So I'll hit Enter and it will
start to do the meshing. Now the mesh is
over. So now you can see that in the poly mesh, we have more files, not just boundary faces, points and owner and neighbor. We have more. We also got
a new file called sets. So if I go to boundary
now, we have five. Like we also have pipe. Previously, we had only four. Now we also have pipe. This is what Snappy
Higgs mesh has added. Now we will actually
view the mesh. I'll go here, hide the pipe. For ParadotFm, I'm
going to give refresh. You can see it has pipe in it. We have generated the
mesh of the pipe. So this is the background mesh. It stays consistent,
it doesn't change. Now, I can go here and select inlet
outlet and Pipe alone. Okay. We have the inlet, we have the outlet, and
we also have the pipe. Yeah, it is a
decent enough mesh. It's not good to run simulation, but to learn
meshing, it is fine. So as you can see, this is almost all quad, all hexahedral. This is what snappy hex meshes. The x means hexahedral. Mostly, it is hexahydrate. Sometimes it fails
and makes tetra, but 99%, it is hexahedral. We have this pipe. If you
want to see a slice of it, you can also do that
I create a slice. To create a slice,
you can click on this button and
hide the show plain upl you can see we
have the only as a line because we have
removed internal mesh. I'll select Internal mesh. I select the slice as
surface with edges. As you can see, this
is what we have got. We have the layers
also, good amount of layers. We have the mesh. This is a very coarse mesh. If you want to work on
the refinement levels, it's up to you. But I'm saying that once you
start refining the mesh, it is going to take
a lot of time. So for tutorial purpose, I have kept it very low. You can go up to 67
refinements also. Okay. Now we have done the
pipe meshing outside the pipe. But what if we want to
do inside the pipe? The procedure remains
literally the same, okay? So I'm going to go to
the internal pipe case. We have the block mesh, we
have surface met extract date, snap x mesh, and we will pretend that this
doesn't exist already. So initially, you
will have only this. We have the tri surface and inside that we have
the pipe dot STL, and we have these files also. Now, the method to do, as you know already, is go to the right location. Check if it is the
right location, then run block mesh,
get a good end, and do surface feature extract, get a good end, ensure
that it has created the extended feature edge mesh
folder and the dotty mesh. And we already set up
the snappy hex mesh, but there is a slight change. As you said, the location
in mesh is going to change. Previously it was zero, 0.50, but now it is one
comma 0.25 comma 0.25 because that is going
to reside inside the pipe and not
on the block mesh. So I'll show You can see the block mesh
is exactly the same. There is no change at all. But the point which
I have chosen, it lies inside the pipe,
somewhere in the middle. It need not be exactly middle. It just has to reside
inside the pipe. Then the enter mesh
is going to be inside the pipe and
not on the block mesh. Okay. But the problem is, it is not going to do the
inlet outlet and all. It's going to be getting
completely remote. We will look how to do that
also in a later tutorial. But for now, this is fine. Now the next thing is run
Snappy x mesh, override. If you want to play and learn what the command
without override does, then you can just run Snappy x mesh and see what it
does to the timestep. Apart from the zero timestep, it will also have
other timesteps. If you want to play around
that, you are free to do. The meshing is over very fast. Go here and give refresh. As you can see, this
is our only mesh. This is all that we have.
I'll close this and open it again so you can see the boundary conditions
also properly. You see, we have one
pipe here, nothing else. This is what the inside
the location will do. Okay. We have this mesh. So this is the internal mesh. So now you understood
how to make Snappyx mesh outside as well as
inside the geometry. This works pretty much
with every geometry, even if it is an aircraft
or a ship, it works. Okay. So you can try to download some STL files from Grab card or any online sources or if
you're good at designing, you can design your own STL
files and try to do this. So we will now do check
mesh quality command. So it will ensure the accuracy, it will check the accuracy of the mesh that is generated by the SNAPX mesh or any mesh even if you do just the
block mesh, you can do this. And it can be helpful in identifying potential
problems in the mesh. So the command is
just check mesh. So now, since we
have all the mesh, we will do check mesh. You see, it has given all
the necessary details right from at what time it has
checked the number of points, phases, number of cells, and how many
hexahedral is there, how many prism is there, how many wedge or
pyramid is there, how many polyhedral is there? And breakdown of the polyhedral
number of phases like four phase thing is 16 and
six phase thing is 118. So all these data you get, this is very highly informative. And the topology, like
what are the patch names and what is the phase uh, how many pass it has,
how many points it has, and how is the surface? Like? Is it okay
on the topology? Is it closed, singly connected? So these are the
things which are uh, known from this
check mesh command. And it also gives
us simply mesh, okay or mesh problems. If there is some
problem, it will say what problem it face, like one error or two error, then you can check
what problem it has. It says, Okay for
bound ray openness, says okay for a couple
point location, for maximum skews
it is saying, Okay, non orthoganity check
it is saying, Okay, so you can see the
cell volume is okay, phase a magnitude is okay. If something is not okay, it will say one
error and you can go back and check,
which is not fine. Okay, so this is the purpose
of doing check mesh command. And it will basically say
skewness aspect ratio, non orthogonty and mesh
consistency checks. So it will give you an understanding on
the common issue and their implication on the mesh and how it will affect your
final simulation reset. So tips for resolving common
mesh is also found online. You can check the
documentation on how to resolve certain things. Let's say if you are facing
non orthogonality errors, then you can check the documentation and
see how to resolve. It is case by case thing. So we can't generally
say how it is. So you have to learn by
practicing Snappy X mesh. And refining snappy X mesh will generally resolve
most of the errors, but sometimes it also needs
some personalized curation on the mesh and how
it is generated on certain surfaces and
how much refined it is. So it all comes
with practice and experience on how to make
a better snappy hex mesh. So this is how our
final mesh looked, and you have a task now. So create a new mesh
where the mesh is inside the pipe
using the same TL, but now you have to
create a how to say, um, boundary layers
inside the pipe. So we did not have the boundary
layers when we did this. So you have to create
boundary layers inside the pipe, and
that is your task. You can practice it on your own. Okay? So if you
have any questions, feel free to contact me. See you in the next
video. Thank you.
7. Solvers and Case Study: Hello, everyone. Welcome back to the CFD using open form beginner
to intermediate course. This is our class four, and we will see overview
on incompressible solvers, compressible
solvers, and some of the multiphase solvers which
are available in open form. Then we will do a
hands on tutorial on as study on lid
driven cavity, same as what we did in
the previous class, but it will be much
refined and we will actually see how
the simulation goes. Instead of a bad mesh, we
will have a very good mesh. So incompressible solvers. Incompressible solvars
in open form are used to simulate fluid flows where the fluid density
remains constant. So not just in open form. Whenever you are trying to do any analytical calculations or in most of the
commercial solvers, the incompressibility is assumed in most of the cases
unless you are working with very high speed sonic or external
aerodynamics thing. Otherwise, mostly it
is incompressible. These always are ideal
for simulating flows at very low MAC number where compressible effects
can be neglected. So mostly less than
Mac mostly subsonic. The key incompressible solva available in open
foam or ICO foam. So as we already saw ICO
foam is a transient solva for incompressible laminar
flow of Newton and fluids. The application can be used for time dependent
simulation that is transient simulation involving
very simple fluid flow, laminar case, it is useful in simulating transient flow
in a pipe or a channel. So it can be very easily set up and we can get good results. The next most widely used
solvare is simple foam. It is known among almost
everyone using open foam. So it is the most common one. It is a steady state
solve for incompressible. It can also work for
turbulent flows. Both laminar and turbulence
can be simulated here and it has a variety
of turbulence models. The application will
be suitable for steady state problems in various engineering
applications, mostly in cases of air flow or an airfoil or water flow in a hydraulic structure where the flow will get to steady
state after some time. So that is where we
can generally use. It is always steady. That's why we are using
simple algorithm inside. And we have a pimple form. So this is a combination of PO algorithm and
simple algorithm. So that is how the
name pimple came. It is not available in any
other commercial solvers. So the description is this is a transient solver
for incompressible, I can handle both
laminar and turbulent. It is very similar
to simple foam, but this can also work on
time dependent simulation. That is transient simulations. So unlike simple foam, this can work on transient
simulation. So it is like flow around resilient air or moving airfoil, where the mesh mose
dynamic meshing is also possible and where
there is vortex shedding. In those cases, we
can use pimple foam. This is also widely used
equally as simple foam. So the implementation steps
are going to remain the same. Either you use block mesh alone or along with Snap x mesh, are generating the
mesh, then we will be setting up the zero directory
for boundary conditions. Then we will be setting up the transport properties,
turbulence properties. Then we will configure
whatever we want to do in the system directory
under control deck, and we will initiate
the simulation. If it is ICO form, just type ICO form and it
will get initiated. If it is simple form,
then simple form. So you get the point. We have to use the name of the
solver to initiate it. So introduction to compressible
solvers in open form, handle fluid flows where density changes are
very significant. These solvers are essential
for high speed flows, shock waves, and other
compressible phenomena. So the most important
solver is row central form. So it is a density based
compressible flow solvers. So whatever we saw
in incompressible or pressure based solvers, no row central form is
a density based solver. So it is suitable for
high speed aerodynamic and shockwave kind
of simulation. One of the examples is, if you want to simulate
a supersonic flow over a wedge or
through a nozzle, then you can use
Row central foam. And there is one very popular compressible
solver called sonic foam. So as the name says, it
works for sonic flows. Uh, a transient solver, and for transonic,
supersonic subsonic, anything you can use. But it assumes that the gas
or the fluid is compressible. That is the only thing.
So if it is compressible, mostly it is gas,
it can be a liquid. And applications is useful for simulating time dependent
compressible flows, which is transient
and simulating a shock tube or expansion
of a gas in a nozzle. These are the kind of things
sonic foam is good at doing. Then we have row pimple
form as it says, row is for density based, and pimple is for transient. So it is a transient for turbulence flows of
compressible fluids. Unlike pure simple form, this can also handle
compressible fluids. It is applicable to wide range of compressible fluid problems, including high speed train
or an aircraft wing. Okay. And implementation step is going to remain the same. But we also have to define the pressure and
velocity differently. Since it is density based, we will be defining
thermophysical properties because it has to account
for the compressible nature. So we will be defining
thermophysical properties. Which will handle
the compressibility. Otherwise, it is going to remain the same on most
of the levels, like, do the mesh, set up the
boundary condition, initial condition, then
run the simulation. Okay? So for multiphase, the multiphase always in
open form are used to simulate fluid flows involving
more than one fluid. So whatever we have
run till now is like one phase or one fluid, right. So if we are working
with two fluids, let's say, water
mixing with oil, and we want to see
how fast the oil will rise over the water. So if you want to do such
kind of multiphase things, then you can use open
for multiphase solvers. These always are crucial
for application in mostly chemical engineering,
environmental engineering, and also fluid
structure interactions, where we will be
having like a flap of an airfoil and we want
to see what it happens. If you want to work on fluid
structure interaction, then you can use
multiphase solvers. Then the key multiphase
always are interfom. This is the most
widely used one. So it uses volume
of fluid method, uh you can recall it from
your CFD theoretical course. If you took multiphase
uh, subjects. So it will use volume of fluid, which is highly complicated, but you can set it up
easily using open foam. It is ideal for simulating
interface between two fluids, and simulating the
break of waves or dam breaks it is popularly known as the flow in a mixing tank, if you have a very big tank with oil and if you are pouring water into it and how it will react if you want to see
how the bubbles are formed. So those things
can be done in the multiphase solve
using interfoam. We have multiphase interfoam. So this is also the
same as interfoam. But again, it has some, um tweaks to the solver and
how it is getting sold. So there is slight difference. If you want to know more, you can check the
documentations, because it is beyond the
mathematics of the course, okay. Implementation steps
will be mesh generation, and we will be setting up
the boundary condition, initial condition
phase fraction here. It is an additional setting. We have to set which area
has what fluid initially. So we have to set that and
we will also be defining the thermophysical
properties for each of the fluid,
each of the phase. And we will do the control
dict setup as usual, and we will run the simulation. So now we are going to do
a lid driven cavity case. So lead driven cavity flow is a classic benchmark problem
in fluid mechanics. It involves a square
cavity filled with fluid like how I
explained already. There is a big cavity,
all our walls, there is a lead on top. We are trying to move the lead towards right side
at a constant bit. Now it is going to create
a re circulation region. So this is used as
a benchmark problem to see whether all the
algorithm works in your solver is because it is having a complex flow phenomena like boundary layer
separation, vortex shedding. And there is also
recirculation zones. Mostly watesding
is not happening here because if you're
working with LES, then you might get
small small vortex, but in most cases, you are not going to get
vortex shedding in this. It is mostly
recirculation zones, and we are going to check that. So it is a valuable
taste case for validating computational
flow dynamics codes. So the objective of this
case study is that to understand the fundamentals of incompressible flow
simulation using open foam, they're going to implement appropriate boundary
condition for the lad driven cavity case. And we are going to analyze the flow characteristics
such as velocity profile, pressure distribution
and vorticity patterns. We are going to
validate the simulation against established benchmarks
or experimental data, but this is a homework for you, like validating the case. I will tell you how to do
the setup in open form, and it's up to you to validate it and see how accurate it is. So the case setup is going
to consider these steps. First, we will
prepare a geometry. It will be a square cavity. We have already seen how to generate this block
mesh for this case. And in the flow regime, you are going to do an
incompressible flow with low to moderate
renounce number. How we are going to set the
renounce number is based on how fast we are
moving the lid, and the boundary
condition lid will have constant velocity
boundary condition, which is no slip and waltz is also going
to contain no slip. When I say lid is
having no slip, I mean, At the surface of the lead
just next to the lead, it is going to have
zero velocity. But as there is a shear, it is going to move with
a constant velocity with respect to rest of
the fluid particles. With respect to the lead, the fluid particle
just next to the lead is at zero velocity. But with respect to
rest of the fluids, it is moving at a
constant velocity. So that is the
basic understanding here on setting up the
boundary condition. So the simulation parameters
or we are going to use block mesh to develop
the structure mesh. Then this is a
transient simulation, we are going to use Co foam, and the turbulence model is obviously laminar
because it is icofoam. Okay. If you want to look at what is the
boundary condition, I have displayed it here.
You can look at it. As you can see, the
first is velocity, you can recognize it
by the dimensions. So the velocity of
the moving wall is 1 meter/second
towards X axis. For the pressure, it is zero
gradient and zero gradient. And for Kyamtic viscosity, it has 0.01 and
the SI unit only. And the application is ICO form, the start from is start time. So which is zero, and
we are going to end at 0.05 and the Delta T here is 0.005 unlike what we did in the previous
thing, like 0.005. Here it is much smaller. So after we set the
boundary conditions, then we are just going to
analyze the velocity profile, pressure distribution, at city
patterns, and validation. So this validation is on
you. This is like a homer. We have to do it. We will be seeing how to post process
for velocity profile, pressure distribution, and at CD patterns using Para view. But validation is up to you. So we will now run this
simulation, actually, okay? This is the case,
have cavity case. Okay. And we have zero
constant paraforman system. So I will open it. Okay. So under zero, we have velocity and pressure. So these are exactly
the same as what you saw in the presentation,
like these things. So I'm not going to go
over every one of them. I'll show you
transport properties. The new is 0.01. And in the system, the
block mesh is same, and the control date it is slightly going
to be different. Like, it is starting from
zero, ending as 0.05. That is same, but the
delta t is 0.0 005. Write interval is for every
two time steps or yeah, time steps, it is going to write one as well, which means 0.001. For every 0.001, there
is going to be one sell. Now we can run it to run it. All we have to do is do
block mesh, and co foam. It is going to take
only that much time. Now we can run it or
visualize it using paraview. We got all the time steps. I'll go to Para view,
click on Apply. Now you can see we have
the pressure profile. I'll choose velocity profile. Now we are in the
0.001 time step. To play, I can click on this and you can see
how it is growing. You get how it has converged. Okay. This is the
velocity profile. We got the pressure
profile also. But how to plot stream lines to understand what a city we have to plot
stream lines, right? So to do that, first, we will do a slice. So to click on the slice and choose Z normal, we
will have this plane. I usually remove hoplane
and click on Apply. So on this slide, you
can choose velocity. We have the velocity profile
and you see this, right? So it is a stream tracer. If you click on
that, it will plot from the minimum to maximum. Click on Apply and usually
it is in pressure. You can choose velocity. You can reduce the
number of points. Now it is 1,000, you can keep
it around 500 or even less. I keep 100. Now you can see how the velocity is in circulation region. That is one thing, but if
you want to do the um, vectors also you can
work with the glyphs, but that's not going to be
very useful in this case. So I'll keep it
with stream lines. If you want to hide this line, just click on this
and it will be done. You want to save this as
animation, click on file, save animation and
give some name, let's say, lead driven cavity. Choose as MP four, click on Okay, and you
can choose the frame. Let's say I want
to do ten frames, which will be 0.1 second
will be the one frame. You click on Okay, don't
worry about this error. I always appears.
We have the pile. We have the stream lines. Now if you want to do
just for the pa view, hide this, hide this, and again, can save animation. Now I'll do it driven cavity, velocity, click on
Okay and click Okay. Now we got the velocity. Now this will be much lower because I chose
one frame per again. So you can actually
play with this, and that is all about
this tutorial Okay. And the next week's homework
task is, go to this link. It will be available
in resources. This is a tutorial I made for a mesh preparation using Block Mesh for
backward pacing step. So this will be used
in our next class. So make sure you understand everything from this tutorial. Pause the video
whenever you need, do it hands on, do it parallel
and understand everything. If you have any questions,
feel free to contact me. Thank you for
watching this video. See you in the next class.
8. Boundary Conditions and Intro to Turbulence Modeling: Hello, everyone. Welcome back to the CFD using open Form beginner
to intermediate course. In this class, we will
be seeing the types of boundary conditions,
practical implementation, examples of those
boundary conditions, turbulence modeling
introduction, and setting up and running
some RN simulation. So what are the types
of boundary condition? As we already saw, we have two. One is dish lay
boundary condition, and the other is Neiman
boundary condition. To do a dish ley 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. Here I have done
inlet as a function. This will be
defining 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 directed in
the opposite direction. If you see num and
boundary condition, it is a fixed gradient. So it specifies a
fixed gradient, a 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 he can also define other types of gradients with specific
values if you want. So that is also possible. Here I have 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 solare 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 open form keyword is
using just symmetry plane. So it is mostly useful
in cases like a nozzle. Instead of doing entire three D, even if you take
a two D section, you are still going
to see the flow. But even in a two D, 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 these entraxs. So you can define
the entrax phase as symetrblne 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
an value at the outlet, we can give it as
the inlet as well. So that is what the cyclic says. So the application is used in simulations of 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, uh, given to the inlet thing. So it is mostly periodic a cyclic and it can be
considered as an infinite pipe. The open form 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 patch
as 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 values. The practical
implementation example is what we are going to see now. We have a backward phasing
step of a two day. 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 Turbulen 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, fixer w, and front and back. If you see the front
and back is said to empty because we are
treating it as two decays. Then we have the velocity. The velocity we have used directly boundary condition
where we are defining the uniform velocity as one minus three which is ten per 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 gradent in the inlet. And for the outlet, we are
setting zero pressure. So it is also in SA unit. So we will be
defining fixed value, and the value is uniform zero. And for fixed walls for
velo state is no slip, it is just a 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. And front and back is obviously empty because we are
doing a two D case. If you see the
transport properties, we are using a
Newtonian model with a kinematic viscosity of 1.56
into ten per minus five, and the simulation type is
laminar for this tutorial. And in the control date, the
application is simple form. Start time is zero, and we'll 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'll be working on. So I will open that
location by doing the command explore
dot Exspacdt. So this is exactly the
case which I showed you. All the case wells
belong to this. Now we are going to
run the block mesh. So I run the block mesh, 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 iteration. As you can see,
since it conversed, it did not bother to go
till, uh, 2000 iterations. Now we can visualize
the results. I'll open the paraviewFle. I'll click on Apply. Okay, now we have
got the pressure, but since we are
interested only in the last timestep
where it converged, we will press this and go to the last timestep, which is 483. I'll press on this to set the value to the range
which is visible here. And we can visualize
the pressure. As you can see, we are getting a good steady
state over here. Okay. Now, the most important
result which we are seeing in a backward phasing step is the reattachment length and
the recirculation region. So we will see how to visualize the recirculation region
by plotting stream lines. So I'll press on this, which will plot the stream
lines, click on Apply. Initially, it will show
only the pressure colors. You can change it
to lo city colors. Now, if you want
to hide the line, you can press on this.
I will hide the line. You can see that there is a recirculation reason and a
reattachment point for this. But this tutorial is not about calculating the
reattachment point, so I'm not going to
touch upon that. If you think like there are too many number
of stream lines, then you can probably reduce
like this is a good number, we are able to see
distinct lines here. So this is how we will
be plotting streamlines. And if you just want to see how it looks without
these stream lines, then you can go here, hide this, and this is your rest. 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 renune 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
flouid mechanical system, aeronautical engineering, and environmental engineering
also we there and HVAC. The turbulence model
overview is mostly this. We are mostly interested in only three types of
turbulence modeling. One is direct numerical
simulation where we will be solving the entire Navy Stokes equation
without any modeling. It is computationally
expensive and not feasible for
high renals number. Then we have large
AD simulations, which will resolve large
scale turbulence structures while modeling smaller scales, and it is suitable
for unsteady flows with moderate computation cost. Then we have renalds
average Navy stokes, popularly known as RNs or in open form terms, it's RS RAs. It solves the time
averaged equation of motion with turbulence
effic modeled, widely used due to its balance between accuracy and
computational cost. So this is the introduction
to turbulence modeling. You'll be using RNs
throughout this course. In RNs, there are mostly
three main models. One is known as K Epsilon, where it is a two
equation model, where it is 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
dissiputation trait, 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 Car
stress better than this. Then we have the
palatalmors 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 phasing step two D turbulent case tutorial. So I'll go here. I will enter the
second tutorial. Clear this. Okay, now we are going to see
the boundary files. Again, the boundary is going to remain the same. The
message is the same. And for velocity, we have
given 0.05 meters/second. It's quite high from
what we used already. Then we have the K, which is tubulin kinetic energy. For inlet, we are giving
fixed value and value. We are giving a reference value, which is uniform, 1.09
into temper 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 open form. 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 as, we are
using KQR all function. And again, the value was
referenced to internal field. Frontenb is, again, empty. Then for Nut, we are giving the inlet a zero
outlet also as zero. Fixed walls as Nut blended all 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 just explain all the
function in the videos. So we have the front
and back as empty. So nut is just turbulent
kynmtic scarcity. Then 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 this sold to correct it for us. And if you notice in NT, we are giving it calculated. So that is also same. We
are setting it as zero, a very low value and asking the solvat to
calculate it for us. So that's what's happening. And in the control date, it is going to remain the same. And this is what we are uh expecting out of
this 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 thousand 378 iterations. Now we can visualize
it using Para view. 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 turbulens
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 turbulens
values like K, Epsilon and Omega, you can check the
documentation and editor. There are many tutorial
cases which you can refer to and
try it on your own.
9. Transient Simulations and Parallel Processing: Hello, everyone.
Welcome back to the CFD using open form beginner
to intermediate course. This is our class six. In this class, we will be
seeing introduction to transient solvers,
decomposing methods, which will be useful
in running cases in parallel if you are interested in running
parallel processing. Then we will also see how to run parallel processing
for Snappy hex mesh. The entire machine
process through Snappy hex mesh can
be done in parallel. So we will see how to do that. Okay. Now, introduction
to transient solvers. So transient solvers, it uses
time dependent simulation. So we will be getting a sort of animation where every time
step is converged solution, so we will get a feel of the
flow progressing over time. The key features are the model here is unsteady or
transient flows, such as vortex shedding
behind a cylinder. Example, solvers in open form or pimple form,
icofoPsofom interfom. So applications are
like in most cases, the examples are aerodynamics, combustion or multiphase
phenomena like mixing processes. The advantage of using a
transient solver is to capture time
dependent phenomena, analyze dynamic behavior. So in solver settings, apart from what we
have done until now, we will also define
our timestep, which is Delta T, and
we will be seeing how to set the
convergence criteria which defines solution accuracy. We will also set
maximum Quran number, CFL number and so on. So we will be seeing
multiple tutorial cases. The first one will be
backward phasing step two decase in open form terms, it's called pitch daily. We will be seeing Kepsil
and turbulence model, and the solare which we will
be using is pimple form. So as you can see, this is
the part of control dit file, which will control the entire
simulation parameters. So the start frame start
from is set to latest time. So basically, when we don't have any time steps before
running the simulation, zero is the latest time, so
it will start at latest time. But if you want to start
at start time every time, then you can start you can set the start from to
start time instead of latest time too many
times in a sentence. Stop at will be end time and
you can set the end time. That is the flow time in seconds where your
simulation will end. In this case, your simulation
will end at 0.3 seconds. So it's like you're starting a simulation, you're
starting a flow. And after if you
stop the simulation or stop recording the
simulation after 0.3 seconds, whatever video you
would have got, that is exactly what we are
trying to simulate here. Then we have the Delta T,
which is the time step. In this case, it
is 11e minus four. So that is very small, and we will see
why we said that. Okay? In the control deck, sorry, in the control, we are setting it to adjustable and the right interval is 0.01, which means our
Delta is 0.0 001. But for every 0.01 seconds, we will be saving
a timestep file, which will cater us to
the animation finally. We will get a frame of reference
for every 0.01 seconds. So the perjurte is mostly useful only for
steady state case. What it means is if I
set perjurte to five, then only the latest five
time steps will be stored. Everything else
will be deleted to save some storage space. The format should be aski. You don't have to
touch any of these. If you just come below, you'll find runt modifiable. You can set it to S
because if you see that this simulation is running and you feel like 0.3 is not enough. Then you can set the time to 0.5 while the
simulation is running. If you want to do that, then
you have to set the runtime modifiable to S. And in
the adjusted timestep, if you keep S, then what it means is you are doing
adaptive time stepping. In case of adaptive
time stepping, you also have to define your maximum Cora number only
then it will, uh, do it. Generally, maximum Cora
number has to be one. That is the realistic case. It is also popularly known as CFL Current Friedrich
levy number. But in open form terms, it's maximum Cora number. We can monitor Cora number while this emulsion is running
for every timestep. By default, this tutorial
comes with a maxo of five. Let's tick on to the tutorial. But when you are actually
setting up a case, make sure that mostly it is one or depends
on the physics. So the next image is from
turbulence properties file. The simulation type is
going to be RAs and the arrays model is going
to be Epsilon, K epsilon. The turbulence is turned on, and the print coefficient
is also turned on. What this does is in the command prompt or
the console window, you'll be able to see
the coefficients of turbulence parameters
like K epsilon and nut while the
simulation is running. So after running the simulation, we will be getting multiple
files from 0.01, 0.02, 0.03. So on to 0.3 seconds, we will be visualizing
those things, those frames of animation in Para view after
running this case. So this is what we are
trying to visualize. So the left one is 0.01 seconds, and the right one
is 0.3 seconds. This is how it starts
and it ends here. So this is just a
backward pacing step. Now we will jump into our command prompt and try
to simulate this case. I'm in class six folder. Here we have the first
pitch daily tutorial. Here we have zero
constant and system. So as you might already know, uh, pitch daily comes
with a block mesh. So I will run block mesh. And we will find out
what is this solver, as we already saw, this is a pimple foam case. Sorry. This is a
pimple foam case. So I will write it
to pimple foam. And let's wait for the
simulation to end. Meanwhile, I'll just somewhere if you scroll your
mouse over here, it will snap to specific time, and it will keep on running. It won't stop, but you can just scroll and it
will just stop there. You can see it is progressing, the Delta T is progressing, and it is not same as
what we had defined because we have said the maximum Kura number and
we also have the Delta T, so it can alter the Delta T to adapt to the
maximum CRA number. That's what adjustable
timestep is. It's mostly adaptive
timestepping. Also you can monitor at what time this
simulation is happening. This is 0.018 and so on. And we can see the parameters, residual parameters for UX UI, and we also have for Epsil and K, pressure,
continuity, everything. So this goes on. And finally, when it reaches 0.3, this simulation will end. So when you're doing this, you can actually go to
that location and see it. So I will tell you what the
latest time is all about. Now, if I want to
stop this simulation, I can just do Control C, and it will just end there. Now I will do Explore dot x. So this location is open, and you can see we
have all the timesteps coming here from 0.01, and it is slowly progressing. We have up to 0.14. So since we have
given latest time, now we see the last time
it ran was 0.14 1795. So when I run the
pimple form again, it will just start from 0.14. It is starting from 0.14 because that is the latest
available timestep. So it is starting
to write from 0.15. That is the advantage of having the start time as latest
time instead of start time. Okay. Now this
simulation is over, as you can see it
took so much time to finish this though I have got all the running
time in the video. So it took a lot of
time and you can see how many actual
seconds it took here. You can also monitor that and you can see it ended at 0.3. Maximum Delta T was
around 0.0 002. So that was much greater
than what we defined, like 0.0 001 was
what we defined. But you can see, maximum Gura
number is just five here. So that's why it got adapted. Okay, now we have
all the files here. I'll open the paraviw. Now it has loaded. I'll click on Apply and I'll
change it to velocity. Okay. Now, as you can see, we
are at 0.01 flow time, it is always advisable
to first go to the last frame and
click on this thing, which is rescale to visible data range and then go back to your first timestep. Mostly, that would be better if you are running a
transient cases. But if you think the
physics is like, initially, it will
be high in velocity. And finally, it will
be lower in velocity. Then you have to do the
rescaled visible data range in the first timestep. So in this case, the final timestep has some less velocity than
the first timestep. So first time step has to be rescaled so that it can adapt
till the last timestep. You will understand
when you're actually working on multiple cases
and you will get it. So I will click on play. So this is how the
flow is progressing. You can see the time
is changing here. I'll click Play again
and it will start from 0.000 0.01 seconds. Now, as you can see, the minimum is 0.01. But if you want to include
the zero time step as well, you can check on this
button and click Apply. Now, you would also
have the zero timestep, but mostly it wouldn't
make sense at all because it is just
initial condition. Click on run and
it would be done. So it is not generally
advised to take the zero time step because
it is just initial values. It won't give you
any proper insight. Okay, now we got the velocity. Similarly, you can also monitor pressure and go
to the first time step, rescale it, click on pressure, and you can see it is
getting an animation. Now I can do this same
thing for KUTEpsilon. So you get the point. Now if I want to do uh velocity streamlines as an animation, then
I can still do. I just plot streamline just like the way I
would do normally, I'll hide the line. Maybe reduce the
number of lines here. Now I can do the same
thing like start, play, and it is running. Now it is a bit slow
and loading because it is loading all the time steps and plotting the streamlines. So it is doing multiple
things at the same time, so it is a bit glitchy. So what you can
do is go to File, click on Save Animation, and probably I will
save it as streamlines. Hit Okay, and probably I
would take for this case, I would take just one
frame per second. But if you want a
realistic skill, then you have to choose
ten frame per second for for you to get a slowed
down animation of ten times. But if you do 100
frames per second, then you would get the exact
realistic thing because our lowest timestep is
0.01 and our Delta T, I mean, Delta T in terms
of saving animation. Every frame here, as we
saved it is 0.01 seconds. When you want everything
for 1 second, you just have to
multiply it by 100. But that would be
too fast because the animation will
end in 0.3 seconds. I'll change it to one tlicono. So you don't have to
worry about this error. It is because of the resolution. Okay, it doesn't matter. Now we got the file saved,
the animation file, and I can open the streamlines, and it would be decent
enough and fine. As you can see, it is saving
one frame per 1 second. You can get some good
insight from this. But if you really want a
fast forward kind of thing, like a realistic
animation kind of thing, maybe a ten times slow, but animation kind of thing, then you can choose ten frames
per second in this case. I'll just save it. Now I will run this. Now you can see it is much better and looking
like an animation. Since it is a streamline, we can't infer much as well. I will go here and save
this as velocity file. But instead of ten, I'm
even going to use 20. It is just half scaled down. Here, run the velocity file. This run very fast,
as you can see. This is what a real animation
would look like at the end. If we had much higher
time steps flow time, then we would have
a longer animation. But this was just for
demonstration, so this is okay. Now we understood how to set up a transient case and run this. This is the first
part of the video. From the second part, we would continue, okay? Okay. Now we are going to
see decomposing methods. Decomposing is a method
where you will split the mesh into separate sections or regions and give your processors each part of the mesh and ask it
to solve for you. This is done through a process called message
passing interface, also popularly known as MPI. Open form comes with
the MPI installation. Generally, people have
to write MPI codes. To parallel process
their simulations. But since open foam comes with the installation of
MPI, we can use it. So it also depends on the
number of cores system has. So cores are the number of physical processors
your CPU comes with. You CPU will have certain number of physical cores
and logical cores. Open foam can access
only physical course. Commercial software
like AncesFluent can access even
logical processors, but open foam can access
only the physical course. We will see how to find out the physical course in
UR PC because this is the number or value
which you have to remember by decomposing. So I have given a set of methods to find out
the course in your PC. So you just have to open your task manager and you will go to the
performance section, and inside that, you
will go to CPU section. Under there, you will go to course and you can find
the number of course. So you just have to remember it. Sometimes your laptop comes with the stickers saying a number of course if it is
a gaming laptop. But if you are on a
very regular laptop, then mostly it won't be there,
so you have to find it. So to do that, either you
can open task manager from this or any shortcut
methods which you know. There are a lot of
shortcuts for this. So I'll go here,
click on performance, and on CPU, as you can see, we have the number
of cores here. In my system, it is eight. So whenever I'm using eight
for decomposing an MPI, please remember that
you have to use the value which your PC
is supposed to have. This because I'm typing
eight somewhere, please don't follow the
same and face errors. So just replace it in
the appropriate places. I'll close the task manager now. Okay. Now we are going to
see the decomposing methods. So decomposing in open
form is done through a file called decompose pardto. We will see the file as well. So this is how the file
actually looks like. It will have number
of subdomains, and it will ask
you for a method. If you choose hierarchyal, then you have to define
the coefficients. So the coefficients are like, if you have an entire mesh
and in each direction, how many subdivisions
do you need? So in this example, we are subdividing the
X in four subdivisions, the Y into two subdivisions, and the set is going
to be just one, which means it might
be a two decas we are interested
in decomposing one. X and Y. So what is important about the
four, two, and one? And why did I choose that? It is like when you
multiply X by Y by Z, you have to get the
number of processors. So in this case, it is
four times two times one, which is eight, which is the same as number
of subdomains. It is not mandatory that you always have to use all
the cores which you have. If you have eight cores, you can still use
just six or just two or just four, okay. But it is very recommended that you use even numbers and
not odd numbers. So use two, four, six or eight, things like that, but don't use odd numbers. Mostly, it can't work well. That is why laptops or computers come with
even numbers of cores. Okay? So you always
use even numbers. If you want to find out why
it has to be even numbers, you have to study about
message passing interface. Okay, now, in other method, which is called Scotch, you don't have to define
the coefficients. The program will do it for you. So you just have to specify the number of subdomains
and the method. So to execute the
decompose padict file and decompose your case, the command is just
decompose par. The purpose of decomposing is to divide the computational
domain into smaller parts. The benefit is it enables
parallel processing and reduces computational time by splitting the work to all the processors. When you are running in series, the computation will be done in a series manner
by one processor. But you are doing
parallel processing. The work will be split to
multiple processor and it runs in parallel
so you get it faster. So the method is like first
you split the domain into subdomains and assign different
tasks to each processor, and you will be able to run
the simulation or mesh. So the open form command
is decompose part. Okay. So before we jump into what parallel
processing and how to do it, we will see how to
do the decomposing. I'll go to the terminal. I'll clear this and go to the
second tutorial of today. Okay, we have zero constant
and system as usual. But if you see under system, we have one more file
called decompose Pardi. So that is what we are
going to view now, okay? I will go to the second folder. We have decompose Pardit. Here initially, I
have chosen scotch, but if you want to trial with hierarchical, you can do it. So we have the number of subdomains where I
have specified eight, you have to specify
the number of cores and the method,
in this case is scotch. Otherwise, it is just
normal Pitch daily case, which we run here for
transient phenomena. We will see the control dict. So we are again using
pimple foam only, and the timestep is
Delta T is equal to 0.0 001 and let the maximum
O B five, sorry. This shouldn't be there.
That was my mistake. Okay. So we have the
delta T as 0.001, and maximum Kura number as five. Okay? So we are going
to decompose it now. As you can see, initially, we have only zero
constant on system. So this zero file has U, P, Nut, K, and Epsil. Because we are using K
epsilon turbulence model, all you need as
turbulence parameters is just these three Turbulen
viscosity, K and Epsilon. If you want to explore what I said for the
boundary condition, you can go in and check it, but that's not the scope
of this video. So we have zero. We don't have any other timestep because we didn't run it. Now I will go here and I
will execute decomposing. So the command is decompose par with P capital, hit Enter. As you can see, it is saying
that it is subdivided. It is subdividing the
time zero into 027, which is eight fill transfer, and you can see the
number of cells, number of points has been
assigned to each processor. So it might be a little
bit more or less, but each processor has
a set of mesh which it has to work on and
do the simulation. Okay? So after we do this, we got these files, processor 02 process seven. So when you go into
processor zero, you have made a
copy of zero files. And the constant file. Under Polymsh, you will have only the mesh this
processor is assigned to. It will not have all the mesh which you generated
using block mesh. It will have only
the mesh content which is necessary
for this processor. And same applies to
every processor. So it has the zero file
because we are going to run things in parallel and it needs reference for zero. So it has the zero timestep. Now, I will explain what parallel processing
is and how to do it. So parallel
processing using MPI. So MPI is message
passing interface. The definition is it is standard
for parallel computing, and the functionality is it allows processes to
communicate with each other. In implementation for open form, you will enable
parallel processing for faster simulation, which is the same for
any CFD software. And you will run a piece of
form simulation for this, uh as an example for self, you will try a piece of
foam tutorial if you want, and you can try it using MPI. For now, we will
be sticking with the pimple foam tutorial and
we will see a demonstration. But if you want to do it with
ICO foam or simple foam, the methodology
remains the same. All you have to do
is you have to copy this decompose padick and put it into any system
directory of any case, and you can decompose it. You just have to set
everything properly, like the number of subdomains. Okay? So that is the only
thing which you have to do. Okay. The benefit is it utilizes multiple
processes simultaneously, and it scales well with increasing computational
resources. So let's see what is the step to do parallel
processing using MPI. The first thing is
decomposed par. But before that, you
must have a mesh and initial boundary
condition in 05. So that's what I mentioned as polymsh must be available
because not just block mesh, you could have generated
that with Snappy hex mesh or imported from ANS is fluent mesh, which
we will see later. Anyways, all the mesh will be in polyms, so
it has to be there. Then you are running
decomposed par which will divide every mesh
for each processes. Then the command to
initiate the solution or simulation is Pi run
space hyphen NP, space the number of processor, which in my case is
eight and process, which is in this
case, pimple form. If it is a simple form, then
you have to do simple form. If it is an ICO form, you have to type ICO
foam in place of process and space
hyphen parallel. So this is what will initiate the solver to run in parallel. I have put some examples. If it is an eight core
processor, it will be pin, space hyphen NP, space eight, and the command if it is simple form space hyphen parallel. If it is six cores, then NP six pimple
form parallel. We will see about reconstruct after we run the
simulation actually. Now that we have all
the decomposed files, we can initiate it
through pi ran NP eight, eight in my case, pimple form. Parallel. When I hit Enter, it would start to
do the same process which we did previously, but in parallel, so it is
going to end super fast. As you can see, it
is running super fast than what it was
running previously, because it is just eight
times faster right now. So let's wait for the simulation to end and I will
get back to you. So the simulation
is about to end. Okay, it is done. Now I will do LS. Again, all you can
see is processes 027. We are not able to
see the timestep. But what happened?
Because everything is inside processor. So we have 0.1 to 0.3, everything here for
every processor. Okay. We have to
reconstruct everything and then we can see
the visualization. What reconstructing
will do is it will take the mesh information
from every processor, collectively put it and just save everything as a
separate time step. And then it would look
something like this. But if you don't want to reconstruct because it
takes a bit of time, you can open Para Vew and instead of directly clicking on Apply, you can
change it here. Instead of reconstructed case, you can go to decomposed case
and then click on Apply. Okay. Now, what if I just
click on reconstructed case? You're not going to see anything because it doesn't
know if there are any files at all
because it is expecting the time 0.01, but
it is not there. So you have to give
decomposed case, so it will go inside
every processor and try to recollect it for
you for visualization. Now I can see the velocity. Now, if I play, it is going to be playing because it
is trying to recollect. But since the mesh is less, mesh count is less, you
are not getting stuck. But when the mesh count
is very high, let's say, in a three D case where
there are millions of cells, then every loading timestep
is going to be very high. That's why we are going to reconstruct and then visualize
it very easily. Okay? Be it takes time for
Pare to reconstruct every single timestep without storing it and
displaying it to you. It's too much on the memory. So we will see how
to reconstruct it. To reconstrate, the
very simple thing is just run reconstruct par. That's all you have to do. So just like how you
did decompose par, now you have to do
reconstruct PR. Now I will go to
my terminal and I will reconstruct par and
you will see what happens. It is starting to reconstruct every single timestep by
putting the timestep name. See, it is saying time 0.01, and it is reconstructing
all the fields, olim scalar field, vector field and surface scalar fields. So as you can see, it is
taking a bit of time. It is running slow. We will also see a method to run
this parallel as well. But for now, this is the
most popular method, so let it run. You're not going to
wait for it to end completely because this is
just for demonstration. We will stop it at 0.05.
Till then let's wait. Okay. Now it is done before
it starts with 0.06. If you want to end any process, just hit Control C, and it will be interrupted
by the keyboard. If I go here, now you can see, we have 0.01 to 0.05. Okay. Let's assume that you have reconstructed
everything, you don't need these files
anymore because these are Going to consume a lot of space. Since this is a
very small scale, it is less, otherwise, it's
going to be gigabytes. We don't want these anymore because the data has
been reconstructed. What you can do is RM
space minus R Brock star. It just says that delete
everything and everything inside those folder which starts
with the four letters PROC and we don't care
what comes later. So any folder that starts
with PROC will be deleted. When you're doing
through terminal, it's going to be faster
than what you will be manually clicking and
deleting through Windows. Since this is through WSL, it's going to be faster than
what Windows can even do. So as you can see, it is slowly getting
deleted one by one. And now it is all done. Okay. Now you can go to Para view and click on
reconstructed case, click on Apply and
it would still work, but we have only 0.05
seconds of data. Okay. Now, let's say you don't
want these timestep also. You want to start from
scratch by changing, let's say, Delta T or
maximum core number. If you want to choose it as two and if you
want to run it, you have to delete all
the timesteps right. Now it is just like
around 100 times step. But what if it is so much? You can't delete
everything one by one or even if you select
everything and delete, Windows is going to
take a lot of time. So open foam gives you this nice command,
Foam list times. Notice that L and TR
capital space hyphen RM, hit Enter, and all the timesteps will be gone in an instant. So you have deleted all the timesteps through this command. This is just some
additional information apart from today's topic. So this is just nice to know because when we are
working with terminal, it will be much faster than what you can do directly
with Windows. Now we know how to
decompose a case and run it in parallel using MPI and
also reconstruct par. Now we are going to see how
to run snappy hex mesh. Snappy hex mesh is
a meshing process and we are going to do meshing itself as, uh
parallel processing. As I was saying, we must have a poly mesh to generate
any sort of decomposing, because we need a
poly mesh to even put it in constant and split
the mesh to the processor. But snappy Higgs mesh
itself is a mesh. What we are going to
do is we will generate the block mesh and split the block mesh to
different processor, and we will do Snappy hig mesh as a process to every processor. I think you get the point and we will do the tutorial so
you understand it better. I'll clear this go to the
third case for this class. Now we just have constant and system no zero file because we are not interested in running
simulation. So just this. Now what I'm going to
do is I'm going to do block mesh because first we are going to run the block mesh. This is the pipe external
case which we made, if you remember, meshing
around the pipe. Now I have generated
the block mesh. Then the next command
is to decompose this. I will decompose using decompose bar. Okay. Now we have decomposed
the block mesh. Now the next thing is we
have to initiate SnappyHmsh. So the command is same Pn, Np eight in the process name, which is snappy x mesh,
as usual parallel. If you remember, we always do snappy H mesh with
space overwrite. So we can also include that. It doesn't matter
if you put parallel first or overwrite first,
it's going to be the same. So what I have done is I'll let my short on this so
that you can see it better. Wait. Okay. It is MPI run I'm not able to put
it in a single line or can I? Yeah. So it is
just like MPI run, MPI snappy hex mesh
parallel over right. Now I can hit Enter and this will start this
snappy hex mesh process. Now you see this
running much faster. If you remember at what speed it was running when you
initiated the mesh, you would know that it
is much, much faster. So now let's wait for it to
end and we will reconstruct the mesh through
a special command called reconstruct par mesh. So as you remember, we just did reconstruct
par when we are doing the timestep
reconstruction. But in this case, we have to do reconstruct par mesh space hyphen constant because
we are trying to write this mesh inside
the constant folder. So I will do reconstruct parmesh hyphen constant.
I'll hit Enter. Now you can see it is taking data from all eight processors and putting it in the volumes. Now, we don't need these
processor 027 anymore. So what we can do
is minus r rock. It will delete all
the processor files so we can save up on some space. If you just want
to view the mesh, you can go to Para Para
view, click on Apply. You can go to Wireframe. Now you can see
we have the mesh. The output is going
to be the same, but the process will be faster. That is the advantage
of using MPI. I hope you understood how
to do the um decomposing, as well as reconstruction. Now, let's say you
have a zero file also, and now you want to run
things in parallel. So what you can do is after deleting all the
processor files, now then reconstruct just
like how you would do for any simulation case
like this process. So again, you have to decompose, then you can run
things in parallel and reconstruct P. So that
is the best method. So now we have an
additional tip. What if you want to
reconstruct in parallel? Because reconstruct if it
has too many timesteps, like the previous case, it had a lot of time steps. If the case is like that, then it's going to take a
lot of time to reconstruct. You saw how much time it
took to reconstruct that. What I will do is I will again
run that case and show you how much time it takes when we are reconstructing
it in parallel, it's going to take
a lot less time. So I'll just run this case and get back to you
once this is over. I'm just going to run a few
timesteps, not completely. So we have five timesteps or maybe four because
I stopped it early. Yeah, we have five timesteps. Now you remember
how much time it took when we tried
to reconstruct it. It was very, very slow. But now we are going to try to use this command and see how fast it is going to reconstruct because it's running
in parallel. It is MPI run, Np eight,
again, the same thing. Then we are going to
run redistribute par. Par reconstruct Parl new times. So you just type this. I hope I didn't make any
mistake in spelling and hit tender now you see just how
fast it is reconstructing. Now, it is just done. This was the time it took to just reconstruct two time steps. So this is not very popularly
known among a lot of users. So if you use this, it's
an advantage to you. Okay, if you have any questions about anything related
to this video, please feel free to contact me. See you in the next
class. Thank you.
10. Advanced snappyHexMesh, External Aerodynamics and Plotting force Coefficients: Hello, everyone. Welcome back to the CW using open foam beginner to intermediate course.
This is our class seven. In this class, we
are going to see refinement box feature
in Snappygmeshdg, tutorial case on
external aerodynamics, which is the classic
motorbike case. We are also going to
plot force coefficients which are drag coefficient, lift coefficent like CDCL
and so on, using GNU plot, and we will also be exporting the post processory data
to Excel to plot this. So we are going to
see how to include a refinement reason inside
the entire Snappy X mesh. So as you can see, this is
Snappy HmshFle screenshot. We are defining the
motorbike dot OBJ. That is a geometry here, and we are assigning it
to the group motorbike. And we are defining
something called refinement box under
the geometry function, which means apart from
motorbike dot OBJ, we are also having a new
set of refinement box. So this refinement
box is treated as a new geometry under which
there will be refinement. Okay? So the refinement box
is defined in such a way that you just need two
points to define entire box. So you just need
the minimum point and the maximum point
to define a box. So the minimum point
would be minus one -0.70. So if you take a cuboid, and draw the major diagonal,
it will have two points. One would be minimum,
one would be maximum. So that is what this
refinement box defines. If you just want to
imagine it better, try to plot it in a three D, and you would know using Python or any programming software you are
comfortable with. Sorry, programming language
you are comfortable with, then you have the geometry
of refinement box now. So what you are going
to do is you are going to use a function called
refinement region under which you are assigning the refinement box as the location where you
want a refinement, and you are going
to say move inside, which means you are trying to
refine it inside this box. You can also do the negative, but mostly it is used only for
refinement inside the box. So we will stick
with more inside. And we can also set the levels, which is one E 15 or
four refinements. So the one E 15 is
a standard value which you might have to use, and four is the number
of refinement levels. So we will also see the file and see how this is
getting implemented. So I will go to the case file. We have zero constant
system and Para view. Under system, we have Snappy
hig meshedi as usual. So I'm going inside this and you can see that we
have refinement box. And this refinement box is
referenced when you go below, and you have
refinement surfaces. This is one such area. And similarly, we also
have refinement regions. So this is the one which
you saw in the PPT. Generally, if you don't
want a refinement region, all you can do is
just select this, put it in a command,
and this would be fine. So this should work even
without a refinement box, but you can't remove
this function entirely. So you just have to remove the values and make
the function stay. In this case, we want
a refinement box, so I will have it. So we are just going to
generate the Snappyx mesh now. So if you remember the process, the first process is to
generate the block mesh. It is throwing an error. I'm not inside the
motorbike region, so I have to enter the folder. So this is the mistake
you should not make. Always type Ps and
make sure that you have the zero
constant and system. Okay. Now I'm going to
run the block mesh. Now the second thing is
surface, which are extract. Now that is also done. Now we just have to run
this snappy hex mesh date. But before that, we are going
to see decompospatic file. I have eight core, so I put eight and the
method is scotch. What I'm going to
do is I'm going to decompospa I'm going to run Snappy hex mesh in parallel. I'll get back to you
once this is over. Now the snappy hex mesh is done, so I can reconstruct it now. I'll do reconstruct
Parmesh if in constant. Okay. Now I can safely remove all the processor files because
it's not needed anymore. I will open the PRR view file and show you the mesh
which we just generated. Because I did not give initiative on what the
geometry actual is. As you can see, we
have a big mesh, which is our fluid domain, and we have a bike inside
a nice bike. Okay. So we are just going
to see the bike now. I'll clic on motorbike group of incompressive, sorry,
internal mesh. And I'll choose
surface with edges. So this meshing
took a lot of time. Okay? You can see it took
like 28.4 seconds, okay? So it took really a lot of time. So that's why we
have a bad mesh, but still we have a bad mesh. So if you're going to
refine it further, it's going to take
still more time. So for demonstration purpose, I just kept it low. Okay? So this is the bike, and we are going to do the external
aerodynamic analysis on this. This is not the
best mesh someone could use, but for
demonstration, this would be just fine
because we are just learning and we want
to learn faster. Okay. Now, we will see what is, uh, external aerodynamics
in terms of open form. So first, we ran the block mesh, and we ran surface
feature extract. Then we did decompose Par and also we did the Snappy
x mesh parallel, right. Now then we
reconstructed Par also. So we have reconstructed
everything related to mesh. But now we have to start decomposing and running
the case, right? But you can see when
I try to decompose, it won't be getting
all the files properly because
we have something called zero dot original. When you copy a case
from Tutorials, it is going to come like
this in most cases. It's going to be like
zero dot original. When it is like this,
open foam can't realize that this is
the zero file and it won't put it inside the constant folder
of each processor. So open foam can't
realize that this is the actual zero file and
decompose it properly. So we have to copy this original and put
it in a normal 05. This is there because if you are wanting to make any changes
to the boundary conditions, boundary files, you should not mess up with
the original file. So that's why we
have this. What we can do is either you just copy, paste it here and
rename it to zero. Works fine. No problem. But if you want to
do it the cool way, you can do CP hyphen R, zero original and zero. That would still
do the same thing, but through the terminal. Okay, now we will see
the boundary files. So you can see that there is something called
Include Include folder, which we have not
encountered till now, so I'll explain what it means. So if I go to Include,
we have three files, initial conditions, print back upper patches, and
then fix your inlet. Just remember these names. Now I will go inside the U file since open form
works with C plus plus, we can call in another file and use the functions
inside that. So we are including the file
called initial conditions. And from initial conditions, we are taking in
the value of inlet. Okay? So we have initial
conditions file here. I'll just open it so you
understand it better. The initial conditions is saying the flow
velocity is this, pressure is this, turbulence is this and turbulent
Omega is this. Now when I go to U file, you can see we don't have any inlet patch because for that we have fixed
inlet patch here. See, we have the
inlet patch here. We are just referencing it here, this location so it can get
the function from there. And we also include the set
constant types function, which is from Include et cetera. So this is mandatory to include this so
that open foam can understand that these references are getting referenced properly. Then we are referencing front and back upper patches also. So I need not be like this. You can just copy
and paste this here. But the purpose of
having this is when you're just mentioning
include initial condition, instead of mentioning all of the values in different files, you just put it here and whatever is necessary,
it would be referenced. So I will open let's say I will open Kfile because
we have Kfile there. We are referencing
initial condition. We are including
the fixer inlet, so we don't have to type it
one by one in all the files. Now if you are wanting to change just the
fixer inlet value, instead of changing the
value in every file, all you have to do
is change it in the one file and it will get
reference to all the files. That is the only
motive of doing this. I will open different
back upper patches now. It says upper wall is slip, front and back is also slip. When we are seeing any file, all you have to do is reference the upper back friend patch, and it would take it a slip. So it happens with all
the files. You see? That is the use of having
this kind of include folder. Otherwise, these files are just normal thing and you can play with the
values if you want. In this case, we have set the initial condition as 20
meters/second in X direction. Okay. Now we will see what is there
in the constant folder, we have the tri surface where you put the motorbike to OBJ. Instead of STL, we use OBJ
file. We already saw this. So we have the
transport properties. We are using a
Newtonian model with kymtic viscosity of 1.5
into 104 minus five, and we have
turbulence properties where we are using K Omega IST because it works
well with waltz. We are trying to do an
external aerodynamics, Komega IST is one of the best. So we already saw how to do KF salon in the previous class, but we did not see K Omega. That's why we are seeing
this kind of thing. You also understand
K Omega better. So to do K Omega, the essential files are K, Omega, obviously, and Nut. Okay, now we go to the system. As usual, we have Block
mesh, decomposPadet, and we have scheme,
IV solution, mesh, quality d, snappy, and
surface feature extract. Everything is fine.
But we also have a new file called
force coefficients. If I go inside
force coefficient, you will see that there is a function which says the
type as force coefficient. It is referencing a
library called forces. Right control is saying time step and the
time interval is one. This is all intuitively
understandable. And the log is saying is to
plot it in logarithmic scale. If you have not got what
this file means is, it is just going to take
the CDCL values from here. So that's why we are
plotting it in log. And we are trying to get the data from the
patch motorbike group. If you see the mesh, I have plotted only the
motorbike group here. So on all these mesh points, the calculation will be
done for CD CL, and so on. So we have to define the
reference values like density. This case, the density is taken as one for simplification. You can work with original, uh, exact values of
density if you want. Then we want to define
the lift direction. So if you see this geometry, the lift direction would
be positive Z axis. That's what we have mentioned, and the drag direction
would be positive X. So that's what we
have mentioned again. And the coefficient of, sorry, C of R, which is like the
center of rotation. No it's coefficient.
I'm so sorry. It is center of rotation. That would be 0.720, comma zero. Where did this value come from? I will turn on data axis grid. You can see that this point is kind of the center of
this entire geometry. So 0.72 makes sense, right. So that is why we took 0.72, and we want to pitch axis. So, in which axis it is going
to pitch for drag and left. So that is Y because if you take the normal or perpendicular,
it's going to be Y. So this will pitch
along the Y direction. So we are mentioning Y. And magnitude of U infinite, which is the freestream
velocity in this case, is 20, and we also have to do
the length reference and the area reference
values so that the CDCL values are getting calculated properly because
we need reference values. Open foam can't
take these values from the geometry, so
we have to define it. But just calling this
putting this folder in system directory is not
going to make it work. If you understood open form by now, it's not going
to make it work. You have to reference
it somewhere. The way to reference
it is in control. You open control dt at the end, you just open a new function
called functions inside that you just put this function called the force coefficient, and it will reference
to the function of functions in force
coefficient one function. So we are having this
Icloude force coefficient, so it is going to
take a reference from there and it will
plot all of these. But if you don't
want to do this, then you can just
copy entire thing. Then just replace it under functions in open form.
Sorry, control date. I would just still work fine. But it's not going to be a nice way to keep
your control date. It's going to be messy
when you are going to work with a lot
of functions later. So it's always
fine and better to have things in different
files and referencing it. That's how C plus plus works. So we got how to set up the
force coefficients also. So I would advise
you to download some geometry from Grab
card, like a car model. You know how to set
up Snappy x mesh now. So set up a car case. Try to do this case in car
instead of just this bike. Okay? So I have given this
bike geometry already, but it doesn't come with
the tutorials directly. We have to find it inside
the under tutorials, we have resources folder. Under resources we
have geometries. Under geometry, you will have this motorbike geometry
which you have to download, copy and paste it in
the constant folder. So you will understand
it better when you see and understand
all run files. So for now, you
just don't worry, you can download and do machine using Snapxmsh for any
geometry and work with it. Okay, now we will see
what we have to do next. We have set up
everything, so we can decompose par and run
this case, right? Yes. So I'll do decompose par. It's going to
decompose the case. I hope it doesn't
throw in error. Yeah, I didn't throw error. Okay. All I have to do
is initiate this case. So this case, I'll go to Controict It's
a simple foam case. It's a steady state case, so I'm just going to
do MPI irn NP eight, simple foam Rall, and it enter. So it is going to
take a bit of time. I'll get back to you
after it is over, but you can notice
something different here. It is also giving you
the values of CD and the vectors of CD and we have
CL and vectors of CL also. We also have coefficient
of moment for pitch, roll, ya, and all. Mostly, we just use CD and CL. I'll get back to you once
this simulation is over. The simulation is
over, but still the solution is not
converged as you can see, but I stopped it at the time 500 because it's
taking so much time, it's already 4 seconds. But if you want to run it
completely, you can run it. But for demonstration purpose,
this would just be fine. We can take the latest
timestep and work with it. So I have run the decomposed
case, as you can see. Now I have to reconstruct it. So if you remember the
command to reconstruct it faster, Yeah, I have. Okay. Now the
reconstruction is done. I can safely delete all
the processor files, though it is going to
take a lot of time. Can just go here and
click on refresh. So it is going to load all the files which
is needed for us. I'll go to internal
mesh, click on apply. I will take a sliced plane. So I want it Y normal. Okay. Don't worry about this.
We'll go to Y normal. This is the pressure fields. We go to velocity field
at the last time step. So as you can see, we have the motorbike
case and you can see the velocity
profile here. If you want to plot the
streamlines, of course, you can. But this tutorial
is not about this. It is about plotting
force coefficients. Let's look at how to do that. So we have done all of these Now we also saw how to set up the function and what everything
in the function means. Since we now know how
to set up the case and set up the function to
get the force coefficients, we can now see how to
post process this data. So to do that, you can go
to your working directory, and you will see a folder called post processing
just got created. If you go here, you'll
see the function name, which is force
coefficients one in case. Under that you'll have the
zero folder under that you have the force or
coefficient dot Data. If you open it, it
is just long list of files which generated
and stored the values of CDCL and their vectors or components of CDCL and
coercion of moment and so on. So you can basically
import this into Python also and cross process
it for plotting. But open foam gives
you easy way, which is called foam monitor. So we are going to do that now. So what we are going to do
is we are going to create a plot of the
coefficient things. So the command is form
monitor space hyphen. This hyphen L is for log. So if you don't want a log plot, you don't have to include that hyphenl, we
will also do that. So the location of that
file is post processing, pose coefficients one,
under that we have zero, under that we have
coefficient dot dot. So what it means is you're calling the
application form monitor, which is based on
GNU plot actually. Then we want a log plot, then the location or the path
to the coefficient file. Then you just hit Enter and you'll be
able to see the graph. So you can see we have
the legends here. So the CD is less than one, and you see we have CL so
that is also less than one. We have all this.
This is a log plot, as you can see from the Y axis. But if you don't
want a log plot, let's just assume that
you don't want log plot. When you close the
application of GNU plot, just hit Control C, otherwise, it's going to
respawn and come again. Now I will remove
that hyphen L. You can see we just got
an normal plot where everything is less than
one and close to zero. So you are not going to
see much from this graph. And if you want to zoom and all, you can actually do Zoom
and things like that. Yeah. It all happens here. So it just works
same as Nu plot. I'll close this and hit
Control C. Otherwise, it's going to respond
again and again. Okay. Now, we are going to export this post process data to Excel, and we will try to plot the force coefficients
values using Excel. Okay. Now I will open Excel
I'll open a blank sheet. If you are just working with the library office,
it is still fine. What I'm going to do is I'm going to copy this entire thing. Instead of doing
that, I'll go here and probably hold shift
and click on this. And then just copy here. So this would copy everything. Control C, can control. You can also import if you want, I just find it easier
when I do this. So since this is a
steady state case, first view iteration would be totally senseless,
like these things. Also, we don't want
the components of CCL. So I will remove all of these. We don't want the
coefficient of mom and all. So I will delete all of these. We just need coefficient of
drag and lift against time. We just want to see how good
converged against time. I will also delete
first nine or ten data. Now if you just know
how to plot in Excel, is the same, go here
and select data. Now we have got the CDC plots. You can work on beautifying
this graph using Excel. You can add Shar title and swan. I just told you how to plot it using Excel, how
to input it and all. If you have any questions regarding the content
in this video, you can feel free to contact me. See you in the next
class. Thank you.
11. Import mesh from ANSYS WB and Fluent, Flow over a cylinder vortex shedding case: Hello, everyone. Welcome back to the CFD using open foam beginner
to intermediate course. So this is our class eight. In this class, we'll be seeing importing answers workbench
machine to open form, importing answers fluent
machine to open form, flow over a cylinder, using workbench
machine done mesh. You will use the workbench mesh, imported into open form and do a flow over
a cylinder case. Okay. Importing ACS workbench mesh into open foam is
a very simple process. But the purpose is it use high quality ASIS workbench mesh and open form simulations. If you are someone who uses open foam and you get a project where they have a workbench mesh from ANCS which is the most
popular commercial software, you should not be in a position to not use those mesh and do the simulation because open foam is basically a solver for CFD. So you can use high
quality answers you have D mesh inside open
form and do simulation. So it leverages ACs robust meshing tools and
for complex geometries, which cannot be
highly capturable in block mesh or Snappy
x mesh in some cases. Snappy X mesh is
definitely one of the best tools for
meshing in hex. But if you want to tetra mesh, then CIs might be the commercial software
which will help you. There is also other
software called CF mesh, which you can use as open
source in open form. But you are just interested in inputting ASIS mesh as of now. The process is you have to export the mesh from
Manss workbench, save it in the format of dot H, which is called
workbench mesh format. Then you have to ensure
the compatibility with open form requirements, which we will see the
commands to check that. Then you will convert the mesh, use the command fluent mesh to form or fluent three
D mesh to form, if it is a three D case, using those command,
you can import it. So the usage of that command is like fluent
mesh to form, space, the file name dot message, or fluent three D mesh to form, space, file dot message. And you can always use the checkmsh command
because anyways, even if you are importing
ACS workbench mesh, it is going to get
stored in the format of polymsh inside open form. So you can always do
the checkmsh command, verify the mesh integrity
using check mesh, then address any inconsistencies or errors using answers mesh. So importing ANS is fluent
mesh is a different process. So you have to export the
mesh from ANS is fluent, but in a different
way because ANS is fluent meshing will generate
a file called dotmsh.h5, which is not supported
in open form. You can only use dot sh. So to do that, you have to use the
standalone fluent application and not the one which
comes with the workbench. So you have to use
the standalone fluent machine to
generate the mesh. Then you have to save the mesh. Mesh has dotsh dot Hive, which is fluent mesh, and export the generated mesh in ASQ format and not in binary. So by default, it
will be in binary, and you have to export
it in ASQ format, we will see how to change
that and after exporting, you can rename the file to
dotmsh.h5 while saving itself. So when you do that, it will get saved as dot Mg
instead of dotmsg.h5. But always remember
that it doesn't work with workbench, kind of meshing. I mean, when open form is trying to accept
dotmsh dot Hive, it won't be able to read. So you have to use
standalone fluent machine instead of the fluent mesh, which comes with open with
the answers workbench. Okay, the command,
as you already know, is fluent mesh to form space, uh, file name dot sh. In this example, it is
called mesh mesh dot sh. So for this tutorial, we have done a meshing
using solid works. We have created the
geometry in solid works, I mean, you can see
the dimensions here, and it is saved
as dot IGES file, and it is imported
inside says workbench, which is design modeler. In Design modeler,
you have to choose the object and you have to change it to
fluid instead of solid. You can find this panel
on the left bottom. Only then open form
can understand that this is a fluid region. Also, if you are going to try
to make it as a two D case, then you might have to use
the convert utilities in design modeler and take a phase from the
solid works thing. If you want to know how
to import solid works, three D geometry into As a design modeler and
convert into two D, you can check the video in our YouTube channel, C dynamics. I have made a video on that. After we convert it into
two D and says workbench, then we can do the mesh. In this case, I have
done a generic x mesh. You can do with any mesh, I have also added
some inflation layers near the cylinder. In the naming selections, I have also given
the left as inlet, right as outlet and named the cylinder as cylinder
and upper and lower. Okay. Now to change while saving the file
and workbench meshing, you can click on Export. Then after Export, you
can choose options. From there, if you go inside your export options of meshing. You can change the format of input file as key instead
of binary and click on. Then you have to export the mesh in fluent
input file method. This is what you have to do. You can see the process,
I click on Export, then mesh, then fluent
input mesh, then I export. But before that, you have to go to the options and change this. After we do that, we would
get the file in dot message, which we can see now. I'm in class eight first case. As you can see, I
have the flow over cylinder workbenchmsh,
dot H here. Now we are going to use this and import it
into open form. I'm in the working directory. Now you know the command. Since it is two D mesh, it's fluent mesh to foam. Space a file name
which is flow over cylinder or benchmsh dot mish. I'll click Enter and you can see it is writing the mesh to constant polymsh and it is done. Now we can see the mesh
by clicking on Para view. I'll click on Apply,
as you can see. Though we said it
is a two D mesh, it came with a three
D surface because it's going to set the Z to
one cell automatically. You don't have to do that,
unlike making a block mesh, setting the front
and back to empty, you don't have to
do those things. It is already set to empty, the front end back by
default while importing. So this is the nice
thing about open foam. I already does it. Now we are seeing
the internal mesh. As you can see, we have inlet
outlet, upper and lower. All the naming selection,
whatever we gave in answers, it is still there
in open form also. Now we have the mesh. Now you can decompose,
run the simulation, do whatever you
want, because you have the polymsh folder. You can just copy
and paste it in any tutorial and you can do it. So this is one nice way
to import workbench mesh. Okay, now we are going
to see how this, we saw on how it is adding
front and back planes. Now we will see how
to input fluent mesh. So the geometry is made
in design modeler, and you have to give
the boundary names, which is naming selection in
the design modeler itself. Otherwise, you can't name it
in a fluent machining and how you did it in
workbench machine because we are going to use
standalone fluent machining. It doesn't have those
things. It can only mesh. So you have to create
the naming selection in design modeler itself, and you also have to assign the body to fluid
instead of solid. After that, you have to save the design modeler
file and then open the standalone fluid meshing
application and you have to import the mesh
file and you have to generate the mesh
using Ancis fluid. So that is not the tutorial
which we are going to see. It is about open form
and not Ansis flint. But if you want to see
how to use AnsisFlinmsh, you can check out
Audio tip channel and check the tutorial. Okay. Now, the
methodology to export the fluent mesh is through this. You just click on File
and write and then mesh. But in the mesh, you have to deselect the right binary files. And you also have to change
the file name to dot sh. Instead of saving it
as CFF Mesh files, you just choose
all files and save it as whatever name you
want to give dot MSH. Always, you have
to make sure that it is not written in binary. While saving you just save it as dot MSH and it is just fine. Again, your new thing about fluent mesh is regardless of whether it is
two D or three D, the command to import it is
fluent mesh to form only. So if you are running fluent three D mesh to
form for some mesh, even if it is from bench mesh, and if it is not working, just do fluent mesh to form, give a try and mostly
it would work. Either of the command
would definitely work. So now in the second tutorial, we are going to see how to
import fluent generated mesh. So this is dot MSH, which is generated by fluent, and we have to see whether it is compatible
in open form or not. To do that, you can just open the dot MH file using VS core. And if it makes some sense, then it is a good file. It is open foam readable
and it can be converted. But if you open
it and it is just gibberish and if it doesn't
make any sense at all, if there are no characters, only boxes or Xmax, then it isn't binary. Then open foam can't
understand it. So you shouldn't
export in binary. Just make sure if you are getting the mesh file
from someone else. If it is a consultancy work and someone is giving the mesh, then you have to ensure
before even trying. Otherwise it's
just waste of time for you to check whether
it is working or not. Just open, it should make sense. Now we will import this. Now I will do uent mesh to form and the file name. Now it has converted. We can view it using parav. I now, as you can see, we have inlet outlet
and walls design which we gave in the design modeler
and not in flint machining. Flint machining was
used just for meshing, but we still have it here from the design modeler
assigned names. So this is a nice thing. This is the mesh.
This is a poor mesh, but for demonstration,
this is fine. Okay. Now we will see the
vortex shedding case, how to set up a
vortex shedding case from the mesh which got imported
from the workbench mesh, same as the one which we
use for the first tutor. Okay. Now we are going to use
this palate almors model. We already saw
KClan and KOM ICT. So this tutor will be
about salt almers, which is the third most
popular turbulence model and most probably
the most common used one for external
aerodynamics. So we will be using one
equation model instead of two equation model in palate almers That
is the advantage. We are going to use a two D
flow or cylinder mesh to make a transient case in pimple form with palate almers
turbulence model. This is what we are
trying to expect out of this simulation vortex shedding animation
since it is transient. I will go to the
water shed in case. Now, I'll just close this. Enter the folder. We have zero constant
mesh file and system, so I can import the fluent mesh to foam for flow
Clint M message. It got converted. Okay. Now I'll go to system. As you can see, I have the
decompose pedict right now and I have set it to
my processor capabilities. I will decompose par and it will decompose
the mesh we just imported because
it is in polymsh. It doesn't know it
is from *** fluent or Salome or GMsgblock mes gent. It just knows that the
mesh is in PolymshFolder. Now we have to copy and paste
the zero dot original file. I generally like to do it
from the terminal itself. Okay, now we also
have the zero folder. I'll go here and show you what this palette almors
model is all about. In constant, we have
GF, which is gravity. We have said the gravity
to negative direction of Y axis in the value of 9.81 meters/second squared,
this is an SA unit. So I'll go to
transport properties and we are using R as the fluid, one into ten per minus five, and in the turbulence
properties, we are using spalalmras model. That is the change here. It is also RAS type, so we are using ppealmas. We will look at the 05. In the velocity file, we have inlet outlet cylinder, upper and lower walls, and front and back patches. Inlet velocity is
10 meters/second. The outlet is set to
gradient, zero gradient. The cylinder will have no
slip because it is a wall, and we don't want the
upper and lower wall to have any effect on the flow, so we are setting it to slip. Which means it is a wall, but it will act as slip. Then front and back
planes will be empty because this
is a two D case. Now we can see the
pressure file. Since we define the
inlet for velocity, we don't have to
define pressure. So we have zero
gradient in inlet and outlet is said to fixed value of zero neutron perimeter
square. It is an SA unit. So the cylinder will
be zero gradient, upper and lower wall
will be zero gradient, which means the solver
will calculated for us. Front and back planes
are obviously empty. Then we have our turbulent
kinematic viscosity. Which is set to calculated and set to
zero as initial values. So this is what we
generally follow. New TK all function
for all the walls, and all the patches will
be set to calculate it with a value of zero front
and back will be empty. And finally, the main file of this turbulence model,
which is new Tilda, if you want to understand
what new Tilda is and how this one equation model
for spit armas works, there is a beautiful
documentation from Open form. Also, there is a beautiful
video from YouTube, the channel fluid
mechanics one oh one. You can check. It is
beautifully explained. So the inlet is set
the value of zero. Outlet, cylinder,
upper and lower wall, everything is zero gradient and front and back planes are empty. Okay. Now we are going
to run the simulation. I actually made a mistake. I changed the name of zero dot original to
zero after decomposing. So it was throwing an error, so I deleted all the
processor files, and then I decomposed
it again so that it would copy
zero perfectly. Now we can run this
simulation using PRN, Np eight, pimple foam
parallel Kit enter, and it will start
doing the calculation. Let's just wait for it to end. Okay, now the
simulation is over, as you can see the
maximum core number was set to one, so
it is around one, and Delta T also varied a
bit to adjust for the time, it took definitely a long time, full 5 minutes to run this. Okay, now we can
reconstruct this. I'll search for the
command which I use, you don't want to type it fully. Okay, I'll hit Enter to
reconstruct all the time steps. So this definitely is going
to take a lot of time. I'll get back to you
once it is over. I thought while it
is still running, I'll tell you how
to view the results while it is still,
uh, reconstructing. I mean, it is still
in the processor 027. So we can view it as
decomposed decase. I'm just going to
open instead of reconstructing it
completely because it's going to take
a lot of time. I'm going to choose
decompose case, click on Apply, and we can
choose velocity and plate. As you can see, we are
getting the flow slowly developed and it is
starting to separate. Now we are getting
the vortex shedding. If you are very well versed with CFD and you set up a lot of floor ceiling of
case for atexhding, you will know this is not how
the pattern actually works. I mean, this area, if you look at the zero
gradient of the outlet, this is not how usually
you would expect it. Also, the domain would
be so long than this, not just this length, it would be much longer. I didn't want to make the
number of cells high because it would cause the simulation to
take a lot of time to end. So I kept the number
of cells low, but now you understood
how to set up a spartt almas
case and perform a vortex shedding using the mesh generated by Anss workbench. So this is the animation
which we have got. If you want, you can go on
and save it as an animation. And if you want, you can
also see the new Delta, it is going to be
completely zero throughout the case and same for annuity. And obviously, pressure
is going to change. So you get the point of
doing the pallet almeras, but if you are really
into flow or cylinders, have seen a lot of tutorials, you would also notice that the vortex wouldn't
look much like this. It is a bit weird. That is what spaltalmers does. So it makes both the equations
K Epsilon and K Omega. And makes it into one equation by dividing those
two parameters. So it is a bit of approximation. That's why we are getting
values here and there, but it is usually good. So if you just want
to do a simple case on wedding or external
aerodynamics, then spalt almors is fine. But if you're working with
a deep, a aerodynamic case, then kaomeg ACST might
be the best choice, especially if you are working
with inflation layers, boundary layers, want to
calculate Y pleasant or. Like in this case, I have
added some inflation layers. So in those cases, kaomeg IST might be the best
choice, in my opinion. As you can see, it is still reconstructing is going
to take a lot of time. So you can try to reconstruct
it, give it some time, and maybe practice by running
a reconstructed case. But I'm ending this
tutorial here. So if you have any questions, please feel free to contact me. See you in the next class.
12. Allrun and Allclean Files: Hello, Evan. Welcome back to the CFD using Open Foam beginner
to intermediate course. So this is our class nine. In this class, we'll
be seeing automation with Arn file and
all Clean file. So automation with run
file works like this. If you have the set of commands
like running block mesh, decomposing and then
running it in parallel, those commands has to be entered manually in terminal as of now. But if you want to
make it automated, then you can use the
Aldrn file to do this. The purpose is streamline the execution of open
boom simulations. Benefit is, it automates the entire simulation workflow by reducing the manual steps. After initiating the dn file, you don't
have to do anything. It just finishes
entire simulation, and then you can interact with the computer
just to post process. So to create an tern file, generally, the components
are like mesh generation, initial condition
setup, sola execution, and call for post processing, like force plotting above,
not the paraviw thing. So the structure would be it is a shell script that sequentially
runs necessary commands. So that is all that
an ran file is. So we have an example here. So you can open Arn file in any text
editor and you can see it. And the command to initiate AlternFle through WSL is Bash, space dot slash Aran. But if you're on bent, it
is just dot slash Aldrin. So you can see that
it has a header. It says, dollar WM
project directory, bin slash tool
slash Run function. So that is essential,
that is like header. If you want to clean
old case files, then the command would look something like run application. Run application is the
shell script command to call the application kind. So it is RM minus RF. It deletes the polymsh
under constant. So it points to the
program that it has to delete any file that starts
with zero to nine any number. So that is one method. And to generate mesh, we will be running the
application block mesh. If you want to set up the initial condition
by decomposing, then it is decompose par, and the hyphen force
is generally not used, but it is a it is just an
example from an Alder and file, so you don't have to
worry about the force. You can stick to whatever we
have learned in this course. Then when you want to
run solve in parallel, you use the command run parallel and simple form space
hyphen parallel, so you don't have to write
MPI, run NPA parallel. All these things are not needed. So have to mention the number
of processes somewhere. And for run application, we can do reconstruct per also and post process
function like forces. We can do all of these
and benefits of Arn file, it ensures that all steps are executed correctly
in the right format. When we are working
with terminal, we are bound to make
mistakes sometimes in the working directory
or while typing the commands and we might be wondering what caused the issue. So these things might happen. To prevent those things, we can use Arn file. The efficiency saves time by
automating repetitive task. Like you are running block mesh you are
waiting for some time, or initiating this all,
let's say pimple form and you are waiting for
some minutes or hours. And then again, when
it is just done, you have to come to computer and do the reconstruction under. Instead of that,
what if you just initiate and get back and you can find all the case files that you just
need all reconstructed, it removes all the
processor file. And if you just need the output, it can be done with
an altern file. You can run your own
altern file also, just the commands
which you want. Documentation is it acts as a record of the
simulation procedure. If you are sending open
foam case to someone, and if they have no
idea on what are the essential steps
to run the case, then they have to contact you. But instead of that, if you
provide the order and file, they can open the
order and file and either know what are the
commands that are needed, or they can just initiate
the order and file and they can get all the
data that is needed, and all they have to do
is just post process. They don't even have to know how the case was set up
or how to run it. So automation with all
clean file is like it cleans up files from previous simulation to
prepare for a new run. So it just sits back
the entire case to its original version so
you can run from scratch. And it also toes a fresh start for simulation by
removing old data. So that is the benefit of
using all clean files. So to create an urn file, we are just going to
remove mesh files and we are going to delete the time directories
and clearing log files. Sorry, it has to see automation
with all clean file. This slide is about all clean, and it is also a
shell script that removes specified
files and directories. This is an example
of all clean file, sorry it's not Arun,
it's all clean. So it removes the
constant polymes folder. Again, it removes all
the time sets 0-9, and it also removes the
post processing folder where we have the
force coefficient, and it also removes
any log files. When you are running
all run files, since you will not be getting
anything on the terminal, it would be stored
as a log file. So that's what
documenting also means. So to initiate this, you can use Bspas dot slash ALCAN
when you are on, uh Windows machine WSL. But when you are bintomchine, just dot slash ACN is fine. So we will be seeing some examples from the
tutorials folder now. When I was talking
about Tutorials folder, I was saying that it can be copied and run even without knowing what that
simulation actually means. So I will open the
tutorial folder here. So just going to go to the Run directory and
open the explorer here. So we have a copy
of tutorials here. So let's take incompressible. In incompressible,
let's take simple form, and let's see a foil to, and let's see what it
has in the all run file. It has a different
set of commands. It says, Restore zero directory. If you try to run this command
in your command prompt, it won't run, but through
shell scripts, it will. You see this is the
header and setting, we are setting parallel to true because we have a
fails condition here. Okay. It is restoring
the zero directory. It means it is copying the zero dot original file
and putting it in zero. So that is what restore
zero directory means. Then we are doing zero
hyphen D constant polymesh and slash
slash copy RF, constant slash polys dot
original two constants polymsh. So what this does,
we have polymh dot original because
we don't want to mess with the original
polymesh file. So this command essentially
copies the polymes dot original and pastes it
in the new name polymsh. So that is what
this command means. Okay? And we are entering
the IL condition, we have set the
parallel to true. So when parallel is true, then we will be running
decomposed par. Then run parallel
would get application. It would be in $1
for a reference. So it would get the
application from Control dict and it will
run that command here. So it would be
running in parallel. And we have run application reconsectP to reconsict
whatever is decomposed. If it is parallel, but when the parallel
is set to false, then it would just get the
application and run it. So it is just basic
ILS condition. Now we will see all clean file. So it just says clean case zero. It is going to clean
all the time steps. It is same as foam
less times RM, but in a shell script way. And we have RM minus RF
constant polymerase, so it is going to delete
the polymes which we just duplicate it from
polymers dot original. Okay, for tutorial purpose, I'm going to copy this and
put it in this week's folder. When you get it,
it would be empty. Okay. Now we have this airfoil. Now what I'm going to
do is I'm not going to do any sort of block mesh or run anything because
it already has polymsh. I'm just going to
initiate the run file and you can see that it is
running everything one by one. First, it restored zero
dot original to zero. Yes, it happened. Then
it did decompose par. Yes, it happened and it is running simple foam
case on eight processes. But you're not getting
anything here at all. Because when you are
running simple foam, it would keep on saying
updating the timesteps because it is getting stored
in log dot simple Fam. So you can open it and always
see what was happening with the case and you can even post process
this if you are very good at
dictionary in Python. So this simulation is done. It is also reconstructing now. And if you want to monitor
reconstruct par, yes, you can open it in VS
code or in text editor, and you can get live updates. All you have to do
is maybe change application or refresh the file. When you change application
and come back here, it would just change
the tab or something. So mostly that works. Okay.
So it is reconstructing. That is all that is important. Okay, now let's just
wait for this to end. It's probably going
to end at 500. Now it is at 300. Or maybe you can also
learn to interrupt. Just hit Control C, and it would be interrupted
right there. Because anyways, we are
going to clean this case. We are not interested in running it completely or
post processing it. So we will also
run the all clean. Now you have these
many files, right. So you can do Bash dot slash, all clean you can see that it is deleting all
the time steps first. And then the
decomposed processes, it deleted all the log file, I deleted the zero copy. It also deleted polymsh. Now it is just as new
as what we copied. Okay? Now, you knew all
these steps in this case. You knew what will happen
in the Airfoil case. But let's say something
like PO form in as, we are not going to
see about s but you really don't have an
idea about as, right? But if you want
to run this case, then you can open this run file and see what
are the commands necessary. Obviously, when someone
gives you this case file, you wouldn't know, these
are the steps, right? But we don't really care
whether it is there or not. Like, we have a command
called R number mesh potential form. We
don't know any of these. But if we still want to get
the result out of this, all you have to do is copy, put it wherever you
want this to be run. Then go to your terminal, enter that folder, then
initiate all run file. That is all that is
needed to do this. See it is now running
Snappy Hicks mesh also. Anyways, I'm just going to interrupt. I'll interrupt here. Okay. But it is running
other commands, so you have to interrupt everything when you
are interrupting. It is just running all the
commands. I'll clear it. Okay. Now we have
all of these files. I'll open all clean. It is going to be very simple. You see, it cleans K zero. It deletes the tri surface, and it also deletes all
the decompose padict. I mean, we have made
some changes to decompose padi and
it is changing it. We really don't want to
understand it as of now. All we want to know
is how to run. All run and all clean files. I see it is deleting everything. Now the case is just as new. I hope you understood about
run and all clean files. So if any case you find in tutorial and
you want to run it, you can always do it
just using clean files. And you can also see the commands and try to
execute them one by one in terminal and find out what each command does or check out the documentation
that works too. Okay. Now your project one
would start from here. So it is flow around a prism with coefficient of
drag and CL plus. So you have to do a flow analysis around a
square prism using open foam. The objective is to analyze the flow characteristics around a square prism and compute the drag coefficient and lift coefficient using open foam. This project will
involve mesh generation, setting a boundary condition, running simulation, and
post processing results to obtain and
analyze CDCL plots. So the duration you
can take for this is you can take three days for
case setup and simulation, two days for plotting
and report preparation, and one day for discussing the report if you really
want to discuss with me, you can mail to me so
you can mail us and we would get back to you if we
have any comments on that. Okay. The project
description is like this. The project involves simulating the flow around a square prism, placed in a uniform flow. So the students will
have to use open foam. I mean, you have to
use open foam to generate the computational
mesh using block mesh only, or you can do it in
snappy hig mesh. You can't import mesh from
answers or anything like that. You have to use only open form. Then you have to set up
the boundary condition seeing the appropriate problem. If you're using
transient turbulent, then you can have
higher anos number. But if you're trying to make
a steady state laminar case, then you have to
keep it very low. Set up the boundary contritions
appropriately and run the simulation using a suitable solverare for that problem. So you can decide
whatever you want to do. Then you have to extract and analyze the force
coefficient CD CL, either using Excel
or foam monitor, then you can take
screenshots from there. Then you can plot the CD
and CL values over time or against other
relevant parameters if you are doing with Excel. Then you have to
interpret the results and discuss the flow characteristics observed around the prism. So this comes with
the knowledge of COD and it is not constrained
to knowledge of open form. So you have to interpret
and discuss what that result or value from the
simulation actually means. So the description
would be like this, prepare a geometry, two d or three D it's up to you
of a square prism. Then measure it using block
mesh or snappy H mesh. Then ensure the mesh is refined around the prism to capture
the boundary layer. If it is snappy H mesh, you can also use add layers. Then you have to specify the proper boundary
condition setup then choose the solver properly, and it is highly recommended
to use K Omega SST, turbulence model and set
the maximum COS one. Include the necessary
function objects to calculate force coefficient. Post process using Para view, study these streamlines,
plot the CDCL graph. You can use either
Foam monitor or Excel. Then you have to make
a detailed report. Either you can keep it for your own reference
or you can mailers and we will get back to
you with the commands. So you can work
on this question. You can check the
PBT for the question or details, and you can do this. If you have any questions, please feel free to contact me. See you in the next
class. Thank you.
13. Multiphaseflows and Case Study: Hello, everyone.
Welcome back to CFD using open form beginner
to intermediate course. This is our last class,
which is class ten. In this video, we will be
seeing introduction to multiphase flow simulations,
modeling approaches, and practical considerations
and the demonstration, which we'll be using multiphase Euler
foam which is one of the most popular multiphase
sola in open form. We'll be doing something
called a dam break case. Usually, it is
done in two phase, but we are going to consider four phases and we are going
to do it in four phase. Introduction to multiphase
flow simulation. Multiphase flow
simulations involve the simultaneous flow
of multiple phases, which can include
combinations of gases, liquid, as well as
solid sometimes. These simulations
are essential in various industries such
as chemical processing, oil and gas, power generation, and environmental engineering. The complexity of
multiphase flow arises from the interaction
between different phases, which can involve mass, momentum, and energy transfers. So modeling approaches and
practical considerations. Eulerian Eulerian models are one of the most followed one. Description of the
Euler Euler model is both phases are treated as
interpenetration continuum, which each phase represent by its own set of
conservation equations. Application is
suitable for flows where the phases
are intermingled, such as bubbly flows
or fluid bits. Example, solver is
multiphase Euler foam, which is what we are going
to see in this video. Then we have Eulerian
lagrangian models. The continuous
phase is treated as a continuum using the
Eulerian approach, while the dispersed phase, which can be particles, droplets, bubbles is tracked using the Lagrangian approach. This is computationally
very expensive. Idal for dilute dispersed flows, such as preys and
particulate flows, we also need a very fine mesh to do this kind of simulation. Example, solvas DPM foam, which is discrete phase model. Then we have the volume
of fluid models. The interface between phases is tracked using a volume
fraction function, which is advected
with the fluid, effective for free
surface flows, such as waves or dam breaks. Example, solver is interfom then we have interface
tracking methods also, which is explicit tracking
of the interface between phases using methods like
level set or front tracking, suitable for detailed phase
interface dynamic studies such as droplet
coalescence or breakup. Reacting multiphase Euler foam for reactive multiphase flows is one of the example solves, but this is very highly
advanced and it's not very popular in
industries either. So practical
considerations while modeling a multi phase
flow, mesh quality, ensure a fine and
high quality mesh, especially near phase interface to capture detailed
interactions. Then about the time step, choose an appropriate
time step to balance the accuracy
and computational cost, considering the Kura number. Generally, we will keep
the ora number as one, but it would be better to keep even less than one
around 0.8 or 0.75. But it also depends on physics and what kind of
accuracy are expecting. Then for the boundary condition, we have to carefully set
the boundary condition to accurately represent
physical phenomena at the boundary domains. For initial condition, proper initialization of
the phase distribution can significantly impact
the convergence and accuracy of the solution
because we have to set the type of phases in every area of the mesh for
the initial condition, which would be
solved by the solver for further changes
in the flow domain. For phase interaction model, we have to implement
appropriate models for interface momentum,
heat, and mass transfer. Multiphase flows can also
do heat equation solving, which will account
for the temperature. But for this tutorial, we'll be using
multiphase euler foam, which doesn't need to solve
the temperature equations. So we will not be seeing
any temperature plot. But if you want to
see temperatures, you can use solves like
two phase euler foam, which would consider
temperature changes also. So now we will see the
demonstration on using multiphase Euler foam for dam
break case for four phase. Now, the picture you are
seeing is the all run file. So we have restore
zero directory, which will copy the
zero dot original and paste it into zero folder. Then we are going to
run the application. Block mesh, then we are going to do something
called set Phils. This is new, which
I will explain. Then as usual, we
will decompose, then run the application, which in this case is
multiphase Euler foam and reconstruct the case. Now this is the mesh that
we are going to use. Now we are seeing
the internal mesh. As you can see, we have
the left wall, lower wall, right wall, default phases, atmosphere wall and empty. As you can see, there
is a big fluid domain, and there is a small
obstacle in between, in the lower place. So we will be having
fluid all over here and we will
release the fluid. So it will tend to
move around here, and this obstacle will
prevent that prevent the flow or cause the
flow disturbance, and we will see how the
flow is propagating. So after setting the fields,
this is how it will look. So we have four phases here. One is air, one is water, then we have oil,
and then mercury. So these are the four phases
we are going to work with. So this can be obtained
at the initial condition, which will be
inside zero folder, and we will see how to do it
using the set fields ****. So if you want to see the
final simulation video, you can jump in here. This is my YouTube channel.
You can check it out. Okay, now we will
run the simulations. I am in the working directory. Okay, now, either
we can initiate the all run or do it one by one. So I will do it manually. If you want to run the case, you can do it yourself. Okay, now we have the zero, zero dot original
constant system. Okay, now, as you know, the
first command is Block mesh, so I'll run Block Msh. Then it is set fields. So before we do set fields, I will explain what
set fields dit actually does and
what that is about. Now we will just see
the mesh which we have. As you could recognize
from the PPD, this is the mesh we have
and this is the obstacle. We had the other three fluids here and rest of the
area where yeah, right. So I will keep everything
at the zero them step. Now, we don't have
any phases at all. Okay? So it will not
have any phases. So now we are going to do something called the set fields. What set fields **** does? Under set fields dict, which is under system directory, we have many functions. So first thing is,
we are going to set the default field values. So in any atmosphere, all we have is R. That is
the default field value. So we are setting
Alpha at R as one. Alpha is the phase fraction. And we are setting Alpha dot, water as zero, Alpha dot, oil as zero and Alpha
dot mercury as zero, and initial vector field value, which is velocity will be zero, zero, zero in the direction. This is the default
field values. Now we are going to
set the regions. Under region, we need three phases now because
everything is already a, we are going to set
three more fields. So the first field
would be a box to sell. So that is the function. Then
we have to define the box. So that box, as you
can see, again, it has a minimum point
and the maximum point, just like what we
did for Snappyxmsh. So we are going to do this, which is 00 minus one, 0.14 61 to 0.291 to one. So if you want to see
what that actually means, you can turn on data axis grade, and you can see we have zero, 020.14 it is somewhere
around here, the X direction and Y
direction, it is 0.292. This is this region. Here we are setting one field. Then we are setting another
field from this 0.0 0.14 610 minus one
to some point, you can ponder over what these points actually mean
from the data axis grade. I'm not going to exactly
show those points. We are just having these points, which you can download this
case and check over it. For the first box,
we are setting it to Alpha dot value of water as one and everything else as zero, which is oil, mercury
and R will be zero. So two phases cannot
exist at the same place, so everything else must be zero. Then we have oil phase. This will be one, everything
else will be zero. Then we have mercury as one
and everything else as zero. So we have set the entire domain into four different phases. If you miss any point
while doing this, that would be set to. So that is the
entire thing about setting default field values. Otherwise, it would
have pure mesh without any values at all. So how is it going to get saved? It is because we
have these files, apart from U, which
we generally have, we also have something called
P underscore RgH Actually, it means P minus RgH as you can realize RgH is the
hydrostatic forces. This is pressure minus
the hydrostatic effects. That is what P minus RgH means. But since we can't use
hyphen in a file name, we are using underscore. Okay. So this is basically pressure minus the
hydrostatic forces, and we are defining
it as flux pressure, and it is all set to zero. Now we have Alpha dot, Alpha dot mercury, alpha dot
oil and Alpha dot water. Similarly, we also have
the velocity for H phases. As I explained in the PPT
for Euler Euler model, we are solving the
transport equation for every different phase
separately because everything has its
density different. So I'll open the Alpha at her, and you can see that
the uniform field is initially set to zero and
everything else is also set. So this can be set based on any templates
which is already available. So we are doing this
called Theta properties. So this Theta properties
is the volume fraction. Or also known as the contact angle of the volume fraction. So when two phases are meeting, it will have some angle. So that angle has to be defined so that it is
resolved properly. And that Alpha contact
angle is called Theta. So we are setting
it to orthogonal, which is 90 degrees, so it will meet at the intersection
of 90 degrees. We have to set it
for every phase. So when you see left wall
that has water R as 90, oil R is 90, Mercury errors 90, water, oil has 90, water,
Mercury has 90, oil, mercury is 90. So we have to put in
all the combination, all different possibilities. So after doing that, you will be setting the
atmosphere as inlet outlet, inlet value as one, one, and we have this. So atmosphere here is just basic outlet
condition on the top wall. Okay. Similarly, we have
for all the four files, you can open and say it
just in case I would open the phase alone. See, we have everything
else as normally. So we only set the Alpha dot air because it is in the default. So we are setting it. Then this would correspond to other files. I'll open Alpha dot oil. See even this is a normal file. So only the default phase, we have to set all these
contact angle on it. Okay. Now, similarly, we
will be having just U, which is the overall
velocity thing. We are setting the
walls as no slip and atmosphere flux corrected
velocity is zero, zero, zero, which is
an oian condition. Then we have the
velocity of air, which is again a normal file. Then we have
velocity of mercury. That is also a normal
velocity file. So only the alpha at air will be different and P minus
Ages is a new thing. So here, apart from transport and turbulence
properties and gravity, we also have something
called motion properties. Where we are setting
it as static Fwmesh. But when you are going to
advance level of open foam, you can do adaptive
refinement in the mesh. So that can be defined here. Instead of static,
we will be using dynamic Fwmesh which we are not going to
cover in this course. So it is just going to be
static FIMs in this case. Now we can see what
other files we have. We have the control deck. So in contradict, you can see the application is
multiphase euler form, and apart from maximum CWO, we are also setting
maximum Alpha CO. So this is taking care of individual phase current
number. So that is 0.5. As I said, one is
fine for most cases, but for multiphase, going
less than one is preferable. Then we have Delta T as 0.001 and we are
ending at time six. So this simulation
is going to take a lot of time to get run. So that is why I have pasted the YouTube link for the
final simulation video. It is going to take
hours of your time. So that is what multiphase does. Now we will do the set fields. Now as you see,
at the time zero, we don't have any phases at all. Okay? Yeah, I'll
go to time zero. So you can see we can see Alpha dot water is
completely zero. Alpha dotir is also
completely zero. And if we see VOC, it is also completely zero because we have set
everything to zero, so it's no surprise. Now what I will do is
I will do set fails. Now the set fields
has been done. Now I will refresh this case. You can see we have something
called Alpha dotar. You can see the Alpha dotiR. Here, one is the maximum
value and blue is zero, everything else is ir. This is the place where we
have other three phases. The mercury is just this place oil has this area and
water has this area. So apart from whatever these three, everything else is here. Okay. So to see all the four
phases in the same map, we will be able to do it only
when we run the simulation. Otherwise, we can't. So you
can see that every phase has mostly zero velocity
only initially. Okay. Now we can run the
case by decomposing. Decompose par is a
regular decompose case, which we said in previous
simulations also. I'm going to run MPI Run NP eight, multiphase oiler, boom. Okay. So it has started
and it is running. Now we have around ten
timesteps, including the zero. While running the command, I missed the hyphen
parallel at the end. So if you followed the video, just make sure that
you are typing the hyphen parallel also. I stopped the
simulation, run it and reconstructed and dilted
all the processor files. Okay. Now I'll go
here to the Paire. I'll refresh the case. Now I'll go to the
last timestep. I'll choose Alphas. Now you can see that
we have the animation, sort of animation, it is moving. So when you run the
entire simulation, it would look
something like this. So this is the render video. You can check out that link. Now I will play it for you. As you can see, it
predicts all the bubbles. It releases air, it
accounts for density, it accounts for the waviness. So when you are seeing
it, it feels realistic. So that is what we
can achieve by having a good mesh and good timestep by
maintaining the a number. So I hope you learn a
lot in this course. If you have any specific abouts regarding the contents
in this course, you can always contact me. Thank you for taking
up this course. Look up for advanced level of courses regarding open
foam by C dynamics. Also check out our YouTube
channel regularly for more information
on using open form and specific features
inside open form. Thank you. See you
in another course.