Hello everyone.
Welcome back to the CFD using Openfoam beginner to intermediate course.
So this is our class eight.
In this class we'll be seeing importing Ansys workbench mesh into Openfoam.
Importing Ansys fluent machine to Openfoam.
Flow over a cylinder using workbench.
Meshing done mesh so you will use the workbench mesh uh, imported into Openfoam and do a flow over
a cylinder case.
Okay, importing Ansys workbench mesh into Openfoam is a very simple process, but the purpose is it.
Use high quality Ansys workbench mesh in Openfoam simulations.
If you are someone who uses Openfoam and you get a project where they have a workbench mesh from Ansys,
which is the most popular commercial software, you should not be in a position to not use those mesh
and do the simulation, because Openfoam is basically a solver for CFD.
So you can use high quality CFD mesh inside Openfoam and do your simulation so it leverages Ansys.
Robust machine tools are for complex geometries which cannot be highly capturable in block, mesh or
snap in some cases.
Snap mesh is definitely one of the best tools for meshing in hex, but if you want a data mesh, then
Asus might be the, uh, commercial software which will help you.
There is also other software called CF mesh, which you can use as open source in Openfoam, but we
are just interested in importing Ansys mesh as of now.
Okay.
The process is you have to export the mesh from Ansys workbench, save it in the format of dot mesh,
which is called workbench mesh format.
Then you have to ensure the compatibility with Openfoam requirements, which we will see the commands
to check that.
Then you will convert the mesh, use the command Fluent mesh to form our fluent 3D mesh to form.
If it is a 3D 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 mesh or fluent 3D mesh to form space, file name, dot message.
And you can always use the check mesh command because anyways, if you are import, even if you are
importing Ansys workbench mesh, it is going to get stored in the format of poly mesh inside Openfoam.
So you can always do the check mesh command.
Verify the mesh integrity using check mesh.
Then address any inconsistencies or errors using Ansys meshing.
So importing Ansys fluent mesh is a different process.
So you have to export the mesh from Ansys fluent.
Uh, but in a different way, because Ansys fluent meshing will generate a file called dot mesh dot
h file, which is not supported in openfoam.
You can only use dot msh.
So to do that you have to use the standalone fluent machine.
So our 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 dot msh dot h file which is fluent mesh and export the generated mesh in Ascii format and not
in binary.
So by default it will be in binary and you have to export it uh, in Ascii format.
We will see how to change it, and after exporting you can rename the file to dot msh dot h5 while saving
itself.
So when you do that it will get saved as dot msh instead of dot msh dot h.
But uh, always remember that it doesn't work with workbench.
Uh, kind of meshing.
I mean, when Openfoam is trying to accept dot mesh dot h file, it won't be able to read.
So you have to use standalone fluent meshing instead of the fluent mesh which comes with the open,
uh, with the Ansys workbench.
Okay.
The command, as you already know, is fluent mesh to form space.
Uh, file name dot mesh.
In this example it is called mesh mesh dot mesh.
So for this tutorial we have done a machine using SolidWorks.
We have created the geometry in SolidWorks.
I mean you can see the dimensions here and it is saved as dot IG is file and it is imported inside Ansys
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 Openfoam can understand that this is a fluid region, and also if you are going to try to
make it as a 2D case, then you might have to use the convert utilities in uh, Design Modeler and take
a face from the SolidWorks thing.
If you want to know how to import SolidWorks, uh, 3D geometry into Ansys or Design Modeler and convert
it into 2D, you can check the video in our YouTube channel for dynamics.
So I have made a video on that.
After we convert it into 2D Ansys workbench, then we can do the mesh.
So in this case I have done a generic hex mesh you can do with any mesh.
I have also added some inflation layers near the cylinder.
Okay, in the naming selections, I have also given the left as inlet, right as outlet and named the
cylinder as cylinder and upper and upper and lower.
Okay, now to uh, change while saving the file in workbench machine, you can, uh, click on export.
Then after export you can choose options from there.
If you go inside your export uh, options of meshing, you can change the format of input file as Ascii
instead of binary and click on okay.
Then you have to export the mesh in fluent input file method.
So 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 mesh which we can see now okay.
Okay I am I'm in class eight first case.
So as you can see I have the flow over cylinder workbench mesh dot mesh here.
Now we are going to use this and import it into Openfoam.
So I am in the working directory.
Now you know the command since it is 2D mesh is fluent mesh to form space.
The file name which is flow over cylinder.
Workbench mesh dot msh.
I'll click enter and you can see it is writing the mesh to constants slash poly mesh and it is done.
Now we can see the mesh by clicking on Paraview.
I'll click on apply.
As you can see though, we said it is a 2D mesh.
It came with a 3D surface because it's going to set the Z to one cell automatically.
You don't have to do that.
Unlike, uh, making a block mesh, setting the front end back to empty.
You don't have to do those things.
It is already set to empty.
I mean, the front and back by default while importing.
So this is the nice thing about openfoam Openfoam.
It already does it.
Okay, 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 Ansys, it is still there in Openfoam.
Also.
Now we have the mesh.
Now you can decompose, run the simulation, do whatever you want because you have the, uh, polymesh
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 uh, okay, we saw on how it is adding front and back planes.
Now we will see how to import fluent mesh.
So the geometry is made uh, 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 Ansys fluent meshing and like how you did it in workbench machine because
we are going to use standalone fluent meshing.
It doesn't have those things, it can only mesh.
So you have to create the naming selection and design modeler itself.
And you also have to assign the body to fluid instead of solid.
After that, you have to save the design modular file and then open the standalone fluid machine, uh,
application.
And you have to import the mesh file and you have to generate the mesh using Ansys fluid.
So that is not the tutorial which we are going to see.
It is about Openfoam or not Ansys fluent.
But if you want to see how to use Ansys Fluent Mesh, you can check out our YouTube 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 write binary files.
Okay.
And you also have to uh, change the file name to dot mesh.
Okay.
Uh, instead of saving it as c f CF mesh files, you just choose all files and save it as whatever name
you want to give Dot a message.
Always.
You have to make sure that it is not written in binary.
Okay, while saving you just save it as dot mesh and it is just fine again.
Uh, a new thing about fluent mesh is regardless of whether it is 2D or 3D, the command to import it
is fluent mesh to form only.
So if you are running fluent 3D mesh to form for some mesh, even if it is from workbench mesh and if
it is not working, just do fluent mesh to form.
Just 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 mesh which is generated by fluent.
And we, uh, have to see whether it is compatible in open form or not.
To do that, you can just open the mesh file using VS code.
And if it makes some sense then it is a good file.
It is open, form 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 X marks, then it is in binary, then Openfoam 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.
Okay, now we will import this.
Okay.
Now I will do low end.
Mesh to form.
And the file name.
Now it has converted.
We can view it using Paraview.
Now, as you can see, we have inlet outlet and walls which we designed, which we gave in the design
modeler and not in fluent machine.
Fluent machine was used just for machine.
But we still have it here from the design modeler assigned names.
Okay, 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 the same
as the one which we use for the first tutorial.
Okay, now we are going to use this model.
We already saw K-epsilon and K-omega SST.
So this tutorial will be about Spalart-allmaras, which is the third most popular, uh, turbulence
model and most probably the most commonly used one for external aerodynamics.
Uh, so we will be using one equation model instead of two equation model in Spalart-allmaras.
That is the advantage.
We are going to use a 2D flow or cylinder mesh to make a transient case in a simple form with Spalart-allmaras
turbulence model.
So this is what we are, uh, trying to expect out of this simulation of vortex shedding animation since
it is transient.
Okay.
So I will go to the vortex shedding case.
Okay.
Now I'll just close this.
Enter the folder.
We have zero constant, the mesh file and system.
So I can import the fluent mesh to form for flow over a cylinder dot mesh.
It got converted okay.
Now I'll go to system.
As you can see I have the decomposed verdict right now, and I have set it to my processor capabilities.
So I will decompose power and it will decompose the mesh we just imported.
Because it is in poly mesh, it doesn't know it is from as fluent or Salome or mesh or block generator.
It just knows that it is in the mesh is in poly mesh folder.
Okay, 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 model is all about.
In constant we have G five which is gravity.
We have set the gravity to negative direction of y axis in the value of 9.81m/s².
This is a unit.
So I will go to transport properties and we are using air as the fluid one into ten power minus five.
And in the turbulence properties we are using Spalart-allmaras model.
So that is the change here.
It is also a race type.
So we are using Spalart-allmaras.
We will look at the zero file.
So in the velocity file we have inlet outlet cylinder upper and lower walls and front and back patches.
Uh inlet velocity is ten meters per 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 2D case.
Now we can see the pressure file since we defined the inlet for velocity.
We don't have to define for pressure, so we have zero gradient in inlet.
And outlet is set to a fixed value of zero Newton per meter squared.
It is an AC unit, so the cylinder will be zero gradient.
Upper and lower wall will be zero gradient, which means the solver will calculate it for us.
Front and back planes are obviously empty.
Then we have our turbulent kinematic viscosity, which is uh, set to calculated and set to zero as
initial values.
So this is what we generally for.
Follow new t k wall function for all the walls and all the patches will be set to calculated with a
value of zero.
Front and back will be empty.
And finally the main file of this turbulence model which is new tilde.
If you want to understand what new tilde is and how this one equation model for parallel turbulence
works, there is a beautiful documentation from Openfoam.
Also there is a beautiful video from YouTube, the channel Fluid Mechanics 101.
You can check.
It is beautifully explained.
Uh, 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.
Okay.
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.
And now we can run the simulation using Mpirun NP eight.
Simple for parallel, hit enter and it will start doing the calculation.
So let's just wait for it to end.
Okay, now the simulation is over.
As you can see, the maximum current number was set to one, so it is around one.
And delta t also varied a bit to adjust for the time and it took definitely a long time.
A full five minutes to run this.
Okay, now we can reconstruct this.
I'll search for the command which I use.
I 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.
So I thought while it is still running, I will tell you how to view the results while it is still,
uh, reconstructing.
I mean, it is still in the process of 027, right?
So we can view it as decompose decays.
So 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 I'll play it.
So 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 flow or cylinder case for vortex shedding.
You will know this is not how the pattern actually works.
I mean, these area if you look at these euro 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 separate case and perform a vortex shedding using the mesh generated
by Ansys workbench.
So this is the animation which we have got.
If you want you can go on and save it as an animation if you want.
You can also see the new tilde.
It is going to be completely zero throughout the case.
And same for new T and obviously pressure is going to change so you get the point of doing this.
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 Spalart-allmaras does.
So it, uh, 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 uh values here and there.
But it is usually good.
So if you just want to do a simple case on, uh, vertex shading or external aerodynamics, then spalart-allmaras
is fine.
But if you are working with a deep aerodynamic case, then K Omega SSD might be the best choice, especially
when if you are working with inflation layers, boundary layers want to calculate y plus and R like
in this case I have added some inflation layers.
So in those cases k omega SSD 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 uh, maybe practice by running a reconstructed
case.
But I am ending this tutorial here, so if you have any questions, please, please feel free to contact
me.
See you in the next class.