# FeatFlow - Fast External CFD Solver Integration with FEATool

Continually making physics simulation easier, better, and more approachable, this post introduces FeatFlow, a very fast and efficient finite element FEM based computational fluid dynamics (CFD) solver for the incompressible Navier-Stokes equations. The FeatFlow solver interface is now available in FEATool Multiphysics, and can be called directly from the FEATool GUI and/or command line making it easy to perform high performance CFD simulations directly in Matlab and Octave.

FeatFlow is a finite element CFD code based on using an efficient FEM discretization (Rannacher-Turek non-conforming ansatz functions) together with a geometric multigrid approach for solving linear systems [1][2]. This results in a very fast and computationally efficient solver typically yielding a magnitude or more of speedup compared to the built-in direct solver in Matlab (UMFPACK). Additionally, an iterative solver, such as in FeatFlow, uses much less memory than a direct one allowing for much larger simulations. Being a very stable and tested CFD code, FeatFlow has been used and validated in many commercial CFD projects, and studies have shown FeatFlow to be significantly more efficient than both Ansys CFX and OpenFOAM with respect to the total CPU time required to achieve a target accuracy [3].

The video below is a tutorial showing how to set up and solve a backwards facing step using the FEATool GUI as a Matlab CFD Toolbox. For this backwards facing step benchmark example the FeatFlow solver is about 50 times faster compared to using the default built-in solver.

## Notes

• FeatFlow strictly employs quadrilateral grids in two dimensions. In the FEATool GUI one can use the Grid > Convert Grid Cells menu option to change an unstructured triangular simplex grid into quadrilateral one. On the Matlab and Octave command lines one can also use the `tri2quad`, `quadmesh`, and grid primitive functions such as `rectgrid`, `circgrid`, `ringgrid`, `holegrid` etc. to generate quadrilateral grids. Alternatively, one can also import a pre-made external quadrilateral grid in any of the import format that are supported in FEATool, such as for example from GiD.

• In contrast to most other CFD and physics simulation codes it is in FeatFlow desirable to start with a very coarse grid. FeatFlow will then internally uniformly refine this grid a prescribed number of times to generate the multigrid level hierarchies, and also adapt boundaries to the geometric boundary parametrization. In this way one can achieve optimal conditions for the geometric multigrid solver. This also means that the output from FeatFlow will correspond to a much finer grid and have a higher quality solution.

## System Requirements

The FeatFlow CFD solver is installed in the featflow subdirectory. It includes the monolithic cc2d and cc3d solver, while the projection method based solvers (pp2d and pp3d) will possibly be made available in a future release.

In addition to Matlab or Octave with FEATool installed, the system requirements for running the FeatFlow solver is Linux, or Windows 10 with Windows Subsystem for Linux/Bash on Ubuntu on Windows installed with a 64-bit x86 processor based system.

## Usage (GUI)

Instead of using the usual solve button `=` in Solve Mode of the FEATool GUI, one can use the FeatFlow toolbar button to call the external FeatFlow solver for Navier-Stokes physics mode models.

The FeatFlow solver dialog box allows one to first Export the current grid and model definition to FeatFlow data files. The Solve option calls the FeatFlow CC2D solver using the exported data. Import finally reads a computed FeatFlow solution and imports it into the FEATool GUI (refining the initial grid as necessary determined by the FeatFlow Grid refinement level setting).

The FeatFlow solver settings are described as follows

• Grid refinement level - Number of grid refinements of the imported grid to compute on. FeatFlow uses a geometric multigrid solver approach where the initial coarse input grid is uniformly refined several times to generate the finer multigrid levels. Thus it is often desirable to start with a quite coarse input grid.

• Artificial stabilization - Select between streamline diffusion and upwinding for artificial stabilization of convective terms.

• Stabilization parameter - Stabilization tuning parameter.

• Solver type - Select either Stationary (monolithic) or Time-Dependent problem and solver type.

• Time stepping scheme - Choose between implicit 2nd order Fractional-step-theta, Crank-Nicolson, and 1st order Backward Euler time stepping schemes.

• Time step - Sets the macro time step size (internally FeatFlow takes three sub-time steps for each macro time step).

• Simulation time - Maximum/final simulation time.

• Time stopping criteria - Stationary limit to stop a time dependent simulation.

• Full settings - Access all FeatFlow CC2D solver parameters (see the FeatFlow documentation for a description of these) [1].

## Usage (CLI)

The `featflow` function can also be used on the command line as follows.

``````FEA = FEATFLOW( FEA, VARARGIN ) Export, solves, or imports the solved
problem described in the FEA finite element struct using the FeatFlow
CFD solver. Accepts the following property/value pairs

Input   Value/{Default}                Description
-----   ----------------------------   ------------------------------------------
mode    export/solve/import            Command mode to call (string)
data    default                        Default FeatFlow solver parameter data struct
fdir    featflow                       FeatFlow processing directory
fname   ft2ff                          FeatFlow output filename
wbash   C:\Windows\System32\bash.exe   Windows bash path
``````

## Limitations

• Linux and Windows 10 64-bit systems
• 2D and 3D Cartesian coordinates
• Single geometry object with quadrilateral (2D) / hexahedral (3D) grid
• 100000 grid points (FEATool Lite and Multiphysics) / Unlimited (FEATool Professional)
• Single Navier-Stokes physics mode
• Constant density and viscosities
• Zero initial conditions
• Prescribed velocity, wall, and neutral Neumann outflow boundary conditions
• Prescribed velocity boundary condition must be linear expressions and may not include dependent variables (velocities or pressure)
• (Gfortran-GCC libraries might be required in some cases)

## References

[1] S. Turek, C. Becker, FeatFlow, Finite element software for the incompressible Navier-Stokes equations, User Manual, Release 1.1, Heidelberg, 1998.

[2] S. Turek, Efficient Solvers for Incompressible Flow Problems: An Algorithmic and Computational Approach, Series: Lecture Notes in Computational Science and Engineering , Volume 6, Springer-Verlag, 1999.

[3] E. Bayraktar, O. Mierka, S. Turek, Benchmark Computations of 3D Laminar Flow Around a Cylinder with CFX, OpenFOAM and FeatFlow, International Journal of Computational Science and Engineering, 7, 3, 253-266, 2012.

Category: cfd solver

Tags: featflow

Published: