Next Article in Journal
Some Bounds on Zeroth-Order General Randić Index
Next Article in Special Issue
Strong Solutions of the Incompressible Navier–Stokes–Voigt Model
Previous Article in Journal
Numerical Solutions for Multi-Term Fractional Order Differential Equations with Fractional Taylor Operational Matrix of Fractional Integration
Previous Article in Special Issue
Nonlinear Spatiotemporal Viral Infection Model with CTL Immunity: Mathematical Analysis
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Nonlinear Multigrid Implementation for the Two-Dimensional Cahn–Hilliard Equation

1
Department of Mathematics, Korea University, Seoul 02841, Korea
2
Department of Mathematics, Kangwon National University, Chuncheon-si 200-090, Korea
*
Author to whom correspondence should be addressed.
Mathematics 2020, 8(1), 97; https://doi.org/10.3390/math8010097
Submission received: 19 December 2019 / Revised: 2 January 2020 / Accepted: 4 January 2020 / Published: 7 January 2020
(This article belongs to the Special Issue The Application of Mathematics to Physics and Nonlinear Science)

Abstract

:
We present a nonlinear multigrid implementation for the two-dimensional Cahn–Hilliard (CH) equation and conduct detailed numerical tests to explore the performance of the multigrid method for the CH equation. The CH equation was originally developed by Cahn and Hilliard to model phase separation phenomena. The CH equation has been used to model many interface-related problems, such as the spinodal decomposition of a binary alloy mixture, inpainting of binary images, microphase separation of diblock copolymers, microstructures with elastic inhomogeneity, two-phase binary fluids, in silico tumor growth simulation and structural topology optimization. The CH equation is discretized by using Eyre’s unconditionally gradient stable scheme. The system of discrete equations is solved using an iterative method such as a nonlinear multigrid approach, which is one of the most efficient iterative methods for solving partial differential equations. Characteristic numerical experiments are conducted to demonstrate the efficiency and accuracy of the multigrid method for the CH equation. In the Appendix, we provide C code for implementing the nonlinear multigrid method for the two-dimensional CH equation.

1. Introduction

In this paper, we consider a detailed multigrid [1] implementation of the following two-dimensional Cahn–Hilliard (CH) equation [2] and provide its C source code:
ϕ ( x , y , t ) t = M Δ μ ( x , y , t ) , ( x , y ) Ω , t > 0 , μ ( x , y , t ) = F ( ϕ ( x , y , t ) ) ϵ 2 Δ ϕ ( x , y , t ) ,
where ϕ is a conserved scalar field; M is the mobility; F ( ϕ ) = 0.25 ( ϕ 2 1 ) 2 is the free energy function (see Figure 1); ϵ is the gradient interfacial energy coefficient; and Ω R 2 is a bounded domain.
The homogeneous Neumann boundary conditions are used and are given as follows:
n · ϕ = 0 ,
n · μ = 0   on   Ω .
Here, n is the unit normal vector on the domain boundary Ω . The first boundary condition (1) implies that the interface contacts the domain boundary at a 90 ° angle. The second boundary condition (2) implies that the total mass is conserved.
We can derive the CH equation from the following total free energy functional
E ( ϕ ) = Ω F ( ϕ ) + ϵ 2 2 | ϕ | 2 d x .
Taking the variational derivative of E with respect to ϕ , we define the chemical potential:
μ = δ E δ ϕ = F ( ϕ ) ϵ 2 Δ ϕ .
Conservation of mass implies the following CH equation
ϕ t = · F ,
where the flux is given by F = M μ . If we differentiate E ( ϕ ) and Ω ϕ d x with respect to time t, then we have
d d t E ( ϕ ) = Ω F ( ϕ ) ϕ t + ϵ 2 ϕ · ϕ t d x = Ω μ ϕ t d x = M Ω μ Δ μ d x = M Ω μ μ · n d s M Ω μ · μ d x = M Ω | μ | 2 d x 0
and
d d t Ω ϕ d x = Ω ϕ t d x = M Ω Δ μ d x = M Ω μ · n d s = 0 ,
which imply that the total energy is decreasing and that the total mass is conserved in time, respectively. The CH equation was originally developed by Cahn and Hilliard to model spinodal decomposition in a binary alloy. The CH equation has been used to address many major problems such as the spinodal decomposition of a binary alloy mixture [3,4], inpainting of binary images [5,6], microphase separation of diblock copolymers [7,8], microstructures with elastic inhomogeneity [9,10], two-phase binary fluids [11,12], tumor growth models [13,14,15] and structural topology optimization [14,16]. Further details regarding the basic principles and practical applications of the CH equation are available in a recent review [14]. Thus, knowing how to implement a discrete scheme for the CH equation in detail is very useful because this equation is a building-block equation for many applications. The CH equation is discretized by using Eyre’s unconditionally gradient stable scheme [17] and is solved by using a nonlinear multigrid technique [1], which is one of the most efficient iterative methods for solving partial differential equations. Several studies have used the nonlinear multigrid method for the CH-type equations [18,19,20,21,22,23]. However, details regarding the implementation, multigrid performance, and source codes have not been provided.
Therefore, the main purpose of this paper is to describe a detailed multigrid implementation of the two-dimensional CH equation, evaluate its performance and provide its C programming language source code.
The remainder of this paper is organized as follows. In Section 2, we describe the numerical solution in detail. In Section 3, we describe the characteristic numerical experiments that are conducted to demonstrate the accuracy and efficiency of the multigrid method for the CH equation. In Section 4, we provide a conclusion. In the Appendix A, we provide the C code for implementing the nonlinear multigrid technique for the two-dimensional CH equation.

2. Numerical Solution

We consider a finite difference approximation for the CH equation. An unconditionally gradient energy stable scheme, which was proposed by Eyre, is applied to the time discretization. A nonlinear multigrid technique [1] is applied to solve the resulting system at an implicit time level.

2.1. Discretization

