title | tags | authors | affiliations | date | bibliography | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SARAS: A general-purpose PDE solver for fluid dynamics |
|
|
|
23 June 2020 |
resources/paper.bib |
The laws that govern natural systems can often be modelled mathematically using
partial differential equations (PDEs).
Usually the resultant PDEs are not solvable analytically,
leaving numerical solutions as the only recourse to gain useful insights into such systems.
As a result, it is important to efficiently calculate numerical solutions of PDEs
to further our understanding of such systems.
In this paper we briefly describe the design and validation
of SARAS
, a general-purpose PDE solver based on finite difference
method [@Anderson:book:CFD; @Ferziger:book:CFD].
There are a number of open-source solvers for Computational Fluid Dynamics.
Some well known solvers include OpenFOAM [@Weller:1998FOAM], Pencil Code [@Brandenburg:2002CPC],
Gerris [@Popinet:2003JCP], SU2 [@Palacios:2013AIAA], etc. to name a few.
However, many of them, for instance, SU2, OpenFOAM, etc. use finite-volume method
with structured or unstructured meshes.
On the other hand, the use of finite-difference method restricts the solver to simpler domains,
but offers comparatively higher accuracy with lesser computational effort.
In this regard, the Pencil Code also uses finite-difference method, but is used to
solve compressible flows, unlike SARAS
which is designed for incompressible flows.
Moreover, SARAS
is written in C++ with an object oriented structure like OpenFOAM.
The design of SARAS
is inspired by TARANG
[@Verma:Pramana2013tarang],
a pseudo-spectral solver developed in our lab.
TARANG
has been shown to scale up to 196608 cores [@Chatterjee:JPDC2018], and SARAS
has been designed with the goal of achieving similar scaling performance.
We conducted a preliminary scaling analysis of SARAS
using up to 1024 cores for the
lid-driven cavity (LDC) problem on a SARAS
is at par with that of OpenFOAM.
Recently, we also performed a comparative study between spectral and finite difference
codes in the context of exascale computing [@Verma:SNCS2020], using SARAS
.
In SARAS
, the underlying mathematical constructs like vector and scalar fields
are defined as classes.
Moreover, vector calculus operations associated with such fields, like gradient and
divergence, are defined using these classes.
This design makes the code intuitive, allowing users to quickly cast PDEs into
readable codes.
The initial conditions, boundary conditions, and source/forcing terms
are implemented using initial
, boundary
and force
classes.
These classes are readily extensible so that users can add custom
initial conditions, source terms, and so on.
SARAS
includes solvers for hydrodynamic flows, namely the incompressible
Navier-Stokes initial value problem (IVP), as well as for scalar convection,
like Rayleigh Benard Convection.
Presently, we use semi-implicit Crank-Nicholson [@Crank:1947] method for time-advancing
the IVP.
The solver uses Marker and Cell method (MAC) [@Harlow:PF1965] for discretizing
the velocity and pressure fields.
The Navier-Stokes equations, which govern the dynamics of fluid flow, can be written as
$$
\frac{\partial \mathbf{u}}{\partial t} + \mathbf{u}\cdot\nabla\mathbf{u} = -\nabla p + \mathbf{f} + \nu\nabla^2\mathbf{u},
$$
where
If the velocity and pressure field at time SARAS
uses a Geometric Multigrid library to solve the above equation [@Wesseling:MG2004; @Briggs:MG2000].
Presently the library employs the Full Multigrid (FMG) V-Cycle to solve the Poisson equation.
Other methods like F-Cycle and W-Cycle are planned updates to the library in future.
Finally, using the above pressure correction, the velocity and pressure fields corresponding to the next time-step are obtained as $$ p_{n+1} = p_n + p^, $$ $$ \mathbf{u}_{n+1} = \mathbf{u}^ - \Delta t(\nabla p^*). $$ The numerical implementation of the above procedure will be discussed in the next section.
SARAS
uses finite-difference method [@Ferziger:book:CFD] to calculate derivatives of the field variables.
Presently the solver uses second-order central difference stencils to compute first and second derivatives.
We use a highly optimized and fast array manipulation library, Blitz++ [@Veldhuizen:CP1998], for all array operations.
Blitz++ also offers finite-difference stencils on uniformly spaced grids.
SARAS
augments this feature with grid-transformation terms [@Anderson:book:CFD] to perform simulations on grids with non-uniform spacing.
SARAS
offers a set of extensible boundary and initial conditions, as well as source terms.
Presently the solver can switch between periodic, Neumann, and Dirichlet boundary conditions.
There also exists a mixed boundary condition class that can simulate many practical applications,
such as a conducting heating plate on an adiabatic wall [@Teimurazov:2017].
Currently the solver is restricted to Cartesian grids, but it will be extended to cylindrical, toroidal, and spherical grids in the future.
The solver also supports adaptive time-stepping, where the Courant-Friedrichs-Lewy (CFL) condition
[@Courant:1928CFL] is used to dynamically compute the appropriate time-step.
We validate our code using two very well-known test problems: lid-driven cavity and decaying turbulence.
We simulate these problems using SARAS
and compare the results with standard and validated solutions.
We solve the two-dimensional lid-driven cavity (LDC) problem using SARAS
,
and compare the results with those of @Ghia:JCP1982.
LDC is an important fluid system and it serves as a benchmark for testing numerical methods.
This system consists of a square cavity of dimension
At the start of the simulation, the fluid, which is at rest, is driven impulsively by the top lid.
This results in the formation of a vortex at the upper-right corner of the cavity,
and this vortex rapidly grows in size and occupies the entire region of the cavity.
For the simulation we employ a SARAS
at the final time is used for comparison with the results of @Ghia:JCP1982
In the website we supply the Bash and Python scripts to compile and run this test case.
After automatic execution of SARAS
, a Python script reads the output
from SARAS
and compares the horizontal and vertical velocity profiles across
the geometric center of the square cavity.
The corresponding results from @Ghia:JCP1982 are also available with the installation.
We compare the two results and exhibit them in Figure \ref{figure1}.
We observe that the profiles computed by SARAS
match very well with those by @Ghia:JCP1982, thus providing a strong validation for our code.
This quick validation of the solver, which can be done as a part of its installation, is one of the strengths of this package.
We simulate decaying turbulence using SARAS
with Taylor-Green vortex [@Taylor:RSPA1937] as the initial condition.
That is,
$$
\mathbf{u}(x,y,z, t=0) = u_{0} \begin{bmatrix}
\sin(2 \pi k_{0} x) \cos(2 \pi k_{0}y) \cos(2 \pi k_{0}z) \
-\cos(2 \pi k_{0} x) \sin(2 \pi k_{0}y) \cos(2 \pi k_{0}z) \
0
\end{bmatrix},
$$
where
To validate the accuracy of the finite difference scheme of SARAS
,
we compare the results of SARAS
with those of a pseudo-spectral code TARANG
,
which has been benchmarked and scaled up to 196608 cores of Cray XC40,
Shaheen II of KAUST [@Chatterjee:JPDC2018; @Verma:Pramana2013tarang].
Note that pseudo-spectral method yields very accurate derivatives [@Canuto:book:SpectralFluid].
We perform our spectral simulation using the same initial condition and grid resolution as above, up to SARAS
results with those of TARANG
provides another validation of SARAS
.
The results of TARANG
and SARAS
are quite similar, as exhibited in Figures \ref{figure2} and \ref{figure3}.
In Figure \ref{figure2}(a) we exhibit the plots of the total energy (
Figure \ref{figure3} exhibits the magnitude of velocity, TARANG
and SARAS
are very similar.
This paper provides a brief description and validations tests of a new parallel finite-difference code SARAS
.
SARAS
has been designed as a general PDE solver using the object-oriented features of C++.
We validate SARAS
using two test cases: lid-driven cavity and decaying turbulence.
We gratefully acknowledge the contributions from Gaurav Gautham, Saurav Bhattacharjee, Rishabh Sahu and Mohammad Anas during the development of SARAS. We also thank Kyle Niemeyer and the reviewers at JOSS, whose useful suggestions greatly improved the solver, with true open-source ethos. Part of our computations were performed on the Cray XC40 (Shaheen II) of KAUST supercomputing laboratory, Saudi Arabia, through Projects k1052 and k1416.