Hello everyone.
Welcome back to the CFD using Openfoam beginner to intermediate course.
So this is our class nine.
Uh, in this class we'll be seeing automation with Aldrin file and all clean file.
So automation with Aldrin 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 old file to do this.
The purpose is streamlined execution of Openfoam simulations.
Benefit is it automates the entire simulation workflow by reducing the manual steps.
After initiating the alternate file, you don't have to do anything.
It just finishes the entire simulation.
And then you can interact with the computer just to post-process.
So to create an alternate file, generally the components are like mesh generation, initial condition
setup, solver execution, and call for post-processing like force plotting and all.
Not the paraview thing.
So the structure would be it is a shell script that sequentially runs necessary commands.
So that is all that uh, and all run file is.
So we are we have an example here.
So you can open all file in any text editor.
And you can see it.
And the command to initiate alternate file through WSL is bash uh space dot slash Aldrin.
But if you're on ubuntu it is just dot slash Aldrin.
So you can see that it has a header.
It says uh dollar w rm 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 delete deletes the polymesh under constant.
So it points to the uh program that it has to delete any file that starts with 0 to 9 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 decomposed power.
And the hyphen force is generally not used.
But it is a.
It is just an example from an alternate 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 solver in parallel, you use the command run parallel and simple form space
hyphen parallel so you don't have to write MPI, run and be a parallel.
All these things are not needed so it will do it for you.
Just have to mention the number of processors somewhere and for run application we can uh do reconstruct
part also and post process function like forces.
So we can do all of these and benefits of order and 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 order and file the efficiency.
It saves time by automating repetitive, repetitive tasks like you are running block as you're waiting
for some time, or initiating the solver.
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.
So instead of that, what if you just initiate and get back and you can file or find all the case files
that you just need all reconstructed.
It removes all the process of file and if you just need the output, it can be done with an alternate
file.
You can run your own alternate file.
Also just the commands which you want and documentation is like it acts as a record of the simulation
procedure.
If you are sending a openfoam 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 alternate file, they can open the alternate file and either
know what are the commands that are needed, or they can just initiate the alternate 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 ensures a fresh start for simulation by removing old data.
So that is the benefit of using all clean files.
So to create an alternate file we are just going to, uh, remove mesh files and deletion.
Uh, we are going to delete the time directories and the clearing log files.
Sorry.
It has to say automation with all clean files.
This slide is about all clean, and it is also a shell script that removes specified specified files
and directories.
So this is an example of all clean files.
Sorry, it's not all done.
It's all clean.
So it removes the constant polymesh folder.
Again.
It removes all the time steps from 0 to 9.
And it also removes the post-processing folder where we had the force coefficient, and it also removes
any log files when you are running all run file.
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 bash space, dot slash or all clean when you are on a windows machine.
But when you are on an ubuntu machine just dot slash all clean is fine.
So we will be seeing some examples from the tutorials folder now.
Okay, when I was talking about uh 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 okay.
In incompressible let's take simple form and let's see airfoil 2D.
And let's see what it has in the old run file.
See 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 if else 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 zero restore zero directory means.
Then we are doing zero hyphen d constant polymesh and uh slash slash copy rf constant slash polymesh
dot original two constant slash polymesh.
So what this does.
We have polymesh original because we don't want to mess with the original polymesh file.
So this command essentially copies the polymerized or original and pastes it in the new name Polymesh.
So that is what this command means.
Okay.
And we are entering the if else condition we have set the parallel to true.
So when parallel is true then we will be running decompose power.
Then run parallel would be get application.
It would be in a dollar 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 reconstruct part to reconstruct 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 if else 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 form less times but in a shell script way.
And we have our rm minus rf constants slash polymesh.
So it is going to delete the polymesh which we just duplicated from polymesh dot origin.
Okay, for tutorial purpose I am 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.
Okay, now what I'm going to do is I'm not going to do any sort of like block mesh or run anything because
it already has polymers.
So I'm just going to initiate the all 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 and then it did decompose part as it happened.
And it is running simple form keys on eight processes.
But you're not getting anything here at all, right?
Because when you are running simple form, it would keep on saying updating the time steps because it
is getting stored in logged or simple form.
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.
Okay, So this simulation is done.
It is also reconstructing now.
And if you want to monitor reconstruct part, yes you can open it in VSCode or any text editor.
And you can get live updates like all you have to do is maybe change application or refresh the file.
When you change application and come back here, it will just work like 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 Ctrl C and it would be interrupted right there.
Okay.
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, uh, run the all clean.
Now you have these many files right.
So you can do bash dot slash all clean.
And you can see that it is deleting all the time steps first.
And then the decomposed processes it deleted all the log file.
It it deleted the zero copy.
It also deleted polymesh.
So 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 piece of form in alias.
Okay.
We are not going to see about alias, but you really don't have an idea about alias, right?
But if you want to run this case, okay, then you can open this alternate 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 see, we have a command called renumber 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 Smash also.
Okay, anyways, I'm just going to interrupt.
I'll interrupt here.
Okay.
Uh, but it is running other commands, so you have to interrupt everything when you are interrupting.
It is just running all the commands.
Okay, 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 decomposed par dict.
Uh, I mean, we have made some changes to decompose par 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.
Now, see, it is deleting everything.
Now the case is just as new.
So I hope you understood about all 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 ultra clean
files.
And you can also see the commands and try to execute them one by one in terminal and find out what what
each command does.
Or check out the documentation that works too.
Okay, now your, uh, project one would start from here.
So it is flow around a prism with coefficient of drag and clip loss.
So you have to do a flow analysis around a square prism using Openfoam.
So the objective is to analyze the flow characteristics around a square prism and compute the drag coefficient
and lift coefficient using openfoam.
This project will involve mesh generation, setting a boundary condition, running simulation and post-processing
results to obtain and analyze CL 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, uh, comments on that.
Okay.
The project description is like this.
The project involves simulating the flow around a square prism, uh, placed in a uniform flow.
So the students will have to use openfoam.
I mean, you have to use Openfoam to generate the computational mesh using block mesh only, or you
can do it in snappy hex mesh.
You can't import mesh from Ansys or anything like that.
You have to use only Openfoam and you have to set up the boundary condition using the appropriate problem.
Like if you are using transient or turbulent, then you can have higher Reynolds number.
But if you are trying to make a steady state laminar case, then you have to keep it very low.
So set up the boundary conditions appropriately and run the simulation using a suitable solver for that
problem.
So you can decide whatever you want to do.
Then you have to extract and analyze the force coefficient CL either using Excel or foam monitor.
Then you can take screenshots from there.
Then you can plot the KD and CL values over time or against other relevant parameters.
If you are doing with Excel.
Then you can.
You have to interpret the results and discuss the flow characteristics observed around the prism.
So this comes with the knowledge of CFD and it is not constrained to knowledge of Openfoam.
So you have to interpret and discuss what that result or value from the simulation actually means.
So the description would be as like this.
Prepare a geometry 2D or 3D.
It's up to you of a square prism.
Then mesh it using block mesh or snap x mesh.
Then ensure the mesh is refined around the prism to capture the boundary layer.
If it is, snap a hex mesh.
You can also use uh, 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 SEO as one.
Include the necessary function objects to calculate force coefficient postprocess using Paraview.
Study the streamlines.
Plot the CL graph uh.
You can use either for Monitor monitor or Excel.
Then you have to make a detailed report.
Either you you can keep it, uh, for your own reference, or you can mail us.
And we will get back to you with the comments.
So you can work on this question.
You can take the PDF 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.