Non uniform inlet profil with codedFixedValue
The codedFixedValue boundary condition
The boundary condition code is located in:
[pastacode lang=”bash” manual=”%24FOAM_SRC%2FfiniteVolume%2Ffields%2FfvPatchFields%2Fderived%2FcodedFixedValue” message=”” highlight=”” provider=”manual”/]
The structure of the boundary condition
The setting of the boundary condition is done as follows:
[pastacode lang=”cpp” manual=”%20%20%20%20inlet%20%2F%2Fname%20of%20the%20patch%20where%20you%20want%20to%20define%20a%20boundary%20condition%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20type%20%20%20%20%20%20%20%20%20%20%20%20codedFixedValue%3B%20%2F%2F%20tell%20to%20OF%20that%20you%20want%20to%20use%20codedFixedValue%0A%20%20%20%20%20%20%20%20value%20%20%20%20%20%20%20%20%20%20%20uniform%20(0%200%200)%3B%20%2F%2F%20initialization%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20redirectType%20bc_name%3B%20%2F%2Fname%20of%20the%20boundary%20condition.%20Do%20to%20not%20use%20the%20same%20name%20on%20other%20patches%0A%0A%20%20%20%20%20%20%20%20code%20%2F%2F%20define%20the%20section%20where%20the%20implementation%20of%20the%20BC%20is%20done%0A%20%20%20%20%20%20%20%20%23%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2Fmy%20code%0A%0A%20%20%20%20%20%20%20%20%23%7D%3B” message=”General structure of the codedFixedValue BC” highlight=”” provider=”manual”/]
A concrete example !
To illustrate the possibilities offered by the use of codedFixedValue we will study the case of the flow, in laminar regime (\(R_{e}=500\)), in a bend. In this case study, we want to impose a fully developed velocity profile. The analytical expression of the profile, in laminar regime (obtained after solving the Navier-Stokes equation under simplifying assumptions) is as follows:
\(U(r) = U_{max}(1-\frac{r}{R})^2\)
The pipe radius \(R\) is 24 mm and the bulk velocity \(U_{max}\) is 0.0105 m/s. The figures below show the geometry of the elbow and the mesh composed of 430,000 cells generated with snappyHexMesh (volume refinement at the elbow area, refinement with a distance mode for the wall patch and insertion of 5 boundary layer elements ).
Bend geometry (left) and mesh (right)
The circular input patch (in red) in the figure is centered in x = 0, y = 0.1344 m and z = 0. This offset must be taken into account in the calculation of the radius. The implementation of the codedFixedValue boundary condition and its visualization under Paraview are shown in the figure below:
CodedFixedValue (left) and code visualization under paraview (right)
The calculation is performed (4 cores) with the simpleFoam incompressible solver and converges in 500 iterations. The converged velocity field is shown in the following figure: