FOSSEE OpenFOAM Case Study
==========================
CFD_Analysis_of_Shear_Thinning_Fluid_Flow_in_a_Converging_Diverging_Channel
-----------------------------------
OpenFOAM version
-----------------------------------
This case is prepared for OpenFOAM v2012 (OpenCFD distribution).

The solver used for the simulations is:

    nonNewtonianIcoFoam

The case investigates the flow behaviour of a shear-thinning non-Newtonian
fluid through a two-dimensional converging-diverging channel, with particular
focus on pressure, velocity and viscosity.
---------------------------
Case description
----------------------------
The study consists of:

- Mesh independence study using five mesh levels:
    - Coarse
    - Moderate
    - Fine
    - Very Fine
    - Very Very Fine

- Geometry study using a fixed converging angle of 11° and diverging angles
  of 4°, 5°, 6° and 7°.

- Analysis of pressure, velocity and dynamic viscosity at selected locations
  along the channel.

The fluid is represented using a power-law non-Newtonian model with:

    k = 0.02
    n = 0.6

Since n < 1, the fluid exhibits shear-thinning behaviour.
-----------------------------------------------
Important directories and files
-----------------------------------------------

- 0/
    Initial and boundary-condition fields.

- constant/
    Physical properties and mesh data.

- system/
    Simulation controls, numerical schemes, solver settings, mesh
    definition and face-zone settings.

- system/blockMeshDict
    Defines the converging-diverging channel geometry and mesh.

- system/topoSetDict
    Defines the face zones used for extracting flow quantities.

- system/controlDict
    Controls simulation time, time step, output and function objects.

- system/fvSchemes
    Contains the numerical discretisation schemes.

- system/fvSolution
    Contains solver and algorithm settings.

- constant/transportProperties
    Defines the power-law non-Newtonian fluid model.

- Allrun
    Automates the case setup and simulation.

- Allclean
    Removes generated results and resets the case.
------------------------------------------------------
Parallel mesh-independence case
------------------------------------------------------
Only the Very Very Fine mesh case uses parallel decomposition.

For this case, the following additional file is required:

    system/decomposeParDict

The other mesh-independence cases and the geometry-study cases are run
normally in serial and do not require decomposeParDict.

The Very Very Fine case uses:

    decomposePar
    nonNewtonianIcoFoam -parallel
    reconstructPar

The number of processors must match the numberOfSubdomains specified in
system/decomposeParDict.
-------------------------------
Preparing the case
-------------------------------
Before running the case, load the OpenFOAM v2012 environment:

    source /path/to/OpenFOAM-v2012/etc/bashrc

Navigate to the case directory.

Make the helper scripts executable:

    chmod +x Allrun Allclean
--------------------------------------
Running a normal case
--------------------------------------
For the Coarse, Moderate, Fine and Very Fine cases, the case is run normally.

Execute:

    ./Allrun

The normal workflow is:

    Allclean
        |
    blockMesh
        |
    checkMesh
        |
    topoSet
        |
    nonNewtonianIcoFoam

No decomposition or reconstruction is required for these cases.
-----------------------------------------------------
Running the Very Very Fine case
-----------------------------------------------------
The Very Very Fine mesh is the only case that uses parallel execution.

The workflow is:

    Allclean
        |
    blockMesh
        |
    checkMesh
        |
    topoSet
        |
    decomposePar
        |
    nonNewtonianIcoFoam -parallel
        |
    reconstructPar

The commands can also be executed manually:

    blockMesh
    checkMesh
    topoSet
    decomposePar
    mpirun -np <N> nonNewtonianIcoFoam -parallel
    reconstructPar

Replace <N> with the number of subdomains specified in:

    system/decomposeParDict

After decomposition, directories such as the following are created:

    processor0/
    processor1/
    processor2/
    ...

The processor directories contain the decomposed mesh and solution data.
------------------------------------------
Mesh independence study
------------------------------------------
Five mesh levels were investigated:

    Coarse                  54 cells per block
    Moderate              80 cells per block
    Fine                     120 cells per block
    Very Fine             180 cells per block
    Very Very Fine     270 cells per block

The Very Fine mesh was selected for the final geometry study.

The Very Very Fine mesh was additionally simulated using parallel
decomposition as part of the mesh-independence study.
-----------------------------------
Final geometry study
-----------------------------------
The final geometry study uses:

    Converging angle = 11°

The diverging angles investigated are:

    4°
    5°
    6°
    7°

The inlet velocity for the final geometry study is:

    U = 2.0 m/s

The main quantities extracted are:

- Pressure
- Velocity
- Kinematic viscosity
- Dynamic viscosity
---------------------
Fluid model
---------------------
The fluid is modelled using a power-law viscosity model.

The relevant parameters are:

    transportModel    powerLaw;

    k                 0.02;
    n                 0.6;

    nuMin             1e-05;
    nuMax             1e-01;

The value n = 0.6 represents shear-thinning behaviour.
----------------------------------
Boundary conditions
----------------------------------
The main boundary conditions are:

Inlet:

    fixedValue

Outlet:

    zeroGradient

Walls:

    noSlip

Front and back planes:

    empty
-------------------
Face zones
-------------------
The following face zones are used for extracting area-averaged quantities:

    inletZone
    x20Zone
    x40Zone
    throatInZone
    throatOutZone
    x110Zone
    outletZone

The surfaceFieldValue function object is used to obtain area-averaged
pressure and velocity at these locations.
-------------------------------
Simulation settings
-------------------------------
The solver used is:

    nonNewtonianIcoFoam

The final simulations are run for a physical simulation time of:

    5 s

The cases use transient incompressible non-Newtonian flow calculations.
-------------------------------
Solver information
-------------------------------
Solver information is recorded using the solverInfo function object.

The generated solver information is stored under:

    postProcessing/solverInfo/

This output can be used to examine the solver behaviour during the
simulation.
-------------------------
Post-processing
-------------------------
After a normal serial simulation, the generated time directories can be
opened directly using ParaView.

For the Very Very Fine parallel case, reconstruct the results first:

    reconstructPar

Then open the reconstructed case using:

    paraFoam

or open the generated .foam file in ParaView.

The main quantities examined during post-processing are:

- Pressure distribution
- Velocity distribution
- Kinematic viscosity
- Dynamic viscosity
- Area-averaged values at selected face zones
-----------------------------
Cleaning the case
------------------------------
For a normal case, run:

    ./Allclean

For the Very Very Fine parallel case, Allclean also removes the generated
processor directories so that the case can be decomposed again from a clean
state.

The following generated data may be removed during cleaning:

    processor*/
    constant/polyMesh/
    postProcessing/
    simulation time directories
    log files
    temporary .foam files

The original case setup files, including 0/, system/, and
constant/transportProperties, are retained.
----------------------------------------
Things to keep in mind
----------------------------------------
1. Use the OpenFOAM version specified above when running the case.

2. The decomposeParDict file is required only for the Very Very Fine
   mesh-independence case.

3. Do not run decomposePar for the normal serial cases.

4. For the Very Very Fine case, the number of MPI processes must match
   numberOfSubdomains in system/decomposeParDict.

5. Run reconstructPar after the parallel simulation before performing
   full-domain post-processing.

6. Make sure topoSet is executed after the mesh has been generated.

7. Check the mesh using checkMesh before starting the solver.

8. The Very Fine mesh is used for the final geometry comparison after the
   mesh-independence study.

9. The power-law parameters k = 0.02 and n = 0.6 should remain consistent
   with the reported study.

10. The reported geometry cases use a converging angle of 11° and diverging
    angles of 4°, 5°, 6° and 7°.