We discretize the CH equation in the two-dimensional space Ω = ( a , b ) × ( c , d ) . Let N x = 2 p and N y = 2 q be the numbers of mesh points with integers p and q. Let Δ x = ( b a ) / N x and Δ y = ( d c ) / N y be the mesh size. Let Ω i j = { ( x i , y j ) : x i = a + ( i 0.5 ) Δ x , y j = c + ( j 0.5 ) Δ y , 1 i N x , 1 j N y } be a discrete computational domain. Let ϕ i j n and μ i j n be approximations of ϕ ( x i , y j , t n ) and μ ( x i , y j , t n ) , respectively. Here, t n = n Δ t and Δ t represent the temporal step. We assume a uniform mesh grid h = Δ x = Δ y and a constant mobility M = 1 . Using the nonlinear stabilized splitting scheme of Eyre’s unconditionally gradient stable scheme, the CH equation is discretized as
ϕ i j n + 1 ϕ i j n Δ t = Δ h μ i j n + 1 ,
μ i j n + 1 = ( ϕ i j n + 1 ) 3 ϕ i j n ϵ 2 Δ h ϕ i j n + 1 ,
where the discrete Laplace operator is defined by Δ h ψ i j = ( ψ i + 1 , j + ψ i 1 , j + ψ i , j + 1 + ψ i , j 1 4 ψ i j ) / h 2 . The homogeneous Neumann boundary conditions (1) and (2) are discretized as
ϕ 0 j = ϕ 1 j , ϕ N x + 1 , j = ϕ N x , j , μ 0 j = μ 1 j , μ N x + 1 , j = μ N x , j , j = 1 , , N y ,
ϕ i 0 = ϕ i 1 , ϕ i , N y + 1 = ϕ i , N y , μ i 0 = μ i 1 , μ i , N y + 1 = μ i , N y , i = 1 , , N x .
We define the discrete residual as
r i j = Δ h μ i j n + 1 ϕ i j n + 1 ϕ i j n Δ t .
For each element a i j of size N x × N y in matrix A, we define the Frobenius norm with a scaling and infinite norm as
A F = i = 1 N x j = 1 N y | a i j | 2 N x N y and A = max 1 i N x , 1 j N y | a i j | ,
respectively. The discretizations (5) and (6) are conservative, that is,
i = 1 N x j = 1 N y ϕ i j n + 1 = i = 1 N x j = 1 N y ϕ i j n .
To show this conservation property, we take the summation of Equation (5)
i = 1 N x j = 1 N y ϕ i j n + 1 ϕ i j n Δ t = i = 1 N x j = 1 N y Δ h μ i j n + 1 = j = 1 N y μ N x + 1 , j n + 1 μ N x j n + 1 h 2 μ 1 j n + 1 μ 0 j n + 1 h 2 + i = 1 N x μ i , N y + 1 n + 1 μ i N y n + 1 h 2 μ i 1 n + 1 μ i 0 n + 1 h 2 = 0 .
Here, we used the homogenous Neumann boundary conditions (7) and (8). Therefore, Equation (11) holds. We define the discrete energy functional as
E h ( ϕ n ) = h 2 i = 1 N x j = 1 N y F ( ϕ i j n ) + ϵ 2 2 j = 1 N y ( ϕ 1 j n ϕ 0 j n ) 2 2 + i = 1 N x 1 ( ϕ i + 1 , j n ϕ i j n ) 2 + ( ϕ N x + 1 , j n ϕ N x j n ) 2 2 + ϵ 2 2 i = 1 N x ( ϕ i 1 n ϕ i 0 n ) 2 2 + j = 1 N y 1 ( ϕ i , j + 1 n ϕ i j n ) 2 + ( ϕ i , N y + 1 n ϕ i N y n ) 2 2 = h 2 i = 1 N x j = 1 N y F ( ϕ i j n ) + ϵ 2 2 j = 1 N y i = 1 N x 1 ( ϕ i + 1 , j n ϕ i j n ) 2 + ϵ 2 2 i = 1 N x j = 1 N y 1 ( ϕ i , j + 1 n ϕ i j n ) 2 ,
where we used the homogenous Neumann boundary conditions (7) and (8). We also define the discrete total mass as
M h ( ϕ n ) = i = 1 N x j = 1 N y ϕ i j n h 2 .
Then, the unconditionally gradient stable scheme satisfies the reduction in the discrete total energy [24]:
E h ( ϕ n + 1 ) E h ( ϕ n ) ,
which implies the pointwise boundedness of the numerical solution:
ϕ n 1 + 2 E h ( ϕ 0 ) / h 2 for   all   n .
The proof of Equation (16) can be found in Reference [25]. We provide the proof herein for the sake of completeness. We show that a constant K exists for all n values that satisfy the following inequality:
ϕ n K .
Let us assume that there is an integer n K that is dependent on K such that ϕ n K > K for any K. Then, ϕ i j n K exists such that | ϕ i j n K | > K . Let K be the largest solution of E h ( ϕ 0 ) = h 2 F ( K ) , that is, K = 1 + 2 E h ( ϕ 0 ) / h 2 . We then have
E h ( ϕ 0 ) = h 2 F ( K ) < h 2 F ( | ϕ i j n K | ) E h ( ϕ n K ) E h ( ϕ 0 ) ,
where we utilize the fact that the total energy is decreasing and F ( ϕ ) is a strictly increasing function on ( K , ) . Equation (18) leads to a contradiction. Therefore, Equation (17) should be satisfied.

2.2. Multigrid V-Cycle Algorithm

We use the nonlinear full approximation storage (FAS) multigrid method to solve the nonlinear discrete systems (5) and (6). For simplicity, we define the discrete domains, Ω 2 , Ω 1 , and Ω 0 , which represent a hierarchy of meshes ( Ω 2 , Ω 1 , and Ω 0 ) created by successively coarsening the original mesh Ω 2 , as shown in Figure 2.
We summarize here the nonlinear multigrid method for solving the discrete CH system as follows: First, let us rewrite Equations (5) and (6) as
N S O ( ϕ n + 1 , μ n + 1 ) = ( ξ n , ψ n ) ,
where the linear operator N S O is defined as
N S O ( ϕ n + 1 , μ n + 1 ) = ϕ n + 1 / Δ t Δ h μ n + 1 , μ n + 1 ( ϕ n + 1 ) 3 + ϵ 2 Δ h ϕ n + 1 ,
and the source term is denoted by
ξ n , ψ n = ϕ n / Δ t , ϕ n .
Next, we describe the multigrid method, which includes the pre-smoothing, coarse grid correction and post-smoothing steps. We denote a mesh grid Ω k as the discrete domain for each multigrid level k. Note that a mesh grid Ω k contains 2 k × 2 k grid points. Let k m i n be the coarsest multigrid level. We now introduce the SMOOTH and V-cycle functions. Given the number ν 1 of pre-smoothing and ν 2 of post-smoothing relaxation sweeps, the V-cycle is used as an iteration step in the multigrid method.
FAS multigrid cycle
Now, we define the FAScycle:
{ ϕ k m + 1 , μ k m + 1 } = F A S c y c l e ( k , ϕ k m , μ k m , N S O k , ξ k n , ψ k n , β ) .
In other words, { ϕ k m , μ k m }   and   { ϕ k m + 1 , μ k m + 1 } are the approximations of ϕ n + 1 ( x i , y j ) and μ n + 1 ( x i , y j ) before and after an FAScycle, respectively. Here, ϕ k 0 = ϕ k n and μ k 0 = μ k n .
(1) Pre-smoothing
{ ϕ ¯ k m , μ ¯ k m } = S M O O T H ν 1 ( ϕ k m , μ k m , N S O k , ξ k n , ψ k n ) ,
which represents ν 1 smoothing steps with the initial approximations ϕ k m , μ k m , source terms ξ k n , ψ k n and the S M O O T H relaxation operator to obtain the approximations ϕ ¯ k m , μ ¯ k m . One S M O O T H relaxation operator step consists of solving the systems (22) and (23), given as follows by 2 × 2 matrix inversion for each i   and   j . Here, we derive the smoothing operator in two dimensions. Rewriting Equation (5), we obtain:
ϕ i j n + 1 Δ t + 4 μ i j n + 1 h 2 = ξ i j n + μ i + 1 , j n + 1 + μ i 1 , j n + 1 + μ i , j + 1 n + 1 + μ i , j 1 n + 1 h 2 .
Because ( ϕ i j n + 1 ) 3 is nonlinear with respect to ϕ i j n + 1 , we linearize ( ϕ i j n + 1 ) 3 at ϕ i j m , that is,
( ϕ i j n + 1 ) 3 ( ϕ i j m ) 3 + 3 ( ϕ i j m ) 2 ( ϕ i j n + 1 ϕ i j m ) .
After substituting of this into (6), we obtain
4 ϵ 2 h 2 + 3 ( ϕ i j m ) 2 ϕ i j n + 1 + μ i j n + 1 = ψ i j n 2 ( ϕ i j m ) 3 ϵ 2 h 2 ( ϕ i + 1 , j n + 1 + ϕ i 1 , j n + 1 + ϕ i , j + 1 n + 1 + ϕ i , j 1 n + 1 ) .
Next, we replace ϕ α , β n + 1   and   μ α , β n + 1 in Equations (20) and (21) with ϕ ¯ α , β m   and   μ ¯ α , β m for α i   and   β j , otherwise with ϕ α , β m   and   μ α , β m , that is,
ϕ ¯ i j m Δ t + 4 μ ¯ i j m h 2 = ξ i j n + μ i + 1 , j m + μ ¯ i 1 , j m + μ i , j + 1 m + μ ¯ i , j 1 m h 2 ,
4 ϵ 2 h 2 + 3 ( ϕ i j m ) 2 ϕ ¯ i j m + μ ¯ i j m = ψ i j n 2 ( ϕ i j m ) 3 ϵ 2 h 2 ( ϕ i + 1 , j m + ϕ ¯ i 1 , j m + ϕ i , j + 1 m + ϕ ¯ i , j 1 m ) .
(2) Compute the defect
( d 1 m ¯ k , d 2 m ¯ k ) = ( ξ k n , ψ k n ) N S O k ( ϕ ¯ k m , μ ¯ k m ) .
(3) Restrict the defect and { ϕ ¯ k m , μ ¯ k m }
( d 1 ¯ k 1 m , d 2 ¯ k 1 m ) = I k k 1 ( d 1 ¯ k m , d 2 ¯ k m ) .
The restriction operator I k k 1 maps k-level functions to ( k 1 ) -level functions.
d k 1 ( x i , y j ) = I k k 1 d k ( x i , y j ) = 1 4 [ d k ( x i 1 2 , y j 1 2 ) + d k ( x i 1 2 , y j + 1 2 ) + d k ( x i + 1 2 , y j 1 2 ) + d k ( x i + 1 2 , y j + 1 2 ) ] .
(4) Compute the right-hand side
( ξ k 1 n , ψ k 1 n ) = ( d 1 m ¯ k 1 , d 2 m ¯ k 1 ) + N S O k 1 ( ϕ ¯ k 1 m , μ ¯ k 1 m ) .
(5) Compute an approximate solution { ϕ ^ k 1 m , μ ^ k 1 m } of the coarse grid equation on Ω k 1 , that is,
N S O k 1 ( ϕ k 1 m , μ k 1 m ) = ( ξ k 1 n , ψ k 1 n ) .
If k = 1 , we explicitly invert the 2 × 2 matrix to obtain the solution. If  k > 1 , we solve Equation (24) by performing a FAS k-grid cycle using { ϕ ¯ k 1 m , μ ¯ k 1 m } as the initial approximation:
{ ϕ ^ k 1 m , μ ^ k 1 m } = FAScycle ( k 1 , ϕ ¯ k 1 m , μ ¯ k 1 m , N S O k 1 , ξ k 1 n , ψ k 1 n , β ) .
(6) Compute the coarse grid correction (CGC):
v ^ 1 k 1 m = ϕ ^ k 1 m ϕ ¯ k 1 m , v ^ 2 k 1 m = μ ^ k 1 m μ ¯ k 1 m .
(7) Interpolate the correction:
v ^ 1 k m = I k 1 k v ^ 1 k 1 m , v ^ 2 k m = I k 1 k v ^ 2 k 1 m .
Here, the coarse values are simply transferred to the four nearby fine grid points, that is, v k ( x i , y j ) = I k 1 k v k 1 ( x i , y j ) = v k 1 ( x i + 1 2 , y j + 1 2 ) for i and j odd-numbered integers.
(8) Compute the corrected approximation on Ω k
ϕ k m ,   after   C G C = ϕ ¯ k m + v 1 ^ k m , μ k m ,   after   C G C = μ ¯ k m + v 2 ^ k m .
(9) Post-smoothing
{ ϕ k m + 1 , μ k m } = S M O O T H ν 2 ( ϕ k m ,   after   C G C , μ k m ,   after   C G C , N S O k , ξ k n , ψ k n ) .
This completes the description of the nonlinear FAScycle. One FAScycle step stops if the consequent error ϕ n + 1 , m + 1 ϕ n + 1 , m is less than a given tolerance t o l . The two-grid V-cycle is illustrated in Figure 3.

