Keywords

1 Introduction

This paper revisits a version of the global Galerkin method whose development started in the author’s PhD thesis [16] and, being continued later, resulted in an effective approach for stability analysis of model incompressible flows, so that well known and less known results had being published continuously from 1994 until 2005. Several years ago I was asked to present this approach again, and it triggered some interest among several young colleagues. It is mainly their interest that inspired me to review all that was done and to make a more or less consistent description of all the technical details, which were distributed over several papers, and sometimes omitted. Naturally, I added some comments on my personal current opinion of what was done and what possibly can be done in future.

The development of this approach started in the era when computer memory was measured in kilobytes, so that even storage of a large matrix was a problem. The only way to reduce the required memory was reducing the number of degrees of freedom of numerical method. Since discretization of the flow region (domain) requires fine grids, the decrease of number of degrees of freedom was sought in different versions of global weighted residual methods, called also spectral methods. These methods do not discretize the domain, and approximate solutions as truncated series of basis functions. It was shown by many authors that weighted residuals methods allow for a very significant reduction of degrees of freedom (see, e.g., [9]). Straight-forward application of these methods to incompressible fluid dynamics involves so-called algebraic constraints that are related to the boundary conditions and the continuity equation. Removal of these constraints by an appropriate choice of basis functions would decrease the number of degrees of freedom even more. The construction of such basis functions, is the main topic of this text. For problems with periodic boundary conditions the choice of Fourier series is natural, and also allows for application of the fast Fourier transform when the non-linear terms are evaluated by the pseudo-spectral approach. However, the choice of basis functions is not so obvious for non-periodic boundary conditions. Quite an apparent idea to linearly combine some well-known functions, e.g., the Chebyshev polynomials, into expressions that satisfy linear and homogeneous boundary conditions of a problem, appears in Orszag [54, 55]. To the best of the author’s knowledge, this is the first appearance of this idea, at least in CFD. Many authors, including this one, rediscovered this way of constructing the basis functions (see Sect. 9).

The next step was to combine these linear superpositions into a two-dimensional divergence-free vector, for which Chebyshev polynomials of the first and second kinds fit very well [16, 17]. The Galerkin method based on the divergence-free basis functions, that satisfy all linear and homogeneous boundary conditions (LHBC in the further text), really allowed for noticeable reduction of the number of degrees of freedom, as was already shown in Gelfgat and Tanasawa [17]. Later, the computer power grew, so grew possibilities of applications of the method. A relatively small amount of degrees of freedom resulted into Jacobian matrices of relatively small size, which already could be treated numerically for computation of steady flows, as well as for solution of the eigenvalue problems associated with the flows linear stability [20,21,22]. The divergence free functions were extended to cylindrical coordinates, which allowed us to consider flow in the rotating disk—cylinder system and to obtain first stability results (Gelfgat et al. [18]) for this configuration.

Since then a number of different problems addressing steady state flows, possible multiplicity of states, and stability were solved for different flows in two-dimensional rectangular cavities and cylinders. The periodic circumferential coordinate in the cylindrical geometry allows one to study stability of an axisymmetric base flow with respect to three-dimensional perturbations. The linearized problem for the 3D disturbances separates for each circumferential Fourier mode, so that the final answer is obtained by consideration of several 2D-like problems. Subsequently, a considerable amount of results was obtained for stability of flows in cylinders, which were driven by rotation of boundaries, buoyancy convection, and magnetic field.

The first attempt to study 3D instability in Cartesian coordinates was done in Gelfgat [24] for the Rayleigh–Bénard problem in rectangular box, which considers stability of quiescent fluid heated from below. No attempts were made by the author to study stability of fully developed 3D flow. At the same time, the three-dimensional bases found an unexpected application for visualization of incompressible 3D flows [39].

The following text starts from a brief description of the weighted residuals and Galerkin method formulated for an incompressible fluid dynamics problem. Then the proposed way of construction of basis functions is explained, starting from a one-dimensional two-point problem. Treatment of inhomogeneities and boundary conditions singularities is explained. This follows by discussion of the resulting dynamical system and explanations of how it was treated in the cited works, as well as how it can be treated for fully 3D problems. After that, several illustrative examples are presented. Finally, a discussion of possible future studies is given.

2 The Problem and the Numerical Method

We consider flow of incompressible fluid in a two-dimensional rectangle \( 0 \le x \le A_{x} , 0 \le y \le A_{y} \), or in a three-dimensional box \( 0 \le x \le A_{x} , 0 \le y \le A_{y} , 0 \le z \le A_{z} \). The rectangular shape of the domain is the main restriction for all the following. Below we discuss how this restriction can be relaxed to a canonical shape, i.e., the domain bounded by the coordinate surfaces belonging to a certain system of orthogonal curvilinear coordinates. The momentum and continuity equations for velocity \( \varvec{v} \) and pressure \( p \) (\( Re \) is the Reynolds number) read

$$ \frac{{\partial \varvec{v}}}{\partial t} + \left( {\varvec{v} \cdot \nabla } \right)\varvec{v} = - \nabla p + \frac{1}{Re}\Delta \varvec{v} + \varvec{f} $$
(2.1)
$$ \nabla \cdot \varvec{v} = 0 $$
(2.2)

We assume also that boundary conditions for all the three velocity components are linear and homogeneous, e.g., the no-slip conditions on all the boundaries. The Eq. (2.1)–(2.2) can be considered together with other scalar transport equations for, e.g., temperature and/or concentration, an example of which will be given below.

To formulate the Galerkin method we assume that the solution \( \varvec{v} \) belongs to a space of divergence-free vectors satisfying all the (linear and homogeneous) boundary conditions, LHBC. Assume that vectors \( \left\{ {\varvec{\varphi }_{K} } \right\}_{K = 1}^{\infty } \) form a basis in this space. Then the solution \( \varvec{v} \) can be represented as

$$ v = \sum\limits_{K = 1}^\infty {{c_K}{\varphi_K}} . $$
(2.3)

The coefficients \( c_{K} \) can be obtained by evaluation of inner products of Eq. (2.3) by a basis vector \( \varvec{\varphi }_{L} \):

$$ \left\langle {v,{\varphi_L}} \right\rangle = \sum\limits_{K = 1}^\infty {{c_K}\left\langle {{\varphi_K},{\varphi_L}} \right\rangle } ,\quad L = 1,2,3, \ldots $$
(2.4)

Here we assumed that the space is supplied by an inner product \( \langle \cdot , \cdot \rangle \), which is yet to be defined. If the functions \( \left\{ {\varvec{\varphi }_{K} } \right\}_{k = 1}^{\infty } \) form the orthogonal basis, then the coefficients \( c_{K} \) are obtained as

$$ c_{K} = \frac{{\left\langle {v,\varvec{\varphi }_{K} } \right\rangle }}{{\left\langle {\varvec{\varphi }_{K} ,\varvec{\varphi }_{K} } \right\rangle }},\quad K = 1,2,3, \ldots $$
(2.5)

However, if the basis functions are not orthogonal, the expressions (2.4) form an infinite system of linear algebraic equation, which can be solved only with a certain truncation. Keeping only \( N \) first terms in the series (2.3) and defining a vector of coefficients \( \varvec{c} = \left\{ {c_{1} ,c_{2} ,c_{3} , \ldots ,c_{N} } \right\} \), the first \( N \) coefficients can be obtained as

$$ \varvec{c} = G^{ - 1} \varvec{f},\quad G_{KL} = \left\langle {\varvec{\varphi }_{K} ,\varvec{\varphi }_{L} } \right\rangle ,\quad f_{L} = \left\langle {\varvec{v},\varvec{\varphi }_{L} } \right\rangle . $$
(2.6)

Here \( G \) is the Gram matrix, and \( N \) is the truncation number.

In the relations (2.4)–(2.6) we assumed that the vector \( \varvec{v} \) is known. If it is unknown, the coefficients \( c_{K} \) can be obtained only approximately by minimization of residual of the governing equations. To show a way for their calculation, we first assume that the coefficients \( c_{K} \) are time-dependent and the basis functions \( \left\{ {\varvec{\varphi }_{K} } \right\}_{k = 1}^{\infty } \) depend only on coordinate values. Then the representation (2.3) defines a time- and space-dependent function \( \varvec{v} \). Note that the continuity Eq. (2.2), as well as all the boundary conditions are already satisfied because \( \varvec{v} \) belongs to the space . Clearly, the solution we are looking for also belongs to this space, so that the momentum equation is the only one to be solved. Now we rewrite the momentum Eq. (2.1) in two additional and equivalent forms

$$ \frac{{\partial \varvec{v}}}{\partial t} + \left( {\varvec{v} \cdot \nabla } \right)\varvec{v} + \nabla p - \frac{1}{Re}\Delta \varvec{v} - \varvec{f} = \varvec{R} = 0 $$
(2.7)
$$ \frac{{\partial \varvec{v}}}{\partial t} = - \nabla p + \frac{1}{Re}\Delta \varvec{v} - \left( {\varvec{v} \cdot \nabla } \right)\varvec{v} + \varvec{f} $$
(2.8)

Here \( \varvec{R} \) is residual of the momentum equation. If \( \varvec{v} \) is the solution then \( \varvec{R} \equiv 0 \). For a general case we assume that all possible residuals belong to a certain functional space , which is also supplied by an inner product \( \langle \cdot , \cdot \rangle_{W} \). Assume also that \( \left\{ {\varvec{\phi}_{K} } \right\}_{K = 1}^{\infty } \) is a basis in . Then the requirement of the zero residual will be equivalent to the requirement that the residual \( \varvec{R} \) is orthogonal to all the basis functions \( \varvec{\phi}_{K} \), namely

$$ \left\langle {\varvec{R},\varvec{\phi}_{K} } \right\rangle_{W} = 0,\quad K = 1,2,3, \ldots $$
(2.9)

The Eq. (2.9) form an infinite set of non-linear time-dependent ODEs that must be solved to find the time-dependent coefficients \( c_{K} \left( t \right) \). However, this system of equations is not closed yet, since nothing is said about the pressure. To proceed, we assume that the pressure belongs to a space of scalar time-dependent functions, differentiable at least two times into the domain, with the basis \( \left\{ {s_{K} } \right\}_{K = 1}^{\infty } \). The pressure is represented as

$$ p = \sum\limits_{K = 1}^\infty {{d_K}\left( t \right){s_K}} . $$
(2.10)

The equation of pressure is formed in the standard way, by applying the divergence operator to both sides of the momentum Eq. (2.1), which yields

$$ \Delta p = - div\left[ {\left( {\varvec{v} \cdot \nabla } \right)\varvec{v} - \varvec{f}} \right]. $$
(2.11)

Boundary conditions needed to be supplied to this equation will be discussed later. Note, that the velocity representation (2.3), even in the truncated form used below, guarantees zero velocity divergence. Since the Laplacian and divergence operators are evaluated analytically, they commute in every approximate (truncated) formulation. We introduce the residual \( D \) of the pressure equation

$$ D = \Delta p + div\left[ {\left( {\varvec{v} \cdot \nabla } \right)\varvec{v} - \varvec{f}} \right]. $$
(2.12)

For the residual \( D \) we demand only piecewise continuity in all spatial directions, so that it formally belongs to another space of scalar functions. This space is denoted as , its basis as \( \left\{ {q_{K} } \right\}_{K = 1}^{\infty } \), and the scalar product as \( \langle \cdot , \cdot \rangle_{D} \). Now, for the solution of the problem represented by \( \varvec{v} \) and \( p \), the scalar non-linear algebraic equations

$$ \left\langle {D,q_{L} } \right\rangle_{D} = 0,\quad L = 1, 2,3, \ldots $$
(2.13)

must be added. Equation (2.13) define the coefficients \( d_{K} \left( t \right) \) and must be satisfied together with the Eq. (2.9). Note that these equations do not contain the time derivative and, therefore, are algebraic constraints for the ODEs (2.9).

Obviously, and . To build a numerical procedure for obtaining \( N_{v} \) and \( N_{p} \) first coefficients of the velocity and pressure series (2.3) and (2.10), we truncate the series together with the residual projection Eqs. (2.9) and (2.13). These results in

$$ \varvec{v} \approx \sum\nolimits_{K = 1}^{{N_{v} }} {c_{K} \left( t \right)\varvec{\varphi }_{K} } ,\quad \left\langle {\varvec{R},\varvec{\phi}_{L} } \right\rangle_{W} = 0,\quad L = 1,2,3, \ldots ,N_{v} , $$
(2.14)
$$ p \approx \sum\nolimits_{K = 1}^{{N_{p} }} {d_{K} \left( t \right)s_{K} } ,\quad \left\langle {D,q_{M} } \right\rangle_{D} = 0,\quad M = 1,2,3, \ldots ,N_{p} , $$
(2.15)

which defines \( N_{v} \) non-linear ODEs and \( N_{p} \) non-linear algebraic constraints for calculation of the time-dependent coefficients \( c_{K} \left( t \right) \) and \( d_{K} \left( t \right) \). Altogether, it is called method of weighted residuals [7, 9, 14]. The ODEs and the algebraic constraints resulting from projections of the momentum and pressure equation residuals onto the basis functions are

$$ \begin{aligned} \sum\nolimits_{K = 1}^{{N_{v} }} {\dot{c}_{K} \left( t \right)} \left\langle {\varvec{\varphi }_{K} ,\varvec{\phi}_{M} } \right\rangle_{W} & = - \sum\nolimits_{K = 1}^{{N_{v} }} {\sum\nolimits_{L = 1}^{{N_{v} }} {c_{K} \left( t \right)c_{L} \left( t \right)} } \left\langle {\left( {\varvec{\varphi }_{L} \cdot \nabla } \right)\varvec{\varphi }_{K} ,\phi_{M} } \right\rangle_{W} \\ & - \sum\nolimits_{K = 1}^{{N_{p} }} {d_{K} \left( t \right)} \left\langle {\nabla s_{K} ,\phi_{M} } \right\rangle_{W} + \frac{1}{Re}\sum\nolimits_{K = 1}^{{N_{v} }} {c_{K} \left( t \right)} \left\langle {\Delta \varvec{\varphi }_{K} ,\phi_{M} } \right\rangle_{W} \\ & \quad + \left\langle {\varvec{f},\phi_{M} } \right\rangle_{W} ,\quad M = 1, 2,3, \ldots ,N_{v} \\ \end{aligned} $$
(2.16)
$$ \begin{aligned} \sum\nolimits_{K = 1}^{{N_{p} }} {d_{K} \left( t \right)} \left\langle {\Delta s_{K} ,q_{J} } \right\rangle_{D} & = - \sum\nolimits_{K = 1}^{{N_{v} }} {\sum\nolimits_{L = 1}^{{N_{v} }} {c_{K} \left( t \right)c_{L} \left( t \right)} } \left\langle {\nabla \cdot \left( {\varvec{\varphi }_{L} \cdot \nabla } \right)\varvec{\varphi }_{K} ,q_{J} } \right\rangle_{D} \\ & \quad + \left\langle {\nabla \cdot \varvec{f},q_{J} } \right\rangle_{D} ,\quad J = 1, 2,3, \ldots ,N_{p} \\ \end{aligned} $$
(2.17)

Following common definitions, \( \left\{ {\varvec{\varphi }_{K} } \right\}_{k = 1}^{\infty } \) and \( \left\{ {s_{K} } \right\}_{K = 1}^{\infty } \) are called coordinate basis systems, while \( \left\{ {\varvec{\phi}_{K} } \right\}_{k = 1}^{\infty } \) and \( \left\{ {q_{K} } \right\}_{K = 1}^{\infty } \)—projection basis systems.

Note that the weighted residuals method can be formulated also for coordinate basis functions that do not satisfy some or all boundary conditions. Fletcher [14] distinguishes between the coordinate functions that satisfy only (linear) differential equation, satisfy only boundary conditions, and do not satisfy anything, calling these three cases boundary, interior, and mixed, respectively. Within this classification, and noticing that the equations are non-linear, we discuss mainly interior methods.

To arrive to the Galerkin formulation we assume that the boundary conditions do not explicitly involve time. Then l.h.s. of Eq. (2.8) satisfies the LHBC of the velocity and is divergence-free. Then, the same can be said about the r.h.s. of Eq. (2.8), and finally about the residual of the momentum equation \( \varvec{R} \) defined in Eq. (2.7). Thus, for the time-independent boundary conditions, the residual \( \varvec{R} \) belongs to the space , so that we can choose \( \varvec{\phi}_{K} = \varvec{\varphi }_{K} \) for all \( K \). Also assuming that the coordinate systems \( \left\{ {\varvec{\varphi }_{K} } \right\}_{k = 1}^{\infty } \) and \( \left\{ {s_{K} } \right\}_{K = 1}^{\infty } \) are usually built from the trigonometric functions or polynomials that are differentiable infinite number of times, the residual \( D \) will also be differentiable infinite number of times. Since the physical problem does not specifies any pressure boundary conditions, we can assume that both \( p \) and \( D \) belong to the same space , and to choose \( q_{K} = s_{K} \) for all \( K \). Thus, we arrive to a particular version of the weighted residuals method, in which the coordinate and projection basis systems coincide. This version is known as the Galerkin or Boubnov—Galerkin method.

