A Toolkit For Computational Fluid Dynamics Using Spectral Element Method in Scilab
A Toolkit For Computational Fluid Dynamics Using Spectral Element Method in Scilab
a r t i c l e i n f o a b s t r a c t
Article history: Computational Fluid Dynamics (CFD) is a discipline that solves a set of equations governing the fluid flow
Available online xxxx over any geometrical configuration. Three classes of solution techniques have emerged in CFD namely,
the finite difference techniques, the finite element methods, and the spectral techniques. The spectral-
Keywords: element method combines the generality of the finite element method with accuracy of spectral tech-
Computational Fluid Dynamics (CFD) niques. This technique makes use of a Lobatto nodal base. One of the advantages of using spectral ele-
Spectral Element method ment method is that a stable solution algorithms and high accuracy can be achieved with a low
Scilab
number of elements under a broad range of conditions. In the present study spectral element method
software library is developed and implemented using Scilab, which is a high-level, numerically oriented
programming language an also an open source. In the present study the software library of Scilab has
been used to develop a toolkit for one dimension steady diffusion equation, unsteady diffusion equation,
and Laplace’s equation. The accuracy of the spectral method has also been emphasized by comparing it
with the finite element method solution.
Copyright Ó 2023 Elsevier Ltd. All rights reserved.
Selection and peer-review under responsibility of the scientific committee of the International Confer-
ence on Smart and Sustainable Developments in Materials, Manufacturing and Energy Engineering.
https://doi.org/10.1016/j.matpr.2023.04.341
2214-7853/Copyright Ó 2023 Elsevier Ltd. All rights reserved.
Selection and peer-review under responsibility of the scientific committee of the International Conference on Smart and Sustainable Developments in Materials,
Manufacturing and Energy Engineering.
Please cite this article as: V. J S, R.H.M. Somanath Swamy, G. Mahesh et al., A toolkit for computational fluid dynamics using spectral element method in
Scilab, Materials Today: Proceedings, https://doi.org/10.1016/j.matpr.2023.04.341
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx
Finite volume, finite element, spectral and also finite difference c) Plotting of the solution
methods may be viewed as a specific application of the method of
weighted residuals. In general the method of weighted residuals The solution obtained here is element end nodes and the
employs expansion functions as basic functions for a truncated ser- Lobatto interpolation nodes. These are plotted using Scilab’s inbuilt
ies expansion of the solution of the partial differential equation. In plot function. The input data are, Domain length L = 1, Number of
order to ensure that the approximate solution, defined by the trun- elements N = 2, Ratio r = 3, Polynomial expansion order m1 = 6 for
cated series expansion, satisfies the differential equation as closely 1st element, and Polynomial expansion order m2 = 4 for 2nd
as possible, test functions are used to minimize the residual that is element.
formed when the approximate solution is substituted into the par- The discretization of a line domain is unsymmetrical. This gen-
tial differential equations. Traditionally the finite element method erates the element end nodes and global spectral nodes. The circle
has always used polynomial expansions and this may be attributed marks indicates the position of the element end nodes. The tilted
to the historical use of Taylor series expansions which allow ana- square mark indicates the position of the Lobatto interpolation
lytical functions to be expressed in terms of polynomials [3]. Poly- nodes. The total no of element end nodes generated are N + 1,
nomial functions also have the added advantage of discrete i.e. 3. The total no of Lobatto interpolation nodes are m1 + m2 +
integration rules which enable easy computer implementations 1,.i.e. 11. Since the element end nodes are coinciding with Lobatto
[4]. interpolation nodes the total nodes appeared in the plot is only 11.
The main focus here is to implement spectral element method Consider steady-state heat conduction through a rod length, L,
and develop library files for one dimension problem and two in the presence of a distributed source of heat due, for example,
dimensions problem using open source software. Scilab is open to a chemical reaction. We begin by introducing the axis along
source software used for programming. This is an initial stage of the rod, and flux along it is given by Fick’s Law.
spectral element implementation in Scilab, the software library is
df
restricted to one and two dimension CFD problems. We have qðxÞ ¼ k ð4:4Þ
dx
developed the toolkit for one and two dimension CFD problem
by using this software library. The validation of this work is done where k is the thermal conductivity of the rod material and f(x) is
by comparing previous Matlab work as shown in Figs. 1–5. the temperature.
We shall assume that the boundary conditions specify:
4.1. Discretization of line and generation of spectral nodes. The heat flux at the left end of the rod located at,
df
A discretization is said to be unsymmetrical if element distribu- q0 k ð4:5Þ
dx x¼0
tion is asymmetric with respect to the interval midpoint.
The temperature at the right end of the rod located at x = L,
a) Input data
f ðx ¼ LÞ f L ð4:6Þ
Input data consist of basic information which is must for a code Eqn. (4.4) expressed a Neumann boundary condition that is the
to perform desired operations and hence to give results. Here we condition on the derivative of the unknown function and the Eqn.
are giving input data in a file (*.sce) which consists of length of (4.5) expressed a Dirichlet boundary condition that is a condition
the domain, number of elements N, ratio r, polynomial expansion on the value of the unknown function. In the steady diffusion equa-
order mi for each individual element. tion problem the unknown vector, diffusion flux f, contains the
solution at all nodes is need to find out.
b) Discretization:
a) Data input
In this step a line segment is divided into a graded mesh of ele-
ments subtended between the left end-point and right end – point, Input data consist of basic information which is must for a code
variable ratio is the ratio of the length of the last element to the to perform desired operations and hence to give results. Here we
length of the first element as shown in eqn. are giving input data in a file (*.sce) which consists of length of
2
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx
the domain, number of elements N, ratio r, polynomial expansion Plotting is done using the Scilab’s inbuilt plot function.
order mi for each individual element, thermal conductivity k, heat Input data are:
generation q_0, flux at the boundary fL.
& Domain length, L = 1
b) Element node generation & Thermal conductivity, k = 1
& Heat generation, q_0 = -1.0
The domain discretization and generation of the Lobatto inter- & Flux at the boundary, fL = 0.0
polation nodes is the same as in section 4.3. Also from the Lobatto & Number of elements, N = 3
3
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx
& Ratio, r = 5 one hundred twenty – eight global nodes, NG = 128, is accurate
& Polynomial order for 1st element, np(1) = 2 only to the fourth significant figure. This shows the spectral ele-
& Polynomial order for 2nd element, np(2) = 2 ment method gives more accurate and convergence solution com-
& Polynomial order for 3rd element, np(3) = 4 pare to finite element method.
f) Result
4.3. Grid generation
The output plot is for the diffusion flux against the element end
nodes in this computation three elements are used with corre- In this work, disk like shape are considered as domain to imple-
sponding polynomial expansion are 2, 2, and 4. The crosses on ment spectral element method in two dimensions. The triangula-
the graph denote the computed nodal values at the interpolation tion technique is used for grid generation because of it’s
nodes. Table 1 Accuracy and convergence of the spectral element distinguish feature of successive subdivision. The refinement level
method compare to the Finite element method with linear is determined by the input flag ndiv
elements.
The result shows, comparison of the numerical solutions for a At ndiv = 0 produces ancestral 4 elements.
fixed global nodes, NG, clearly demonstrates the spectral element At ndiv = 1 produces ancestral 16 elements
method over the linear element method. For example, the spectral At ndiv = 2 produces ancestral 64 elements.
element solution with sixteen global nodes, NG = 16 i.e accurate to At ndiv = 3 produces ancestral 256 elements.
the fifth significant figure. Whereas finite element solution with
4
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx
Table 1
Accuracy and convergence of the spectral element method compare to the Finite element method with linear elements.
Each triangle is defined by six nodes, including vertex nodes Fifth step constitute global diffusion matrix using element dif-
and three edge nodes. The elements have triangular shapes defined fusion matrix and connectivity.
by small group of geometrical element nodes. The collection of all
geometrical element nodes comprises a set of NGN unique geomet- e) Assemble the right – hand side of the linear system.
rical global nodes.
Result: At ndiv = 0, produces 4 triangles and 24 nodes, at ndiv = 1 Assembling the right - hand side of the linear system by using
produces 16 triangles and 96 nodes. At ndiv = 3 produces 256 tri- global diffusion matrix and global node flag.
angles, i.e1536 nodes. The spectral element solution for Laplace’s equation on disk like
domain is shown in Fig. 5 for Dirichilet boundary conditions with
4.4. Laplace’s equation the discritization level is 2 and the 6 noded triangular elements
are being used. To isolate from the domain to solution domain
The layout of the spectral element code for solving Laplace’s deform 0.6 being introduced over the global nodes. Different colour
equation indicates the variation in temperature on each and individual
elements.
r2 f ¼ 0 ð4:9Þ
Subject to the Dirichlet boundary condition applied all around
the boundary of the solution domain. 5. Conclusions
a) Data input The presented work started with understanding the basic the-
ory of finite element method, spectral element method, function
Input data consist of basic information which is must for a code interpolation and grid generation. It started without knowing
to perform desired operations and hence to give results. Here we how to develop software library in Scilab. With the little difficulties
are giving input data in a file (*.sce) which consists of discretization in the initial phase of the project, the software library could be
level ndiv and number of quadrature base points NQ. exceptionally utilized according to the project requirement.
A study has been carried out with successful implementation of
b) Grid generation spectral element method in Scilab, also developed software library
files.
Grid generation is done by using triangulation method. Which The tool kit has been developed for one dimension steady diffu-
generates the triangular elements, global nodes, connectivity sion, unsteady diffusion and two dimensions Laplace’s equation.
matrix and element-node and global –node flags. This toolkit didn’t require again and again compilation for same
problem with different initial and boundary condition.
c) Specify the Dirichlet boundary condition. This work demonstrates the spectral element method requires
fewer degrees of freedom than lower – order method. That is spec-
The specification of the Dirichilet boundary condition at bound- tral element method provides accuracy and convergence at very
ary node is done via connectivity matrix. Apply to all unique global less number of element compared to the finite element method.
nodes NG. This work is compared with existing Matlab packages the
agreement is seen to be good.
d) Assembly the global diffusion matrix.
To generate the element diffusion matrix over each triangular 6. Future work
element first step is to generate mapping coefficients alpha, beta
and gamma. The present work developed software library for one and two
dimensions CFD problem, the basis formulation is same for three
1 1 1
a¼
; b ¼
x6 x3 ; c ¼
ð4:10Þ dimensions also, hence easily extended to three dimension case.
2 x5 x2
1 þ xx44 x
x1 1 þ x6 x1 1 þ x5 x3
In this work we used successive subdivision techniques for grid
generation for two dimensions case, employing Delaunay triangu-
In second step the mapping is done with area of the triangle in lation technique one can use for various shapes of one and two
physical xy plane over the area of the triangle in the parametric ng dimensions problems can be easily solved.
plane. The spectral element basic implementation done in Scilab, need
In third step introducing Abscissas and weight for Gaussian to employ on practical application oriented one and two dimen-
integration over a flat triangle in, the xi-eta plane the integration sions problems.
is performed. This software library can be used for the further developing
Fourth step the generation of the element diffusion matrix, the incompressible Navier - Stokes equation for the fluid flow problem.
corresponding element mass matrix using isoparametric interpola- The software library developed here can be used directly for
tion and corresponding abscissas and weights. developing software packages.
5
V. J S, R.H.M. Somanath Swamy, G. Mahesh et al. Materials Today: Proceedings xxx (xxxx) xxx
CRediT authorship contribution statement [3] F.N. van de Vosse, P.D. Minev, Spectral element methods: theory and
applications, Vol. 96-W-001, Eindhoven University of Technology, 1996.
[4] K. Raghavendra Pai, Ajit M. Hebbale, J.S. Vishwanatha, B. Sachin, Study of
J.S. Vishwanatha: Conceptualization, Writing – original draft. R. tribological properties on aluminium based hybrid composite developed
H.M. Somanath Swamy: Validation, Supervision. G. Mahesh: through microwave energy, Materials Today: Proceedings,Vol. 44, 2021, pp.
4245-4250.
Investigation. H. Virupaksha Gouda: Software.
[5] Russell G. DeAnna, Incompressible Spectral-Element Method - Derivation of
Equations, NASA Technical Memorandum, 1993.
Data availability [6] D. John, A. Jr, Computational Fluid Dynamics The Basics with Applications,
Department of Aerospace Engineering, University of Maryland, 1995.
[7] Charles Hirsch, Numerical Computation of Internal and External Flows,
Data will be made available on request. Fundamentals of Computational Fluid Dynamics, Volume 1, Second edition
Butterworth-Heinemann is an imprint of Elsevier, 2007.
[8] Satish Annigeri, Scilab- A Hands on Introduction, 2004.
Declaration of Competing Interest [9] S.L. Campbell, Jean-Philippe Chancelier, RamineNikoukhah, Modelling and
Simulation in Scilab/Scicos, Springer, New York, NY, 2009.
The authors declare that they have no known competing finan- [10] R.H.M. Somanath Swamy, G. Hiregoudar Yerrennagoudar, JS.V. Mahesh,
Performance of CI Engine Using Swirl Type Retrofit, Journal of Physics:
cial interests or personal relationships that could have appeared Conference Series (2021).
to influence the work reported in this paper. [11] Gilberto E Urroz, Introduction to Scilab, 2001.
[12] T.J. Chung, Computational Fluid Dynamics, University of Alabama, Huntsville,
2002.
References
[13] J. Balazek, Computational Fluid Dynamics: Principles and Applications,
ELSEVIER publication, 2001.
[1] G.E.M. Karniadakis, S.J. Sherwin, Spectral / hp Element Methods for CFD, [14] AnilW. Date, Introduction to Computational Fluid Dynamics, Cambridge
Oxford University Press, New York Oxford, 1999. University Press, 2005.
[2] Anthony T. Petera, A spectral element method for fluid dynamics laminar flow
in channel expansion, Journal of computational Physics 54 (3) (1984) 468–488.