Further Numerical Schemes for the CH Equation

Previous studies have described the numerical solution of the CH equation with a variable mobility [19], the adaptive mesh refinement technique [26,27], the Neumann boundary condition in complex domains [20], the Dirichlet boundary conditions in complex domains [28], contact angle boundary [29], parallel multigrid method [30] and fourth-order compact scheme [31].

3. Numerical Experiments

In numerical experiments, we consider an equilibrium solution ϕ ( x , ) = tanh ( x / 2 ϵ ) for the CH equation on the one-dimensional infinite domain Ω = ( , ) . In other words, ϕ ( x , ) satisfies μ ( ϕ ( x , ) ) = F ( ϕ ( x , ) ) ϵ 2 ϕ x x ( x , ) = 0 and is an equilibrium solution. Then, across the interfacial regions, ϕ varies from 0.9 to 0.9 over a distance of approximately ξ = 2 2 ϵ tanh 1 ( 0.9 ) (see Figure 4). Therefore, if we want this value to be approximately m h , the  ϵ value can be taken as ϵ = ϵ m = m h / [ 2 2 tanh 1 ( 0.9 ) ] [32].
All computational simulations described in this section are performed on an Intel Core i5-6400 CPU @ 2.70 GHz with 4 GB of RAM.

3.1. Phase Separation

For the first numerical test, we consider spinodal decomposition in binary alloys. This decomposition is a process by which a mixture of binary materials separates into distinct regions with different material concentrations [2]. Figure 5a–c show snapshots of the phase-field ϕ at t = 100 Δ t , 200 Δ t and  1000 Δ t , respectively. The initial condition is ϕ ( x , y , 0 ) = 0.1 ( 1 2 rand ( x , y ) ) on Ω = ( 0 , 1 ) × ( 0 , 1 ) , where rand ( x , y ) is a random value between 0 and 1. The parameters ϵ = ϵ 4 , h = 1 / 64 , Δ t = 0.1 h 2 and a tolerance of t o l = 1.0 × 10 10 are used.

3.2. Non-Increase in Discrete Energy and Mass Conservation

Figure 6 shows the time evolution of the normalized discrete total energy E h ( ϕ n ) / E h ( ϕ 0 ) (solid line) and the average mass M h ( ϕ n ) / ( h 2 N x N y ) (diamond) of the numerical solutions with the initial state (25) on Ω = ( 0 , 1 ) × ( 0 , 1 ) .
ϕ ( x , y , 0 ) = 0.1 ( 1 2 rand ( x , y ) ) ,
where rand ( x , y ) is a random value between 0 and 1.
We use the simulation parameters, ϵ = ϵ 4 , h = 1 / 64 , Δ t = 0.1 h 2 and  t o l = 1.0 × 10 10 . The energy is non-increasing and the average concentration is conserved. These numerical results agree well with the total energy dissipation property (3) and the conservation property (4). The inscribed small figures are the concentration fields at the indicated times.

3.3. Convergence Test

We consider the convergence of the Frobenius norm with a scaling of the residual error with respect to the grid size. The initial condition on the domain Ω = ( 0 , 1 ) × ( 0 , 1 ) is given as
ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) .
We fix ϵ = 0.06 , Δ t = 0.01 and  t o l = 1.0 × 10 15 . Here, we use the V ( 2 , 2 ) scheme with a Gauss–Seidel relaxation, where ( 2 , 2 ) indicates 2 pre- and 2 post-correction relaxation sweeps. We define the residual after m V-cycles as
r i j m = Δ h μ i j n + 1 , m ϕ i j n + 1 , m ϕ i j n Δ t .
Table 1 shows the residual norm r m F after each V-cycle. Because no closed-form analytical solution exists for this problem, we define the Frobenius norm with a scaling of the residual error r m F = Δ h μ n + 1 , m ( ϕ n + 1 , m ϕ n ) / Δ t F . The grid sizes are set as 32 × 32 , 64 × 64 and  128 × 128 . The error norms and ratios of residual between successive V-cycle are shown in Table 1. As we have expected, the residual error decreases successively along with the V-cycle. The sharp increase in the residual norm ratio during the last few cycles reflects the fact that the numerical approximation is already accurate to near machine precision.

3.4. Effect of Tolerance

The effect of multigrid tolerance is related to the average mass convergence. We set the initial condition ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) on Ω = ( 0 , 1 ) × ( 0 , 1 ) with tolerance, t o l = 1.0 × 10 1 1.0 × 10 2 1.0 × 10 3 , and 1.0 × 10 10 to investigate the relationship between the mass convergence and t o l . We use the simulation parameters ϵ = ϵ 4 , SMOOTH relaxation = 2, h = 1 / 32 , Δ t = 1 / 32 and mesh size 32 × 32 . To compare the theoretical value (solid line) with the computational value t o l = 1.0 × 10 1 (dotted line), t o l = 1.0 × 10 2 (dash-dot line), t o l = 1.0 × 10 3 (dashed line) and  t o l = 1.0 × 10 10 (square), we set the interval of average mass from 0.0019 to 0.0023 . In Figure 7, the average mass M h ( ϕ n ) / ( h 2 N x N y ) gradually converges to a theoretical value with the decrease in tolerance. In addition, comparing the results of t o l = 1.0 × 10 1 , 1.0 × 10 2 , 1.0 × 10 3 and  1.0 × 10 10 , we observe that the average mass become nearly convergent for t o l = 1.0 × 10 10 .

3.5. Effects of the Smooth Relaxation Numbers ν 1 and ν 2

