potentialFoam is a useful solver to validate OpenFOAM since the assumptions of
potential flow are such that an analytical solution exists for cases whose
geometries are relatively simple. In this example of flow around a cylinder an
analytical solution exists with which we can compare our numerical solution.
potentialFoam can also be run more like a utility to provide a (reasonably)
conservative initial field for a problem. When running certain cases, this can
useful for avoiding instabilities due to the initial field being unstable. In short,
potentialFoam creates a conservative field from a non-conservative initial field
supplied by the user.
Mesh generation using blockMesh has been described in tutorials in the User
Guide. In this case, the mesh consists of blocks as shown in Figure 3.2.
Figure 3.2:
Blocks in cylinder geometry
Remember that all meshes are treated as 3 dimensional in OpenFOAM. If we wish
to solve a 2 dimensional problem, we must describe a 3 dimensional mesh that is
only one cell thick in the third direction that is not solved. In Figure 3.2 we show
only the back plane of the geometry, along , in which the vertex
numbers are numbered 0-18. The other 19 vertices in the front plane, ,
are numbered in the same order as the back plane, as shown in the mesh
description file below:
Using FoamX or editing case files by hand, set the boundary conditions in
accordance with the problem description in Figure 3.1, i.e. the left boundary
should be an Inlet, the right boundary should be an Outlet and the down and
cylinder boundaries should be symmetryPlane. The top boundary conditions
is chosen so that we can make the most genuine comparison with our
analytical solution which uses the assumption that the domain is infinite in
the direction. The result is that the normal gradient of is small
along a plane coinciding with our boundary. We therefore impose the
condition that the normal component is zero, i.e. specify the boundary as a
symmetryPlane, thereby ensuring that the comparison with the analytical is
reasonable.
No fluid properties need be specified in this problem since the flow is assumed to
be incompressible and inviscid. In the system subdirectory, the controlDict specifies
the control parameters for the run. Note that since we assume steady flow, we
only run for 1 time step:
potentialFoam executes an iterative loop around the pressure equation which it
solves in order that explicit terms relating to non-orthogonal correction in
the Laplacian term may be updated in successive iterations. The number of
iterations around the pressure equation is controlled by the
nNonOrthogonalCorrectors keyword in controlDict. In the first instance
we can set nNonOrthogonalCorrectors to 0 so that no loops are
performed, i.e. the pressure equation is solved once, and there is no
non-orthogonal correction. The solution is shown in Figure 3.3(a) (at
, when the steady-state simulation is complete).
(a) With no non-orthogonal correction
(b) With non-orthogonal correction
(c) Analytical solution
Figure 3.3:
Streamlines of potential flow
We expect the solution to show smooth streamlines passing across the domain as in
the analytical solution in Figure 3.3(c), yet there is clearly some error in the
regions where there is high non-orthogonality in the mesh, e.g. at the join of
blocks 0, 1 and 3. The case can be run a second time with some non-orthogonal
correction by setting nNonOrthogonalCorrectors to 3. The solution shows
smooth streamlines with no significant error due to non-orthogonality as shown in
Figure 3.3(b).
Source code is included in the $OpenFOAM_TUTORIALS/potentialFoam/analyticalCylinder
directory to generate the analytical solution for the potential flow case. The
velocity at any point at a distance and angle from the cylinder centre is
described analytically as
(3.3)
where is the cylinder radius and is the inlet flow velocity. Here,
describes the angle subtended from the -axis.
Let us examine some details of the source code in the analyticalCylinder directory.
In createFields.H, the velocity field is read in using the IOobject::NO_WRITE
option to ensure that the field data can never be overwritten during execution of
analyticalCylinder. The inlet velocity and cylinder radius are taken from
data read from the mesh and a field UA is set up to store the analytical
solution:
The analytical solution is plotted as streamlines as shown in Figure 3.3(c). Note
that differences in the analytical and numerical solutions at the top plane are due
to the fact that the analytical solution assumes an infinite boundary and the
numerical solution specifies a zeroGradient boundary condition at that
boundary.
Investigate the accuracy of the numerical solution by implementing some measure
of comparison between the numercial and analytical in analyticalCylinder.