BlockMesh drill down challenge
Given conditions: inlet velocity= 1m/s
outlet pressure should be taken as atmospheric pressure and the condition should be given as guage pressure = 0.
The grading has to be given at the walls and they are captured even more precisely by the mesh cells which lead to accurate results at the walls
The spacing between the cells has to be monitored closely as increasing the spacing a lot or decreasing it a lot could lead to either inaccurate results for the former case and could lead to long time consuming simulation as in latter case. There has to be a proper check on the number of mesh elements for a quicker and accurate simulation.
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
frontAndBack
{
type empty;
}
topandbottom
{
type zeroGradient;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (1 0 0);
}
outlet
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
topandbottom
{
type noSlip;
}
}
// ************************************************************************* //
Procedure to naviagate through the terminal and writing the code:
1) Open the terminal and type foam. In foam type tut and go into tutorials.
2) go to the incompressible directory. We can change directories using the cd incompressible/ command.
3) Inside the incompressible folder, change to cd icoFoam/ after that cd cavity/
4) Inside the cavity folder, there is another cavity folder. Now we have to copy this folder into FOAM_RUN folder by typing cp -r cavity/ $FOAM_RUN/.
5) Now change the working directory to FOAM_RUN. Type ls and now again change the working directory to cavity by typing cd cavity/
6) In the cavity folder, there are three sub folders 0, constant, system.
7) The system folder has got blockMeshDict , controlDict , fvschemes and fvsolution files.
8) Using the gedit command, enter into each of the blockMeshDict and controlDict files. The geometry, scaling, the vertices, number of cells can be assigned and edited in the blockMesh files.
9) in the controlDict file, the values of time step and the start and end times can be edited. This is very very important as the time step and the end time of the simulation have to be assigned properly. It is the one that is directly proportional to the courant number. Ideally a time step in the range of 1e-6 is preferable for the purpose of simulating properly.
10) After editing these files , press cd .. to come back to the cavity directory and now go to the 0 file in cavity by pressing cd 0/.
11) In this 0 file there are two files of pressure and velocity. Edit the necessary conditions for the inlet, outlet, walls and empty faces of the created geometry.
12) now press cd .. to come back to the cavity directory again and enter blockMesh. The blockMesh would be created. The blockmesh would be created without any problems if the vertices coordinates and the faces are assigned properly.
11) press checkMesh for checking for any errors in the mesh. If the mesh check is OK then we are ready to proceed to the simulation.
12) After the simulation ends, post process for the results in paraview . For this purpose, press paraFoam.
13) In paraview, we can obtain the required values for pressure, velocity.
Note: Dont make the number of cells too many on the x or y axis. This would decrease the dx or the spacing between the cells and would result in the increase of the courant number. We need to make sure that the value of the courant number is less than 1 for the simulation to run. Increasing the number of cells would lead to crashing of the solution or not it could take long time for the simuation to complete.
If we are obtaining any floating point exception after we start the simulation, it is due to courant number valu being very high so in this case, decrease the value of the time step( trouble shoot the simulation accordingly).
Mesh without grading:
Velocity contour:
Mesh with grading factor of 0.2 at the walls:
Velocity contour :
velocity profile at a distance of 0.085m:
Mesh with gradin factor 0.5
velocity contour:
velocity profile at 0.085m:
mesh with grading 0.8:
velocity contour:
veocity profile at 0.085m:
Conclusions:
1) The results for each of the scaling factors are almost the same. We obtain same plots of velocity contours hence prooving that the simulation is grid inependent.
2)The walls offer resistance to the flow and hence the velocity is reduced near the walls.
3) The execution time is lower for less number of cells.
4) The magnitude of the velocity at distance of 0.085m from the inlet is almost equal to 1.1m/s from the above graphs. This value is almost same for all the three grading factors.
5) The velocity keeps on increasing upto the maximum value and the it decreases along the length of the cavity. This happens because at the walls, the velocity decreases and since the flowrate of the fluid is conserved, to compensate for the less mass flow rate near the walls, the velocity increases towards the centre part of the geometry leading to increase in the mass flow rate in the centre part keeping the overall mass flow rate conserved.