An obvious reason to choose the Galerkin method among all possible weighted residual formulations follows from the fact that . By projecting on a “smaller” space , we expect that with increase of the truncation number convergence will be faster. Another, less obvious and more profound reason follows from definition of the inner products via volume integrals. For scalar and vector functions defined into the domain \( V \) and on its boundary we define

$$ \left\langle {f\left( {x,y,z} \right),g\left( {x,y,z} \right)} \right\rangle_{\rho } = \int_{V} {\rho \left( {x,y,z} \right)fgdV} , $$
(2.18)
$$ \left\langle {\varvec{u}\left( {x,y,z} \right),\varvec{v}\left( {x,y,z} \right)} \right\rangle_{\rho } = \int_{V} {\rho \left( {x,y,z} \right)} \varvec{u} \cdot \varvec{v }dV, $$
(2.19)

where \( \rho \left( {x,y,z} \right) > 0 \) is the weight function. The simplest and the most robust formulation is obtained with the unity weight \( \rho \left( {x,y,z} \right) = 1 \), for which the inner products (2.18), (2.19) may also have some physical meaning. For example, the norm produced by (2.19) becomes doubled dimensionless kinetic energy. An important additional advantage of the unity weight follows from consideration of the inner product of gradient of an arbitrary scalar field \( f\left( {x,y,z} \right) \) by divergence free vector \( \varvec{u}\left( {x,y,z} \right) \). Assume that \( \Gamma \) is the domain boundary, \( \varvec{n } \) its normal, and that the component of \( \varvec{u} \) normal to the boundary vanishes. Keeping in mind that \( \nabla \cdot \varvec{u} = 0 \) and \( \varvec{u} \cdot \varvec{n} = 0 \), we have

$$ \left\langle {\nabla f,\varvec{u}} \right\rangle_{1} = \int_{V} {\nabla f \cdot \varvec{u}dV} = \int_{V} {\left[ {\nabla \cdot \left( {f\varvec{u}} \right) - f\nabla \cdot \varvec{u}} \right]dV} = \int_{V} {\nabla \cdot \left( {f\varvec{u}} \right)dV} = \int_{\varGamma } {f\varvec{u} \cdot \varvec{n}\,d\varGamma } = 0 $$
(2.20)

Thus, if the velocity does not penetrate the boundary, and the inner product is chosen as in (2.19), the projection of the pressure gradient on all the velocity basis functions vanishes. This means that equation systems (2.16) and (2.17) separate, so that velocity can be calculated from (2.14) without any knowledge about pressure. The pressure then can be computed from (2.15) using the previously found velocity field. In this case Eq. (2.16) become

$$ \begin{aligned} \sum\nolimits_{K = 1}^{{N_{v} }} {\dot{c}_{K} \left( t \right)} \left\langle {\varvec{\varphi }_{K} ,\varvec{\varphi }_{M} } \right\rangle_{1} & = - \sum\nolimits_{K = 1}^{{N_{v} }} {\sum\nolimits_{L = 1}^{{N_{v} }} {c_{K} \left( t \right)c_{L} \left( t \right)} } \left\langle {\left( {\varvec{\varphi }_{L} \cdot \nabla } \right)\varvec{\varphi }_{K} ,\varvec{\varphi }_{M} } \right\rangle_{1} \\ & \quad + \frac{1}{Re}\sum\nolimits_{K = 1}^{{N_{v} }} {c_{K} \left( t \right)} \left\langle {\Delta \varvec{\varphi }_{K} ,\varvec{\varphi }_{M} } \right\rangle_{1} + \left\langle {\varvec{f},\varvec{\varphi }_{M} } \right\rangle_{1} ,\quad M = 1,2,3, \ldots ,N_{v} \\ \end{aligned} $$
(2.21)

This is the formal Galerkin formulation for calculation of an approximate solution of a problem. Note that the exclusion of pressure by the Galerkin projection (2.20) is not restricted to only closed flow regions with non-penetrative boundaries. The inhomogeneity in the velocity boundary conditions can be removed by change of variables, which is discussed below in more detail.

To proceed we need to explain how to build basis functions, which are divergence-free and satisfy the whole set of LHBC. Then we will discuss how to handle inhomogeneous boundary conditions, curvilinear coordinates, and weight functions others than the unity one.

3 Basis Functions

We start from the question of how to satisfy all the LHBC for a scalar unknown function. We assume that the basis functions for all three-dimensional time-dependent scalar variables, e.g., temperature and/or concentration, are represented as products of some one-dimensional bases. Thus for a function \( \theta \left( {x,y,z,t} \right) \) defined in a box \( 0 \le x \le A_{x} , 0 \le y \le A_{y} , 0 \le z \le A_{z} \) we are looking for representation in the form of the tensor (Kronecker) product of one-dimensional bases

$$ \theta \left( {x,y,z,t} \right) = \sum\nolimits_{k = 1}^{{N_{z} }} {\sum\nolimits_{j = 1}^{{N_{y} }} {\sum\nolimits_{i = 1}^{{N_{x} }} {d_{ijk} \left( t \right)f_{i} \left( x \right)g_{j} \left( y \right)h_{k} \left( z \right)} } } , $$
(3.1)

Here \( d_{ijk} \left( t \right) \) are unknown time-dependent coefficients, \( N_{x} , N_{y} , N_{z} \) are the truncation numbers specified in each spatial direction separately, and \( f_{i} \left( x \right), g_{j} \left( y \right), h_{k} \left( z \right) \) are one-dimensional bases that must be defined in each direction. The three-dimensional basis corresponding to those defined in the previous chapter is

$$ F_{J} \left( {x,y,z} \right) = f_{i} \left( x \right)g_{j} \left( y \right)h_{k} \left( z \right), J = N_{x} \left[ {N_{y} \left( {k - 1} \right) + j - 1} \right] + i $$
(3.2)

Clearly, the global index \( J \) can be defined as a function of the 1D indices \( i,j,k \) differently, but the definition chosen must be kept through the whole computational process. Starting from here we will use capital letters for the global indices, and small letters for the one-dimensional ones.

If all the boundary conditions for \( \theta \) are linear and homogeneous, the functions \( f_{i} \left( x \right), g_{j} \left( y \right) \) and \( h_{k} \left( z \right) \) must satisfy the boundary conditions posed in the x-, y-, and z- directions, respectively. Assume now, that there are M boundary conditions in the x-direction posed in the form

$$ \sum\nolimits_{l = 0}^{L} {\alpha_{ml} f^{\left( l \right)} } \left( {x_{m} } \right) = 0,\quad m = 1,2, \ldots ,M. $$
(3.3)

Here \( \alpha_{ml} \) are known coefficients, \( l \) is the derivative number, and \( x_{m} \) are the borders (that are parts of coordinate surfaces \( x = x_{m} \)) where the boundary conditions are posed. For the following we can also extend (3.3) by assuming that negative \( l \) correspond to integrals, and that surfaces \( x = x_{m} \) are not necessarily the boundary points, but also can lie inside the flow region, as it happens in a two-fluid example below. Now assume that a set of functions \( \left\{ {s_{k} \left( x \right)} \right\}_{k = 1}^{\infty } \) forms a basis in, say, \( C^{\infty } \left( {\left[ {0,A_{x} } \right]} \right) \). It can be, for example, a trigonometric Fourier basis, or a set of orthogonal polynomials defined on \( \left[ {0,A_{x} } \right] \). For some reasons we choose this basis for representation of the solution, but the functions \( s_{k} \left( x \right) \) do not satisfy the boundary conditions (3.3). We build an alternative basis by considering superpositions of \( M + 1 \) consequent basis functions as

$$ r_{k} \left( x \right) = \sum\nolimits_{n = 0}^{M} {\beta_{nk} s_{k + n} \left( x \right)} $$
(3.4)

Substituting \( r_{k} \left( x \right) \) into the boundary conditions (3.3) we obtain

$$\sum\nolimits_{l = 0}^{L} {\alpha_{ml} } \sum\nolimits_{n = 0}^{M} {\beta_{nk} s_{k + n}^{\left( l \right)} \left( {x_{m} } \right)} = 0,\quad m = 1,2, \ldots ,M $$
(3.5)

For each \( k \) the relations (3.5) form a system of M equations that can be used to find \( M + 1 \) coefficients \( \beta_{nk} \). To make the equations solvable we choose \( \beta_{0,k} = 1 \), that leaves us with M linear algebraic equations for M remaining coefficients \( \beta_{nk} \) for every fixed \( k \). The matrix of this system will be regular if the boundary conditions (3.3) are independent. In this way, the functions \( r_{k} \left( x \right) \) are fully defined and satisfy all the boundary conditions (3.3). Obviously they form a basis in the subspace \( span\left\{ {r_{k} \left( x \right)} \right\} \subset C^{\infty } \left( {\left[ {0,A_{x} } \right]} \right) \), which contains functions that satisfy conditions (3.3) and are differentiable infinite number of times. In this way we form bases \( f_{i} \left( x \right), g_{j} \left( y \right) \) and \( h_{k} \left( z \right) \) for the representation (3.1).

In the following all the examples will be based on the Chebyshev polynomials of the first and the second type, \( T_{k} \left( x \right) \) and \( U_{k} \left( x \right) \), briefly described in the Appendix A. In the further text these polynomials will always be chosen as the basis \( \left\{ {s_{k} \left( x \right)} \right\}_{k = 1}^{\infty } \).

3.1 Example: Two-Point Boundary Value Problem

Consider a two-point boundary value problem for \( \theta \left( x \right) \) posed on the interval \( 0 \le x \le 1 \) with the two \( (M = 2) \) boundary conditions

$$ a_{0} \theta^{{\prime }} \left( 0 \right) + b_{0} \theta \left( 0 \right) = 0,\quad a_{1} \theta^{{\prime }} \left( 1 \right) + b_{1} \theta \left( 1 \right) = 0, $$
(3.1.1)

where \( a_{0} , b_{0} , a_{1} , b_{1} \) are known coefficients. Recalling the Chebyshev polynomials and taking into account \( \beta_{0,k} = 1 \), our new basis functions are defined as

$$ r_{k} \left( x \right) = \sum\nolimits_{n = 0}^{2} {\beta_{nk} T_{k + n} \left( x \right)} = T_{k} \left( x \right) + \beta_{1k} T_{k + 1} \left( x \right) + \beta_{2k} T_{k + 2} \left( x \right). $$
(3.1.2)

The boundary values of the Chebyshev polynomials and their derivatives are given in Appendix A. Substituting \( r_{k} \left( x \right) \) into the boundary conditions (3.1.1) and using Eqs. (A.3) and (A.5), we obtain two equations for the coefficients \( \beta_{1k} \) and \( \beta_{2k} \):

$$ - \beta_{1k} \left[ {2a_{0} \left( {k + 1} \right)^{2} + b_{0} } \right] + \beta_{2k} \left[ {2a_{0} \left( {k + 2} \right)^{2} + b_{0} } \right] = - 2a_{0} k^{2} - b_{0} $$
(3.1.3)
$$ \beta_{1k} \left[ {2a_{1} \left( {k + 1} \right)^{2} + b_{1} } \right] + \beta_{2k} \left[ {2a_{1} \left( {k + 2} \right)^{2} + b_{1} } \right] = - 2a_{1} k^{2} - b_{1} $$
(3.1.4)

These equation are easily solved analytically, which yields

$$ \beta_{1k} = \frac{{\left( {2a_{1} k^{2} + b_{1} } \right)\left[ {2a_{0} \left( {k + 2} \right)^{2} + b_{0} } \right] - \left( {2a_{0} k^{2} + b_{0} } \right)\left[ {2a_{1} \left( {k + 2} \right)^{2} + b_{1} } \right]}}{{\left[ {2a_{0} \left( {k + 1} \right)^{2} + b_{0} } \right]\left[ {2a_{1} \left( {k + 2} \right)^{2} + b_{1} } \right] + \left[ {2a_{1} \left( {k + 1} \right)^{2} + b_{1} } \right]\left[ {2a_{0} \left( {k + 2} \right)^{2} + b_{0} } \right]}}, $$
(3.1.5)
$$ \beta_{2k} = \frac{{\left( {2a_{1} k^{2} + b_{1} } \right)\left[ {2a_{0} \left( {k + 1} \right)^{2} + b_{0} } \right] + \left( {2a_{0} k^{2} + b_{0} } \right)\left[ {2a_{1} \left( {k + 1} \right)^{2} + b_{1} } \right]}}{{\left[ {2a_{0} \left( {k + 1} \right)^{2} + b_{0} } \right]\left[ {2a_{1} \left( {k + 2} \right)^{2} + b_{1} } \right] + \left[ {2a_{1} \left( {k + 1} \right)^{2} + b_{1} } \right]\left[ {2a_{0} \left( {k + 2} \right)^{2} + b_{0} } \right]}}, $$
(3.1.6)

and defines a new basis, which satisfy both boundary conditions. This idea was introduced in Orszag [54] for two-point homogeneous Dirichlet boundary conditions, and in Orszag [55] for boundary conditions of the Orr-Sommerfeld equation. It was formalized for an arbitrary set of boundary conditions (3.1.1) in Gelfgat [16]. Note that for a similar problem defined on the interval \( 0 \le x \le A_{x} \) we need only to replace \( x \) by \( x/A_{x} \) in Eq. (3.1.2), while the expressions (3.1.5) and (3.1.6) will be only slightly altered.

3.2 Two-Dimensional Divergence-Free Basis

To construct basis functions, which are two-dimensional divergence-free vectors satisfying all the boundary conditions, we start from constructing a divergence-free basis that does not involve yet any boundary conditions. Using the Chebyshev polynomials, and assuming the flow region is a rectangle \( 0 \le x \le A_{x} , 0 \le y \le A_{y} \), we define

$$ \varvec{w}_{ij} = \left\{ {\begin{array}{*{20}c} {w_{ij}^{\left( x \right)} } \\ {w_{ij}^{\left( y \right)} } \\ \end{array} } \right\} = \left\{ {\begin{array}{*{20}c} {\frac{{A_{x} }}{2i}T_{i} \left( {\frac{x}{{A_{x} }}} \right)U_{j - 1} \left( {\frac{y}{{A_{y} }}} \right)} \\ { - \frac{{A_{y} }}{2j}U_{i - 1} \left( {\frac{x}{{A_{x} }}} \right)T_{j} \left( {\frac{y}{{A_{y} }}} \right)} \\ \end{array} } \right\},\quad i,j = 1,2,3, \ldots $$
(3.2.1)
$$ \varvec{w}_{0j} = \left\{ {\begin{array}{*{20}c} {\frac{{A_{x} }}{2}U_{j - 1} \left( {\frac{y}{{A_{y} }}} \right)} \\ 0 \\ \end{array} } \right\},\quad \varvec{w}_{i0} = \left\{ {\begin{array}{*{20}c} 0 \\ {\frac{{A_{y} }}{2}U_{i - 1} \left( {\frac{x}{{A_{x} }}} \right)} \\ \end{array} } \right\} $$
(3.2.2)

Applying the relation (A.2), it is easily seen that \( \nabla \cdot \varvec{w}_{ij} = 0 \). Now, to implement the boundary conditions and to keep the divergence zero, we keep the x- and y- components of the vector dependent on each other, like in (3.2.1). To do that we implement all the velocity boundary conditions in the x-direction in the x-dependent part of the vector, and do the same in the y-direction. In the x-direction the boundary conditions are posed at \( x = 0 \) and \( x = A_{x} \) for the two velocity components, so that we have four boundary conditions in total. The same takes place in the y-direction. Thus, we construct the basis using linear superpositions of five (4 + 1) consecutive Chebyshev polynomials. This results in

$$ \varvec{\varphi }_{ij} \left( {x,y} \right) = \left\{ {\begin{array}{*{20}c} {\frac{{A_{x} }}{2}\sum\nolimits_{m = 0}^{4} {\frac{{\sigma_{im} }}{i + m}T_{i + m} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\tau_{jm} U_{j + m - 1} \left( {\frac{y}{{A_{y} }}} \right)} } \\ { - \frac{{A_{y} }}{2}\sum\nolimits_{m = 0}^{4} {\sigma_{im} U_{i + m - 1} } \left( {\frac{x}{{A_{x} }}} \right)\sum\nolimits_{m = 0}^{4} {\frac{{\tau_{jm} }}{j + m}T_{j + m} \left( {\frac{y}{{A_{y} }}} \right)} } \\ \end{array} } \right\} $$
(3.2.3)

It is easy to check that \( \nabla \cdot \varvec{\varphi }_{ij} = 0 \). The coefficients \( \sigma_{im} \) and \( \tau_{jm} \) must be found by substituting \( \varvec{\varphi }_{ij} \) in the boundary conditions. For example, assume that the rectangle has a stress free boundary at \( y = A_{y} \), while all the other boundaries are no-slip. This leads to the following boundary conditions for velocity \( \varvec{v} \):

$$ \varvec{v}\left( {x = 0,y} \right) = \varvec{v}\left( {x = A_{x} ,y} \right) = \varvec{v}\left( {x,y = 0} \right) = 0, v_{y} \left( {x,y = A_{y} } \right) = \frac{{\partial v_{x} }}{\partial y}\left( {x,y = A_{y} } \right) = 0 $$
(3.2.4)

The assignment \( \sigma_{i0} = \tau_{i0} = 1 \) and substitution of (3.2.3) into (3.2.4) yields

$$ \sigma_{i1} = \sigma_{i3} = 0,\quad \sigma_{02} = - \frac{8}{3},\quad \sigma_{04} = \frac{4}{3} $$
(3.2.5)
$$ \sigma_{i2} = - \frac{i}{i + 2} - \frac{{\left( {i + 1} \right)\left( {i + 4} \right)^{2} }}{{i\left( {i + 2} \right)\left( {i + 3} \right)}},\quad \sigma_{i4} = \frac{{\left( {i + 1} \right)\left( {i + 4} \right)}}{{i\left( {i + 3} \right)}},\quad i > 0 $$
(3.2.6)
$$ \tau_{01} = \frac{2}{7},\quad \tau_{i1} = 2\frac{{i^{2} + 2i + 1}}{{i^{3} + 5i^{2} + 7i}},\quad i > 0 $$
(3.2.7)
$$ \tau_{02} = - \frac{16}{7},\quad \tau_{i2} = - 2\frac{{i^{4} + 8i^{3} + 26i^{2} + 40i + 24}}{{i^{4} + 8i^{3} + 22i^{2} + 21i}},\quad i > 0 $$
(3.2.8)
$$ \tau_{03} = - \frac{6}{7},\quad \tau_{i3} = - 2\frac{{i^{2} + 4i + 3}}{{i^{3} + 5i^{2} + 7i}},\quad i > 0 $$
(3.2.9)
$$ \tau_{04} = \frac{4}{7},\quad \tau_{i4} = \frac{{i^{4} + 8i^{3} + 22i^{2} + 27 + 12}}{{i^{4} + 8i^{3} + 22i^{2} + 21i}},\quad i > 0 $$
(3.2.10)

3.3 Three-Dimensional Divergence-Free Basis

Generalization of the 2D basis functions for a three-dimensional case is not straight-forward, since it is unclear how to produce divergent-free vectors, similar to those defined in (3.2.3), that will form a complete set of basis functions. To use a similar approach, we need to make several additional evaluations.

Assume that \( \varvec{v} = \left( {u,v,w} \right) \) is a divergence-free three-dimensional vector that satisfies the no-slip conditions on all the boundaries of the rectangular box \( 0 \le x \le A_{x} , 0 \le y \le A_{y} , 0 \le z \le A_{z} \). Since \( \nabla \cdot \varvec{v} = \partial u/\partial x + \partial v/\partial y + \partial w/\partial z = 0 \), so that \( w = - \smallint \left( {\partial u/\partial x + \partial v/\partial y} \right)dz \), a 3D incompressible vector field can be decomposed as

$$ \varvec{v} = \left( {\begin{array}{*{20}c} u \\ v \\ w \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} u \\ 0 \\ {w_{1} } \\ \end{array} } \right) + \left( {\begin{array}{*{20}c} 0 \\ v \\ {w_{2} } \\ \end{array} } \right),\quad w_{1} = - \int_{0}^{z} {\frac{\partial u}{\partial x}dz} ,\quad w_{2} = - \int_{0}^{z} {\frac{\partial v}{\partial y}dz} $$
(3.3.1)

Since both vectors \( \varvec{v}^{{\left( {x,z} \right)}} = \left( {u,0,w_{1} } \right) \) and \( \varvec{v}^{{\left( {y,z} \right)}} = \left( {0,v,w_{2} } \right) \) are divergence-free, this decomposition shows that the divergence-free velocity field can be represented as superposition of two fields having components only in the (x, z) or (y, z) planes. For each of two vectors we can construct basis functions similar to (3.2.3)

$$ \varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} \left( {x,y,z} \right) = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {\frac{{A_{x} }}{2}\sum\nolimits_{l = 0}^{4} {\frac{{\hat{a}_{il} }}{{\left( {i + l} \right)}}T_{i + l} \left( {\frac{x}{{A_{x} }}} \right)} \mathop \sum \limits_{m = 0}^{4} \hat{b}_{jm} T_{j + m} \left( {\frac{y}{{A_{y} }}} \right)\sum\nolimits_{n = 0}^{{\tilde{n}}} {\hat{c}_{kn} U_{k + n - 1} \left( {\frac{z}{{A_{z} }}} \right)} } \\ 0 \\ \end{array} } \\ { - \frac{{A_{z} }}{2}\sum\nolimits_{l = 0}^{4} {\hat{a}_{il} U_{i + l - 1} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\hat{b}_{jm} T_{j + m} \left( {\frac{y}{{A_{y} }}} \right)} \sum\nolimits_{n = 0}^{{\tilde{n}}} {\frac{{\hat{c}_{kn} }}{{\left( {k + n} \right)}}T_{k + n} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \right] $$
(3.3.2)
$$ \varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} \left( {x,y,z} \right) = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} 0 \\ {\frac{{A_{y} }}{2}\sum\nolimits_{l = 0}^{4} {\tilde{a}_{il} T_{i + l} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\frac{{\tilde{b}_{jm} }}{{\left( {j + m} \right)}}T_{j + m} \left( {\frac{y}{{A_{y} }}} \right)} \sum\nolimits_{n = 0}^{{\tilde{n}}} {\tilde{c}_{kn} U_{k + n - 1} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \\ { - \frac{{A_{z} }}{2}\sum\nolimits_{l = 0}^{4} {\tilde{a}_{il} T_{i + l} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\tilde{b}_{jm} U_{j + m - 1} \left( {\frac{y}{{A_{y} }}} \right)} \sum\nolimits_{n = 0}^{{\tilde{n}}} {\frac{{\tilde{c}_{kn} }}{{\left( {k + n} \right)}}T_{k + n} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \right] $$
(3.3.3)

As above, the coefficients \( \hat{a}_{il} \), \( \hat{b}_{jm} \), \( \hat{c}_{kn} \), \( \tilde{a}_{il} \), \( \tilde{b}_{jm} \), and \( \tilde{c}_{kn} \) are defined after substitution of the functions in the boundary conditions. Note that the number of polynomials included in the linear superpositions in z-direction, \( \tilde{n} + 1 \), is not defined yet. This is because at \( z = A_{z} \) only the sum \( w_{1} \left( {x,y,A_{z} } \right) + w_{2} \left( {x,y,A_{z} } \right) \) is zero, while the boundary values of \( w_{1} \left( {x,y,A_{z} } \right) \) and \( w_{2} \left( {x,y,A_{z} } \right) \) are not known. An example of such decomposition can be found in Gelfgat [39]. Therefore there are only three boundary conditions in the z-direction to be satisfied by the basis functions \( \varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} \) and \( \varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} \), so that \( \tilde{n} = 3 \). It is still possible to use these bases, but to satisfy the boundary conditions for \( w \) at \( z = A_{z} \), an additional algebraic constraints will be needed. Note that there is no such a problem if boundary conditions in the z-direction are periodic.

Let us assume now that \( \tilde{n} = 4 \) in (3.3.2) and (3.3.3), so that the functions \( \varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} \) and \( \varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} \) are divergence-free and satisfy all the boundary conditions. In this case, using (3.2.5) and (3.2.6),

$$ \hat{a}_{il} = \tilde{a}_{il} = \hat{b}_{il} = \tilde{b}_{il} = \hat{c}_{il} = \tilde{c}_{il} = \sigma_{il} ,\;\hat{b}_{j1} = \tilde{b}_{j1} = \hat{b}_{j3} = \tilde{b}_{j3} = \hat{b}_{j4} = \tilde{b}_{j4} = 0,\;\hat{b}_{j2} = \tilde{b}_{j2} = - \frac{{\left( {j + 2} \right)^{2} }}{{j^{2} }} $$
(3.3.4)

Projection of the solution \( \varvec{v} \) on \( span\left\{ {\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} } \right\} \) and \( span\left\{ {\varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} } \right\} \) results in a vector \( \tilde{\varvec{v}} \)

$$ \tilde{\varvec{v}} = \left( {\begin{array}{*{20}c} {\tilde{u}} \\ 0 \\ {\tilde{w}_{1} } \\ \end{array} } \right) + \left( {\begin{array}{*{20}c} 0 \\ {\tilde{v}} \\ {\tilde{w}_{2} } \\ \end{array} } \right), $$
(3.3.5)

which is divergence-free, satisfies all the boundary conditions, but may not be a good approximation of \( \varvec{v} \) because set of the basis functions still is not complete. To complete the basis we notice that \( span\left\{ {\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} } \right\} \) and \( span\left\{ {\varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} } \right\} \) project the velocity on the \( \left( {x,z} \right) \) and \( \left( {y,z} \right) \) planes, so that it is straight-forward to add projections on the \( \left( {x,y} \right) \) planes as well. Thus, similarly to (3.3.2) and (3.3.3) we add another set of divergence-free basis functions satisfying all the boundary conditions

$$ \varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} \left( {x,y,z} \right) = \left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} {\frac{{A_{x} }}{2}\sum\nolimits_{l = 0}^{4} {\frac{{\bar{a}_{il} }}{{\left( {i + l} \right)}}T_{i + l} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\bar{b}_{jm} U_{j + m - 1} \left( {\frac{y}{{A_{y} }}} \right)} \sum\nolimits_{n = 0}^{4} {\bar{c}_{kn} T_{k + n} \left( {\frac{z}{{A_{z} }}} \right)} } \\ {\frac{{ - A_{y} }}{2}\sum\nolimits_{l = 0}^{4} {\bar{a}_{il} U_{i + l - 1} \left( {\frac{x}{{A_{x} }}} \right)} \sum\nolimits_{m = 0}^{4} {\frac{{\bar{b}_{jm} }}{{\left( {j + m} \right)}}T_{j + m} \left( {\frac{y}{{A_{y} }}} \right)} \sum\nolimits_{n = 0}^{4} {\bar{c}_{kn} T_{k + n} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \\ 0 \\ \end{array} } \right] $$
(3.3.6)

Similarly to the previous functions, for the no-slip boundary conditions posed on all boundaries,

$$ \bar{a}_{il} = \bar{b}_{il} = \sigma_{il} ,\quad \bar{c}_{k1} = \bar{c}_{k3} = \bar{c}_{k4} = 0,\quad \bar{c}_{k2} = - \frac{{\left( {k + 2} \right)^{2} }}{{k^{2} }} $$
(3.3.7)

Finally, we are looking for a three-dimensional solution as

$$ \begin{aligned} \varvec{v} & \approx \mathop \sum \limits_{i = 0}^{{L^{{\left( {x,y} \right)}} }} \mathop \sum \limits_{j = 0}^{{M^{{\left( {x,y} \right)}} }} \mathop \sum \limits_{k = 0}^{{N^{{\left( {x,y} \right)}} }} C_{i,j,k}^{{\left( {x,y} \right)}} \left( t \right)\varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} \left( {x,y,z} \right) \\ & \quad + \mathop \sum \limits_{i = 0}^{{L^{{\left( {x,z} \right)}} }} \mathop \sum \limits_{j = 0}^{{M^{{\left( {x,z} \right)}} }} \mathop \sum \limits_{k = 0}^{{N^{{\left( {x,z} \right)}} }} C_{i,j,k}^{{\left( {x,z} \right)}} \left( t \right)\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} \left( {x,y,z} \right) \\ & \quad + \mathop \sum \limits_{i = 0}^{{L^{{\left( {y,z} \right)}} }} \mathop \sum \limits_{j = 0}^{{M^{{\left( {y,z} \right)}} }} \mathop \sum \limits_{k = 0}^{{N^{{\left( {y,z} \right)}} }} C_{i,j,k}^{{\left( {y,z} \right)}} \left( t \right)\varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} \left( {x,y,z} \right) \\ \end{aligned} $$
(3.3.8)

Projection of residual of the momentum equation on all three bases yields three sets of ODEs for calculation of the three sets of time-dependent coefficients \( C_{i,j,k}^{{\left( {x,y} \right)}} , C_{i,j,k}^{{\left( {x,z} \right)}} \), and \( C_{i,j,k}^{{\left( {y,z} \right)}} \). Since the basis functions are not orthogonal it will be necessary to inverse the Gram matrix that is formed as

$$ G = \left[ {\begin{array}{*{20}c} {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,y} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,z} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {y,z} \right)}} } \right\rangle } \\ {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,y} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,z} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {y,z} \right)}} } \right\rangle } \\ {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {y,x} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,y} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {y,x} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {x,z} \right)}} } \right\rangle } & {\left\langle {\varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} ,\varvec{\varphi }_{pqr}^{{\left( {y,z} \right)}} } \right\rangle } \\ \end{array} } \right] $$
(3.3.9)

A simple numerical test for the no-slip boundary conditions and equal truncation numbers (starting from 4 and larger) in each direction and for each set of the functions shows that the Gram matrix is singular. This means that some of the functions are linear dependent and must be excluded. Basing on the above discussion, we see that in the case of periodic boundary conditions in the z-direction, all the set (3.3.6) can be omitted. However, some functions of this set must be added in the case of no-slip boundaries. This shows that the complete set of linearly independent basis functions differs for different boundary conditions. Unfortunately, the author could not arrive to a rigorous mathematical procedure that would allow one to know which functions must be excluded at certain boundary conditions. At the same time, a simple numerical experiment can be helpful.

Considering the no-slip conditions at all the boundaries, we varied \( N^{{\left( {y,z} \right)}} \) in the last sum of Eq. (3.3.7). In other words, we varied truncation number in the z-direction for the functions defined in (3.3.6) only. We found that taking \( N^{{\left( {y,z} \right)}} = 0 \), i.e., one basis function in the z-direction, we obtain a regular Gram matrix. Increase of \( N^{{\left( {y,z} \right)}} \) to \( N^{{\left( {y,z} \right)}} \ge 1 \), makes the Gram matrix singular. Furthermore, taking a single basis function in the z-direction, with the third index \( k \ge 1 \), which means polynomials of larger degrees in (3.3.6), also results in a singular Gram matrix. This shows that the addition of the first polynomial in the z-direction, corresponding to \( N^{{\left( {y,z} \right)}} = 0 \), is essential, while all the other can be omitted. Using (3.3.7), this first polynomial is \( 8\left( {z - z^{2} } \right) \). Returning to the sets (3.3.2) and (3.3.3) with the coefficients defined in (3.3.4), we observe that the polynomials corresponding to the x- and y- vector components start form the second degree, while those corresponding to the z-component start from the third one. Thus, the missing polynomial of the degree two must be added with the help of another set (3.3.6).

3.4 Basis Functions in Cylindrical Coordinates

Consider flow in a cylinder with radius R and height H. The whole problem is defined now in the cylindrical coordinates \( \left( {r,\theta ,z} \right), 0 \le r \le R, 0 \le \theta \le 2\pi , 0 \le z \le H \). Using \( 2\pi \)-periodicity in the azimuthal direction we represent the flow as a Fourier series

$$ \varvec{v} = \sum\nolimits_{k = - \infty }^{\infty } {\varvec{v}_{k} \left( {r,z} \right)exp\left( {ik\theta } \right)} , $$
(3.4.1)

so that the basis functions in the \( \theta \)-direction are complex exponents \( exp\left( {ik\theta } \right) \). The continuity equation for \( \varvec{v}_{k} \left( {r,z} \right) = \left( {u_{k} \left( {r,z} \right),v_{k} \left( {r,z} \right),w_{k} \left( {r,z} \right)} \right) \) is

$$ \frac{1}{r}\frac{{\partial \left( {ru_{k} } \right)}}{\partial r} + \frac{ik}{r}v_{k} + \frac{{\partial w_{k} }}{\partial z} = 0 $$
(3.4.2)

Here we must distinguish between the axisymmetric case and axisymmetric Fourier mode, for which \( k = 0 \), and all the others \( k \ne 0 \) modes. The axisymmetric flow (axisymmetric mode) is represented by a single set of the basis functions, which is built similarly to the above 2D Cartesian case, but with taking into account the continuity Eq. (3.4.2). Note that if an axisymmetric flow has also a non-zero azimuthal component, the latter can be treated as a scalar function. Then the axisymmetric vector basis should include only the radial and axial components. An example of such basis, successfully used in several studies (see below) is

$$ \varvec{U}_{ij} \left( {r,z} \right) = \left\{ {\begin{array}{*{20}c} {u_{0} } \\ {w_{0} } \\ \end{array} } \right\} = \left\{ {\begin{array}{*{20}c} {\frac{1}{2}\frac{r}{R}\sum\nolimits_{m = 0}^{4} {\frac{{\sigma_{im} }}{i + m}T_{i + m} \left( {\frac{r}{R}} \right)} \sum\nolimits_{m = 0}^{4} {\mu_{jm} U_{j + m - 1} \left( {\frac{z}{{A_{z} }}} \right)} } \\ { - \frac{{A_{z} }}{2}\sum\nolimits_{m = 0}^{4} {\sigma_{im} \tilde{U}_{i + m - 1} \left( {\frac{r}{R}} \right)} \sum\nolimits_{m = 0}^{4} {\frac{{\mu_{jm} }}{j + m}T_{j + m} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \right\}, $$
(3.4.3)

where \( \tilde{U}_{n} \left( {\frac{r}{R}} \right) = T_{n + 1} \left( {\frac{r}{R}} \right) + r\left( {n + 1} \right)U_{n} \left( {\frac{r}{R}} \right) \). As above, the zero divergence of \( \varvec{U}_{ij} \left( {r,z} \right) \) follows from Eq. (A.2), and the coefficients \( \sigma_{im} \) and \( \mu_{jm} \) are obtained by substitution of \( \varvec{U}_{ij} \left( {r,z} \right) \) in the boundary conditions. Note also that r-component of velocity vanishes at the polar axis \( r = 0 \), so that for flow in a cylinder only 3 conditions in the radial direction must be additionally satisfied. If the domain is a cylindrical layer (e.g., Taylor-Couette flow) then the polar axis is cut out and one remains with the four boundary conditions, as in the Cartesian coordinates case.

Now consider Fourier modes of (3.4.1) corresponding to \( k \ne 0 \). Using the same idea as in Eq. (3.1.1) we observe that

$$ \varvec{v}_{k} = \left( {\begin{array}{*{20}c} {u_{k} } \\ {v_{k} } \\ {w_{k} } \\ \end{array} } \right) = \left( { - \begin{array}{*{20}c} {u_{k} } \\ {\frac{1}{ik}\frac{{\partial \left( {ru_{k} } \right)}}{\partial r}} \\ 0 \\ \end{array} } \right) + \left( { - \frac{r}{ik}\begin{array}{*{20}c} 0 \\ {\frac{{\partial w_{k} }}{\partial z}} \\ {w_{k} } \\ \end{array} } \right). $$
(3.4.4)

Obviously, the sum of two azimuthal components of this relation satisfies the boundary conditions for \( \varvec{v}_{k} \). It is not clear, however, whether each of them satisfies the boundary conditions separately. The author is not sure that this can be proved for a general case, but it can be easily examined for the no-slip conditions at \( r = R \) and \( z = 0,H \). Since \( w_{k} \left( {r = R} \right) = 0 \) the derivative \( \partial w_{k} /\partial z \) also vanishes at \( r = R \). Since the sum of two azimuthal components vanishes at \( r = R \), the azimuthal component of the first vector of the r.h.s also vanishes there, so that each component satisfies boundary conditions in the radial direction. Similarly, we consider \( \partial \left( {ru_{k} } \right)/\partial r \) at \( z = 0, H \) and conclude that it vanishes there because \( u_{k} \left( {r,0} \right) = u_{k} \left( {r,H} \right) = 0 \). Then also the second azimuthal component vanishes at \( z = 0, H \), and all the no-slip boundary conditions for the azimuthal velocity, as well as the condition at the axis, are satisfied by each r.h.s. vector of (3.4.4) separately. Thus, considering flows with the no-slip cylindrical boundaries, we can decompose \( \varvec{v}_{k \ne 0} \) into two independent bases, so that the whole flow will be represented as

$$ \varvec{v} = \sum\nolimits_{i = 0}^{{M_{r} }} {\sum\nolimits_{j = 0}^{{M_{z} }} {A_{ij} \left( t \right)U_{ij} \left( {r,z} \right)} } + \sum\nolimits_{{\begin{array}{*{20}c} {k = - \infty } \\ {k \ne 0} \\ \end{array} }}^{k = + \infty } {\left\{ {\sum\nolimits_{i = 0}^{{N_{r} }} {\sum\nolimits_{j = 0}^{{N_{z} }} {\left[ {B_{ij}^{k} \left( t \right)V_{ij} \left( {r,z} \right) + C_{ij}^{k} \left( t \right)W_{ij} \left( {r,z} \right)} \right]} } } \right\}exp\left( {ik\theta } \right)} $$
(3.4.5)

Here \( U_{ij} \left( {r,z} \right) \) represent the axisymmetric part of the flow and are defined in (3.4.3). \( V_{ij} \left( {r,z} \right) \) and \( W_{ij} \left( {r,z} \right) \) represent the two vectors in r.h.s. of (3.4.4) and are defined as

$$ \varvec{V}_{ij} \left( {r,z} \right) = \left\{ {\begin{array}{*{20}c} { - ik\left( {\frac{r}{R}} \right)^{q} \sum\nolimits_{m = 0}^{4} {\bar{\sigma }_{im} T_{i + m} \left( {\frac{r}{R}} \right)} \sum\nolimits_{l = 0}^{4} {\bar{\mu }_{jl} T_{j + l} \left( {\frac{z}{{A_{z} }}} \right)} } \\ {\sum\nolimits_{m = 0}^{4} {\bar{\sigma }_{im} \bar{U}_{i + m - 1} \left( {\frac{r}{R}} \right)} \sum\nolimits_{l = 0}^{4} {\bar{\mu }_{jl} T_{j + l} \left( {\frac{z}{{A_{z} }}} \right)} } \\ {0}\end{array} } \right\}, $$
(3.4.5)
$$ \varvec{W}_{ij} \left( {r,z} \right) = \left\{ {\begin{array}{*{20}c} {0} \\ {\left( {\frac{r}{R}} \right)^{2} \sum\nolimits_{m = 0}^{4} {\overline{\overline{\sigma }}_{im} T_{i + m} \left( {\frac{r}{R}} \right)} \sum\nolimits_{l = 0}^{4} {\overline{\overline{\mu }}_{jl} U_{j + l - 1} \left( {\frac{z}{{A_{z} }}} \right)} } \\ { - \frac{{ikA_{z} }}{2}r\sum\nolimits_{m = 0}^{4} {\overline{\overline{\sigma }}_{im} T_{i + m} \left( {\frac{r}{R}} \right)} \sum\nolimits_{l = 0}^{4} {\frac{{\overline{\overline{\mu }}_{jl} }}{j + l}T_{j + l} \left( {\frac{z}{{A_{z} }}} \right)} } \\ \end{array} } \right\}, $$
(3.4.6)

Here \( q = 0 \) for \( \left| k \right| = 1 \) and \( q = 1 \) for \( \left| k \right| > 1 \), \( \bar{U}_{n} \left( x \right) = \left( {q + 1} \right)r^{q} T_{n} \left( x \right) + 2nr^{q + 1} U_{n - 1} \left( x \right) \). Again, the zero divergence of the functions \( \varvec{V}_{ij} \left( {r,z} \right)exp\left( {ik\theta } \right) \) and \( \varvec{W}_{ij} \left( {r,z} \right)exp\left( {ik\theta } \right) \) follow from Eqs. (3.4.2) and (A.2), and the coefficients \( \bar{\sigma }_{im} \), \( \bar{\mu }_{jm} \), \( \overline{\overline{c}}_{im} \), and \( \overline{\overline{\mu }}_{jm} \) are defined after substitution of (3.4.5) and (3.4.6) in the boundary conditions. The integer parameter q appears because of different boundary conditions posed for \( \left| k \right| = 1 \) and \( \left| k \right| \ne 1 \) at the polar axis [9, 23], which are

At \( r = 0 \): \( u_{k = 0} = 0, v_{k = 0} = 0, \frac{{\partial w_{k = 0} }}{\partial r} = 0 \)

$$ \begin{aligned} & u_{k = \pm 1} \ne 0, v_{k = \pm 1} \ne 0, w_{k = \pm 1} = 0 \\ & u_{\left| k \right| > 1} = 0, v_{\left| k \right| > 1} = 0, w_{\left| k \right| > 1} = 0 \\ \end{aligned} $$
(3.4.7)

For the no-slip conditions at the top, bottom and sidewall of the cylinder the coefficients \( \sigma_{im} \), \( \mu_{jm} \), \( \bar{\sigma }_{im} \), \( \bar{\mu }_{jm} \), \( \overline{\overline{\sigma }}_{im} \), and \( \overline{\overline{\mu }}_{jm} \) are defined as

$$ \sigma_{i1} = - \frac{{i^{3} + 7i^{2} + 15i + 9}}{{i^{3} + 6i^{2} + 12i + 8}},\quad \sigma_{i2} = - \frac{{i^{2} }}{{\left( {i + 2} \right)^{2} }},\quad \sigma_{i3} = \frac{{i^{3} + 3i^{2} + 3i + 1}}{{i^{3} + 6i^{2} + 12i + 8}},\quad \sigma_{i4} = 0 $$
(3.4.8)
$$ \bar{\sigma }_{i1} = - \frac{{4\left( {i + 1} \right)}}{2i + 3},\quad \bar{\sigma }_{i2} = \frac{2i + 1}{2i + 3},\quad \bar{\sigma }_{i3} = \frac{2i + 1}{{4\left( {i + 2} \right)}},\quad \bar{\sigma }_{i4} = 0 $$
(3.4.9)
$$ \overline{\overline{\sigma }}_{i1} = - 1,\quad \overline{\overline{\sigma }}_{i2} = 0,\quad \overline{\overline{\sigma }}_{i3} = 0,\quad \overline{\overline{\sigma }}_{i4} = 0 $$
(3.4.10)
$$ \mu_{i1} = \mu_{i3} = \overline{\overline{\mu }}_{i1} = \overline{\overline{\mu }}_{i3} = 0,\quad 4\mu_{02} = \overline{\overline{\mu }}_{02} = - \frac{8}{3}, \mu_{04} = \overline{\overline{\mu }}_{04} = \frac{4}{3}; $$
(3.4.11)
$$ \mu_{i2} = \overline{\overline{\mu }}_{i2} = - \frac{i}{i + 2} - \frac{{\left( {i + 1} \right)\left( {i + 4} \right)^{2} }}{{i\left( {i + 2} \right)\left( {i + 3} \right)}},\quad \mu_{i4} = \overline{\overline{\mu }}_{i4} = \frac{{\left( {i + 1} \right)\left( {i + 4} \right)}}{{i\left( {i + 3} \right)}} , i > 0 $$
(3.4.12)
$$ \bar{\mu }_{i1} = \bar{\mu }_{i3} = \bar{\mu }_{i4} = 0,\quad \bar{\mu }_{i2} = - 1 $$
(3.4.13)

This example of divergence-free basis functions built for cylindrical geometries also shows how construction of divergence free basis satisfying all the boundary conditions can be approached in other orthogonal coordinate systems. The process can be noticeably simplified if two periodic spatial coordinates are involved in the formulation of the problem. In these cases only one-dimensional basis based on the linear superpositions will be needed. Alternatively, the divergence-free basis in cylindrical and spherical coordinates with two periodic directions can be defined as in Messeguer and Melibovsky [51] or Dumas and Leonard [11].

4 Inhomogeneous Boundary Conditions

If the problem has inhomogeneous boundary conditions, they can be included as additional algebraic constraints. A better way would be a change of variables so that all inhomogeneities are moved from the boundary conditions to the equations. Then the boundary conditions will become homogeneous, and the corresponding basis functions can be built as in the Sect. 3.4. We assume, of course, that all the boundary conditions are linear. Such change of variables can use analytical, as well as numerically calculated functions. Several examples of that, successfully applied to different problems, are briefly described below.

The simplest example for the change of variables is convection in a box, which has constant temperatures at the opposite sides, while all the other boundaries are perfectly thermally conducting or perfectly insulated. In the first case the temperature varies linearly along these boundaries, while in the second case normal to the boundary temperature derivative must vanish. These boundary conditions are satisfied by the linear temperature profile, which corresponds to the temperature distribution in a purely conducting case. For example, if for the dimensionless temperature \( \theta \left( {x,y,z} \right) \), the boundary conditions in the x-direction are \( \theta \left( {x = 0,y,z} \right) = 1, \theta \left( {x = 1,y,z} \right) = 0 \), the change of variable is \( \theta = \left( {1 - x} \right) + \tilde{\theta }\left( {x,y,z} \right) \). The function \( \left( {1 - x} \right) \) satisfies all homogeneous and inhomogeneous boundary conditions, so that all the boundary conditions for new unknown function \( \tilde{\theta }\left( {x,y,z} \right) \) are homogeneous. This change of variables was applied in all cited works of Gelfgat that treated convection in rectangular cavities starting from Gelfgat and Tanasawa [17].

The inhomogeneities can be excluded from the boundary conditions by extracting a known analytical function from the solution only if the boundary conditions are continuous, including continuity at the corners of the computational domain. Another example of this is parabolic heating of a vertical cylinder that was considered in Gelfgat et al. [25, 28]. The dimensionless temperature at the cylindrical sidewall was prescribed as \( \theta \left( {r = 1,z} \right) = f\left( z \right) = z\left( {1 - z/A} \right), 0 \le z \le A \), and was zero at the top and bottom, \( z = 0,A \). Since the function \( f\left( z \right) \) vanishes at the top and the bottom, the simplest change of variables in this case is \( \theta = f\left( z \right) + \tilde{\theta }\left( {r,z} \right) \), which was applied in the mentioned studies.

Clearly, when the boundary conditions are discontinuous, use of a simple analytical function for the change of variables becomes problematic. Such function can be built, for example, as a solution of Laplace equation with the discontinuous boundary conditions needed. The analytical solution of the latter will suffer from the Gibbs phenomenon that may destroy the convergence of the whole process. On the other hand, a low-order numerical solution can smooth the discontinuity up to acceptable level, as it happens in many calculations of lid-driven cavity flow, however this will take us too far from our Chebyshev polynomials based Galerkin approach. Thus, for calculation of the lid-driven cavity flow in Gelfgat [35] we used analytically smoothed boundary condition, then solved the Stokes problem with the smoothed boundary conditions, and then used the Stokes problem solution for change of variables. The Stokes problem was solved using the same Galerkin approach.

In the studies considering swirling flows in a cylinder with rotating lid, as well as independently rotating top, bottom and sidewall of the cylinder [18, 19, 27, 49] we solved the Stokes problem for the azimuthal velocity component. A similar Galerkin method in scalar formulation was applied. The boundary conditions with discontinuities in the corners were included as additional algebraic constraints by adding collocation points along the boundaries.

A more complicated case was treated in Erenburg et al. [12]. There we considered convection in a rectangular cavity with partially heated and partially insulated sidewall as is sketched in Fig. 1. All the boundaries are no-slip. The dimensionless boundary conditions for the temperature are (here \( A = H/L, a_{1} = h_{1} /L, a_{2} = h_{2} /L \))

Fig. 1
figure 1

Sketch of the temperature boundary conditions of the problem of Erenburg et al. [12]

$$ \theta \left( {x;y = 0,A} \right) = 0, $$
(4.1)
$$ \theta \left( {x = 0,1; a_{1} \le y \le a_{2} } \right) = 1, $$
(4.2)
$$ \frac{\partial \theta }{\partial x}\left( {x = 0,1;y < a_{1} \,or\,y > a_{2} } \right) = 0. $$
(4.3)

To arrive to a formulation with continuous and homogeneous boundary conditions on all the boundaries for a single unknown function, we split the temperature into two functions

$$ \theta \left( {x,y,t} \right) =\Theta \left( {x,y,t} \right) + \tilde{\theta }\left( {x,y,t} \right) $$
(4.4)

where \( \tilde{\theta }\left( {x,y,t} \right) \) is the new unknown function for which a continuous set of boundary conditions is required, i.e.,

$$ \tilde{\theta }\left( {x;y = 0,A} \right) = 0,\quad \frac{{\partial \tilde{\theta }}}{\partial x}\left( {x = 0,1;y} \right) = 0 $$
(4.5)

The function \( \Theta \left( {x,y,t} \right) \) is used to adjust the boundary conditions for \( \theta \left( {x,y,t} \right) \) to (4.1)–(4.3). Therefore, the boundary conditions for \( \Theta \left( {x,y,t} \right) \) are

$$ \Theta \left( {x;y = 0,A} \right) = 0, $$
(4.6)
$$ \Theta \left( {x = 0,1;a_{1} \le y \le a_{2} } \right) = 1 - \tilde{\theta }, $$
(4.7)
$$ \frac{{\partial\Theta }}{\partial x}\left( {x = 0,1;y < a_{1} \,or\,y > a_{2} } \right) = 0 $$
(4.8)

To avoid the appearance of an additional source term in the energy equation we also require that \( \Theta \left( {x,y,t} \right) \) be a solution of the Laplace equation,

$$ \Delta\Theta = 0. $$
(4.9)

The solution of problem (4.6)–(4.9) can be represented as

$$ \Theta \left( {x,y,t} \right) =\Theta _{0} \left( {x,y,t} \right) +\Theta _{1} \left( {x,y,t} \right) $$
(4.10)

where \( \Theta _{0} \left( {x,y,t} \right) \) is the part of the solution of (4.6)–(4.9) corresponding to \( \tilde{\theta } = 0 \) and \( \Theta _{1} \left( {x,y,t} \right) \) is the part dependent on \( \tilde{\theta } \). Both functions \( \Theta _{0} \) and \( \Theta _{1} \) are calculated numerically by the Galerkin method inside the cavity and collocation points at the sidewalls. Obviously, the part \( \Theta _{0} \left( {x,y,t} \right) \) is defined by the geometry of the problem only, and is time-independent, so that it must be calculated only once. The problem formulation for \( \Theta _{1} \left( {x,y,t} \right) \) is straight-forward, and its solution can be presented as \( \Theta _{1} = L^{ - 1} \tilde{\theta } \), where \( L \) is the operator defining the problem, and approximated by its Galerkin/collocation projection. The representation of the temperature (4.4) now becomes

$$ \theta \left( {x,y,t} \right) =\Theta \left( {x,y,t} \right) + \tilde{\theta }\left( {x,y,t} \right) =\Theta _{0} + \left( {L^{ - 1} + I} \right)\tilde{\theta }, $$
(4.11)

where \( I \) is the identity operator. The energy equation becomes

$$ \left( {L^{ - 1} + I} \right)\frac{{\partial \tilde{\theta }}}{\partial t} + \left( {\varvec{v} \cdot \nabla } \right)\left( {L^{ - 1} + I} \right)\tilde{\theta } = \frac{1}{Pr}\Delta \left( {L^{ - 1} + I} \right)\tilde{\theta } - \left( {\varvec{v} \cdot \nabla } \right)\Theta _{0} . $$
(4.12)

Thus, after the function \( \Theta _{0} \) and the operator \( \left( {L^{ - 1} + I} \right) \) are calculated, the remaining problem for \( \tilde{\theta } \) is defined with the homogeneous boundary conditions (4.5) only. Other details can be found in Erenburg et al. [12].

5 Basis Functions for Two-Fluid Flow and Boundary Conditions at Liquid-Liquid Interface

Here we give an example of basis functions that were used to calculate a two-phase flow with a capillary interface separating two liquids. A two-fluid Dean flow sketched in Fig. 2 was considered in Gelfgat et al. [30]. The two fluids occupy adjacent thin cylindrical layers, \( a \le r \le a + b \) and \( a + b \le r \le a + d \), respectively, with the assumption \( \bar{a} = a/d \gg 1 \). The two fluids are separated by the border \( r = a + b \). The base flow in both fluids is driven by an azimuthal pressure gradient. This formulation is an extension of the classical Dean [10] problem to two-fluid system and is a simplified model of flow in a curved channel. Here we leave all the details on the evaluation of base flow and formulation of the stability problem to Gelfgat et al. [30], and focus only on the boundary conditions and incorporation of them into the basis functions. The three-dimensional velocity perturbation in the cylindrical coordinates is defined as \( \varvec{v} = \left( {u\left( x \right),v\left( x \right),w\left( x \right)} \right)exp\left( {\lambda t + in\theta + ikz} \right) \). For convenience, we define a new dimensionless coordinate \( x = \left( {r - a} \right)/d \), and define \( \bar{b} = \left( {b - a} \right)/d \). The dimensionless amplitude of the interface perturbation is \( \bar{\delta } \). Indices 1 and 2 denote the variables in each sublayer, \( \rho_{12} = \rho_{1} /\rho_{2} \) and \( \mu_{12} = \mu_{1} /\mu_{2} \) are the ratio of densities and viscosities, respectively. After the axial velocity \( w \) and the pressure \( p \) are excluded from the equations system, the boundary conditions for the radial and azimuthal components at the borders and the interface read

Fig. 2
figure 2

Sketch of the two-fluid Dean flow problem

$$ x = 0: \quad u_{1} = v_{1} = \frac{{du_{1} }}{dx} = 0 $$
(5.1)
$$ x = 1:\quad u_{2} = v_{2} = \frac{{du_{2} }}{dx} = 0 $$
(5.2)
$$ x = \bar{b}: \quad u_{1} = u_{2} , v_{1} = v_{2} $$
(5.3)
$$ \frac{{du_{1} }}{dx} = \frac{{du_{2} }}{dx} $$
(5.4)
$$ \frac{{dv_{1} }}{dx} = \mu_{12} \frac{{dv_{2} }}{dx} $$
(5.5)
$$ \frac{{d^{2} u_{1} }}{{dx^{2} }} + k^{2} u_{1} = \mu_{12} \left[ {\frac{{d^{2} u_{2} }}{{dx^{2} }} + k^{2} u_{2} } \right] $$
(5.6)
$$ \lambda \bar{\delta } = u_{1} - \frac{in}{{\bar{b}}}V\bar{\delta } $$
(5.7)
$$ \begin{aligned} \lambda \left[ {\rho_{12} \frac{{du_{2} }}{dx} - \frac{{du_{1} }}{dx}} \right] & = \frac{{\bar{\delta }}}{{\bar{a}}}k^{2} \left( {\rho_{12} - 1} \right)V^{2} + \frac{1}{Re}\left[ {\frac{{d^{2} }}{{dx^{2} }} - 2\frac{d}{dx} - k^{2} } \right]\left( {\mu_{12} u_{2} - u_{1} } \right) \\ & \quad - \rho_{12} \frac{in}{{\bar{a}}}V\frac{d}{dx}\left( {\rho_{12} u_{2} - u_{1} } \right) - \frac{{k^{2} }}{We}\left[ {\frac{{1 - n^{2} }}{{\bar{b}^{2} }} - k^{2} } \right]\bar{\delta } \\ \end{aligned} $$
(5.8)

To build basis functions, we start from a particular case of non-deformable interface. In this case we add \( u_{1} = u_{2} = 0 \) to the boundary condition (5.3) and omit (5.7) and (5.8). Then the unknowns \( u\left( x \right) \) and \( v\left( x \right) \) are approximated by truncated series

$$ u\left( x \right) = \sum\nolimits_{m = 1}^{N} {c_{m} \left( t \right)\psi_{m} \left( x \right)} ,\quad v\left( x \right) = \sum\nolimits_{l = 1}^{N} {d_{m} \left( t \right)\varphi_{m} \left( x \right)} , $$
(5.9)

where

$$ \varphi_{m} \left( x \right) = \left\{ {\begin{array}{*{20}l} {\sum\nolimits_{l = 0}^{2} {\alpha_{ml}^{\left( 1 \right)} T_{m + l} } ,} \hfill & {0 \le x \le \bar{b}} \hfill \\ {\sum\nolimits_{l = 0}^{2} {\alpha_{ml}^{\left( 2 \right)} T_{m + l} } ,} \hfill & {\bar{b} \le x \le 1} \hfill \\ \end{array} } \right., $$
(5.10)
$$ \psi_{m} \left( x \right) = \left\{ {\begin{array}{*{20}l} {\sum\nolimits_{l = 0}^{4} {\beta_{ml}^{\left( 1 \right)} T_{m + l} \left( {\frac{x}{{\bar{b}}}} \right),} } \hfill & {0 \le x \le \bar{b}} \hfill \\ {\sum\nolimits_{l = 0}^{4} {\beta_{ml}^{\left( 2 \right)} T_{m + l} \left( {\frac{{x - \bar{b}}}{{1 - \bar{b}}}} \right),} } \hfill & {\bar{b} \le x \le 1} \hfill \\ \end{array} } \right.. $$
(5.11)

Here the superscripts \( \left( 1 \right) \) and \( \left( 2 \right) \) denote the sublayers. The coefficients \( \alpha_{ml}^{\left( 1 \right)} , \alpha_{ml}^{\left( 2 \right)} , \beta_{ml}^{\left( 1 \right)} \), and \( \beta_{ml}^{\left( 2 \right)} \) are obtained after substitution of the basis functions (5.11) in the boundary conditions (5.1)–(5.6). The inner product is defined as

$$ \left\langle {f,g} \right\rangle = \int_{0}^{1} {f\left( x \right)g\left( x \right)dx} = \int_{0}^{{\bar{b}}} {f\left( x \right)g\left( x \right)} dx + \int_{{\bar{b}}}^{1} {f\left( x \right)g\left( x \right)} dx. $$
(5.12)

and after application of the Galerkin method, the time-dependent coefficients \( c_{m} \left( t \right) \) and \( d_{m} \left( t \right) \) are the same for the whole domain.

For the linear stability problem with deformable interface the solution is represented as

$$ u\left( x \right) = c_{0} \left( t \right)\phi \left( x \right) + \mathop \sum \limits_{m = 1}^{N} c_{m} \left( t \right)\psi_{m} \left( x \right),\quad v\left( x \right) = \mathop \sum \limits_{l = 1}^{N} d_{m} \left( t \right)\varphi_{m} \left( x \right) . $$
(5.13)

The bases \( \varphi_{m} \left( x \right) \) and \( \psi_{m} \left( x \right) \) remain unchanged. An additional function \( \phi \left( x \right) \) is introduced to satisfy the boundary conditions for deformable interface (5.7) and (5.8). It is defined as

$$ \phi \left( x \right) = \left\{ {\begin{array}{*{20}l} {\sum\nolimits_{l = 0}^{4} {\gamma_{ql}^{\left( 1 \right)} T_{q + l} \left( {\frac{x}{{\bar{b}}}} \right)} ,} \hfill & {0 \le x \le \bar{b}} \hfill \\ {\sum\nolimits_{l = 0}^{4} {\gamma_{ql}^{\left( 2 \right)} T_{q + l} \left( {\frac{{x - \bar{b}}}{{1 - \bar{b}}}} \right)} ,} \hfill & {\bar{b} \le x \le 1} \hfill \\ \end{array} } \right.. $$
(5.14)

The coefficients \( \gamma_{ql}^{\left( 1 \right)} \) and \( \gamma_{ql}^{\left( 2 \right)} \) are defined to satisfy the boundary conditions (5.1), (5.2), (5.4) and (5.6) subject to the normalization condition \( \phi \left( {\bar{b}} \right) = 1 \). Choice of the index \( q \) is arbitrary, e.g., \( q = 0 \).

With the normalization condition \( \phi \left( {\bar{b}} \right) = 1 \) applied, the coefficient \( c_{0} \) can be interpreted as the amplitude of the radial velocity at the deformed interface. This coefficient, and the interface amplitude \( \bar{\delta } \), are defined by the two remaining boundary conditions (5.7) and (5.8). Thus, the Galerkin projections of the governing equations together with the boundary conditions (5.7) and (5.8) form a closed algebraic system for calculation of the coefficients \( c_{m} \) and \( d_{m} \) together with two additional unknown scalars \( d_{m} \) and \( \bar{\delta } \). The stability problem reduces to a generalized eigenvalue problem. In Gelfgat et al. [30] coefficients of the basis functions \( \alpha_{ml}^{\left( 1 \right)} , \alpha_{ml}^{\left( 2 \right)} , \beta_{ml}^{\left( 1 \right)} \), \( \beta_{ml}^{\left( 2 \right)} \), \( \gamma_{ql}^{\left( 1 \right)} \), and \( \gamma_{ql}^{\left( 2 \right)} \) were obtained by means of computer algebra.

6 The Dynamic ODEs System for Time-Dependent Coefficients

6.1 General Expressions to Be Used Coding the Calculations

In the following we assume that all the inner products are defined with the unity weight. We also assume that all the necessary changes of variables are made, so that the boundary conditions of all the unknown vector and scalar fields are linear and homogeneous. Then, after the basis functions are constructed, and the Galerkin projections are made, and the pressure is excluded by Eq. (2.20), we arrive to an ODEs system (2.21) for calculation of the time-dependent coefficients. We store all the unknown time-dependent coefficients of the problem in the vector \( \varvec{X}\left( t \right) = \left\{ {X_{I} \left( t \right)} \right\}_{I = 1}^{N} \), where \( N \) is the total number of scalar unknowns (degrees of freedom), the time-dependent coefficients are renumbered as in (3.2). Note that the vector \( \varvec{X}\left( t \right) \) contains coefficients of velocity series, as well as coefficients of all the other possible unknowns, e.g., temperature and/or concentration, excluding pressure. Then the resulting dynamic ODEs system has the following form (the Einstein summation rule is assumed)

$$ G_{IJ} \dot{X}_{J} = L_{IJ} X_{J} + N_{IJK} X_{J} X_{K} + F_{I} . $$
(6.1.1)

Here \( G_{IJ} \) is the Gram matrix, \( L_{IJ} \), \( N_{IJK} \), and \( F_{I} \) are projections of the linear, nonlinear and free terms of the momentum Eq. (2.7), respectively. This dynamic systems has several nice properties that follow from the fact that the basis functions satisfy all boundary conditions, and are divergence-free. We can easily see that from the Green theorems for a scalar function and for a divergence-free velocity

$$ \left\langle {\Delta \theta ,\theta } \right\rangle = - \left\langle {\nabla \theta ,\nabla \theta } \right\rangle ,\left\langle {\Delta \varvec{v},\varvec{v}} \right\rangle = - \left\langle {\nabla \times \varvec{v},\nabla \times \varvec{v}} \right\rangle $$
(6.1.2)

follows that the matrices \( L_{IJ} \) corresponding to the dissipative terms are symmetric and negative defined independently on the truncation number. Furthermore, from the conservative properties

$$ \left\langle {\left( {\varvec{v} \cdot \nabla } \right)\varvec{v},\varvec{v}} \right\rangle = 0,\quad \left\langle {\left( {\varvec{v} \cdot \nabla } \right)\theta ,\theta } \right\rangle = 0 $$
(6.1.3)

It follows that

$$ N_{IJK} X_{I} X_{J} X_{K} = 0 $$
(6.1.4)

for any truncation number. This means that for any truncations number the non-linear term preserves conservation of momentum. Additionally, these properties yield a very convenient tool for the code debugging.

Computation of steady state flows reduces to an algebraic system of quadratic equations

$$ L_{IJ} X_{J} + N_{IJK} X_{J} X_{K} + F_{I} = 0, $$
(6.1.5)

for which we do not need to consider the Gram matrix. The application of Newton iteration is straight-forward and requires computation and inverse of the Jacobian matrix

$$ {\Im }_{IJ} = L_{IJ} + \left( {N_{IJK} + N_{IKJ} } \right)X_{K} . $$
(6.1.6)

Analysis of linear stability of the calculated steady states reduces to computation of the eigenvalues of another Jacobian matrix, which includes the inversed Gram matrix

$$ {\hat{\Im }}\varvec{Y} = \lambda \varvec{Y},\quad {\hat{\Im }}_{IJ} = G_{IM}^{ - 1} \left[ {L_{MJ} + \left( {N_{MJK} + N_{MKJ} } \right)X_{K} } \right] = \hat{N}_{IJ} + \left( {\hat{N}_{IJK} + \hat{N}_{IKJ} } \right)X_{K} . $$
(6.1.7)

The inverse of Gram matrix is also needed for the straight forward time integration, for which the dynamic system (6.1.1) has the form

$$ \dot{X}_{I} = G_{IM}^{ - 1} \left[ {L_{MJ} X_{J} + N_{MJK} X_{J} X_{K} + F_{M} } \right] = \hat{L}_{IJ} X_{J} + \hat{N}_{IJK} X_{J} X_{K} + \hat{F}_{I} , $$
(6.1.8)

where matrices multiplied by \( G^{ - 1} \) are denoted by \( \widehat{\;} \).

Explicit representation of the dynamic system (6.1.8) allows one to perform additional analytical evaluations to enable weakly non-linear analysis of bifurcations. The latter was implemented for the Hopf bifurcation in Gelfgat et al. [18] and Gelfgat [32]. Assume that with the increase of the Reynolds number, at \( Re = Re_{cr} \), a complex conjugated pair \( \Lambda = \pm i\omega_{0} \) of leading eigenvalues of the problem (6.1.7) crosses the imaginary axis. Then the instability sets in as the Hopf bifurcation if all the conditions of the Hopf theorem hold, which is the most common case. We are interested in an asymptotic approximation of the oscillations period and amplitude at small super-criticalities. Assume that \( \varvec{X}^{0} \) is the steady state at the critical point, and \( \varvec{U} \) and \( \varvec{V} \) are the left and right eigenvectors corresponding to the eigenvalue \( \Lambda = i\omega_{0} \). We also denote the r.h.s. of the dynamic system (6.1.8) as \( \varvec{F}\left( {\varvec{X};Re} \right) = \dot{\varvec{X}} \). Then, according to Hassard et al. [43], the oscillating state, i.e., the limit cycle, is approximated as

$$ Re = Re_{cr} + \mu_{1} \varepsilon^{2} + O\left( {\varepsilon^{4} } \right) $$
(6.1.9)
$$ \tau \left( {Re} \right) = \frac{2\pi }{{\omega_{0} }}\left[ {1 + \tau_{1} \varepsilon^{2} + O\left( {\varepsilon^{4} } \right)} \right] $$
(6.1.10)
$$ \varvec{X}\left( {t,Re} \right) = X^{0} \left( {Re_{cr} } \right) + \varepsilon Real\left[ {\varvec{V}exp\left( {\frac{2\pi i}{\tau }} \right)} \right] + O\left( {\varepsilon^{2} } \right) $$
(6.1.11)

Here \( \varepsilon \) is a formal positive parameter, \( Re - Re_{cr} \) is the super-criticality, \( \tau \) is the period of oscillations, and \( \varvec{X}\left( {t,Re} \right) \) is the asymptotic oscillatory solution of the ODE system (6.1.8) for the Reynolds number defined in (6.1.9). This asymptotic expansion is defined by two parameters \( \mu_{1} \) and \( \tau_{1} \), which are calculated using the following process [43]

$$ \mu_{1} = - \frac{Real\left( \sigma \right)}{{\alpha_{r} }},\quad \tau_{1} = - \frac{1}{{\omega_{0} }}\left[ {Im\left( \sigma \right) + \mu_{1} \alpha_{i} } \right],\quad \alpha = \alpha_{r} + i\alpha_{i} = \left( {\frac{{{\text{d}}\Lambda }}{dRe}} \right)_{{Re = Re_{cr} }} $$
(6.1.12)

The parameter \( \sigma \) is obtained as

$$ \sigma = \frac{1}{2}H_{21} + \frac{1}{{2\omega_{0} }}\left[ {g_{11} - 2\left| {g_{11} } \right|^{2} - \frac{1}{3}\left| {g_{02} } \right|^{2} } \right] $$
(6.1.13)
$$ g_{20} = 2\varvec{U}^{T} \varvec{f}_{20} ,\quad g_{02} = 2\varvec{U}^{T} \bar{\varvec{f}}_{20} ,\quad g_{11} = 2\varvec{U}^{T} \varvec{f}_{11} . $$
(6.1.14)

The vectors \( \varvec{f}_{11} \) and \( \varvec{f}_{20} \) are the second derivatives of the r.h.s., and \( H_{21} \) is the third derivative in the complex plane \( C \), \( \xi \in C \):

$$ \varvec{f}_{20} = \left\{ {\frac{{\partial^{2} }}{{\partial \xi^{2} }}\varvec{F}\left[ {X^{0} + Real\left( {\varvec{V}\xi } \right);Re_{cr} } \right]} \right\}_{\xi = 0} ,\quad \varvec{f}_{11} = \left\{ {\frac{{\partial^{2} }}{{\partial \xi \partial \bar{\xi }}}\varvec{F}\left[ {X^{0} + Real\left( {\varvec{V}\xi } \right);Re_{cr} } \right]} \right\}_{\xi = 0} $$
(6.1.15)
$$ H_{21} = \left\{ {\frac{{\partial^{3} }}{{\partial \xi^{2} \partial \bar{\xi }}}\left( {2\varvec{U}^{T} \varvec{F}\left[ {X^{0} + Real\left( {\varvec{V}\xi + {\varrho }_{20} \xi^{2} + {\varrho }_{11} \xi \bar{\xi }} \right);Re_{cr} } \right]} \right)} \right\}_{\xi = 0} , $$
(6.1.16)

and the vectors \( {\varrho }_{20} \) and \( {\varrho }_{11} \) are solutions of the following systems of linear algebraic equations (\( \underline{I} \) is the identity matrix and \( \otimes \) denotes the Kronecker product)

$$ {\hat{\Im }\varrho }_{11} = - \varvec{h}_{11} ,\quad \left[ {{\hat{\Im }} - 2i\omega_{0} \underline{I} } \right]{\varrho }_{11} = - \varvec{h}_{20} ,\quad \varvec{h}_{ij} = \left[ {\underline{I} - Real\left( {V \otimes U^{T} } \right)} \right]\varvec{f}_{ij} $$
(6.1.17)

The eigenvalue derivative (6.1.12) can be easily evaluated numerically. However, the most difficult part of this calculation is evaluation of the second and the third derivatives of the right hand side of the ODE system (6.1.15) and (6.1.16). These derivatives must be evaluated in the complex plane. The number of degrees of freedom is large, so that differentiation by finite differences and consequent summation can lead to unacceptably large errors. However, the explicit form of (6.1.8) allows for analytical calculation of the derivatives. The result is

$$ f_{20,k} = \frac{1}{2}\left[ {N_{KIJ} \left( {V_{I}^{\left( r \right)} V_{J}^{\left( r \right)} - V_{{}}^{\left( i \right)} V_{J}^{\left( i \right)} } \right) + iN_{KIJ} \left( {V_{I}^{\left( r \right)} V_{J}^{\left( i \right)} - V_{I}^{\left( i \right)} V_{J}^{\left( r \right)} } \right)} \right], $$
(6.1.18)
$$ f_{11,k} = \frac{1}{2}N_{kij} \left( {V_{I}^{\left( r \right)} V_{J}^{\left( r \right)} + V_{{}}^{\left( i \right)} V_{J}^{\left( i \right)} } \right), $$
(6.1.19)
$$ G_{21} = \frac{1}{2}U_{i} \left( {N_{ijm} + N_{imj} } \right)\left( {2{\varrho }_{11,j} V_{m} + 2{\varrho }_{20,j} \bar{V}_{m} } \right), $$
(6.1.20)

where superscripts \( \left( r \right) \) and \( \left( i \right) \) denote real and imaginary parts, respectively. These analytical expressions allow one to compute the asymptotic expansions (6.1.9)–(6.1.11) without significant loss of accuracy. The CPU-time requirements for such calculations are comparable with the calculation of two steady state solutions and their spectra. Note, that the sign of \( \mu_{1} \) defines whether the bifurcation is sub- or super-critical.

6.2 Main Computational Difficulties

All the possible computations, described in the previous section, are restricted by two main difficulties. To describe the difficulties, we note that in all the studies where this method was successfully applied, the number of basis functions in one direction was not less than 20 and was not larger than 70. Therefore, to make some estimates, we’ll address three types of truncation in one direction with 30, 60 and 100 basis functions for both two- and three-dimensional problems.

The first difficulty is connected with the Gram matrix \( G \). In two-dimensional and quasi two-dimensional cases, e.g., 3D instability of an axisymmetric base flow, there is no specific problems neither in the storing of the Gram matrix in memory, nor in the computation of its inverse. Really, even with the truncation number 100, the Gram matrix consists of blocks of the order 1002 = 104, which leads to an order of 108 non-zero entries, which fits in several Gb memory. The inverse of this matrix that is symmetric and positive defined, can be done by Choleski decomposition, which is much faster than the Gauss elimination. Since this inverse must be done only once for each specific problem, and can be stored on a disk, it does not cause too difficult problems. However, for all the calculations, except the Newton iterations, the r.h.s. of dynamic system must be multiplied by \( G^{ - 1} \). If the truncation number is relatively small, the matrices \( \hat{L} = G^{ - 1} L \) and \( \hat{N} = G^{ - 1} N \) in the dynamical system (6.1.7) can be computed and stored before other heavy computations begin. At larger truncation number the storage of matrix \( \hat{N} \) becomes impossible (see below), which makes the time-dependent calculations too slow. At the same time, the stability analysis, as well as the weakly non-linear analysis, require only few, usually less than 10, evaluations of the Jacobian matrix \( {\hat{\Im }} \), thus making all the computational process affordable.

Treatment of the Gram matrix in a three-dimensional formulation is much more difficult. Here the largest block to be inversed has the order of \( \left( {\left( {2M} \right)^{3} } \right)^{2} \) elements, where M is the truncation number. Storage of so large matrices becomes problematic already at relatively small truncation numbers \( M \ge 30 \), and is unaffordable at \( M = 100 \). Thus, among all the described possibilities, one can make only steady state calculations. A solution for that can be orthonormalization of the whole set of the basis functions, which is discussed below.

The second difficulty is the numerical evaluation of non-linear term in (6.1.5) and (6.1.7), which requires the order of \( \left( {number\,of\,degrees\,of\,freedom} \right)^{3} \) multiplications, assuming that the matrix \( \hat{N} \) is stored and evaluations of its terms does not require additions operations. Again, it can be affordable for the steady state, stability, and weakly non-linear calculations when 2D and quasi-2D problems are solved, because all these require very few evaluations of the r.h.s. In the fully 3D cases it seems to be not feasible, unless some additional evaluations of the non-linear terms are performed.

6.3 Treatment of Non-linear Terms

As a simplest example of handling the non-linear terms and avoiding the \( N^{3} \) multiplications, we consider the Burgers equation in the interval \( 0 \le x \le 1 \)

$$ \frac{\partial u}{\partial t} + u\frac{\partial u}{\partial x} = \nu \frac{{\partial^{2} u}}{{\partial x^{2} }},\quad u\left( {0,t} \right) = u\left( {1,t} \right) = 0. $$
(6.3.1)

The initial condition used in Gelfgat [36] was \( u\left( {x,0} \right) = sin\left( {2\pi x} \right) + sin\left( {\pi x} \right)/2 \), but this is not relevant to the purpose of this section. We look for the solution as a truncated series

$$ u\left( {x,t} \right) = \sum\nolimits_{i = 0}^{M - 1} {c_{i} \left( t \right)\varphi_{i} \left( x \right)} ,\quad \varphi_{i} \left( x \right) = T_{i} \left( x \right) - T_{i + 2} \left( x \right), $$
(6.3.2)

where the basis functions \( \varphi_{i} \left( x \right) \) are built as linear superpositions of the Chebyshev polynomials to satisfy the boundary conditions (see Eq. (A.3)). After the Galerkin projections are applied we arrive to the ODEs system (6.1.1), where coefficients \( c_{i} \left( t \right) \) are stored in the vector \( \varvec{X} \). For this problem the matrices in (6.1.1) are defined as

$$ G_{ij} = \left\langle {\varphi_{j} ,\varphi_{i}} \right\rangle,\quad L_{ij} = \left\langle {\varphi_{j}^{{{\prime \prime }}} ,\varphi_{i}}\right\rangle ,\quad F_{i} = 0,\quad N_{ijk} = \left\langle {\varphi_{j} \varphi_{k}^{{\prime }} ,\varphi_{i}}\right\rangle , $$
(6.3.3)

and evaluation of the non-linear term requires \( M^{3} \) operations.

To reduce the number of multiplications, we notice that \( \varphi_{j} \varphi_{k}^{{\prime }} \) is a polynomial of the order \( j + k + 1 \) that satisfies the boundary conditions of the problem, so that we can express it as a series of \( \varphi_{i} \left( x \right) \):

$$ \varphi_{j} \left( x \right)\varphi_{k}^{{\prime }} \left( x \right) = \sum\nolimits_{l = 0}^{j + k - 1} {b_{l} \varphi_{l} \left( x \right)} $$
(6.3.4)

The coefficients \( b_{ljk} \) can be evaluated analytically using Eqs. (A.7) and (A.12) in the following way

$$ \begin{aligned} \varphi_{j} \left( x \right)\varphi_{k}^{{\prime }} \left( x \right) & = \left[ {T_{j} \left( x \right) - T_{j + 2} \left( x \right)} \right]\left[ {T_{k}^{{\prime }} \left( x \right) - T_{k + 2}^{{\prime }} \left( x \right)} \right] \\ & = \left[ {T_{j} \left( x \right) - T_{j + 2} \left( x \right)} \right]\left[ {4k\sum\limits_{p = 0}^{{\left[ {\left( {k - 1} \right)/2} \right]}} {a_{k - 1 - 2p} T_{k - 1 - 2p} \left( x \right) - 4\left( {k + 2} \right)} \sum\limits_{p = 0}^{{\left[ {\left( {k + 1} \right)/2} \right]}} {a_{k - 1 - 2p} T_{k - 1 - 2p} \left( x \right)} } \right] \\ & = 2k\sum\limits_{p = 0}^{{\left[ {\left( {k - 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ {\left[ {T_{k - 1 - 2p - j} \left( x \right) + T_{k - 1 - 2p + j} \left( x \right)} \right] - \left[ {T_{k - 1 - 2p - j - 2} \left( x \right) + T_{k - 1 - 2p + j + 2} \left( x \right)} \right]} \right\}} \\ \end{aligned} $$
(6.3.5)
$$ \begin{aligned} & - 2\left( {k + 2} \right)\sum\limits_{p = 0}^{{\left[ {\left( {k + 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ {\left[ {T_{k - 1 - 2p - j} \left( x \right) + T_{k - 1 - 2p + j} \left( x \right)} \right] - \left[ {T_{k - 1 - 2p - j - 2} \left( x \right) + T_{k - 1 - 2p + j + 2} \left( x \right)} \right]} \right\}} \\ & \quad = 2k\sum\limits_{p = 0}^{{\left[ {\left( {k - 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ {T_{k - 1 - 2p - j} \left( x \right) - T_{k - 1 - 2p - j - 2} \left( x \right) + T_{k - 1 - 2p + j} \left( x \right) - T_{k - 1 - 2p + j + 2} \left( x \right)} \right\}} . \\ \end{aligned} $$
$$ \begin{aligned} & - 2\left( {k + 2} \right)\sum\limits_{p = 0}^{{\left[ {\left( {k + 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ {T_{k - 1 - 2p - j} \left( x \right) - T_{k - 1 - 2p - j - 2} \left( x \right) + T_{k - 1 - 2p + j} \left( x \right) - T_{k - 1 - 2p + j + 2} \left( x \right)} \right\}} \\ & \quad = 2k\sum\limits_{p = 0}^{{\left[ {\left( {k - 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ { - \varphi_{k - 1 - 2p - j - 2} \left( x \right) + \varphi_{k - 1 - 2p + j} \left( x \right)} \right\}} \\ & \quad - 2\left( {k + 2} \right)\sum\limits_{p = 0}^{{\left[ {\left( {k + 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ { - \varphi_{k - 1 - 2p - j - 2} \left( x \right) + \varphi_{k - 1 - 2p + j} \left( x \right)} \right\}} \\ & \quad = - 4\sum\limits_{p = 0}^{{\left[ {\left( {k - 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ { - \varphi_{k - 1 - 2p - j - 2} \left( x \right) + \varphi_{k - 1 - 2p + j} \left( x \right)} \right\}} \\ & \quad - 2\left( {k + 2} \right)\sum\limits_{{p = \left[ {\left( {k - 1} \right)/2} \right] + 1}}^{{\left[ {\left( {k + 1} \right)/2} \right]}} {a_{k - 1 - 2p} \left\{ { - \varphi_{k - 1 - 2p - j - 2} \left( x \right) + \varphi_{k - 1 - 2p + j} \left( x \right)} \right\}} \\ \end{aligned} $$

Defining additionally \( \varphi_{k < 0} = 0 \), noticing that \( \left[ {\left( {k - 1} \right)/2} \right] + 1 = \left[ {\left( {k + 1} \right)/2} \right] \), and comparing the above result with (6.3.4) we observe that the coefficients \( b_{ljk} \) can be assembled by the following procedure. Starting from \( b_{0} = 0 \),

$$ \begin{array}{*{20}r} \hfill {b_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] - j - 2}} = b_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] - j - 2}} + 2\left( {k + 2} \right)a_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right]}} ,} \\ \hfill {if\quad k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] - j - 2 \ge 0} \\ \hfill {b_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] + j}} = b_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] + j}} - 2\left( {k + 2} \right)a_{{k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right]}} ,} \\ \hfill {if\quad k - 1 - 2\left[ {\left( {k + 1} \right)/2} \right] + j \ge 0} \\ \end{array} $$
(6.3.6)

For \( p = 0 \) to \( p = \left[ {\left( {k - 1} \right)/2} \right]: \)

$$ b_{k - 1 - 2p - j - 2} = b_{k - 1 - 2p - j - 2} + 4a_{k - 1 - 2p} ,\quad if\,k - 1 - 2p - j - 2 \ge 0 $$
$$ b_{k - 1 - 2p + j} = b_{k - 1 - 2p + j} - 4a_{k - 1 - 2p} ,\quad if\,k - 1 - 2p + j \ge 0 $$

Now, using (6.3.4), we form a new set of time-dependent coefficients:

$$ \sum\nolimits_{j,k = 0}^{M - 1} {c_{j} \left( t \right)c_{k} \left( t \right)\varphi_{j} \left( x \right)\varphi_{k}^{{\prime }} \left( x \right)} = \sum\nolimits_{m = 0}^{{2\left( {M - 1} \right)}} {C_{m} \left( t \right)\varphi_{m} \left( x \right)} , $$
(6.3.7)
$$ C_{m} \left( t \right) = c_{j} \left( t \right)c_{k} \left( t \right)\sum\nolimits_{l = 0}^{j + k - 1} {\left( {b_{ljk} + b_{lkj} } \right)} ,m = j + k $$
(6.3.8)

And finally,

$$ \sum\nolimits_{j,k = 0}^{M - 1} {N_{ijk} c_{j} \left( t \right)c_{k} \left( t \right)} = \sum\nolimits_{j,k = 0}^{M - 1} {\varphi_{j} \varphi_{k}^{{\prime }} ,\varphi_{i} c_{j} \left( t \right)c_{k} \left( t \right)} = \sum\nolimits_{m = 0}^{{2\left( {M - 1} \right)}} {C_{m} \left( t \right)\varphi_{m} ,\varphi_{i} } $$
(6.3.9)

Now, we can make an estimate of the number of multiplications required. The coefficients \( b_{l} \), and the sums in (6.3.8) depend only on the basis functions and, therefore, can be computed only once in the beginning of the whole computational process. Computation of the coefficients \( C_{m} \left( t \right) \) requires \( 2M^{2} \) multiplications and is the most CPU-time consuming part. Then, evaluation of (6.3.9) needs \( 2\left( {M - 1} \right) \) multiplications providing that all the inner products are pre-computed. Since the operations in (6.3.8) and (6.3.9) are easily scalable, a vectorization and/or parallel computing can speed up the calculations additionally.

Returning to the non-linear terms of momentum equation, we observe that in the case of no-slip conditions the non-linear terms \( u\partial u/\partial x, v\partial u/\partial y, w\partial u/\partial z \), etc., satisfy the no-slip boundary conditions for \( u, v \), and \( w \), respectively. Thus, these terms also can be decomposed into series of appropriate basis functions, which will lead to similar decrease in the number of needed multiplications. In the cases when boundary conditions are more complicated, e.g., a stress-free boundary, one can add additional functions in which only boundary conditions satisfied by the non-linear terms are implemented. Alternatively, regardless any boundary conditions, the non-linear terms can be presented as Chebyshev polynomial series, which will also decrease the number of multiplications.

6.4 Orthogonalization and Other Polynomial Bases

In this section we address two questions: do (i) orthogonalization of the basis or (ii) another polynomials-based basis change the final result? The answer is “no”, but it requires some additional explanations.

After choosing the truncation number we are looking for the solution in the form of (3.3.8). The solution belongs to the linear space \( {\mathcal{L}} = span\left\{ {\varvec{\varphi }_{ijk}^{{\left( {x,y} \right)}} ,\varvec{\varphi }_{ijk}^{{\left( {x,z} \right)}} ,\varvec{\varphi }_{ijk}^{{\left( {y,z} \right)}} } \right\} \). The indices \( i,j,k \) in each set of functions vary as in (3.3.8). This space consists of divergence-free vectors that satisfy all the LHBC of the problem, and their components are polynomials of the order not larger than \( max\left[ {L^{{\left( {x,y} \right)}} ,L^{{\left( {x,y} \right)}} ,L^{{\left( {y,z} \right)}} } \right] + 4 \) in the x-direction, with the similar expressions in two other directions. We denote the order of space \( {\mathcal{L}} \) as \( N_{{\mathcal{L}}} \) and store all the basis functions of (3.3.8) in a set of vectors \( \varvec{Q} = \left\{ {\varvec{q}_{\varvec{i}} } \right\}_{i = 1}^{{N_{{\mathcal{L}}} }} \). Clearly, this set forms a basis in \( {\mathcal{L}} \), \( {\mathcal{L}} = {\text{span}}(Q)\). Assume now another basis in \( {\mathcal{L}} \), denoted as \( \hat{\varvec{Q}} = \left\{ {\hat{\varvec{q}}_{i} } \right\}_{i = 1}^{{N_{{\mathcal{L}}} }} \). The connection between the two bases is given by a matrix \( {\mathcal{B}} \). the order \( N_{{\mathcal{L}}} \) as

$$ \hat{\varvec{Q}} = {\mathcal{B}}\varvec{Q},\quad \varvec{Q} = {\mathcal{B}}^{ - 1} \hat{\varvec{Q}} $$
(6.4.1)

Elements of the matrix \( {\mathcal{B}} \) are solution of the following system of linear algebraic equations (summation over repeating indices is assumed)

$$ \left\langle {\hat{\varvec{q}}_{i} ,\hat{\varvec{q}}_{j} } \right\rangle = {\mathcal{B}}_{ik} \left\langle {\varvec{q}_{k} ,\hat{\varvec{q}}_{j} } \right\rangle $$
(6.4.2)

The transformation (6.4.1) can be interpreted as transformation to another polynomial basis, a particular case of which is an orthonormal polynomial basis. In the latter case the matrix \( {\mathcal{B}} \) is then the operator of the Gram-Schmidt or Householder orthogonalization procedure. Assume now that projection of the solution \( \varvec{v} \) on each of the bases is described by coefficients \( X_{i} \) and \( \hat{X}_{i} \). Clearly, the same inner product is applied in both cases. Since these coefficients describe the orthogonal projection of the vector \( \varvec{v} \) on the same space, the result of projection on either basis must be identical, i.e.,

$$ v \approx X_{i} \varvec{q}_{i} = \hat{X}_{i} \hat{\varvec{q}}_{i} = \hat{X}_{i} {\mathcal{B}}_{ik} \varvec{q}_{k} , $$
(6.4.3)

from which it follows that

$$ X_{i} = \hat{X}_{i} {\mathcal{B}}_{ik} ,\varvec{X} = {\mathcal{B}}^{T} \hat{\varvec{X}},\quad \hat{\varvec{X}} = \left( {{\mathcal{B}}^{T} } \right)^{ - 1} \varvec{X} = \left( {{\mathcal{B}}^{ - 1} } \right)^{T} \varvec{X} $$
(6.4.4)

The Galerkin procedure applied with either of the two bases, will result in two different ODEs systems similar to (6.1.1):

$$ G_{ij} \dot{X}_{j} = L_{ij} X_{j} + N_{ijk} X_{j} X_{k} + F_{i} \quad ,\quad \hat{G}_{ij} \dot{\hat{X}}_{j} = \hat{L}_{ij} \hat{X}_{j} + \hat{N}_{ijk} \hat{X}_{j} \hat{X}_{k} + \hat{F}_{i} , $$
(6.4.5)

where

$$ G_{ij} = \left\langle {\varvec{q}_{j} ,\varvec{q}_{i} } \right\rangle ,L_{ij} = \frac{1}{Re}\left\langle {\Delta \varvec{q}_{j} ,\varvec{q}_{i} } \right\rangle ,N_{ijk} = \left\langle {\left( {\varvec{q}_{j} \cdot \nabla } \right)\varvec{q}_{k} ,\varvec{q}_{i} } \right\rangle ,F_{i} = \left\langle {\varvec{f},\varvec{q}_{i} } \right\rangle $$
(6.4.6)
$$ \hat{G}_{ij} = \left\langle {\hat{\varvec{q}}_{j} ,\hat{\varvec{q}}_{i} } \right\rangle ,\hat{L}_{ij} = \frac{1}{Re}\left\langle {\Delta \hat{\varvec{q}}_{j} ,\hat{\varvec{q}}_{i} } \right\rangle ,\hat{N}_{ijk} = \left\langle {\left( {\hat{\varvec{q}}_{j} \cdot \nabla } \right)\hat{\varvec{q}}_{k} ,\hat{\varvec{q}}_{i} } \right\rangle ,\hat{F}_{i} = \left\langle {\varvec{f},\hat{\varvec{q}}_{i} } \right\rangle $$
(6.4.7)

Note that the two ODEs systems in (6.4.5), (6.4.6) describe the orthogonal projection of the residual on the same linear space \( {\mathcal{L}} \), so that the result again must be identical. However, it is not clear yet whether the coefficients \( X_{i} \) and \( \hat{X}_{i} \) yielded by solution of the two systems will be connected via Eq. (6.4.4). Let us evaluate how the matrices in (6.4.6) and (6.4.7) are connected.

$$ \hat{F}_{i} = \left\langle {\varvec{f},\hat{\varvec{q}}_{i} } \right\rangle = \left\langle {\varvec{f},{\mathcal{B}}_{ip} \varvec{q}_{p} } \right\rangle = {\mathcal{B}}_{ip} F_{p} , $$
(6.4.8)
$$ \hat{G}_{ij} = \left\langle {\hat{\varvec{q}}_{j} ,\hat{\varvec{q}}_{i} } \right\rangle = \left\langle {{\mathcal{B}}_{jk} \varvec{q}_{k} ,{\mathcal{B}}_{ip} \varvec{q}_{p} } \right\rangle = {\mathcal{B}}_{jk} {\mathcal{B}}_{ip} G_{kp} , $$
(6.4.9)
$$ \hat{L}_{ij} = \frac{1}{Re}\left\langle {\Delta \hat{\varvec{q}}_{j} ,\hat{\varvec{q}}_{i} } \right\rangle = \frac{1}{Re}\left\langle {{\mathcal{B}}_{jk} \Delta \varvec{q}_{k} ,{\mathcal{B}}_{ip} \varvec{q}_{p} } \right\rangle = {\mathcal{B}}_{jk} {\mathcal{B}}_{ip} L_{kp} , $$
(6.4.10)
$$ \hat{N}_{ijk} = \left\langle {\left( {\hat{\varvec{q}}_{j} \cdot \nabla } \right)\hat{\varvec{q}}_{k} ,\hat{\varvec{q}}_{i} } \right\rangle = \left\langle {\left( {{\mathcal{B}}_{jm} \varvec{q}_{m} \cdot \nabla } \right){\mathcal{B}}_{kl} \varvec{q}_{l} ,{\mathcal{B}}_{ip} \varvec{q}_{p} } \right\rangle = {\mathcal{B}}_{jm} {\mathcal{B}}_{kl} {\mathcal{B}}_{ip} N_{pml} . $$
(6.4.11)

Consider now how all the terms of the second system of (6.4.5) are expressed via matrices and unknowns of the first system

$$ \hat{G}_{ij} \dot{\hat{X}}_{j} = {\mathcal{B}}_{jk} {\mathcal{B}}_{ip} G_{kp} {\mathcal{B}}_{jq}^{ - 1} \dot{X}_{q} = {\mathcal{B}}_{ip} G_{kp} \dot{X}_{k} , $$
(6.4.12)
$$ \hat{L}_{ij} \hat{X}_{j} = {\mathcal{B}}_{jk} {\mathcal{B}}_{ip} L_{kp} {\mathcal{B}}_{jq}^{ - 1} X_{q} = {\mathcal{B}}_{ip} L_{kp} X_{k} , $$
(6.4.13)
$$ \hat{N}_{ijk} \hat{X}_{j} \hat{X}_{k} = {\mathcal{B}}_{jm} {\mathcal{B}}_{kl} {\mathcal{B}}_{ip} N_{pml} {\mathcal{B}}_{jq}^{ - 1} X_{q} {\mathcal{B}}_{kr}^{ - 1} X_{r} = {\mathcal{B}}_{ip} N_{pjk} X_{j} X_{k} . $$
(6.4.14)

Substituting (6.4.8), (6.4.12)–(6.4.14) into the second system of (6.4.5) we obtain

$$ {\mathcal{B}}_{ip} G_{kp} \dot{X}_{k} = {\mathcal{B}}_{ip} L_{kp} X_{k} + {\mathcal{B}}_{ip} N_{pjk} X_{j} X_{k} + {\mathcal{B}}_{ip} F_{p} , $$
(6.4.15)

And multiplying (6.4.15) by \( {\mathcal{B}}^{ - 1} \) we return to the first system of (6.4.5). This proves that both systems of (6.4.5) yield identical solutions if their initial conditions are connected via eq. (6.4.4).

To conclude, we notice that looking for another polynomials-based basis functions is meaningless, since we’ll arrive to exactly the same approximate solution. On the other hand, the orthonormalization procedure can be meaningful, since it does not change the solution, but allows one to avoid inverse of the Gram matrix.

7 Inner Products with Arbitrary Weight

If a scalar problem is being solved, e.g. Orr-Sommerfeld or Burgers equations, the choice of the weight function in the inner product (2.18) is arbitrary. In the case of unity or Chebyshev weight, the inner products can be evaluated analytically using properties of the Chebyshev polynomials listed in Appendix A. In other cases the Gauss quadrature formulae can be efficiently applied. An appropriate choice of the weight function can drastically improve the convergence, as it was demonstrated in Gelfgat [36] for the Burgers equation.

As explained, in the case of incompressible Navier–Stokes equation, use of the unity weight function allows one to exclude the pressure by the Galerkin projection. The unity weight also yields important conservative properties of the resulting ODEs system (6.1.3) and (6.1.4). At the same time, if the weight function can be optimized such that the convergence is noticeably improved, then the total number of degrees of freedom in the resulting dynamic system can be noticeably decreased. In such a case it can be reasonable to give up on the nice properties of the unity weight and proceed with the optimized one. Then it will be necessary to solve the pressure Eq. (2.11), so that the ODEs system with the algebraic constraints (2.16), (2.17) will be considered. In the following we follow Gelfgat [36] to show how the algebraic constraints can be removed in the framework of the discussed Galerkin approach.

First of all, the pressure Eq. (2.11) needs boundary conditions. It was shown in Gelfgat [36] that the boundary conditions proposed by Gresho and Sani [42], which are limits of the momentum equation at the boundaries, yield a correct pressure field. The boundary conditions on the boundary \( \varGamma \) are

$$ \left[ {\frac{\partial p}{\partial n}} \right]_{\varGamma } = \varvec{n} \cdot \left[ {\frac{1}{Re}\Delta \varvec{v} - \left( {\varvec{v} \cdot \nabla } \right)\varvec{v} + \varvec{f}} \right]_{\varGamma } , $$
(7.1)

where \( \varvec{n} \) is the normal to \( \varGamma \), and the boundary conditions for velocity are assumed to be steady. Note that Rempfer [59] argued that the numerical solution of the pressure problem (2.11), (7.1), together with the momentum Eq. (2.7), do not yield a divergence free solution for velocity. The global Galerkin method with divergence-free velocity basis functions described here does not have this problem, because the continuity equation is satisfied analytically by the basis functions, before the numerical process starts. Thus, any approximation of a solution is analytically divergence free.

For the following we represent the pressure as a truncated Chebyshev series

$$ p\left( {x,y,z,t} \right) = \sum\nolimits_{i,j,k} {\vartheta_{ijk} \left( t \right)T_{i} \left( x \right)T_{j} \left( y \right)T_{k} \left( z \right)} . $$
(7.2)

Here we cannot introduce any boundary conditions into the basis functions, because we cannot propose any general enough change of variables that will replace the non-homogeneity of the boundary conditions (7.1) into the pressure Eq. (2.11). To obtain a problem for the unknown coefficients \( \vartheta_{ijk} \left( t \right) \) we perform Galerkin projections of the residuals of (2.11) and (7.1) on the Chebyshev basis (7.2), and require that the projections vanish. In other words, we apply the Galerkin method separately in the flow region and on the boundaries. Clearly the total number of unknown \( \vartheta_{ijk} \left( t \right) \) must be equal to the total number of equations used. Recalling that the velocity coefficients are stored in the vector \( \varvec{X} \), we store additional coefficients of pressure \( \vartheta_{ijk} \left( t \right) \) in the vector \( \varvec{Y} \). After the Galerkin process is completed, the system of linear algebraic equation for \( \varvec{Y} \) has the following form

$$ Q_{IJ}^{\left( p \right)} Y_{J} = B_{IJ}^{\left( p \right)} \dot{X}_{J} + L_{IJ}^{\left( p \right)} X_{J} + N_{IJK}^{\left( p \right)} X_{J} X_{K} + F_{I}^{\left( p \right)} $$
(7.3)

As mentioned, these equations are formed from the projections of Eqs. (2.11) and (7.1). The superscript \( \left( p \right) \) is used to underline that all the matrices belong to the pressure problem. The matrix \( Q_{ij}^{\left( p \right)} \) is singular, because the Neumann problem for the pressure has to be solved, so that the pressure is defined to within an additive constant. This singularity can be easily removed by, e.g., an additional requirement \( \vartheta_{000} = 0 \), after which the matrix \( Q_{{}}^{\left( p \right)} \) is regular and its inverse is denoted as \( Q_{{}}^{ - 1} \). The Galerkin coefficients of velocity must be calculated using the Eq. (2.16), which attains the following form

$$ G_{IJ} \dot{X}_{J} = P_{IJ} Y_{J} + L_{IJ} X_{J} + N_{IJK} X_{J} X_{K} + F_{I} . $$
(7.4)

Here the first term of r.h.s. is the projection of the pressure gradient on the velocity basis. Substituting \( Y_{j} \) from Eq. (7.3) into Eq. (7.4) we obtain

$$ \tilde{G}_{IJ} \dot{X}_{J} = \tilde{L}_{IJ} X_{J} + \tilde{N}_{IJK} X_{J} X_{K} + \tilde{F}_{I} $$
(7.5)

where

$$ \tilde{G} = G - PQ^{ - 1} B^{\left( p \right)} ,\tilde{L} = L + PQ^{ - 1} L^{\left( p \right)} ,\tilde{N} = N + PQ^{ - 1} N^{\left( p \right)} ,\tilde{F} = F + PQ^{ - 1} F^{\left( p \right)} $$
(7.6)

Thus, after some analytical and numerical evaluations we arrive to the ODE system (7.5), whose structure is equivalent to that of (6.1.1). Generally, matrices of (7.5) do not obey the properties (6.1.3) and (6.1.4), however all the rest written about the system (6.1.1) is applicable also to (7.5).

Some numerical experiments comparing convergence of the Galerkin method with Chebyshev and unity weights are reported in Gelfgat [36]. There the lid-driven cavity flow and convection in a laterally cavity were taken as test problems. It was found that the Chebyshev weight allows for a better resolution of boundary layers in the convection flow, however slows down the convergence in the case of lid driven flow. The latter was attributed to the problems of approximation of the corner discontinuities.

The problem of optimization of the weight function was never considered for a realistic fluid dynamics problem. The only optimization example is given in Gelfgat [36] for the Burgers equation. Considering the weight functions in the form of \( \left( {x - x^{2} } \right)^{ - \alpha } \), \( \alpha \ge 0 \), it was found that the convergence is fastest at \( \alpha = 1.3 \).

8 Solved Problems and Other Applications of the Method

The effectivity of the described Galerkin approach follows from a possibility to decrease number of degrees of freedom of a numerical model. The decrease is usually of an order of magnitude or larger. One of the earliest examples of that is shown in Fig. 3. There we consider flow in a cylinder with rotating lid. Steady states of this flow exhibit the vortex breakdown phenomenon, which was experimentally studied by Escudier [13]. At certain Reynolds number a weak reverse circulation attached to the cylinder axis appears. In tall cylinders up to three distinct recirculation zones were observed. The intensity of the reverse vortices is 3–5 orders of magnitude lesser that that of the main meridional circulation, which makes its numerical modeling quite challenging. As is seen from the figure, the experimental result, i.e., the reverse circulations size and position, is well reproduced with 34 × 34 basis functions (Fig. 3a), as well as with 200 × 200 finite volume grid (Fig. 3c). At the same time the upper recirculation zone is resolved inaccurately with the 100 × 100 grid (for a more detailed comparison see Gelfgat et al. [18]). The total number of degrees of freedom of the Galerkin method is defined by total amount of unknown Galerkin coefficients of the meridional velocity vector and rotating velocity component, which separates as a scalar in the axisymmetric formulation. In the finite volume approach it is the number of unknown functions multiplied by the number of grid nodes. Clearly the total number of degrees of freedom consumed by the Galerkin method, \( 2 \cdot 34^{2} = 2312 \), is smaller than that of the finite volume method, \( 3 \cdot 200^{2} = 120,000 \), in about 1.5 orders of magnitude.

Fig. 3
figure 3

Comparison of numerical results with the experimental phograph of Escudier [13]. From Gelfgat et al. [18]. The flow at H/R = 3.25, Re = 2752. a Calculation with the Galerkin method using 34 × 34 basis functions. b, c Calculation with the finite volume method using 100 × 100 and 200 × 200 grids, respectively

The next example presented in Fig. 4 is a thermocapillary convective flow in a laterally heated cavity with the aspect ratio length/height = 4. The velocity boundary condition at the upper surface is

Fig. 4
figure 4

Patterns of flow and amplitude of the most unstable perturbation at the critical Marangoni number for thermocapillary convection of low-Prandtl-number fluid (Pr = 0.015) in a cavity of aspect ratio length/height = 4. From Gelfgat [37]

$$ v = 0, \frac{\partial u}{\partial y} = - Mn\frac{\partial \theta }{\partial x}, $$
(8.1)

where \( \theta \) is the dimensionless temperature, \( Mn = Ma/Pr \), and \( Ma \) and \( Pr \) are the Marangoni and Prandtl numbers, respectively (other details are in [37]. The problem was treated with the truncation of 50 × 20 basis functions with 100 collocation points at the upper surface to satisfy the boundary condition (8.1). A calculation of critical Marangoni number, corresponding to transition from steady to oscillatory flow regime, resulted in \( Mn_{cr} = 4781 \) and the dimensionless critical frequency (imaginary part of the leading eigenvalue) \( \omega_{cr} = 6674 \). This result was never published because the value of \( \omega_{cr} \) seemed to be too large compared with the values already known for the buoyancy convection [21]. Owing to the computer restrictions of that time, the convergence could not be rigorously checked. Later, the same problem was solved using the 800 × 200 stretched finite volume grid [37] and the result was \( Mn_{cr} = 4779 \) with the same value of the critical frequency. The convergence of the critical values obtained by the finite volume method was found to be very slow. The reason for that is seen in Fig. 4. The flow streamlines and the isotherms are smooth, so that the velocity and temperature fields can be calculated relatively easy. At the same time, the perturbation patterns exhibit very steep maxima, which must be numerically resolved to arrive to correct critical values. We observe here again that the Galerkin method yielded the correct result with much smaller number of degrees of freedom.

As mentioned, the smaller amount of degrees of freedom, as well as analytical representation of the Jacobian matrix (6.1.6), allows one to effectively apply the Newton iteration for calculation of the steady states. To follow different solution branches one can apply also the arc-length or similar continuation technique. The latter is illustrated in Fig. 5 for the convection in a cavity with partially heated sidewall [12], the boundary conditions for which were discussed in Sect. 4. Since the boundary conditions are symmetric, the flow at low Grashof number \( Gr \) is symmetric. The symmetry breaks at \( Gr = 180 \). The diagram in Fig. 5 shows difference between the Nusselt numbers calculated at the left and right vertical boundaries, so that in the symmetric state the difference is zero. After the symmetry breaks, we observe several interconnected solution branches with qualitatively different flow patterns. Those depicted by red color are stable, and those depicted by the blue color are oscillatory unstable. In spite that most of the steady state branches are unstable, we speculate that there can exist multiple oscillatory states with similar flow patterns.

Fig. 5
figure 5

Bifurcation diagram for convection in a vertical cavity with partially heated sidewall. Red lines correspond to stable steady states, blue lines to unstable ones. Pr = 10. From Erenburg et al. [12]

The most known results obtained with the discussed method are stability diagrams of swirling rotating disk—cylinder flow and buoyancy convection flows in laterally heated rectangular cavities. First results on the three-dimensional instability of rotating disk—cylinder flow were obtained in Gelfgat et al. [27] using the described Galerkin method with 30 × 30 basis functions. Since then several research groups validated these results experimentally and verified numerically. These comparisons are very convincing and are shown in Figs. 6 and 7. According to our results, the instability is axisymmetric for the aspect ratio of the cylinder (height/radius) varying between 1.6 and 2.7, and is three-dimensional outside of this interval. The three-dimensionality sets in with the azimuthal number \( k = 2 \) at small aspect ratios, and with \( k = 3 \) or \( 4 \) in taller cylinders. Several later studies tried to reproduce these results either by a straight-forward integration in time, or by means of stability analysis, and fully confirmed our conclusions. The quantitative comparison was done for the critical Reynolds numbers and critical frequencies, as well as for the azimuthal mode number. It was possible also to confirm values of the aspect ratio at which the modes replace each other.

Fig. 6
figure 6

Stability diagram for flow in a cylinder covered by rotating disk. The lines correspond to results obtained by the Galerkin method (Gelfgat et al. [27]) for different azimuthal wavenumbers k in (3.4.1). Symbols show results of independent numerical studies [2, 41, 45, 47, 48, 53]

Fig. 7
figure 7

Stability diagram for flow in a cylinder covered by rotating disk. The lines correspond to results obtained by the Galerkin method (Gelfgat et al. [27]) for different azimuthal wavenumbers k in (3.4.1). Symbols show experimental results

A similar comparison, but experimental one, was made by Sørensen et al [61, 62]. Their result is shown in Fig. 7. The flow oscillations were measured by LDA, while the flow azimuthal periodicity by PIV. The symbols in Fig. 7 show experimentally measured points, and their color corresponds to the indication of azimuthal wavenumber as is shown in the figure. The pioneer results of Escudier [13] are also shown. Taking into account all possible experimental uncertainties, the agreement between experiment of Sørensen et al [61] and numerical predictions made by the Galerkin method is quite impressive.

Other stability results obtained by the described Galerkin method for similar swirling flows can be found in Gelfgat et al. [19] for flow in a cylinder with independently rotating to and bottom, and in Marques et al. [49] for independently rotating top and sidewall.

The neutral curves shown in Fig. 6 are plotted through several tens of calculated critical points. The next example, relating to the oscillatory instability of buoyancy convection flows in laterally heated cavities and shown in Fig. 8, needed several hundreds of critical points to complete the study. The calculations were performed with up to 60 × 20 basis functions. With the increase of the cavity aspect ratio A = length/height, and at large enough Grashof number, the single convective cell flow splits into several cells. The number of cells grows with the aspect ratio. At the same time several steady states with different number of rolls can be stable at the same set of the governing parameters, as is shown in Fig. 9. The transition from one number of cells to another one is continuous and takes place at points where a neutral curve of a certain color continues with a different color. At these points the flows with, e.g., two and three rolls are indistinguishable. Other results on stability of convection in rectangular cavities can be found in Gelfgat et al. [2022], Erenburg et al. [12], and Gelfgat [32]. One particularly interesting result reported in Gelfgat [32] showed that weakly non-linear approximation of limit cycle (6.1.9)–(6.1.11) yields results that are very close to those obtained by independent straight-forward time integration.

Fig. 8
figure 8

Stability diagram for convective flow in laterally heated cavities. The curves color corresponds to the number of convective rolls in the flow pattern. The flows are stable below and inside the curves. Dashed regions correspond to the stability regions of similar flows with broken rotational symmetry. Pr = 0. From Gelfgat et al. [21]

Fig. 9
figure 9

Three distinct stable steady states found at Pr = 0, A = 7, Gr = 88,000. From Gelfgat & Bar-Yoseph [33]

Several studies were devoted to three-dimensional instabilities of axisymmetric buoyancy convection in vertical cylindrical containers. These studies were started in Gelfgat et al. [23], where we were able to reproduce a nice experimental result showing an axisymmetry breaking leading to a spoke pattern flow with the azimuthal wavenumber \( k = 9 \). Later we studied cylinders with non-uniformly heated sidewall that mimicked conditions of the Bridgman crystal growth [25, 28, 60]. Later works were devoted to axisymmetric flows driven by rotating or traveling magnetic field [34, 35]. Most of these results were reviewed in more detail in Gelfgat and Bar-Yoseph [33].

There are some additional opportunities that analytical representation of numerical solution via the Galerkin series allows one to do. Clearly, one can differentiate or integrate the series without any noticeable loss of accuracy, which is quite contrary to low-order methods. A rather obvious example is calculation of the flow trajectories using the previously calculated steady or time-dependent flow. Since the velocity field is defined analytically in the whole domain, wherever the liquid particle arrives, its velocity is known without any need of interpolation between grid nodes. This fact was used in Gelfgat [31], where trajectories were calculated over very long time to obtain a Poincare map in the midplane.

Another application of the divergence-free bases (3.3.2), (3.3.3), and (3.3.6) is visualization of three-dimensional incompressible flows, as is described in Gelfgat [39]. Without going into much detail, we only mention that projection of flow on each divergence-free set can be interpreted as a divergence-free projection on coordinate planes \( x = const, y = const, z = const \), which results in two-component divergence-free fields. These can be described by an analog of the stream function. Assembling all the planes, e.g., \( x = const \), we obtain a scalar 3D function whose isosurfaces are tangent to the projected vectors. Three such projections of three sets of coordinate planes complete the visualization of a three-dimensional flow field. All the details and illustrations can be found in Gelfgat [39].

9 Similar Approaches in Studies of Other Authors

As mentioned, the idea to use linear superpositions of Chebyshev polynomials for definition of basis functions satisfying linear and homogeneous boundary conditions was introduced by Orszag [54, 55] for the homogeneous two-point Dirichlet problem. Since then, similar linear-superpositions-based basis functions were used for solution of one-dimensional problems for, e.g., Orr-Sommerfeld and boundary layer equations, by Zebib [71], Holte [44], Pasquarelli [56], Yueh and Weng [70], Yang [69], Borget et al. [4], Yahata [68], Bistrian et al. [3], and Buffat and Le Penven [8]. In all these works the basis functions were based on the Chebyshev polynomials. Recently, Wan and Yu [66] applied the same idea to the Legendre polynomials. Grants and Gerbeth [41], Uhlmann and Nagata [65], and Batina et al. [1] used the same approach for a two-dimensional flow field, but their basis functions were not divergence-free. Picardo et al. [58] used the linear superpositions for two-fluid problem, like it was done in Gelfgat et al. [30].

Moser et al. [52] proposed to multiply linear superpositions of the Chebyshev polynomials by powers of the Chebyshev weight function for a better use of the polynomials orthogonal properties. For problems with two periodic directions, these authors constructed a divergence free basis, in which the non-periodic direction was treated by linear superpositions of the Chebyshev polynomials multiplied by additional weight-dependent functions. Such functions were used for either coordinate or projection systems in the weighted residuals method by Ganske et al. [15], Godeferd and Lollini [40], Kerr [46]. It should be noted that multiplication by either function makes evaluation of derivatives and computations of their Galerkin projections more complicated.

Yahata [67] solved a problem of buoyancy convection in laterally heated cavities similar to those treated by Gelfgat and Tanasawa [17] and later by Gelfgat et al. [20,21,22]. He used linear superpositions of the Chebyshev polynomials to build basis functions for the temperature and the stream functions with consequent orthogonalization of the basis. The inner product was formulated with an arbitrary weight function, however it is not clear which weight was used. It is worth to note that by evaluating derivatives of the stream function basis of Yahata [67] one would arrive to the two-dimensional basis (3.2.3), so that both formulations are equivalent in the 2D case. An extension of Yahata’s approach to 3D formulation will require replacement of the stream function by vector potential, which will only complicate the formulation.

Suslov and Paolucci [63] also solved similar convection problem in cavity with coordinate functions (3.2.3). For the projection system they used the same functions multiplied by the Chebyshev weight, which made the Gram matrix sparser and allowed to use the fast Fourier transform (FFT) to evaluate non-linear terms of the dynamical system. The whole approach was used for straight-forward integration in time, but did not exhibit much advantage compared to other methods and, to the best of the author’s knowledge, had no further continuation.

10 What Else Can Be Done?

To discuss further possible implementations of the described Galerkin approach it is necessary to underline that with the nowadays growth of computer power and state-of-the-art methods of numerical linear algebra, solution of two-dimensional and quasi-two-dimensional problems became feasible, and sometimes more efficient, with lower order methods. A very popular methodology of turning a time-stepping code into a steady state /stability solver can be found in Boronska and Tuckerman [5, 6] and Tuckerman et al. [64]. Another possible methodology together with several examples are given in Gelfgat [37, 38]. For these problems the Galerkin approach can still be more suitable for weakly non-linear bifurcations analysis. It is not clear, however, whether the results applicable only for small supercriticalities will justify the whole effort.

One of possible ways of further applications of the method is consideration of fully three-dimensional flows, steady and unsteady, in axisymmetric domains. In these problems the bases (3.4.5) and (3.4.6) can be combined with the Fourier decomposition in the circumferential direction, so that the Gram matrices will separate for each Fourier mode and will not be too large, so that they will be easily inversed. Finally, one will arrive to an ODEs system, where equations corresponding to different Fourier modes will be coupled via the non-linear terms. Such system allows for computation of steady states, path-following, stability analysis and time-dependent calculations (see, e.g., Boronska and Tuckerman [5, 6]).

Possibly, the most challenging would be to develop a fully three-dimensional solver for flow in a three-dimensional rectangular box. This would require orthogonalization of the whole set of bases (3.3.2), (3.3.3), and (3.3.6) with consequent effective treatment of the non-linear terms. In the case of success, such an approach can allow one to have steady state, stability, and time-dependent solvers within a single computational model, with which very complicated flows can be studied. It should be mentioned here, that the Krylov subspace based solvers are thought to be applicable only to sparse matrices, assuming that the matrix-vector product can be efficiently evaluated. The latter can be also the case for the described method, even if all the related matrices are densely filled.

As mentioned in the very beginning of this paper, the described Galerkin approach is limited to simple domains, which must be curvilinear rectangles, in other words, regions bounded by coordinate surfaces. This is a very hard restriction since it does not allow one to consider a very big set of important problems, in which the boundaries have more complicated shape. Another restriction for implementation of this method is flows with deformable interfaces. One of the ways to solve such problems on fixed grids is the immersed boundary method and/or the diffuse interface approach (not described here). Implementation of these approaches for the described spectral method will need a good approximation of delta function, which can be difficult to do using smooth polynomials. Nevertheless, such an attempt was never made and can be another challenging task.

Finally, it is needed to stress a proposition for flows visualization made in Gelfgat [39]. This relates to flows calculated by either of numerical methods, and can be very helpful for understanding of topology of complicated three-dimensional flows.

11 Concluding Remarks

To conclude, it should be underlined that described version of the Galerkin method should not be regarded as a replacement for other numerical approaches, but rather as a complementing tool that allows one to perform fully independent computations.

It is unclear whether fully three-dimensional version of this numerical approach, if ever be realized, will outperform other numerical methods for any of problems. Nevertheless, the author believes that such potential exists and the effort will be worth of trying. For example, reaching necessary spatial resolution without increase of number of degrees of freedom, possibly even with reduce of it, can be essential for DNS of developed turbulent flows.

An additional possibility, which is only mentioned here, is use of three-dimensional bases for visualization of flows calculated by other numerical methods.