We investigate the effects of the SMOOTH relaxation numbers ν 1 (pre-relaxation) and ν 2 (post-relaxation) on the CPU time. In this test, we perform a numerical simulation with the initial condition ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) on Ω = ( 0 , 1 ) × ( 0 , 1 ) , h = 1 / 128 , ϵ 4 , Δ t = 0.1 h 2 and  t o l  =  1.0 × 10 10 . Table 2 lists the average CPU times and average numbers of V-cycles for various pre- and post-relaxation numbers after 100 time steps. The relaxation numbers are rounded off to the nearest integer. Figure 8 shows the average CPU times for different pre- and post-relaxation numbers. We observe that the average CPU time is the lowest when the numbers of pre- and post-relaxation iterations are ν 1 = 2 and ν 2 = 4 , respectively.
Next, we investigate the effect of SMOOTH relaxation numbers on the finest multigrid level. We perform a numerical simulation with ϵ = 0.0038 and Δ t = 1.0 × 10 7 . The SMOOTH relaxation numbers ν 0 1 and ν 0 2 (on the finest multigrid level) are taken to be 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10. In addition, other multigrid levels ν k 1 = ν k 2 are 1 , 2 , and 3 in the 128 × 128 and 512 × 512 mesh sizes. The other parameters are the same as those used previously. Table 3 shows the variations in average CPU time for different relaxation numbers with a 128 × 128 mesh size. Figure 9 illustrates the results in Table 3.
Table 4 lists the variations in average CPU time for different relaxation numbers with a 512 × 512 mesh size. Figure 10 illustrates the results in Table 4.

3.6. Effect Of V-Cycle

Next, we investigate the effect of V-cycle by changing the multigrid levels. In this test, we use the parameters Δ t = 0.01 , ϵ = 0.06 , SMOOTH relaxation = 2 , t o l = 1.0 × 10 10 and  h = 1 / 128 on Ω = ( 0 , 1 ) × ( 0 , 1 ) with a initial condition ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) . The highest number of V-cycles is taken to be 10000. We use l e v e l 2 , l e v e l 3 , l e v e l 4 , l e v e l 5 , l e v e l 6 and  l e v e l 7 in a single time step as examples to illustrate the effect of the V-cycle. We calculate the CPU time for each level after 100 Δ t , as listed in Table 5.
The number of the multigrid level and CPU time shown in Figure 11 indicate that a greater number of the multigrid level leads to a obvious decrease in CPU time. It is important to select an appropriate multigrid level for a specific mesh size.

3.7. Comparison between Gauss–Seidel and Multigrid Algorithms

We compare the average CPU times required to perform the Gauss–Seidel algorithm and multigrid algorithm. In this test, the initial condition is taken to be ϕ ( x , y , 0 ) = cos ( π x ) cos ( π y ) . The following parameters are used— Δ t = 0.01 , T = 10 Δ t , the SMOOTH relaxation = 2 and  ϵ = 0.06 . The highest number of V-cycle is taken to be 10000. The mesh sizes are 32 × 32 , 64 × 64 and  128 × 128 . The tolerances are 1.0 × 10 3 , 1.0 × 10 4 and  1.0 × 10 5 . Table 6 shows the average CPU times for these two methods after 10 time steps. We observe that the multigrid method require less CPU time than the Gauss–Seidel method does.

3.8. Effects of t o l and Δ t on the V-Cycle

In this test, we study the effects of t o l and Δ t on the V-cycle with the initial condition being ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) , h = 1 / 128 , ϵ = 0.06 . The highest number of the V-cycle is taken to be 10,000. Table 7 shows the number of V-cycle for various t o l and Δ t after a single time step. We can find that lower values of t o l lead to an increase in the V-cycle. For different values of t o l , it is essential to choose an appropriate Δ t to reduce the number of V-cycle.

3.9. Comparison of the Jacobi, Red–Black and Gauss–Seidel

We compare the performance of three relaxation methods: Jacobi, Red–Black and Gauss–Seidel. The initial condition is ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) on Ω = ( 0 , 1 ) × ( 0 , 1 ) . The parameters are h = 1 / 128 , ϵ = 0.06 , Δ t = 10 7 , T = 100 Δ t and  t o l = 1.0 × 10 10 . The SMOOTH relaxation numbers on the finest multigrid level (i.e., ν 1 = ν 2 ) are taken to be from 1 to 5 and those on the other multigrid levels are selected as 2 with the 128 × 128 mesh size. The relaxation numbers are rounded off to the nearest integer. Table 8 shows the average number of V-cycles for different relaxation numbers with the three methods. The relationship between the average numbers of V-cycles and ν 1 = ν 2 with the Jacobi, Red–Black and Gauss–Seidel method is plotted in Figure 12. The Gauss–Seidel method is observed to be the fastest. In the parallel multigrid method, the relaxation options are either Jacobi or Red–Black [33]. The Jacobi method requires approximately twice as many V-cycles as the Red–Black method does.

3.10. Effect of ϵ

Next, we investigate the effect of ϵ = ϵ m , which is related to the interface width. In this test, we perform a numerical simulation with the initial condition
ϕ ( x , y , 0 ) = 1 if 0.15 x 0.85 and 0.15 y 0.85 , 1 otherwise ,
on Ω = ( 0 , 1 ) × ( 0 , 1 ) . We use h = 1 / 128 , Δ t = h , SMOOTH relaxation = 2 , t o l = 1.0 × 10 10 and  T = 1000 Δ t . Figure 13 presents the evolution of the CH equation with the three values ϵ 4 , ϵ 8 and  ϵ 16 . As we have expected, the lower value of ϵ leads to a narrower interface width.

3.11. Effect of mesh size, N x × N y

In this test, we compare the CPU times with different mesh sizes N x × N y . The initial condition is ϕ ( x , y , 0 ) = 0.1 cos ( π x ) cos ( π y ) on Ω = ( 0 , N x / 32 ) × ( 0 , N y / 32 ) . The parameters are h = 1 / 32 , Δ t = h , T = 100 Δ t , ϵ = 0.06 , SMOOTH relaxation = 2 and  t o l = 1.0 × 10 10 . Table 9 shows the CPU times and their ratios (that is, the ratio of the CPU time with the mesh size 2 N x × 2 N y to the CPU time with N x × N y ). We observe that the values converge to 4.

4. Conclusions

In this paper, we presented a nonlinear multigrid implementation for the CH equation in a two-dimensional space. Eyre’s unconditionally gradient stable scheme was used to discretize the governing equation. The resulting discretizing equations were solved using the nonlinear multigrid method. We described the implementation of our numerical scheme in detail. We numerically showed the decrease in discrete total energy and the convergence of discrete total mass. We took a convergence test by studying the reductions in residual error on various mesh sizes in a single time step. The results of various numerical experiments were presented to demonstrate the effects of tolerance, SMOOTH relaxation, V-cycle and  ϵ . The provided multigrid source code will be useful to beginners who needs the numerical implementation of the nonlinear multigrid method for the CH equation.

Author Contributions

All authors, C.L., D.J., J.Y., and J.K., contributed equally to this work and critically reviewed the manuscript. All authors have read and agreed to the published version of the manuscript.

Funding

The first author (C. Lee) was supported by Basic Science Research Program through the National Research Foundation of Korea(NRF) funded by the Ministry of Education(NRF-2019R1A6A3A13094308). D. Jeong was supported by the National Research Foundation of Korea (NRF) grant funded by the Korea government (MSIP) (NRF-2017R1E1A1A03070953). J. Yang is supported by China Scholarship Council (201908260060). The corresponding author (J.S. Kim) expresses thanks for the support from the BK21 PLUS program.

Acknowledgments

The authors thank the editor and the reviewers for their constructive and helpful comments on the revision of this article.

Conflicts of Interest

The authors declare no conflicts of interest.

Appendix A

The C code and MATLAB postprocessing code are given as follows, and the parameters are enumerated in Table A1.
Table A1. Parameters used for the 2D Cahn–Hilliard equation.
Table A1. Parameters used for the 2D Cahn–Hilliard equation.
ParametersDescription
nx, nymaximum number of grid points in the x-, y-direction
n_levelnumber of multigrid level
c_relaxnumber of times being relax
dt Δ t
xleft, yleftminimum value on the x-, y-axis
xright, yrightmaximum value on the x-, y-axis
nsnumber of print out data
max_itmaximum number of iteration
max_it_mgmaximum number of multigrid iteration
tol_mgtolerance for multigrid
hspace step size
h2 h 2
gam ϵ
Cahn ϵ 2
The following C code is available on the following website:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <malloc.h>
#include <time.h>
#define gnx 32
#define gny 32
#define PI 4.0*atan(1.0)
#define iloop for(i=1;i<=gnx;i++)
#define jloop for(j=1;j<=gny;j++)
#define ijloop iloop jloop
#define iloopt for(i=1;i<=nxt;i++)
#define jloopt for(j=1;j<=nyt;j++)
#define ijloopt iloopt jloopt
int nx,ny,n_level,c_relax;
double **ct,**sc,**smu,**sor,h,h2,dt,xleft,xright,yleft,yright,gam,Cahn,**mu,**mi;
double **dmatrix(long nrl,long nrh,long ncl,long nch){
  double **m;
  long i,nrow=nrh-nrl+2,ncol=nch-ncl+2;
  m=(double **) malloc((nrow)*sizeof(double*)); m+=1;m-=nrl;
  m[nrl]=(double *) malloc((nrow*ncol)*sizeof(double)); m[nrl]+=1; m[nrl]-=ncl;
  for (i=nrl+1; i<=nrh; i++) m[i]=m[i-1]+ncol;
  return m;
}
void free_dmatrix(double **m,long nrl,long nrh,long ncl,long nch){
  free(m[nrl]+ncl-1); free(m+nrl-1);
}
void zero_matrix(double **a,int xl,int xr,int yl,int yr){
  int i,j;
  for (i=xl; i<=xr; i++){ for (j=yl; j<=yr; j++){ a[i][j]=0.0; }}
}
void mat_add2(double **a,double **b,double **c,double **a2,
    double **b2,double **c2,int xl,int xr,int yl,int yr){
  int i,j;
  for (i=xl; i<=xr; i++)
    for (j=yl; j<=yr; j++){ a[i][j]=b[i][j]+c[i][j]; a2[i][j]=b2[i][j]+c2[i][j]; }
}
void mat_sub2(double **a,double **b,double **c,double **a2,
    double **b2,double **c2,int nrl,int nrh,int ncl,int nch){
  int i,j;
  for (i=nrl;i<=nrh;i++)
    for (j=ncl; j<=nch; j++){ a[i][j]=b[i][j]-c[i][j];a2[i][j]=b2[i][j]-c2[i][j]; }
}
void mat_copy(double **a,double **b,int xl,int xr,int yl,int yr){
  int i,j;
  for (i=xl; i<=xr; i++){ for (j=yl; j<=yr; j++){ a[i][j]=b[i][j]; }}
}
void mat_copy2(double **a,double **b,double **a2,double **b2,int xl,int xr,int yl,int yr){
  int i,j;
  for (i=xl; i<=xr; i++)
    for (j=yl; j<=yr; j++){a[i][j]=b[i][j]; a2[i][j]=b2[i][j];}
}
void print_mat(FILE *fptr,double **a,int nrl,int nrh,int ncl,int nch){
  int i,j;
  for(i=nrl; i<=nrh; i++){ for(j=ncl; j<=nch; j++)
    fprintf(fptr," %16.15f",a[i][j]); fprintf(fptr,"\n"); }
}
void print_data(double **phi) {
  FILE *fphi;
  fphi=fopen("phi.m","a"); print_mat(fphi,phi,1,nx,1,ny); fclose(fphi);
}
void laplace(double **a,double **lap_a,int nxt,int nyt){
  int i,j;
  double ht2,dadx_L,dadx_R,dady_B,dady_T;
  ht2=pow((xright-xleft)/(double) nxt,2);
  ijloopt {
    if (i>1)  dadx_L=a[i][j]-a[i-1][j];
    else     dadx_L=0.0;
    if (i<nxt) dadx_R=a[i+1][j]-a[i][j];
    else     dadx_R=0.0;
    if (j>1)  dady_B=a[i][j]-a[i][j-1];
    else     dady_B=0.0;
    if (j<nyt) dady_T=a[i][j+1]-a[i][j];
    else     dady_T=0.0;
    lap_a[i][j]=(dadx_R-dadx_L+dady_T-dady_B)/ht2;}
}
void source(double **c_old,double **src_c,double **src_mu){
  int i,j;
  laplace(c_old,ct,nx,ny);
  ijloop{src_c[i][j]=c_old[i][j]/dt-ct[i][j]; src_mu[i][j]=0.0;}
}
double df(double c){return pow(c,3);}
double d2f(double c){return 3.0*c*c;}
void relax(double **c_new,double **mu_new,double **su,double **sw,int ilevel,
    int nxt, int nyt){
  int i,j,iter;
  double ht2,x_fac,y_fac,a[4],f[2],det;
  ht2=pow((xright-xleft)/(double) nxt,2);
  for (iter=1; iter<=c_relax; iter++){
    ijloopt {
      if (i>1 && i<nxt) x_fac=2.0;
      else    x_fac=1.0;
      if (j>1 && j<nyt) y_fac=2.0;
      else    y_fac=1.0;
      a[0]=1.0/dt; a[1]=(x_fac+y_fac)/ht2;
      a[2]=-(x_fac+y_fac)*Cahn/ht2-d2f(c_new[i][j]); a[3]=1.0;
      f[0]=su[i][j]; f[1]=sw[i][j]+df(c_new[i][j])-d2f(c_new[i][j])*c_new[i][j];
      if (i>1) { f[0]+=mu_new[i-1][j]/ht2; f[1]-=Cahn*c_new[i-1][j]/ht2; }
      if (i<nxt) { f[0]+=mu_new[i+1][j]/ht2; f[1]-=Cahn*c_new[i+1][j]/ht2; }
      if (j>1) { f[0]+=mu_new[i][j-1]/ht2; f[1]-=Cahn*c_new[i][j-1]/ht2; }
      if (j<nyt) { f[0]+=mu_new[i][j+1]/ht2; f[1]-=Cahn*c_new[i][j+1]/ht2; }
      det=a[0]*a[3]-a[1]*a[2];
      c_new[i][j]=(a[3]*f[0]-a[1]*f[1])/det;
      mu_new[i][j]=(-a[2]*f[0]+a[0]*f[1])/det; }}
}
void restrictCH(double **uf,double **uc,double **vf,double **vc,int nxc,int nyc) {
  int i,j;
  for (i=1; i<=nxc; i++)
    for (j=1; j<=nyc; j++){
      uc[i][j]=0.25*(uf[2*i][2*j]+uf[2*i-1][2*j]+uf[2*i][2*j-1]+uf[2*i-1][2*j-1]);
      vc[i][j]=0.25*(vf[2*i][2*j]+vf[2*i-1][2*j]+vf[2*i][2*j-1]+vf[2*i-1][2*j-1]);}
}
void nonL(double **ru,double **rw,double **c_new,double **mu_new,int nxt,int nyt) {
  int i,j;
  double **lap_mu,**lap_c;
  lap_mu=dmatrix(1,nxt,1,nyt); lap_c=dmatrix(1,nxt,1,nyt);
  laplace(c_new,lap_c,nxt,nyt); laplace(mu_new,lap_mu,nxt,nyt);
  ijloopt{ ru[i][j]=c_new[i][j]/dt-lap_mu[i][j];
       rw[i][j]=mu_new[i][j]-df(c_new[i][j])+Cahn*lap_c[i][j]; }
  free_dmatrix(lap_mu,1,nxt,1,nyt); free_dmatrix(lap_c,1,nxt,1,nyt);
}
void defect(double **duc,double **dwc,double **uf_new,double **wf_new,double **suf,
    double **swf,int nxf,int nyf,double **uc_new,double **wc_new,int nxc,int nyc) {
  double **ruf,**rwf,**rruf,**rrwf,**ruc,**rwc;
  ruc=dmatrix(1,nxc,1,nyc);rwc=dmatrix(1,nxc,1,nyc);ruf=dmatrix(1,nxf,1,nyf);
  rwf=dmatrix(1,nxf,1,nyf);rruf=dmatrix(1,nxc,1,nyc);rrwf=dmatrix(1,nxc,1,nyc);
  nonL(ruc,rwc,uc_new,wc_new,nxc,nyc);nonL(ruf,rwf,uf_new,wf_new,nxf,nyf);
  mat_sub2(ruf,suf,ruf,rwf,swf,rwf,1,nxf,1,nyf);
  restrictCH(ruf,rruf,rwf,rrwf,nxc,nyc);
  mat_add2(duc,ruc,rruf,dwc,rwc,rrwf,1,nxc,1,nyc);
  free_dmatrix(ruc,1,nxc,1,nyc); free_dmatrix(rwc,1,nxc,1,nyc);
  free_dmatrix(ruf,1,nxf,1,nyf); free_dmatrix(rwf,1,nxf,1,nyf);
  free_dmatrix(rruf,1,nxc,1,nyc); free_dmatrix(rrwf,1,nxc,1,nyc);
}
void prolong_ch(double **uc,double **uf,double **vc,double **vf, int nxc,int nyc){
  int i,j;
  for (i=1; i<=nxc; i++)
    for (j=1; j<=nyc; j++){
      uf[2*i][2*j]=uf[2*i-1][2*j]=uf[2*i][2*j-1]=uf[2*i-1][2*j-1]=uc[i][j];
      vf[2*i][2*j]=vf[2*i-1][2*j]=vf[2*i][2*j-1]=vf[2*i-1][2*j-1]=vc[i][j];}
}
void vcycle(double **uf_new,double **wf_new,double **su,double **sw,int nxf,int nyf,
    int ilevel) {
  relax(uf_new,wf_new,su,sw,ilevel,nxf,nyf);
  if (ilevel<n_level) {
    int nxc,nyc;
    double **duc,**dwc,**uc_new,**wc_new,**uc_def,**wc_def,**uf_def,**wf_def;
    nxc=nxf/2; nyc=nyf/2;
    duc=dmatrix(1,nxc,1,nyc); dwc=dmatrix(1,nxc,1,nyc);
    uc_new=dmatrix(1,nxc,1,nyc); wc_new=dmatrix(1,nxc,1,nyc);
    uf_def=dmatrix(1,nxf,1,nyf); wf_def=dmatrix(1,nxf,1,nyf);
    uc_def=dmatrix(1,nxc,1,nyc); wc_def=dmatrix(1,nxc,1,nyc);
    restrictCH(uf_new,uc_new,wf_new,wc_new,nxc,nyc);
    defect(duc,dwc,uf_new,wf_new,su,sw,nxf,nyf,uc_new,wc_new,nxc,nyc);
    mat_copy2(uc_def,uc_new,wc_def,wc_new,1,nxc,1,nyc);
    vcycle(uc_def,wc_def,duc,dwc,nxc,nyc,ilevel+1);
    mat_sub2(uc_def,uc_def,uc_new,wc_def,wc_def,wc_new,1,nxc,1,nyc);
    prolong_ch(uc_def,uf_def,wc_def,wf_def,nxc,nyc);
    mat_add2(uf_new,uf_new,uf_def,wf_new,wf_new,wf_def,1,nxf,1,nyf);
    relax(uf_new,wf_new,su,sw,ilevel,nxf,nyf);
    free_dmatrix(duc,1,nxc,1,nyc); free_dmatrix(dwc,1,nxc,1,nyc);
    free_dmatrix(uc_new,1,nxc,1,nyc); free_dmatrix(wc_new,1,nxc,1,nyc);
    free_dmatrix(uf_def,1,nxf,1,nyf); free_dmatrix(wf_def,1,nxf,1,nyf);
    free_dmatrix(uc_def,1,nxc,1,nyc); free_dmatrix(wc_def,1,nxc,1,nyc); }
}
double error2(double **c_old,double **c_new,double **mu,int nxt,int nyt){
  int i,j;
  double **rr,res2,x=0.0;
  rr=dmatrix(1,nxt,1,nyt);
  ijloopt { rr[i][j]=mu[i][j]-c_old[i][j]; }
  laplace(rr,sor,nx,ny);
  ijloopt { rr[i][j]=sor[i][j]-(c_new[i][j]-c_old[i][j])/dt; }
  ijloopt { x=(rr[i][j])*(rr[i][j])+x; }
  res2=sqrt(x/(nx*ny));
  free_dmatrix(rr,1,nxt,1,nyt);
  return res2;
}
void initialization(double **phi){
  int i,j;
  double x,y;
  ijloop {x=(i-0.5)*h; y=(j-0.5)*h; phi[i][j]=cos(PI*x)*cos(PI*y);}
}
void cahn(double **c_old,double **c_new){
  FILE *fphi2;
  int i,j,max_it_CH=10000,it_mg2=1;
  double tol=1.0e-10, resid2=1.0;
  source(c_old,sc,smu);
  while (it_mg2<=max_it_CH && resid2>tol) {
    it_mg2++; vcycle(c_new,mu,sc,smu,nx,ny,1);
    resid2=error2(c_old,c_new,mu,nx,ny);
    printf("error2 %16.15f %d \n",resid2,it_mg2-1);
    fphi2=fopen("phi2.m","a");
    fprintf(fphi2,"%16.15f %d \n",resid2,it_mg2-1); fclose(fphi2);}
}
int main(){
  int it=1,max_it,ns,count=1,it_mg=1;
  double **oc,**nc,resid2=1.0;
  FILE *fphi,*fphi2;
  c_relax=2; nx=gnx; ny=gny; n_level=(int)(log(nx)/log(2.0)+0.1);
  xleft=0.0; xright=1.0; yleft=0.0; yright=1.0; max_it=100; ns=10; dt=0.01;
  h=xright/(double)nx; h2=pow(h,2); gam=0.06; Cahn=pow(gam,2);
  printf("nx=%d,ny=%d\n",nx,ny); printf("dt=%f\n",dt);
  printf("max_it=%d\n",max_it); printf("ns=%d\n",ns); printf("n_level=%d\n\n",n_level);
  oc=dmatrix(0,nx+1,0,ny+1); nc=dmatrix(0,nx+1,0,ny+1); mu=dmatrix(1,nx,1,ny);
  sor=dmatrix(1,nx,1,ny); ct=dmatrix(1,nx,1,ny); sc=dmatrix(1,nx,1,ny);
  mi=dmatrix(1,nx,1,ny); smu=dmatrix(1,nx,1,ny); zero_matrix(mu,1,nx,1,ny);
  initialization(oc); mat_copy(nc,oc,1,nx,1,ny);
  fphi=fopen("phi.m","w"); fclose(fphi); print_data(oc);
  for (it=1; it<=max_it; it++) {
    cahn(oc,nc); mat_copy(oc,nc,1,nx,1,ny);
    if (it % ns==0) {count++; print_data(oc); printf("print out counts %d \n",count);}
    printf(" %d \n",it);}
  return 0;
}
The following MATLAB code produces the results shown in Figure 5. The code can also be downloaded from
clear; clc; close all;
ss=sprintf(’./phi.m’); phi=load(ss); nx=32; ny=32; n=size(phi,1)/nx;
x=linspace(0,1,nx); y=linspace(0,1,ny); [xx,yy]=meshgrid(x,y);
for i=1:n
  pp=phi((i-1)*nx+1:i*nx,:);
  figure(i); mesh(xx,yy,pp’); axis([0 1 0 1 -1 1]); view(-38,42);
end

References

  1. Trottenberg, U.; Schüller, A.; Oosterlee, C.W. Multigrid Methods; Academic Press: Cambridge, MA, USA, 2000. [Google Scholar]
  2. Cahn, J.W.; Hilliard, J.E. Free energy of a nonuniform system. I. Interfacial free energy. J. Chem. Phys. 1958, 28, 258–267. [Google Scholar]
  3. Copetti, M.I.M.; Elliott, C.M. Kinetics of phase decomposition processes: Numerical solutions to Cahn–Hilliard equation. Mater. Sci. Technol. 1990, 6, 273–284. [Google Scholar]
  4. Honjo, M.; Saito, Y. Numerical simulation of phase separation in Fe-Cr binary and Fe-Cr-Mo ternary alloys with use of the Cahn–Hilliard equation. ISIJ Int. 2000, 40, 914–919. [Google Scholar]
  5. Bertozzi, A.L.; Esedoglu, S.; Gillette, A. Inpainting of binary images using the Cahn–Hilliard equation. IEEE Trans. Image Process. 2007, 16, 285–291. [Google Scholar]
  6. Bosch, J.; Kay, D.; Stoll, M.; Wathen, A.J. Fast solvers for Cahn–Hilliard inpainting. SIAM J. Imaging Sci. 2014, 7, 67–97. [Google Scholar]
  7. Choksi, R.; Peletier, M.A.; Williams, J.F. On the phase diagram for microphase separation of diblock copolymers: An approach via a nonlocal Cahn–Hilliard functional. SIAM J. Appl. Math. 2009, 69, 1712–1738. [Google Scholar]
  8. Tang, P.; Qiu, F.; Zhang, H.; Yang, Y. Phase separation patterns for diblock copolymers on spherical surfaces: A finite volume method. Phys. Rev. E 2005, 72, 016710. [Google Scholar]
  9. Hu, S.Y.; Chen, L.Q. A phase-field model for evolving microstructures with strong elastic inhomogeneity. Acta Mater. 2001, 49, 1879–1890. [Google Scholar]
  10. Yu, P.; Hu, S.Y.; Chen, L.Q.; Du, Q. An iterative-perturbation scheme for treating inhomogeneous elasticity in phase-field models. J. Comput. Phys. 2005, 208, 34–50. [Google Scholar]
  11. Gurtin, M.E.; Polignone, D.; Vinals, J. Two-phase binary fluids and immiscible fluids described by an order parameter. Math. Models Methods Appl. Sci. 1996, 6, 815–831. [Google Scholar]
  12. Lee, T. Effects of incompressibility on the elimination of parasitic currents in the lattice Boltzmann equation method for binary fluids. Comput. Math. Appl. 2009, 58, 987–994. [Google Scholar]
  13. Jeong, D.; Kim, J. Phase-field model and its splitting numerical scheme for tissue growth. Appl. Numer. Math. 2017, 117, 22–35. [Google Scholar]
  14. Kim, J.; Lee, S.; Choi, Y.; Lee, S.M.; Jeong, D. Basic Principles and Practical Applications of the Cahn–Hilliard Equation. Math. Probl. Eng. 2016, 2016, 9532608. [Google Scholar]
  15. Colli, P.; Gilardi, G.; Sprekels, J. A distributed control problem for a fractional tumor growth model. Mathematics 2019, 7, 792. [Google Scholar]
  16. Myśliński, A.; Wroblewski, M. Structural optimization of contact problems using Cahn–Hilliard model. Comput. Struct. 2017, 180, 52–59. [Google Scholar]
  17. Eyre, D.J. Unconditionally gradient stable time marching the Cahn–Hilliard equation. MRS Proc. 1998, 529, 39. [Google Scholar]
  18. Yang, S.; Lee, H.; Kim, J. A phase-field approach for minimizing the area of triply periodic surfaces with volume constraint. Comput. Phys. Commun. 2010, 181, 1037–1046. [Google Scholar]
  19. Kim, J. A numerical method for the Cahn–Hilliard equation with a variable mobility. Commun. Nonlinear Sci. Numer. Simul. 2007, 12, 1560–1571. [Google Scholar]
  20. Shin, J.; Jeong, D.; Kim, J. A conservative numerical method for the Cahn–Hilliard equation in complex domains. J. Comput. Phys. 2011, 230, 7441–7455. [Google Scholar]
  21. Jeong, D.; Kim, J. A practical numerical scheme for the ternary Cahn–Hilliard system with a logarithmic free energy. Phys. A 2016, 442, 510–522. [Google Scholar]
  22. Lee, H.; Kim, J. A second-order accurate non-linear difference scheme for the N-component Cahn–Hilliard system. Phys. A 2008, 387, 4787–4799. [Google Scholar]
  23. Lee, H.G.; Shin, J.; Lee, J.Y. A High-Order Convex Splitting Method for a Non-Additive Cahn–Hilliard Energy Functional. Mathematics 2019, 7, 1242. [Google Scholar]
  24. Shin, J.; Choi, Y.; Kim, J. An unconditionally stable numerical method for the viscous Cahn–Hilliard equation. Discret. Contin. Dyn. Syst. Ser. B 2014, 19, 1737–1747. [Google Scholar]
  25. Kim, J. Phase-field models for multi-component fluid flows. Commun. Comput. Phys. 2012, 12, 613–661. [Google Scholar]
  26. Kim, J.; Bae, H.O. An unconditionally gradient stable adaptive mesh refinement for the Cahn–Hilliard equation. J. Korean Phys. Soc. 2008, 53, 672–679. [Google Scholar]
  27. Wise, S.; Kim, J.; Lowengrub, J. Solving the regularized, strongly anisotropic Cahn–Hilliard equation by an adaptive nonlinear multigrid method. J. Comput. Phys. 2007, 226, 414–446. [Google Scholar]
  28. Li, Y.; Jeong, D.; Shin, J.; Kim, J. A conservative numerical method for the Cahn–Hilliard equation with Dirichlet boundary conditions in complex domains. Comput. Math. Appl. 2013, 65, 102–115. [Google Scholar]
  29. Lee, H.G.; Kim, J. Accurate contact angle boundary conditions for the Cahn–Hilliard equations. Comput. Fluids 2011, 44, 178–186. [Google Scholar]
  30. Shin, J.; Kim, S.; Lee, D.; Kim, J. A parallel multigrid method of the Cahn–Hilliard equation. Comput. Mater. Sci. 2013, 71, 89–96. [Google Scholar]
  31. Lee, C.; Jeong, D.; Shin, J.; Li, Y.; Kim, J. A fourth-order spatial accurate and practically stable compact scheme for the Cahn–Hilliard equation. Phys. A 2014, 409, 17–28. [Google Scholar]
  32. Choi, J.W.; Lee, H.G.; Jeong, D.; Kim, J. An unconditionally gradient stable numerical method for solving the Allen–Cahn equation. Phys. A 2009, 388, 1791–1803. [Google Scholar]
  33. Baker, A.H.; Falgout, R.D.; Kolev, T.V.; Yang, U.M. Scaling hypre’s multigrid solvers to 100,000 cores. In High-Performance Scientific Computing; Springer: London, UK, 2012; pp. 261–279. [Google Scholar]
Figure 1. Double-well potential F ( ϕ ) = 0.25 ( ϕ 2 1 ) 2 .
Figure 1. Double-well potential F ( ϕ ) = 0.25 ( ϕ 2 1 ) 2 .
Mathematics 08 00097 g001
Figure 2. (ac) represent a sequence of coarse grids starting with h = L / N x . (d) depicts a composition of grids, Ω 2 , Ω 1 and Ω 0 .
Figure 2. (ac) represent a sequence of coarse grids starting with h = L / N x . (d) depicts a composition of grids, Ω 2 , Ω 1 and Ω 0 .
Mathematics 08 00097 g002
Figure 3. Multigrid two-grid V-cycle method.
Figure 3. Multigrid two-grid V-cycle method.
Mathematics 08 00097 g003
Figure 4. Concentration field varying from 0.9 to 0.9 over a distance of approximately ξ = 2 2 ϵ tanh 1 ( 0.9 ) .
Figure 4. Concentration field varying from 0.9 to 0.9 over a distance of approximately ξ = 2 2 ϵ tanh 1 ( 0.9 ) .
Mathematics 08 00097 g004
Figure 5. Snapshots of the phase-field ϕ at (a) t = 100 Δ t , (b) t = 200 Δ t and (c) t = 1000 Δ t . Here, ϵ = ϵ 4 , h = 1 / 64 and Δ t = 0.1 h 2 are used.
Figure 5. Snapshots of the phase-field ϕ at (a) t = 100 Δ t , (b) t = 200 Δ t and (c) t = 1000 Δ t . Here, ϵ = ϵ 4 , h = 1 / 64 and Δ t = 0.1 h 2 are used.
Mathematics 08 00097 g005
Figure 6. Normalized discrete total energy E h ( ϕ n ) / E h ( ϕ 0 ) (solid line) and average concentration M h ( ϕ n ) / ( h 2 N x N y ) (diamond line) of the numerical solutions with the initial state (25).
Figure 6. Normalized discrete total energy E h ( ϕ n ) / E h ( ϕ 0 ) (solid line) and average concentration M h ( ϕ n ) / ( h 2 N x N y ) (diamond line) of the numerical solutions with the initial state (25).
Mathematics 08 00097 g006
Figure 7. Average mass M h ( ϕ n ) / ( h 2 N x N y ) of the numerical solutions in various values of tolerance. Here, the theoretical value (solid line), t o l = 1.0 × 10 1 (dotted line), t o l = 1.0 × 10 2 (dash-dot line), t o l = 1.0 × 10 3 (dashed line) and t o l = 1.0 × 10 10 (square).
Figure 7. Average mass M h ( ϕ n ) / ( h 2 N x N y ) of the numerical solutions in various values of tolerance. Here, the theoretical value (solid line), t o l = 1.0 × 10 1 (dotted line), t o l = 1.0 × 10 2 (dash-dot line), t o l = 1.0 × 10 3 (dashed line) and t o l = 1.0 × 10 10 (square).
Mathematics 08 00097 g007
Figure 8. Average CPU time for different pre- and post-relaxation numbers after 100 time steps.
Figure 8. Average CPU time for different pre- and post-relaxation numbers after 100 time steps.
Mathematics 08 00097 g008
Figure 9. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) and fixed relaxation number 1 , 2 and 3 on other grids with a 128 × 128 mesh size.
Figure 9. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) and fixed relaxation number 1 , 2 and 3 on other grids with a 128 × 128 mesh size.
Mathematics 08 00097 g009
Figure 10. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) and fixed relaxation numbers 1 , 2 and 3 on other grids with a 512 × 512 mesh size.
Figure 10. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) and fixed relaxation numbers 1 , 2 and 3 on other grids with a 512 × 512 mesh size.
Mathematics 08 00097 g010
Figure 11. Required CPU times in various multigrid levels after 100 time steps.
Figure 11. Required CPU times in various multigrid levels after 100 time steps.
Mathematics 08 00097 g011
Figure 12. Plot of the average numbers of V-cycles versus ν 1 = ν 2 with the Jacobi (○), Red–Black (∗) and Gauss–Seidel (△) method.
Figure 12. Plot of the average numbers of V-cycles versus ν 1 = ν 2 with the Jacobi (○), Red–Black (∗) and Gauss–Seidel (△) method.
Mathematics 08 00097 g012
Figure 13. Evolution of the Cahn–Hilliard (CH) equation with different ϵ = ϵ m : (a) initial condition, (bd) m = 4 , m = 8 and m = 16 at T = 1000 Δ t , respectively.
Figure 13. Evolution of the Cahn–Hilliard (CH) equation with different ϵ = ϵ m : (a) initial condition, (bd) m = 4 , m = 8 and m = 16 at T = 1000 Δ t , respectively.
Mathematics 08 00097 g013
Table 1. Error and convergence results for various grid spaces.
Table 1. Error and convergence results for various grid spaces.
Mesh Size 32 × 32 64 × 64 128 × 128
V-Cycle r F Ratio r F Ratio r F Ratio
1 5.28 × 10 2 6.83 × 10 2 9.10 × 10 2
2 2.41 × 10 3 0.05 3.42 × 10 3 0.05 4.30 × 10 3 0.05
3 1.15 × 10 4 0.05 1.56 × 10 4 0.05 2.09 × 10 4 0.05
4 6.54 × 10 6 0.06 7.25 × 10 6 0.05 8.69 × 10 6 0.04
5 4.23 × 10 7 0.06 4.23 × 10 7 0.06 4.66 × 10 7 0.05
6 2.80 × 10 8 0.07 2.65 × 10 8 0.06 2.90 × 10 8 0.06
7 1.83 × 10 9 0.07 1.58 × 10 9 0.06 1.63 × 10 9 0.06
8 1.23 × 10 10 0.07 1.01 × 10 10 0.06 1.01 × 10 10 0.06
9 8.33 × 10 12 0.07 6.75 × 10 12 0.07 6.83 × 10 12 0.07
10 5.46 × 10 13 0.07 4.24 × 10 13 0.06 4.42 × 10 13 0.06
11 3.70 × 10 14 0.07 4.90 × 10 14 0.12 1.69 × 10 13 0.38
12 1.10 × 10 14 0.30 4.10 × 10 14 0.84 1.66 × 10 13 0.98
Table 2. Average CPU times and average numbers of V-cycles (given in parentheses) for various pre- and post-relaxation numbers after 100 time steps.
Table 2. Average CPU times and average numbers of V-cycles (given in parentheses) for various pre- and post-relaxation numbers after 100 time steps.
ν 1 ν 2 12345
10.075(9)0.075(7)0.081(6)0.077(5)0.089(5)
20.075(7)0.079(6)0.090(5)0.089(5)0.081(4)
30.079(6)0.082(5)0.089(5)0.081(4)0.090(4)
40.078(5)0.075(4)0.081(4)0.090(4)0.075(3)
50.072(4)0.081(4)0.090(4)0.075(3)0.082(3)
Table 3. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) after 10 time steps. In other grids, ν k 1 = ν k 2 , ( 1 k ) relaxation number is fixed at 1 , 2 and 3.
Table 3. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) after 10 time steps. In other grids, ν k 1 = ν k 2 , ( 1 k ) relaxation number is fixed at 1 , 2 and 3.
128 × 128 ν k 1 = ν k 2
ν 0 1 = ν 0 2 123
10.0430.0490.054
20.0400.0450.048
30.0270.0290.031
40.0320.0340.037
50.0380.0410.042
60.0440.0470.048
70.0500.0530.054
80.0550.0580.060
90.0620.0650.065
100.0680.0700.072
Table 4. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) after 10 time steps. In other grids, the  ν k 1 = ν k 2 , ( 1 k ) relaxation number is fixed at 1 , 2 and 3.
Table 4. Average CPU times for various relaxation numbers on finest multigrid level ( ν 0 1 , ν 0 2 ) after 10 time steps. In other grids, the  ν k 1 = ν k 2 , ( 1 k ) relaxation number is fixed at 1 , 2 and 3.
512 × 512 ν k 1 = ν k 2
ν 0 1 = ν 0 2 123
12.1822.5062.750
22.0302.2082.397
31.7261.8501.982
42.0962.2272.351
51.8721.9432.047
62.1512.2362.330
72.4262.5142.617
81.8171.8771.944
92.0022.0662.118
102.1972.2522.295
Table 5. Numbers of multigrid levels and CPU times required until tolerance ≤ 1.0 × 10 10 . Here, different levels are used.
Table 5. Numbers of multigrid levels and CPU times required until tolerance ≤ 1.0 × 10 10 . Here, different levels are used.
Level234567
CPU time(s)1271.437342.906103.03266.42266.17265.218
Table 6. Average CPU times for Gauss–Seidel and multigrid algorithms with different tolerances after 10 time steps.
Table 6. Average CPU times for Gauss–Seidel and multigrid algorithms with different tolerances after 10 time steps.
Mesh Size t o l Gauss–SeidelMultigrid
1.0 × 10 3 0.4680.046
32 × 32 1.0 × 10 4 0.6100.063
1.0 × 10 5 0.7350.062
1.0 × 10 3 7.0460.203
64 × 64 1.0 × 10 4 8.9840.234
1.0 × 10 5 11.3600.266
1.0 × 10 3 109.0930.844
128 × 128 1.0 × 10 4 140.2190.906
1.0 × 10 5 174.9221.078
Table 7. Numbers of V-cycles for various t o l and Δ t after a single time step.
Table 7. Numbers of V-cycles for various t o l and Δ t after a single time step.
Δ t t o l 10 7 h 2 10 6 h 2 10 5 h 2 10 4 h 2 10 3 h 2 10 2 h 2 10 1 h 2
1.0 × 10 5 2234688
1.0 × 10 6 10,000234799
1.0 × 10 7 10,00010,0003581010
1.0 × 10 8 10,00010,00010,000591112
1.0 × 10 9 10,00010,00010,00010,000101313
1.0 × 10 10 10,00010,00010,00010,00010,0001415
Δ t t o l h 2 10 h 2 10 2 h 2 10 3 h 2 10 4 h 2 10 5 h 2 10 6 h 2
1.0 × 10 5 878891441
1.0 × 10 6 9999101991
1.0 × 10 7 111010111124140
1.0 × 10 8 121212121328189
1.0 × 10 9 141313131433238
1.0 × 10 10 151415151638288
Table 8. Average numbers of V-cycles for various relaxation numbers. The SMOOTH relaxation numbers on the finest multigrid level (i.e., ν 1 = ν 2 ) are taken to be from 1 to 5.
Table 8. Average numbers of V-cycles for various relaxation numbers. The SMOOTH relaxation numbers on the finest multigrid level (i.e., ν 1 = ν 2 ) are taken to be from 1 to 5.
Case   Jacobi    Red–Black Gauss-Seidal
132139
21686
31165
4854
5753
Table 9. CPU times for different mesh sizes.
Table 9. CPU times for different mesh sizes.
Mesh Size 32 × 32 64 × 64 128 × 128 256 × 256
CPU time(s)0.610 2.812 12.156 50.594
Ratio 4.610 4.323 4.162

Share and Cite

MDPI and ACS Style

Lee, C.; Jeong, D.; Yang, J.; Kim, J. Nonlinear Multigrid Implementation for the Two-Dimensional Cahn–Hilliard Equation. Mathematics 2020, 8, 97. https://doi.org/10.3390/math8010097

AMA Style

Lee C, Jeong D, Yang J, Kim J. Nonlinear Multigrid Implementation for the Two-Dimensional Cahn–Hilliard Equation. Mathematics. 2020; 8(1):97. https://doi.org/10.3390/math8010097

Chicago/Turabian Style

Lee, Chaeyoung, Darae Jeong, Junxiang Yang, and Junseok Kim. 2020. "Nonlinear Multigrid Implementation for the Two-Dimensional Cahn–Hilliard Equation" Mathematics 8, no. 1: 97. https://doi.org/10.3390/math8010097

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop