1 Introduction

Magneto-hydrodynamics (MHD) is the study of flows of a conducting fluid in the presence of an electromagnetic field. Mathematically, MHD phenomena can be modelled by coupling the Navier–Stokes equations with the Maxwell equations of electrodynamics. Earlier attempts at numerical simulations of MHD flow [1,2,3,4] focused on rectangular geometries and used the finite-difference method. Some of them [1, 2] were not capable of capturing the boundary layer effect. A finite-element formulation for steady incompressible MHD flow under constant external magnetic field was presented in [5]. A finite-volume method was used to solve MHD problems in [6, 7]. In other works [8, 9], inductionless MHD phenomena have been modelled, where, instead of the Maxwell equations, only Ohm’s law is used to incorporate the coupling; the magnetic induction effect cannot be modelled using this formulation.

In order to solve the coupled MHD problem, two approaches have been followed, viz., the segregated and the monolithic approaches. In the monolithic approach, both the fluid flow and the magnetic field variables are solved for simultaneously, while in the segregated approach, the Navier–Stokes equations and the Maxwell equations are solved sequentially, with the fluid flow variables obtained by solving the Navier–Stokes equations passed on to the Maxwell equations to obtain the magnetic field variables, which in turn are passed back to the Navier–Stokes equations in order to solve for the fluid flow field variables, and so on. The monolithic approach converges faster, since, unlike the segregated approach, both the fluid flow and magnetic field variables are allowed to vary simultaneously within the context of, say, a Newton–Raphson strategy.

Finite-element formulations for solving the flow field in an incompressible fluid fall under two categories, viz., stable and stabilized. A stable formulation uses interpolations for pressure and velocity that satisfy the Babuska–Brezzi (BB) condition [10]. An example of a stable formulation is ‘Taylor–Hood’ elements, where the pressure interpolation functions are one order lower compared with those for the velocity. In contrast, in stabilized formulations, a stabilizing term is added to the variational formulation so as to circumvent the BB condition, and allow for equal-order interpolations for the velocity and pressure.

Finite-element-based strategies for solving incompressible liquid metal MHD flows have been presented in [11,12,13,14,15,16,17,18,19,20,21,22,23]. In [19,20,21, 23], edge elements have been used for discretizing the magnetic field, while nodal elements are used for modelling the fluid velocity and pressure. Most of the formulations use stabilized formulations [11,12,13,14,15,16,17,18] in order to circumvent the BB condition, and follow the segregated approach [11,12,13,14, 16]. Although stabilized formulations allow the use of equal-order interpolations for the velocity and pressure, a mesh-dependent parameter needs to be set. In contrast, with a stable formulation (which is what we use in this work), there are no parameters that need to be adjusted. In [22, 23], higher order polynomial shape functions have been used to model the magnetostriction effect in MHD. In [22], a formulation in terms of the magnetic potential and a discontinuous pressure interpolation has been used, while in [23], a stress tensor approach has been followed in order to model the magnetostriction effect.

In the current work, we present two- and three-dimensional monolithic strategies for transient and steady-state problems that use a continuous pressure–velocity formulation (which has been shown to have better stability properties compared with a discontinuous pressure–velocity formulation in [24]) for the fluid flow variables, and an interpolation for the magnetic field that is of the same order as that of the velocity. Exact linearization of the variational formulation ensures a quadratic rate of convergence of the monolithic scheme. Comparing against analytical solutions, we show that very good coarse mesh accuracy is obtained with the proposed formulation. Because of the monolithic nature, the proposed method is efficient as well. We also propose a correction to an existing analytical solution.

2 Mathematical formulation

2.1 Governing differential equations for MHD

The strong form of the Maxwell equations is

$$\begin{aligned}&\frac{\partial {{\varvec{B}}}}{\partial t}+{\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{E}}={\mathbf {0}}, \end{aligned}$$
(1a)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot {{\varvec{B}}}=0, \end{aligned}$$
(1b)
$$\begin{aligned} \frac{\partial {\varvec{D}}}{\partial t}-{\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}=-{\varvec{j}}, \end{aligned}$$
(1c)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot {\varvec{D}}=\rho _c, \end{aligned}$$
(1d)

where \({\varvec{E}}\) and \({\varvec{H}}\) are the electric and magnetic fields, respectively, \({\varvec{D}}\) is the electric displacement (electric flux), \({{\varvec{B}}}\) is the magnetic induction (magnetic flux), \(\rho _c\) is the charge density and \({\varvec{j}}\) is the current density. These governing equations are supplemented by the constitutive relations

$$\begin{aligned} {\varvec{D}}&=\epsilon {\varvec{E}}, \end{aligned}$$
(2a)
$$\begin{aligned} {{\varvec{B}}}&=\mu {\varvec{H}},\end{aligned}$$
(2b)

where \(\epsilon \) and \(\mu \) are the electric permittivity and magnetic permeability, respectively. The relative permeability is defined as \(\mu _r=\mu /\mu _0\), where \(\mu _0\) is the permeability of vacuum. Substituting the constitutive relations into Eqs. (1a) and (1c), and assuming that \(\epsilon \) and \(\mu \) are independent of time, we get

$$\begin{aligned}&\frac{\partial {\varvec{H}}}{\partial t}+\frac{1}{\mu }{\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{E}}={\mathbf {0}}, \end{aligned}$$
(3)
$$\begin{aligned} \epsilon \frac{\partial {\varvec{E}}}{\partial t}-{\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}=-{\varvec{j}}. \end{aligned}$$
(4)

From Eqs. (1d), (2a) and (4), we get the compatibility condition

$$\begin{aligned} \frac{\partial \rho _c}{\partial t}+{\boldsymbol{\nabla}}\cdot {\varvec{j}}=0. \end{aligned}$$
(5)

Under the magnetohydrodynamic assumption [12, 25], the charge relaxation time is much shorter than the transit time of electromagnetic phenomena. Hence, we assume \(\partial {\varvec{E}}/\partial t = {\mathbf {0}}\) in Eq. (4), and \(\partial \rho _c/\partial t = 0\) in Eq. (5). Thus, the Maxwell equations reduce to

$$\begin{aligned}&\mu \frac{\partial {\varvec{H}}}{\partial t}+{\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{E}}={\mathbf {0}}, \end{aligned}$$
(6a)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot (\mu {\varvec{H}}) = 0, \end{aligned}$$
(6b)
$$\begin{aligned} {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}={\varvec{j}}, \end{aligned}$$
(6c)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot {\varvec{j}}= 0, \end{aligned}$$
(6d)

where due to flow of the conducting fluid we have

$$\begin{aligned} {\varvec{j}}= \sigma \left( {\varvec{E}}+ {\varvec{u}}\,{\varvec{\times }}\,\mu {\varvec{H}}\right) . \end{aligned}$$
(7)

In this equation, \({\varvec{u}}\) and \(\sigma \) denote the fluid velocity and the conductivity of the fluid, respectively. Using Eqs. (6) and (7), we obtain the governing differential equation for \({\varvec{H}}\) as

$$\begin{aligned} {\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) +\sigma \mu \frac{\partial {\varvec{H}}}{\partial t} = \sigma \mu {\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right)\quad {\text{on}}\; \varOmega , \end{aligned}$$
(8)

where \(\varOmega \) represents the domain. On the other hand, the magnetic field exerts a body force \(\mu {\varvec{j}}\,{\varvec{\times }}\,{\varvec{H}}\) on the fluid. Therefore, assuming an incompressible, Newtonian fluid, the governing equations for the fluid are

$$\begin{aligned}&{\boldsymbol{\nabla}}\cdot {\varvec{u}}=0 \quad {\text{on}}\; \varOmega , \end{aligned}$$
(9a)
$$\begin{aligned} \rho \left[ \frac{\partial {\varvec{u}}}{\partial t}+({\boldsymbol{\nabla}}{\varvec{u}}){\varvec{u}}\right] ={\boldsymbol{\nabla}}\cdot {\varvec{\tau }}+\rho {\varvec{b}}+\mu ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}})\,{\varvec{\times }}\,{\varvec{H}}\quad {\text{on}}\; \varOmega , \end{aligned}$$
(9b)
$$\begin{aligned} {\varvec{\tau }}=-p{\varvec{I}}+2\mu _v{\varvec{D}}\quad {\text{on}}\; \varOmega , \end{aligned}$$
(9c)
$$\begin{aligned} {\varvec{D}}=\frac{1}{2}\left[ ({\boldsymbol{\nabla}}{\varvec{u}})+({\boldsymbol{\nabla}}{\varvec{u}})^T\right] \quad {\text{on}}\; \varOmega , \end{aligned}$$
(9d)
$$\begin{aligned} {\varvec{t}}={\varvec{\tau }}{\varvec{n}}\quad {\text{on}}\; \varGamma , \end{aligned}$$
(9e)
$$\begin{aligned} {\varvec{t}}={\bar{{\varvec{t}}}}\quad {\text{on}}\; \varGamma _t, \end{aligned}$$
(9f)
$$\begin{aligned} {\varvec{u}}={\bar{{\varvec{u}}}}\quad {\text{on}}\; \varGamma _u, \end{aligned}$$
(9g)
$$\begin{aligned} {\varvec{u}}(0)={\varvec{u}}_0\quad {\text{on}}\; \varOmega , \end{aligned}$$
(9h)

where \(\rho \) is the fluid density, \(\nu \) is the kinematic viscosity, \(\mu _v=\rho \nu \) is the fluid dynamic viscosity, \({\varvec{u}}\) is the velocity, p is the pressure, \({\varvec{\tau }}\) is the Cauchy stress tensor, \({\varvec{D}}\) is the rate of deformation, \({\varvec{b}}\) is the body force per unit mass, \({\varvec{t}}\) is the surface traction on the boundary \(\varGamma \), \({\varvec{n}}\) is the outward unit normal to \(\varGamma \), \({\bar{{\varvec{t}}}}\) is the prescribed traction on \(\varGamma _t\) and \({\bar{{\varvec{u}}}}\) is the prescribed velocity on \(\varGamma _u\) with \(\varGamma \equiv \varGamma _t\cup \varGamma _u\).

Summarizing, based on Eqs. (8) and (9), the coupled differential equations for magnetohydrodynamics can be written as

$$\begin{aligned}&{\boldsymbol{\nabla}}\cdot {\varvec{u}}=0 \quad {\text{on}}\; \varOmega , \end{aligned}$$
(10a)
$$\begin{aligned} \rho \frac{\partial {\varvec{u}}}{\partial t}+\rho ({\boldsymbol{\nabla}}{\varvec{u}}){\varvec{u}}= {\boldsymbol{\nabla}}\cdot {\varvec{\tau }}+\rho {\varvec{b}}+\mu ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}})\,{\varvec{\times }}\,{\varvec{H}}\quad {\text{on}}\; \varOmega , \end{aligned}$$
(10b)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot (\mu {\varvec{H}}) = 0, \end{aligned}$$
(10c)
$$\begin{aligned} {\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) + \sigma \mu \frac{\partial {\varvec{H}}}{\partial t} = \sigma \mu {\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \quad {\text{on}}\; \varOmega . \end{aligned}$$
(10d)

2.2 Variational formulation

Denoting the variations of \({\varvec{u}}\) and \({\varvec{p}}\) by \({\varvec{u}}_{\delta }\) and \(p_\delta \), respectively, we can write variational statements corresponding to Eqs. (10a) and (10b) as

$$\begin{aligned}&\int _{\varOmega }p_{\delta }{\boldsymbol{\nabla}}\cdot {\varvec{u}}\,d\varOmega =0\quad \forall p_{\delta }, \end{aligned}$$
(11a)
$$\begin{aligned}&\int _{\varOmega }\rho {\varvec{u}}_{\delta }^T\frac{\partial {\varvec{u}}}{\partial t}\,d\varOmega +\int _{\varOmega }\rho {\varvec{u}}_{\delta }^T({\boldsymbol{\nabla}}{\varvec{u}}){\varvec{u}}\,d\varOmega -\int _{\varOmega }({\boldsymbol{\nabla}}\cdot {\varvec{u}}_{\delta }) p\,d\varOmega \nonumber \\&\quad+ \int _{\varOmega }[{\varvec{D}}_c({\varvec{u}}_{\delta })]^T{\mathbb {C}}_c{\varvec{D}}_c\,d\varOmega = \int _{\varOmega }\rho {\varvec{u}}_{\delta }^T{\varvec{b}}\,d\varOmega \nonumber \\&\quad+ \int _{\varOmega }\mu {\varvec{u}}_{\delta }^T[({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}})\,{\varvec{\times }}\,{\varvec{H}}]\,d\varOmega +\int _{\varGamma _t}{\varvec{u}}_{\delta }^T{\bar{{\varvec{t}}}}\,d\varGamma \quad \forall {\varvec{u}}_{\delta }, \end{aligned}$$
(11b)

where \({\mathbb {C}}_c\) is material constitutive tensor for the viscous stress, and \({\varvec{D}}_c\) is rate of deformation tensor, both expressed in ‘engineering’ form as

$$\begin{aligned} {\varvec{D}}_c=\begin{bmatrix} D_{xx} \\ D_{yy} \\ D_{zz} \\ 2D_{xy} \\ 2D_{yz} \\ 2D_{xz} \end{bmatrix},\quad {\mathbb {C}}_c=\begin{bmatrix} 2\mu _v&0&0&0&0&0 \\ 0&2\mu _v&0&0&0&0 \\ 0&0&2\mu _v&0&0&0 \\ 0&0&0&\mu _v&0&0 \\ 0&0&0&0&\mu _v&0 \\ 0&0&0&0&0&\mu _v \end{bmatrix}. \end{aligned}$$

Note that the only nonlinear term in Eq. (11) is the \(\left( {\boldsymbol{\nabla}}{\varvec{u}}\right) {\varvec{u}}\) term.

Introducing a penalty term similar to the formulation in [26, 27] and carrying out a suitable integration by parts, the variational statement corresponding to Eq. (10d) can be written as

$$\begin{aligned}&\int _{\varOmega }\sigma \mu {\varvec{H}}_{\delta }\cdot \frac{\partial {\varvec{H}}}{\partial t}\,d\varOmega +\int _{\varOmega }\left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}_{\delta }\right) \cdot \left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varOmega \\&\quad + \int _{\varOmega }\left( {\boldsymbol{\nabla}}\cdot {\varvec{H}}_{\delta }\right) \left( {\boldsymbol{\nabla}}\cdot {\varvec{H}}\right) \,d\varOmega - \int _{\varOmega }\sigma \mu \left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}_{\delta }\right) \cdot \left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varOmega \\&\quad\quad = \int _{\varGamma }\sigma \mu \left( {\varvec{H}}_{\delta }\,{\varvec{\times }}\,{\varvec{n}}\right) \cdot \left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varGamma - \int _{\varGamma }\left( {\varvec{H}}_{\delta }\,{\varvec{\times }}\,{\varvec{n}}\right) \cdot \left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varGamma \quad \forall {\varvec{H}}_{\delta }, \end{aligned}$$

where \({\varvec{H}}_{\delta }\) represents the variation of \({\varvec{H}}\). Note that the penalty term satisfies Eq. (10c), which thus does not need to be considered explicitly.

Using Eqs. (6c) and (7), we can rewrite the second boundary term as \(-\int _{\varGamma }\sigma \left( {\varvec{H}}_{\delta }\,{\varvec{\times }}\,{\varvec{n}}\right) \cdot {\varvec{E}}\). This boundary term is zero if either \({\varvec{H}}\,{\varvec{\times }}\,{\varvec{n}}\) is specified or the surface is perfectly conducting \(({\varvec{E}}\,{\varvec{\times }}\,{\varvec{n}}= {\mathbf {0}})\). Thus, under these conditions, this equation reduces to

$$\begin{aligned}&\int _{\varOmega }\sigma \mu {\varvec{H}}_{\delta }\cdot \frac{\partial {\varvec{H}}}{\partial t}\,d\varOmega +\int _{\varOmega }\left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}_{\delta }\right) \cdot \left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varOmega \nonumber \\&\quad + \int _{\varOmega }\left( {\boldsymbol{\nabla}}\cdot {\varvec{H}}_{\delta }\right) \left( {\boldsymbol{\nabla}}\cdot {\varvec{H}}\right) \,d\varOmega - \int _{\varOmega }\sigma \mu \left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}_{\delta }\right) \cdot \left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varOmega \nonumber \\&\quad\quad = \int _{\varGamma }\sigma \mu \left( {\varvec{H}}_{\delta }\,{\varvec{\times }}\,{\varvec{n}}\right) \cdot \left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \,d\varGamma \quad \forall {\varvec{H}}_{\delta }. \end{aligned}$$
(12)

We denote the field variables at times \(t_n\) and \(t_{n+1}\) by superscripts n and \(n+1\), respectively, and the field variables at the previous and current iterations at the current time step \(t^{n+1}\) by superscripts k and \(k+1\) (in which case the superscript \(n+1\) is suppressed). Let \(t_{\Delta }^{n+1}\) denote the difference \(t^{n+1}-t^{n}\). Using the generalized trapezoidal rule for the time discretization of \({\varvec{u}}\) and \({\varvec{H}}\), we have

$$\begin{aligned} {\varvec{u}}^{n+1}&= {\varvec{u}}^{n} + \left[ (1-\alpha ){\dot{{\varvec{u}}}}^{n}+\alpha {\dot{{\varvec{u}}}}^{n+1}\right] t_{\Delta }^{n+1}, \\ {\varvec{H}}^{n+1}&= {\varvec{H}}^{n} + \left[ (1-\alpha ){\dot{{\varvec{H}}}}^{n}+\alpha {\dot{{\varvec{H}}}}^{n+1}\right] t_{\Delta }^{n+1}. \end{aligned}$$

We now linearize the variational statements given by Eqs. (11) and (12) using the following incremental relations:

$$\begin{aligned} {\varvec{u}}^{k+1}&= {\varvec{u}}^{k} + {\varvec{u}}_{\Delta }, \\ p^{k+1}&= p^{k} + p_{\Delta }, \\ {\varvec{H}}^{k+1}&= {\varvec{H}}^{k} + {\varvec{H}}_{\Delta }. \end{aligned}$$

In modelling electromagnetic problems using nodal finite elements, one major difficulty that is encountered is the occurrence of spurious modes. A penalty term is generally added to suppress the spurious modes. Although this strategy works for convex domains, it fails to model sharp corners and edges. In [28], we have developed a strategy for circumventing this problem, whereby we use a thin layer of elements with zero penalty surrounding the surfaces with sharp edges, while in the rest of the domain, a nonzero penalty is used. Based on a large number of benchmark problems, we have shown in [28] that this strategy works successfully.

2.3 Finite-element formulation

Let the magnetic, velocity and pressure fields, and their variations (denoted by subscript \(\delta \)) and increments (denoted by subscript \(\Delta \)) be interpolated as

$$\begin{aligned} &{\varvec{H}}= {\varvec{N}}{\hat{{\varvec{H}}}},\quad {\varvec{u}}={\varvec{N}}{\hat{{\varvec{u}}}},\quad p={\varvec{N}}_p{\hat{{\varvec{p}}}}, \\ &{\varvec{H}}_{\delta }= {\varvec{N}}{\hat{{\varvec{H}}}}_{\delta },\quad {\varvec{u}}_{\delta }={\varvec{N}}{\hat{{\varvec{u}}}}_{\delta },\quad p_{\delta }= {\varvec{N}}_p{\hat{{\varvec{p}}}}_{\delta }, \\ &{{\varvec{H}}_{\Delta }}= {\varvec{N}}{\hat{{\varvec{H}}}}_{\Delta },\quad{{\varvec{u}}_{\Delta }}={\varvec{N}}{\hat{{\varvec{u}}}}_{\Delta },\quad p_{\Delta }= {\varvec{N}}_p{\hat{{\varvec{p}}}}_{\Delta }. \end{aligned}$$

The shape functions \({\varvec{N}}\) for \({\varvec{u}}\) and \({\varvec{H}}\) are the standard Lagrange shape functions, while the pressure field interpolation \({\varvec{N}}_p\) is chosen as in [24] to be continuous and one order lower (‘Taylor–Hood element’), so that the mixed finite-element strategy satisfies the BB (or inf-sup) condition [10]. In this work, we use Q9/Q4/Q9 (biquadratic/bilinear/biquadratic) and B27/B8/B27 (triquadratic/trilinear/triquadratic) elements for two- and three-dimensional problems.

Using these interpolation functions, we have

$$\begin{aligned} {\varvec{D}}_c\left( {{\varvec{u}}_{\Delta }}^{k+1}\right)&={{\varvec{B}}}{\hat{{\varvec{u}}}}_{\Delta }^{k+1}, \\ \left( {\boldsymbol{\nabla}}{{\varvec{u}}_{\Delta }}^{k+1}\right) {\varvec{u}}^k&={\varvec{R}}{{\varvec{B}}}_{NL}{\hat{{\varvec{u}}}}_{\Delta }^{k+1}, \\ {\boldsymbol{\nabla}}\cdot {{\varvec{u}}_{\Delta }}^{k+1}&={{\varvec{B}}}_p{\hat{{\varvec{u}}}}_{\Delta }^{k+1}, \\ {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{{\varvec{H}}_{\Delta }}^{k+1}&= {{\varvec{B}}}_H{\hat{{\varvec{H}}}}_{\Delta }^{k+1}, \\ {\boldsymbol{\nabla}}\cdot {{\varvec{H}}_{\Delta }}^{k+1}&= {{\varvec{B}}}_p{\hat{{\varvec{H}}}}_{\Delta }^{k+1}, \end{aligned}$$

where

$$\begin{aligned} {{\varvec{B}}}&=\begin{bmatrix} N_{1,x}&0&0&N_{2,x}&0&0&.&.&.\\ 0&N_{1,y}&0&0&N_{2,y}&0&.&.&.\\ 0&0&N_{1,z}&0&0&N_{2,z}&.&.&.\\ N_{1,y}&N_{1,x}&0&N_{2,y}&N_{2,x}&0&.&.&.\\ 0&N_{1,z}&N_{1,y}&0&N_{2,z}&N_{2,y}&.&.&.\\ N_{1,z}&0&N_{1,x}&N_{2,z}&0&N_{2,x}&.&.&. \end{bmatrix}, \end{aligned}$$
(13a)
$$\begin{aligned} {{\varvec{B}}}_p&=\begin{bmatrix} N_{1,x}&N_{1,y}&N_{1,z}&N_{2,x}&N_{2,y}&N_{2,z}&.&.&. \end{bmatrix}, \end{aligned}$$
(13b)
$$\begin{aligned} {\varvec{R}}&=\begin{bmatrix} u_x^k&u_y^k&u_z^k&0&0&0&0&0&0 \\ 0&0&0&u_x^k&u_y^k&u_z^k&0&0&0 \\ 0&0&0&0&0&0&u_x^k&u_y^k&u_z^k \end{bmatrix}, \end{aligned}$$
(13c)
$$\begin{aligned} {{\varvec{B}}}_{NL}&=\begin{bmatrix} N_{1,x}&0&0&N_{2,x}&0&0&.&.&.\\ N_{1,y}&0&0&N_{2,y}&0&0&.&.&.\\ N_{1,z}&0&0&N_{2,z}&0&0&.&.&.\\ 0&N_{1,x}&0&0&N_{2,x}&0&.&.&.\\ 0&N_{1,y}&0&0&N_{2,y}&0&.&.&.\\ 0&N_{1,z}&0&0&N_{2,z}&0&.&.&.\\ 0&0&N_{1,x}&0&0&N_{2,x}&.&.&.\\ 0&0&N_{1,y}&0&0&N_{2,y}&.&.&.\\ 0&0&N_{1,z}&0&0&N_{2,z}&.&.&.\end{bmatrix}, \end{aligned}$$
(13d)
$$\begin{aligned} {{\varvec{B}}}_H&=\begin{bmatrix} 0&-N_{1,z}&N_{1,y}&0&-N_{2,z}&N_{2,y}&.&.&. \\ N_{1,z}&0&-N_{1,x}&N_{2,z}&0&-N_{2,x}&.&.&. \\ -N_{1,y}&N_{1,x}&0&-N_{2,y}&N_{2,x}&0&.&.&. \end{bmatrix}. \end{aligned}$$
(13e)

After carrying out a linearization of the variational statements, the discretizations of the various cross-product terms that occur in this formulation are as follows:

$$\begin{aligned} {{\varvec{H}}_{\Delta }}^{k+1}\,{\varvec{\times }}\,{\varvec{u}}^k&= -{\varvec{u}}_{{\text {mat}}}^k{\varvec{N}}{\hat{{\varvec{H}}}}_{\Delta }^{k+1}, \\ {{\varvec{u}}_{\Delta }}^{k+1}\,{\varvec{\times }}\,{\varvec{H}}^k&= -{\varvec{H}}_{{\text {mat}}}^k{\varvec{N}}{\hat{{\varvec{u}}}}_{\Delta }^{k+1}, \\ {\varvec{u}}^k \,{\varvec{\times }}\,{\varvec{H}}^k&= -{\varvec{H}}_{{\text {mat}}}^k{\varvec{u}}^k, \\ {\varvec{H}}_{\delta }\,{\varvec{\times }}\,{\varvec{n}}&= -{\varvec{n}}_{{\text {mat}}}{\varvec{N}}\hat{{\varvec{H}}_{\delta }}, \\ {\varvec{G}}^k&= {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k, \\ ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,{\varvec{\times }}\,{\varvec{H}}^k&= -{\varvec{H}}_{{\text {mat}}}^k{\varvec{G}}^k,\\ {\varvec{u}}_{\delta }\,{\varvec{\times }}\,({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)&= -{\varvec{G}}_{{\text {mat}}}^k{\varvec{N}}{\hat{{\varvec{u}}}}_{\delta }, \end{aligned}$$

where

$$\begin{aligned} {\varvec{u}}_{{\text {mat}}}^k =\begin{bmatrix} 0&-u^k_3&u^k_2 \\ u^k_3&0&-u^k_1 \\ -u^k_2&u^k_1&0 \end{bmatrix},\quad {\varvec{H}}_{{\text {mat}}}^k =\begin{bmatrix} 0&-H^k_3&H^k_2 \\ H^k_3&0&-H^k_1 \\ -H^k_2&H^k_1&0 \end{bmatrix}, \\ {\varvec{G}}_{{\text {mat}}}^k =\begin{bmatrix} 0&-G^k_3&G^k_2 \\ G^k_3&0&-G^k_1 \\ -G^k_2&G^k_1&0 \end{bmatrix}, \quad {\varvec{n}}_{{\text {mat}}} =\begin{bmatrix} 0&-n_3&n_2 \\ n_3&0&-n_1 \\ -n_2&n_1&0 \end{bmatrix}. \end{aligned}$$

Substituting these relations into the linearized form of the variational formulation given by Eqs. (11) and (12), we get the discrete form of the equations as

$$\begin{aligned}&\left( \begin{bmatrix} {\varvec{M}}_{uu}&{\mathbf {0}}&{\mathbf {0}}\\ {\mathbf {0}}&{\mathbf {0}}&{\mathbf {0}}\\ {\mathbf {0}}&{\mathbf {0}}&{\varvec{M}}_{HH} \end{bmatrix} + \alpha t_{\Delta }^{n+1} \begin{bmatrix} {\varvec{K}}_{uu}&{\varvec{K}}_{up}&{\varvec{K}}_{uH} \\ {\varvec{K}}_{pu}&{\mathbf {0}}&{\mathbf {0}}\\ {\varvec{K}}_{Hu}&{\mathbf {0}}&{\varvec{K}}_{HH} \end{bmatrix}\right) \begin{bmatrix} \left( {\hat{{\varvec{u}}}}_{\Delta }^{k+1}\right) ^{n+1} \\ \left( {\hat{{\varvec{p}}}}_{\Delta }^{k+1}\right) ^{n+1} \\ \left( {\hat{{\varvec{H}}}}_{\Delta }^{k+1}\right) ^{n+1} \end{bmatrix} \nonumber \\&\quad = \begin{bmatrix} {\varvec{F}}_u \\ {\varvec{F}}_p \\ {\varvec{F}}_H \end{bmatrix}, \end{aligned}$$
(14)

where

$$\begin{aligned} {\varvec{M}}_{uu}&= \int _{\varOmega }\rho {\varvec{N}}^T{\varvec{N}}\,d\varOmega , \\ {\varvec{M}}_{HH}&= \int _{\varOmega }\sigma \mu {\varvec{N}}^T{\varvec{N}}\,d\varOmega , \\ {\varvec{K}}_{uu}&= \int _{\varOmega }\rho {\varvec{N}}^T({\boldsymbol{\nabla}}{\varvec{u}}^k){\varvec{N}}\,d\varOmega + \int _{\varOmega }\rho {\varvec{N}}^T{\varvec{R}}{{\varvec{B}}}_{NL}\,d\varOmega + \int _{\varOmega }{{\varvec{B}}}^T{\mathbb {C}}_c{{\varvec{B}}}\,d\varOmega , \\ {\varvec{K}}_{up}&= -\int _{\varOmega }{{\varvec{B}}}_p^T{\varvec{N}}_p\,d\varOmega , \\ {\varvec{K}}_{uH}&= \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{H}}_{{\text {mat}}}^k{{\varvec{B}}}_H\,d\varOmega - \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{G}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega , \\ {\varvec{K}}_{pu}&= \int _{\varOmega }{\varvec{N}}_p^T{{\varvec{B}}}_p\,d\varOmega , \\ {\varvec{K}}_{Hu}&= \int _{\varOmega }\mu \sigma {{\varvec{B}}}_H^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega - \int _{\varGamma }\mu \sigma {\varvec{N}}^T{\varvec{n}}_{{\text {mat}}}^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{N}}\,d\varGamma , \\ {\varvec{K}}_{HH}&= \int _{\varOmega }{{\varvec{B}}}_H^T{{\varvec{B}}}_H\,d\varOmega + \int _{\varOmega }{{\varvec{B}}}_p^T{{\varvec{B}}}_p\,d\varOmega - \int _{\varOmega }\mu \sigma {{\varvec{B}}}_H^T {\varvec{u}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega \\&\quad+\int _{\varGamma }\mu \sigma {\varvec{N}}^T{\varvec{n}}_{{\text {mat}}}^T{\varvec{u}}_{{\text {mat}}}^k{\varvec{N}}\,d\varGamma ,\\ {\varvec{F}}_u&= \alpha t_{\Delta }^{n+1}\left \{\int _{\varOmega }\rho {\varvec{N}}^T{\varvec{b}}^{n+1}\,d\varOmega + \int _{\varGamma _t}{\varvec{N}}^T{\bar{{\varvec{t}}}}^{n+1}\,d\varGamma - \int _{\varOmega }{{\varvec{B}}}^T{\varvec{\tau }}^k\,d\varOmega \right.\\&\left.\quad-\int _{\varOmega }\rho {\varvec{N}}^T\left[ ({\boldsymbol{\nabla}}{\varvec{u}}^k){\varvec{u}}^k\right] \,d\varOmega - \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{H}}_{{\text {mat}}}^k({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,d\varOmega \right \} \\&\quad+\int _{\varOmega }\rho {\varvec{N}}^T \left[ {\varvec{u}}^n-{\varvec{u}}^k+(1-\alpha )t_{\Delta }^{n+1}{\dot{{\varvec{u}}}^n}\right] \,d\varOmega , \\ {\varvec{F}}_p&= -\alpha t_{\Delta }^{n+1}\int _{\varOmega }{\varvec{N}}_p^T({\boldsymbol{\nabla}}\cdot {\varvec{u}}^k)\,d\varOmega ,\\ {\varvec{F}}_H&= \alpha t_{\Delta }^{n+1}\left \{\int _{\varGamma }\mu \sigma {\varvec{N}}^T{\varvec{n}}_{{\text {mat}}}^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{u}}^k\,d\varGamma -\int _{\varOmega }\sigma \mu {{\varvec{B}}}_H^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{u}}^k\,d\varOmega \right. \\&\left.\quad-\int _{\varOmega }{{\varvec{B}}}_H^T({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,d\varOmega - \int _{\varOmega }{{\varvec{B}}}_p^T({\boldsymbol{\nabla}}\cdot {\varvec{H}}^k)\,d\varOmega \right \} \\&\quad+\int _{\varOmega }\sigma \mu {\varvec{N}}^T\left[ {\varvec{H}}^n - {\varvec{H}}^k + (1-\alpha )t_{\Delta }^{n+1}{\dot{{\varvec{H}}}^n}\right] \,d\varOmega . \end{aligned}$$

We use a direct sparse matrix solver [29, 30] for solving the system of equations given by Eq. (14).

2.4 Steady-state formulation

Under steady-state conditions, the governing differential equations (10) simplify to

$$\begin{aligned}&{\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\right) = \sigma \mu {\boldsymbol{\nabla}}\,{\varvec{\times }}\,\left( {\varvec{u}}\,{\varvec{\times }}\,{\varvec{H}}\right) \quad {\text{on}}\; \varOmega , \end{aligned}$$
(15a)
$$\begin{aligned} {\boldsymbol{\nabla}}\cdot {\varvec{u}}=0 \quad {\text{on}}\; \varOmega , \end{aligned}$$
(15b)
$$\begin{aligned} \rho ({\boldsymbol{\nabla}}{\varvec{u}}){\varvec{u}}= {\boldsymbol{\nabla}}\cdot {\varvec{\tau }}+\rho {\varvec{b}}+\mu ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}})\,{\varvec{\times }}\,{\varvec{H}}\quad{\text {on}}\; \varOmega . \end{aligned}$$
(15c)

In place of Eq. (14), we now get

$$\begin{aligned} \begin{bmatrix} {\varvec{K}}_{uu}&{\varvec{K}}_{up}&{\varvec{K}}_{uH} \\ {\varvec{K}}_{pu}&{\mathbf {0}}&{\mathbf {0}}\\ {\varvec{K}}_{Hu}&{\mathbf {0}}&{\varvec{K}}_{HH} \end{bmatrix} \begin{bmatrix} {\hat{{\varvec{u}}}}_{\Delta }^{k+1} \\ {\hat{{\varvec{p}}}}_{\Delta }^{k+1} \\ {\hat{{\varvec{H}}}}_{\Delta }^{k+1} \end{bmatrix} = \begin{bmatrix} {\varvec{F}}_u \\ {\varvec{F}}_p \\ {\varvec{F}}_H \end{bmatrix}, \end{aligned}$$
(16)

where

$$\begin{aligned} {\varvec{K}}_{uu}&= \int _{\varOmega }\rho {\varvec{N}}^T({\boldsymbol{\nabla}}{\varvec{u}}^k){\varvec{N}}\,d\varOmega + \int _{\varOmega }\rho {\varvec{N}}^T{\varvec{R}}{{\varvec{B}}}_{NL}\,d\varOmega + \int _{\varOmega }{{\varvec{B}}}^T{\mathbb {C}}_c{{\varvec{B}}}\,d\varOmega , \\ {\varvec{K}}_{up}&= -\int _{\varOmega }{{\varvec{B}}}_p^T{\varvec{N}}_p\,d\varOmega , \\ {\varvec{K}}_{uH}&= \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{H}}_{{\text {mat}}}^k{{\varvec{B}}}_H\,d\varOmega - \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{G}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega , \\ {\varvec{K}}_{pu}&= \int _{\varOmega }{\varvec{N}}_p^T{{\varvec{B}}}_p\,d\varOmega , \\ {\varvec{K}}_{Hu}&= \int _{\varOmega }\mu \sigma {{\varvec{B}}}_H^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega , \\ {\varvec{K}}_{HH}&= \int _{\varOmega }{{\varvec{B}}}_H^T{{\varvec{B}}}_H\,d\varOmega + \int _{\varOmega }{{\varvec{B}}}_p^T{{\varvec{B}}}_p\,d\varOmega - \int _{\varOmega }\mu \sigma {{\varvec{B}}}_H^T {\varvec{u}}_{{\text {mat}}}^k{\varvec{N}}\,d\varOmega ,\\ {\varvec{F}}_u&= \int _{\varOmega }\rho {\varvec{N}}^T{\varvec{b}}\,d\varOmega + \int _{\varGamma _t}{\varvec{N}}^T{\bar{{\varvec{t}}}}\,d\varGamma - \int _{\varOmega }\rho {\varvec{N}}^T\left[ ({\boldsymbol{\nabla}}{\varvec{u}}^k){\varvec{u}}^k\right] \,d\varOmega \\&\quad -\int _{\varOmega }{{\varvec{B}}}^T{\varvec{\tau }}^k\,d\varOmega - \int _{\varOmega }\mu {\varvec{N}}^T{\varvec{H}}_{{\text {mat}}}^k({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,d\varOmega , \\ {\varvec{F}}_p&= -\int _{\varOmega }{\varvec{N}}_p^T({\boldsymbol{\nabla}}\cdot {\varvec{u}}^k)\,d\varOmega ,\\ {\varvec{F}}_H&= -\int _{\varOmega }\sigma \mu {{\varvec{B}}}_H^T{\varvec{H}}_{{\text {mat}}}^k{\varvec{u}}^k\,d\varOmega - \int _{\varOmega }{{\varvec{B}}}_H^T({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,d\varOmega \\&\quad-\int _{\varOmega }{{\varvec{B}}}_p^T({\boldsymbol{\nabla}}\cdot {\varvec{H}}^k)\,d\varOmega . \end{aligned}$$

These equations can be used to solve for the steady-state solution (in case it exists).

2.5 Two-dimensional formulation

For two-dimensional flows, we have \({\varvec{u}}= (u_x,u_y)\) and \({\varvec{H}}= (H_x,H_y)\). Only the z-component of \({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}\) given by \(\partial H_y/\partial x - \partial H_x/\partial y\) is nonzero. In place of Eq. (13), we have

$$\begin{aligned} {{\varvec{B}}}&=\begin{bmatrix} N_{1,x}&0&N_{2,x}&0&.&.&.\\ 0&N_{1,y}&0&N_{2,y}&.&.&.\\ N_{1,y}&N_{1,x}&N_{2,y}&N_{2,x}&.&.&.\end{bmatrix}, \end{aligned}$$
(17a)
$$\begin{aligned} {{\varvec{B}}}_p&=\begin{bmatrix} N_{1,x}&N_{1,y}&N_{2,x}&N_{2,y}&.&.&. \end{bmatrix}, \end{aligned}$$
(17b)
$$\begin{aligned} {\varvec{R}}&=\begin{bmatrix} u_x^k&u_y^k&0&0 \\ 0&0&u_x^k&u_y^k \end{bmatrix}, \end{aligned}$$
(17c)
$$\begin{aligned} {{\varvec{B}}}_{NL}&=\begin{bmatrix} N_{1,x}&0&N_{2,x}&0&.&.&.\\ N_{1,y}&0&N_{2,y}&0&.&.&.\\ 0&N_{1,x}&0&N_{2,x}&.&.&.\\ 0&N_{1,y}&0&N_{2,y}&.&.&. \end{bmatrix}, \end{aligned}$$
(17d)
$$\begin{aligned} {{\varvec{B}}}_H&=\begin{bmatrix} -N_{1,y}&N_{1,x}&-N_{2,y}&N_{2,x}&.&.&. \end{bmatrix}. \end{aligned}$$
(17e)

The following replacements need to be carried out in the three-dimensional formulation to obtain the two-dimensional one:

$$\begin{aligned} {{\varvec{H}}_{\Delta }}^{k+1}\,{\varvec{\times }}\,{\varvec{u}}^k&\rightarrow -\begin{bmatrix}u^k_x&u^k_y \end{bmatrix}{\varvec{S}}{\hat{{\varvec{H}}}}_{\Delta }^{k+1}, \\ {{\varvec{u}}_{\Delta }}^{k+1}\,{\varvec{\times }}\,{\varvec{H}}^k&\rightarrow -\begin{bmatrix}H^k_x&H^k_y \end{bmatrix}{\varvec{S}}{\hat{{\varvec{u}}}}_{\Delta }^{k+1}, \\ {\varvec{u}}^k \,{\varvec{\times }}\,{\varvec{H}}^k&\rightarrow \begin{bmatrix}u^k_x&u^k_y \end{bmatrix} \begin{bmatrix} H^k_y \\ -H^k_x \end{bmatrix},\\ ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)\,{\varvec{\times }}\,{\varvec{H}}^k&\rightarrow -({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)_z\begin{bmatrix} H^k_y \\ -H^k_x \end{bmatrix}, \\ {\varvec{u}}_{\delta }\,{\varvec{\times }}\,({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)&\rightarrow ({\boldsymbol{\nabla}}\,{\varvec{\times }}\,{\varvec{H}}^k)_z{\varvec{S}}{\hat{{\varvec{u}}}}_{\delta }, \end{aligned}$$

where

$$\begin{aligned} {\varvec{S}}= \begin{bmatrix} 0&N_1&0&N_2&.&.&. \\ -N_1&0&-N_2&0&.&.&. \end{bmatrix}. \end{aligned}$$

3 Numerical examples

We now demonstrate the good performance of the monolithic strategy on a number of problems. We compare the performance of the proposed method with either analytical solutions or results obtained using other numerical strategies, e.g., ones that use a stabilized formulation.

3.1 Hartman–Poiseuille flow

A conducting fluid flows between two parallel plates located at \(y=\pm h\) under the influence of a pressure gradient \(-\rho G\) and a magnetic field \({\varvec{H}}= (B_0/\mu ){\varvec{e}}_y\). The analytical solution is given by [31]

$$\begin{aligned} u_x&= V\left( 1-\frac{\cosh ({{\mathrm{Ha}}}\,\eta )}{\cosh ({{\mathrm{Ha}}})}\right) , \\ u_y&= 0, \quad u_z = 0, \\ H_x&= \frac{B_0 {\mathrm {Re}}_{\mathrm{m}}\sinh ({{\mathrm{Ha}}}\,\eta )}{\mu {{\mathrm{Ha}}}\cosh ({{\mathrm{Ha}}})}-\left( 1+\frac{E}{B_0V}\right) \frac{B_0 {\mathrm {Re}}_{\mathrm{m}}\eta }{\mu }, \\ H_y&= \frac{B_0}{\mu }, \quad H_z = 0, \\ p&= -\rho Gx - \frac{\mu H_x^2}{2}, \end{aligned} $$
(18)

where

$$\begin{aligned} {\mathrm {Re}}_{\mathrm{m}} = \mu \sigma Vh, \quad{{\mathrm{Ha}}}= \sqrt{\frac{\sigma }{\mu _v}}B_0h,\quad \eta = \frac{y}{h}, \end{aligned}$$

and

$$\begin{aligned} &V= \frac{\rho G {{\mathrm{Ha}}}}{\sigma B_0^2 \tanh ({{\mathrm{Ha}}})},\quad E= \frac{\rho G}{\sigma B_0}\left( 1-\frac{{{\mathrm{Ha}}}}{\tanh ({{\mathrm{Ha}}})}\right) , \quad {\text { (for\,insulating\,walls)}} \\& V= \frac{\rho G}{\sigma B_0^2},\quad E= 0 \quad {\text { (for\,perfectly\,conducting\,walls).}} \\ \end{aligned}$$

We use the same parameters as in [13], namely, \(\sigma = 7.14\times 10^5\ (\Omega \,{\text {m}})^{-1}\), \(\mu _r = 9.2878\), \(\mu _v = 1.5\times 10^{-4}\, {\text {kg}}/({\text {m s}})\), \(\rho G = 4.85\times 10^{-5}\, {\text {Pa/m}}\), \(h = 0.5\, {\text {m}}\), \(B_0 = 1.4494\times 10^{-4}\, {\text {Tesla}}\) (corresponding to \({{\mathrm{Ha}}}= 5\)). The domain is \([0,1]\,{\text {m}}\times [-0.5,0.5]\,{\text {m}}\). We impose \({\varvec{u}}={\mathbf {0}}\) and \(H_x=0\) on the surfaces \(y=\pm 0.5\), while on the surfaces \(x = 0,1\), we impose the traction (which in this case turns out to be the same as the pressure times the normal) obtained from the analytical solution, and \(H_y = \mu B_0\). The pressure value at the origin is prescribed to be zero (datum value). We use the Q9/Q4/Q9 element for meshing; the mesh specifications for different Hartman numbers are given in table 1. Figure 1 (compare with figures 9 and 10 of [13]) shows the excellent match of the numerical and analytical results. For all cases, convergence was achieved in just 2 iterations. Nizar [12] has solved the same problem with a mesh of 1600 nodes. Shadid et al [14] use a \(200\times 200\) element mesh for \({{\mathrm{Ha}}}= 20\), while in the present formulation, only a 99-node mesh suffices to get an almost perfect match with the analytical solution.

Table 1 Mesh specifications for the Hartman–Poiseuille problem.
Figure 1
figure 1

Variation of (a) velocity \(u_x\) and (b) magnetic field \(B_x^*=H_xB_0/(\rho G h)\) as a function of y for the Hartman–Poiseuille flow with insulating boundary.

3.2 Hartman–Poiseuille flow with external induced current

In the Hartman–Poiseuille flow, if the duct wall has thickness t and length L, has finite conductivity \(\sigma _p\) and carries an external current I, then the solution is the same as that given by Eq. (18) except that now [31]

$$\begin{aligned} E&= \frac{{{\mathrm{Ha}}}}{C{{\mathrm{Ha}}}+\tanh ({{\mathrm{Ha}}})}\left( \frac{-\rho G}{\sigma B_0}\left[ 1-\frac{\tanh ({{\mathrm{Ha}}})}{{{\mathrm{Ha}}}}\right] + \frac{I}{2\sigma L h}\right) , \\ V&= \frac{{{\mathrm{Ha}}}}{C{{\mathrm{Ha}}}+\tanh ({{\mathrm{Ha}}})}\left( \frac{\rho G(1+C)}{\sigma B_0^2}-\frac{I}{2\sigma B_0 Lh}\right) , \end{aligned}$$

where \(C = \sigma _p t/(\sigma h)\). For \(I < 0\) the system can be used as an electromagnetic pump whose discharge is greater than \(I = 0\). For \(0< I < I_{\text {cr}}\), it can be operated as an electrical generator where \(I_{\text {cr}} = (1+C)2hL\rho G/B_0\). For \(I > I_{\text {cr}}\), the Lorentz force opposes the pressure gradient, so that if it is strong enough, it can even reverse the direction of flow.

We have used the same material properties as in the insulated boundary problem. The other properties are \(h = 0.5 \,{\text {m}}\), \(B_0 = 2.8988\times 10^{-4}\) Tesla (corresponding to \({{\mathrm{Ha}}}= 10\)), \(L = 1 \,{\text {m}}\) and \(C = 0.5\). For these parameters \(I_{\text {cr}} = 0.251\). We have used a \(1\times 8\) (51 nodes) mesh of Q9/Q4/Q9 elements for all the cases, and again convergence is obtained with two iterations for each case. Figure 2 shows the almost perfect match between the numerical and analytical values for different I values. The discharge with \(I < 0\) is more than that with \(I = 0\). For \(I = 0.5 > I_{\text {cr}}\), the direction of flow reverses.

Figure 2
figure 2

Variation of (a) velocity \(u_x\) and (b) magnetic field \(B_x^*=H_xB_0/(\rho G h)\) as a function of y for the Hartman–Poiseuille flow with external induced current.

Figure 3
figure 3

Variation of (a) velocity and (b) magnetic field as a function of y for the Hartman–Couette flow with insulating boundary.

Figure 4
figure 4

Variation of (a) velocity and (b) magnetic field as a function of y for the Hartman–Couette flow with conducting boundary.

3.3 Hartman–Couette flow

The flow, instead of being driven by a pressure gradient as in the previous example, is driven by a prescribed velocity \(u_x=u_0\) on the top surface and a magnetic field \({\varvec{H}}=(B_0/\mu ){\varvec{e}}_y\). The bottom and top surfaces are located at \(y=(0,h)\).

The analytical solution is given by [31]

$$\begin{aligned} u_x&= \frac{u_0\sinh ({{\mathrm{Ha}}}\,\eta )}{\sinh ({{\mathrm{Ha}}})} + \frac{E_0}{B_0}\left \{\frac{\sinh ({{\mathrm{Ha}}}\,\eta )(1-\cosh ({{\mathrm{Ha}}}))}{\sinh ({{\mathrm{Ha}}})}+\cosh ({{\mathrm{Ha}}}\,\eta )-1\right \}, \\ u_y&= 0, \\ u_z&= 0, \\ H_x&= -\frac{B_0{\mathrm {Re}}_{\mathrm{m}}\cosh ({{\mathrm{Ha}}}\,\eta )}{\mu {{\mathrm{Ha}}}\sinh ({{\mathrm{Ha}}})}- \frac{\sigma E_0h}{{{\mathrm{Ha}}}}\left\{\frac{\cosh ({{\mathrm{Ha}}}\,\eta )(1-\cosh ({{\mathrm{Ha}}}))}{\sinh ({{\mathrm{Ha}}})} + \sinh ({{\mathrm{Ha}}}\,\eta )\right\}, \\ H_y&= \frac{B_0}{\mu }, \\ H_z&= 0, \\ p&= \frac{\mu }{2} \left[ {H_x^2}|_{\eta =0}-H_x^2\right] , \end{aligned} $$
(19)

where

$$\begin{aligned} {\mathrm {Re}}_{\mathrm{m}}&= \mu \sigma u_0 h, \\ {{\mathrm{Ha}}}&= \sqrt{\frac{\sigma }{\rho \nu }}B_0h, \\ \eta&= \frac{y}{h}, \end{aligned}$$

and

$$\begin{aligned} &E_0= -\frac{B_0u_0}{2},\quad{\text {(for\,insulating\,walls)}}, \\ &E_0= 0,\quad{\text {(for\,perfectly\,conducting\,walls)}}. \end{aligned}$$

The material properties are \(\sigma = 2\, (\Omega \,{\text {m}})^{-1}\), \(\mu _r = 3.3156\times 10^6\) and \(\mu _v = 15\, {\text {kg}}/{\text {m s}}\). We have chosen \(B_0 = 27.3886\) and 54.7722 Tesla (corresponding to \({{\mathrm{Ha}}}= 10\) and 20), and \(h = 1\,{\text {m}}\). The no-slip condition is imposed on the top and bottom surfaces. The traction is prescribed on the surfaces \(x = 0, 1\), and the pressure at the origin is prescribed to zero to fix the datum value. The tangential \({\varvec{H}}\) field is prescribed on all the boundaries.

We have used a \(1\times 8\) mesh of Q9/Q4/Q9 elements (51 nodes and 139 degrees of freedom (dofs)) for all the cases considered. In each case, convergence is achieved in 4 iterations. Figures 3 and 4 show the almost perfect match between the numerical and analytical results for both types of boundary conditions.

3.4 Flux expulsion problem

An infinitely long cylinder of radius \(r_0\) rotates with a constant angular velocity \(\omega _0\) in a conducting medium of magnetic permeability \(\mu \) and conductivity \(\sigma \), in a uniform magnetic field \((B_0,0,0)\), and if the flow velocity is zero outside the cylinder, then the analytical solution is given by [32], for \(r\le r_0\):

$$\begin{aligned} u_x&= -\omega _0 y, \\ u_y&= \omega _0 x, \\ H_x&= {\text {Im}}\left[ \frac{B_0De^{i\theta }}{\mu }\left( \frac{q\sin \theta }{2}\left[ J_0(qr)-J_2(qr)\right] + \frac{i\cos \theta J_1(qr)}{r}\right) \right] , \\ H_y&= {\text {Im}}\left[ \frac{B_0De^{i\theta }}{\mu }\left( \frac{i\sin \theta J_1(qr)}{r}- \frac{q\cos \theta }{2}\left[ J_0(qr)-J_2(qr)\right] \right) \right] , \\ \end{aligned}$$

whereas for \(r>r_0\)

$$\begin{aligned} u_x&= 0,\\ u_y&= 0, \\ H_x&= {\text {Im}}\left[ \frac{B_0e^{i\theta }}{\mu }\left( \left[ 1-\frac{C}{r^2}\right] \sin \theta +\frac{i\cos \theta }{r}\left[ \frac{C}{r}+r\right] \right) \right] , \\ H_y&= {\text {Im}}\left[ \frac{Be^{i\theta }}{\mu }\left( \frac{i\sin \theta }{r}\left[ \frac{C}{r}+r\right] -\cos \theta \left[ 1-\frac{C}{r^2}\right] \right) \right] , \\ \end{aligned}$$

and \(u_z = p = H_z = 0, \;\forall r\). Here, ‘\( {\text {Im}}\)’ denotes the imaginary part of the argument, and

$$\begin{aligned} C&= \frac{r_0\left[ 2J_1(qr_0)-qr_0J_0(qr_0)\right] }{qJ_0(qr_0)},\\ D&= \frac{2}{qJ_0(qr_0)}, \\ q&= \frac{(1-i)k_0}{\sqrt{2}}, \\ k_0&= \frac{\sqrt{{\mathrm {Re}}_{\mathrm{m}}}}{r_0}, \\ {\mathrm {Re}}_{\mathrm{m}}&= \mu \sigma \omega _0 r_0^2. \end{aligned}$$
Figure 5
figure 5

Mesh for the flux expulsion problem.

The domain used is \([-2,2] \,{\text {m}}\times [-1,1] \,{\text {m}}\). The values of the other parameters are \(r_0 = 0.2\) m, \(\sigma =4\ (\Omega \,{\text {m}})^{-1}\), \(\mu =0.25\ {\text {N/A}}^2\), \(B_0 = 1\) Tesla and \({\mathrm {Re}}_{\mathrm{m}} = 96\). The velocity and pressure are prescribed at all the nodes, while on the outer boundary, the tangential \({\varvec{H}}\) field is prescribed. The used mesh of Q9/Q4/Q9 elements is shown in figure 5 (448 elements, 1777 nodes). The solution converges within 2 iterations. In [14], the same problem is solved using 20000 unstructured Q4 elements. Figure 6 shows the close match with the analytical magnetic field, both inside and outside the cylinder.

Figure 6
figure 6

Variation of the magnetic field along the y-axis for the flux expulsion problem.

Figure 7
figure 7

Variation of the velocity and magnetic field along y for Rayleigh flow at different times.

3.5 Rayleigh flow

Consider a semi-infinite domain of a conducting fluid at rest, which is set in motion at \(t=0\) by a constant velocity U applied to the bottom surface, and a constant applied magnetic field \({\varvec{H}}= B_0{\varvec{e}}_y\). A diffusive wave front propagates in the direction normal to the plate. Ahead of the wavefront the fluid remains at rest, while behind the wavefront, the fluid has a nonzero velocity \(u_x\) and induced magnetic field \(H_x\). An analytical solution can be derived under the restriction \(\nu =1/(\mu \sigma )\). Denoting the error function by \( {\text {erf}}\), the analytical expressions for the various field variables at time t are given by [31]

$$\begin{aligned} u_x&= \frac{U}{4}\left\{2-\left[ {\text {erf}}(\lambda _+)+ {\text {erf}}(\lambda _-)\right] +e^{-A_0y/\nu }\left[ 1- {\text {erf}}(\lambda _-)\right] + e^{A_0y/\nu }\left[ 1- {\text {erf}}(\lambda _+)\right] \right\}, \\ u_y&= 0, \\ u_z&= 0, \\ H_x&=\frac{U\sqrt{\rho }}{4\sqrt{\mu }}\left\{\left[ {\text {erf}}(\lambda _-)- {\text {erf}}(\lambda _+)\right] +e^{-A_0y/\nu }\left[ 1- {\text {erf}}(\lambda _-)\right] - e^{A_0y/\nu }\left[ 1- {\text {erf}}(\lambda _+)\right] \right \}, \\ H_y&= \frac{B_0}{\mu }, \\ H_z&= 0, \\ p&= -\frac{\mu H_x^2}{2}, \end{aligned}$$

where

$$\begin{aligned} \lambda _\pm&= \frac{y\pm A_0t}{2\sqrt{\nu t}}, \\ A_0&= \frac{B_0}{\sqrt{\rho \mu }}. \end{aligned}$$

We have used the following values: \(\rho = 4\times 10^{-5}\, {\text {kg}}/ {\text {m}}^3\), \(\sigma = 7.9577\times 10^{5}\ (\Omega \,{\text {m}})^{-1}\), \(\mu _r = 1\), \(\nu = 1\, {\mathrm {m}}^2/ {\text {s}}\), \(U = 1\, {\text {m}}/{\text {s}}\) and \(B_0 = 1.4494\times 10^{-4}\) Tesla. The domain is the rectangle (0,1) \({\hbox {m}}\times \) (0,4) m. The same problem has also been attempted in [14].

We have used a \(1\times 24\) (147 nodes and 424 dofs) mesh of 9-node quadrilateral elements, while in [14], a mesh of \(50\times 250\) (12101 nodes) linear elements has been used. A time step of 0.001 s and \(\alpha =0.5\) are used. The strategy converges within a maximum of 4 iterations at each time step. Figure 7 shows the almost exact match with the analytical solution (compare against figure 8 of [14]).

3.6 2D lid-driven cavity problem in the presence of a magnetic field

The problem domain is a square with dimension 1 m. The top surface starts moving at time \(t = 0\) with velocity 1 m/s. No slip boundary conditions are applied to the other three surfaces. A uniform magnetic field \({\varvec{H}}= 2\ {\varvec{e}}_y\) A/m is applied throughout the domain at all times. Initially, \(H_x\) is set to zero. For the top and bottom surfaces \(H_x = 0\) for all times. The conducting fluid inside the cavity has density \(1000\,{\mathrm {kg/m}}^{3}\), while the other properties are chosen so that \( {\text {Re}} = 1000\), \({\mathrm {Re}}_{\mathrm{m}} = 1\) and \({{\mathrm{Ha}}}= 20\).

Coarse (\(60\times 60\)) and fine (\(120\times 120\)) meshes of 9-node quadrilateral elements are used to mesh the geometry. For the steady-state analysis, 10 load steps are used, with convergence achieved within each load step within 4 iterations. For the transient analysis, we have used \(\alpha =0.5\) and a time step of 0.5 s, with convergence achieved at each time step within a maximum of 5 iterations. Figure 8 shows the evolution of the velocity profiles at various times for both levels of meshing. The convergence with respect to mesh refinement at all times is also evident from the plot. For this loading, a steady-state solution exists and is reached at sufficiently large times while performing the transient analysis. Figure 9 shows the velocity contours at different times. In order to demonstrate the quadratic convergence of our scheme, figure 10 shows the normalized error norm \(||{\varvec{F}}||_i/||{\varvec{F}}||_0\) as a function of the iteration number at different time steps.

Figure 8
figure 8

Variation of different fields for the 2D lid-driven cavity flow.

Figure 9
figure 9

Velocity contours for the 2D lid-driven cavity flow problem.

Figure 10
figure 10

Convergence of the solution with iterations.

3.7 Hartman–Poiseuille flow through a duct with a rectangular cross-section

A conducting fluid of density \(\rho \), kinematic viscosity \(\nu \) and conductivity \(\sigma \) flows through a duct of rectangular cross-section (see figure 11). A pressure gradient \(-\rho G\) is applied along the z-direction, and the applied magnetic field is \({\varvec{H}}= (B_0/\mu ){\varvec{e}}_y\). The surfaces \(x = \pm b\) and \(y = \pm a\) are referred to as side and Hartman wall, respectively. An analytical solution has been presented in [9, 33]. However, this analytical solution fails to satisfy the governing differential equation at \(x=\pm b\) since the solution corresponding to a zero ‘separation-of-variables’ constant was inadvertently omitted. The corrected solution is given by

$$\begin{aligned} &u_x= 0,\quad u_y= 0,\quad u_z= \frac{1}{\mu _v}V\rho G a^2, \\ &H_x= 0,\quad H_y= \frac{B_0}{\mu },\quad H_z= \sqrt{\frac{\sigma }{\mu _v}}H\rho Ga^2, \\ &p= -\rho Gz - \frac{\mu H_z^2}{2}, \end{aligned}$$

where, with \(\xi =x/a\), \(\eta =y/b\) and \(l=b/a\),

$$\begin{aligned} V&= \frac{1}{2}(l^2-\xi ^2)-\sum _{j=1}^{\infty }\cos \left( \frac{a_j\xi }{l}\right) \left[ c_1\cosh (r_{2j}\eta )+c_2\cosh (r_{1j}\eta )\right] ,\\ H&= \sum _{j=1}^{\infty }\cos \left( \frac{a_j\xi }{l}\right) \left[ c_1\sinh (r_{2j}\eta )+c_2\sinh (r_{1j}\eta )\right] ,\\ a_j&= \frac{(2j-1)\pi }{2}, \\ r_{1j}&= \frac{1}{2}({{\mathrm{Ha}}}-s_j), \\ r_{2j}&= \frac{1}{2}({{\mathrm{Ha}}}+s_j), \\ s_j&= \sqrt{{{\mathrm{Ha}}}^2 + \frac{(1-2j)^2\pi ^2}{l^2}}, \\ {{\mathrm{Ha}}}&= \sqrt{\frac{\sigma }{\mu _v}}B_0a. \end{aligned}$$

The constants \(c_1\) and \(c_2\) depend on the boundary conditions imposed on the Hartman and side walls. The following two cases are considered.

Case 1:

Both Hartman and side walls are insulating

$$ c_1= \frac{k_j\sinh (r_{1j})}{\sinh (s_j)}, \quad c_2 = -\frac{k_j\sinh (r_{2j})}{\sinh (s_j)}, $$
Case 2:

Conducting Hartman wall and insulating side walls

$$ c_1= -\frac{k_j}{2(1+p_jr_{2j})\cosh (r_{2j})}, \quad c_2 = -\frac{k_jr_{2j}}{s_j\cosh (r_{1j})}, $$

where

$$\begin{aligned} k_j&= \frac{16(-1)^jl^2}{(2j-1)^3\pi ^3}, \\ p_j&= \frac{2 {{\mathrm{Ha}}}l^2}{(2j-1)^2\pi ^2}. \end{aligned}$$

The parameters that we have used are \(a = 0.2\, {\text {m}}\), \(b = 0.3\, {\text {m}}\), \(\rho G = 20\,{\text {Pa/m}}\), \(\sigma = 100\ (\Omega \,{\text {m}})^{-1}\), \(\mu _v = 1\, {\text {kg}}\,\text{m}^{-1} {\text {s}}^{-1}\), \(\rho = 1\,{\mathrm {kg/m}}^3\), \(\mu = 1\,{\mathrm {N/A}}^2\), \(B_0 = 5\) and \(10\, {\text {Tesla}}\) (corresponding to \({{\mathrm{Ha}}}= 10\) and \({{\mathrm{Ha}}}= 20\)). For the simulation, we have considered the case where the side and Hartman walls are insulating. Taking into account the symmetry about the y-axis, we have modelled half the domain (0,0.3) m\(\times \)(−0.2,0.2) m. Symmetry boundary conditions (normal \({\varvec{u}}\) and normal \({\varvec{H}}\) are zero) are prescribed on the boundary \(x = 0\). No slip boundary conditions are prescribed for the velocity, and the tangential components of \({\varvec{H}}\) are prescribed to zero on the other three boundaries; 27-node hexahedral meshes of \(5\,(x)\times 10\,(y)\times 1\,(z)\) and \(8\,(x)\times 16\,(y)\times 1\,(z)\) elements for \({{\mathrm{Ha}}}=10\) and 20, respectively, are used. We have used 10 load steps, and in each load step, convergence is achieved in a maximum of 3 iterations. Figure 12 shows the almost perfect agreement with the analytical solution for all the field variables.

Figure 11
figure 11

Hartman–Poiseuille flow through a rectangular duct.

Figure 12
figure 12

Variation of different fields for the 3D Hartman–Poiseuille flow.

Figure 13
figure 13

Mesh for the 3D lid-driven cavity problem.

Figure 14
figure 14

Variation of the different fields with time on the \(z = 0.5\) m plane in the 3D lid-driven cavity problem (\( {\text {Re}} = 1000\), \({{\mathrm{Ha}}}= 20\)).

3.8 3D lid-driven cavity problem in presence of magnetic field

Consider a cube of dimension 1 m filled with a conducting fluid of density \(1000\, {\mathrm {kg/m}}^3\). The other properties are such that \( {\text {Re}} = 1000\), \({\mathrm {Re}}_{\mathrm{m}} = 1\) and \({{\mathrm{Ha}}}= 30\). A uniform magnetic field \({\varvec{H}}= 2{\varvec{e}}_y\) A/m is applied. All other components of \({\varvec{H}}\) and the velocity vector are initially zero. At \(t = 0\), the \(y = 1\) plane of the cavity is set in motion with velocity \(u_x = 1\, {\text {m/s}}\). The tangential magnetic fields are prescribed at the walls, i.e., for \(x = 0, 1\) m planes, \(H_y = 2\), \(H_z = 0\), for \(y = 0,1\) m planes, \(H_x = H_z = 0\) and for \(z = 0, 1\) m planes, \(H_x = 0\), \(H_y = 2\). Because of symmetry considerations, we have modelled half the domain given by \((0,1)\,{\text {m}}\times (0,1)\, {\text {m}}\times (0, 0.5)\, {\text {m}}\). The boundary conditions \(u_z = 0\) and \(H_z = 0\) are prescribed on the symmetry face.

A graded mesh of 27-node hexahedral elements (with a finer mesh near the walls) is used to model this problem. Table 2 presents the mesh specifications for the coarse and fine meshes with \(N_b\) denoting the number of elements in the 0.1 m region from each of the 5 boundaries (other than the symmetry boundary), \(N_x\) and \(N_y\) denoting the number of elements along the x- and y-directions, respectively, for the intermediate 0.8 m region, and \(N_z\) denoting the number of elements in the top 0.4 m region along the z-direction. Figure 13 shows the xy and xz views of the coarse mesh.

Table 2 Mesh specifications for the 3D lid-driven cavity problem.

The time step is taken to be 0.5 s. Convergence is achieved within a maximum of 5 iterations in each time step. The steady-state analysis is performed using 10 load steps, and convergence is achieved in a maximum of 4 iterations at each load step. For \( {\text {Re}} = 1000\) and \({{\mathrm{Ha}}}= 20\), figure 14 presents the evolution of different field variables along \(x=0.5\) and \(y=0.5\) on the mid z-plane as a function of time. Convergence of the solution with respect to mesh refinement is evident from the plot. At higher times (not shown in the plot), all field variables converge to the steady-state solution.

4 Conclusion

In this work, a monolithic strategy for magnetohydrodynamics based on a continuous pressure interpolation (which is known to be BB stable) has been presented. Both fully transient and steady-state formulations for two- and three-dimensional problems have been developed. The exact linearization used in the monolithic strategy ensures rapid convergence within each time (or load) step, while the BB-stable nature of the interpolations used ensures that no instabilities arise in the solution. An existing analytical solution has been corrected, and a new analytical solution for wedge-type geometries has been presented. A variety of steady-state and transient problems have been solved and compared in many cases against analytical solutions or against existing numerical solutions. The developed strategy is shown to yield extremely good coarse-mesh accuracy and is, thus, both robust and efficient.