1 Introduction

Numerical simulations of groundwater flow in porous/fractured media are vital to multidisciplinary applications, including, but not limited to, geothermal energy exploration, geologic carbon sequestration, and final disposal of spent nuclear fuels. These simulations require a numerical model to solve the mathematical model formed by reducing groundwater flow mechanisms into mass-balance equations in either a differential or an integral form. A numerical model must include two key elements: a numerical mesh to characterize a site’s hydrogeology and a numerical simulator to solve the mathematical model. However, balancing the (mesh) size-dependent solution accuracy and the computation load remains challenging, not to mention the significant amount of time-consuming and laborious pre-processings and post-processings during and after the simulation. Therefore, to prioritize utilizing simulation results for application purposes, developing a general-purpose workflow to organize the overall simulation procedures systematically is imminent to alleviate the model buildup and data-processing efforts.

Selecting a robust numerical simulator is critical for building a numerical model. The TOUGH (Transport Of Unsaturated Groundwater and Heat) codes are designed to model the non-isothermal transport of multi-component, multiphase fluids in deformable multi-dimensional porous or fractured media (Pruess et al. 2012). They are well known in the scientific community for their theoretical robustness, high adaptability, parallel computation, comprehensive documentation, thorough verification and validity, and affordable price for academic users. Successful applications of the codes, to name a few, include nuclear waste disposal, environmental remediation, exploration of hydrocarbon and geothermal energy, gas hydrate deposits investigation, geologic carbon sequestration, vadose zone hydrology, and other uses that involve coupled thermal, hydrological, geochemical, and mechanical processes in geological media. Theoretical developments and applications of the TOUGH codes can be found and downloaded from the TOUGH webpage at https://tough.lbl.gov/events/tough-symposia/.

The modular structure of TOUGH codes has made them applicable to diverse disciplines. However, such diversity has caused disagreements throughout its revision history between flow modules, repeated code development and maintenance efforts, and confusion among end-users and developers (Jung et al. 2017). Therefore, TOUGH3, with 3 the version number, has evolved as an advanced version of TOUGH codes to address some of the above issues and consolidate relevant capabilities in TOUGH2 V2.1 (Pruess et al. 2012), TOUGH2-MP (Zhang et al. 2008), and the simulator component of iTOUGH2 (Finsterle et al. 2017). Detailed theoretical background and applications of TOUGH3 can be found in Jung et al. (2017, 2018).

TOUGH3 uses the integral finite difference (IFD) method (Narasimhan and Witherspoon 1976) to construct unstructured mesh in various dimensions. However, treating heterogeneity and anisotropy in an IFD format requires tremendous manual editing and subsequent post-processing to visualize the simulation results. Although some commercial tools are available to accomplish mesh editing, it is still impossible to post-process the mesh outside the scope of the tool’s designated capabilities because of the unknown proprietary data format used in these tools (Luu 2020). This reason has motivated us to develop applications from mesh generation to simulation results post-processing for TOUGH3 simulations.

Mesh generation can be divided into structured and unstructured, distinguished by their internal node connectivity algorithm. Both mesh types have conflicting advantages and disadvantages regarding computational cost, memory requirements, numerical accuracy, and ease of mesh generation. Whether the mesh generation process is a science or an art is debatable. The mesh generation can be termed science if rational algorithms are followed during the process, for example, cell height and orthogonality inside the boundary layer, cell size growth rate, grid density, and grid quality. However, a subjective but minor adjustment of the alignment and arrangement of elements may strongly influence the outcome, rendering all meshes not created equal (Sadrehaghighi 2021). It is, therefore, critical to recognize that only through simulations using a science-based mesh can we make reasonable interpretations or decisions from them.

A structured mesh usually has orthogonal quadrilateral (2D) or hexahedral (3D) elements such that an easily-coded indexing algorithm can fully replace the node connectivity to determine the connection between nodes and elements. Therefore, numerical simulations using a structured mesh can save computer memory, boost computational efficiency, and increase solution accuracy. However, generating the structured mesh for a domain with complex geological structures is time-consuming because of decomposing the domain into subblocks depending on the structures’ geometric complexities. In this case, the unstructured mesh is favored by its flexibility and automation in node assignment, though at the cost of storing the node connectivity explicitly and scarifying solution accuracy for the presence of highly skewed elements (Sadrehaghighi 2021). Mesh optimization may partially mitigate the solution accuracy deterioration but cannot thoroughly remove it.

Choosing a mesh type is usually problem-specific and needs to consider factors including geological complexity, memory capacity, computation time, and the need for higher resolution mesh in localized regions. In general, a structured mesh is preferred if the solution accuracy is the priority, while the unstructured mesh is better when the simulation domain has an irregular shape and multiple geometrically complicated structures. The latter mesh type is considered in this study because the geometric complexity of the simulation domain and geologic structures are common to nearly all study areas.

The remainder of this paper is organized as follows. Section 2 explains the processes contained in the proposed workflow. Section 3 presents the geologic model of the study site, the 3D unstructured mesh, and numerical simulation results of the groundwater flow in the study area. Next, sensitivity analysis of mesh design and boundary conditions is discussed in Sect. 4. Finally, the conclusions of the present study are drawn in Sect. 5.

2 Methodology

The hydrogeologic conceptual model for a groundwater flow simulation always makes some simplifications and assumptions to render the resulting mathematical model solvable. One commonly used simplification is to use coarse grids to represent an irregularly shaped geologic structure, accompanied by a mathematical averaging algorithm to represent the hydrogeologic properties in the coarse grid. These simplifications inevitably lead to inaccurate estimations of the aquifer’s hydrogeologic characteristics (e.g., groundwater flow direction and flow rate). This paper overcame these shortcomings by building a series of general-purpose processes, featured by a hierarchical meshing technique, for the numerical simulation of 3D groundwater flow in an aquifer with complicated geology.

This paper selected the Huayu Islet, located in the southwestern rim of the Penghu archipelago formed by 64 islands, as the study area to demonstrate the feasibility of the developed technologies for investigating groundwater flow with variable salinity. The reasons for choosing Huayu are twofold. Firstly, the surface water storage capacity for Huayu is low because of its high evapotranspiration rate than precipitation and lack of perennial streams due to flat terrain, making groundwater a valuable water resource for household usage and irrigation. The second reason is geologic concerns because Huayu is the only island formed by andesite lava flow but is only 34 km southwest of the basaltic Penghu archipelago.

Taking salinity into account for Huayu’s groundwater flow simulation is a requirement because of its seagirt environment. Besides salinity, Huayu’s groundwater table is low during dry seasons. Therefore, the selected numerical simulator must be able to handle the unsaturation effect and salinity-dependent fluid properties in a multiphase and multicomponent system. These reasons make the mass-balance equations highly nonlinear and difficult to solve. Furthermore, a large number of dike structures, some with an irregular geometry, formed by two major dike systems along Huayu’s coast require an extra-fine mesh to investigate their effects on the groundwater flow field, rendering the need for parallel processing to handle the high computational load due to the use of many grid cells. All the above considerations can be appropriately managed in the EOS7 (Equation Of State #7) fluid module in TOUGH3, hereafter referred to as TOUGH3-EOS7.

The developed processes form a trilogy, represented as the workflow shown in Fig. 1, in which each row denotes a process and is represented by a different color. From left to right, the three columns represent each process’s input data, tools, and outcome. It is seen from Fig. 1 that the workflow is implemented sequentially from left to right and then from top to down, starting from collecting the site geological data, with a clear relationship indicating what tools are used to process the input data and to produce the outcome. Package names in the ‘tools’ column with a superscript ‘®’ represent commercial software, while MeshEdit, MyNastranH8, and MyDeCodeTxEOS7 are self-developed tools. MyDeCodeTxEOS7 is a post-processing tool to convert simulation outputs from TOUGH3-EOS7 to a text file used in ParaView, an open-source data analysis and visualization application. Details of each process are described in the following sections.

Fig. 1
figure 1

The trilogy workflow developed in this paper for numerical simulations of groundwater flow. Three main processes in the rightmost column formed the trilogy core, and the input data and tools needed for each process are identified in the left and middle blocks in a row. Starting from the upper left block and following the workflow direction leads to the final step of a TOUGH3-EOS7 simulation

2.1 Study area

Huayu is situated in a NE-SW trending high-magnetic anomaly belt split from the Southeast Coast Magnetic Belt (Chen et al. 2010). In the Cenozoic, the coastal areas in southeast China have been recognized as a rifted margin, and the magmatism was dominated by basaltic eruptions mainly in Eocene and Miocene (Chen et al. 1997; Chung et al. 1994). Therefore, the Penghu archipelago is composed of Late Miocene basaltic rocks, products of intraplate volcanism related to this continental extension. However, Huayu, aged 65–59 Ma (Chen et al. 2010), is the only exception that is non-basaltic and the oldest volcanic rock in the Penghu area.

Although most islets of the Penghu archipelago are composed mainly of mid to late Miocene basaltic lava flow, field surveys have shown that Huayu is composed of andesite lavas intruded by dacite and rhyolite dikes (Chen et al. 2010). Only a limited outcrop of epiclastics is present at the northern cape of Huayu. Dike intrusion occurs mainly along Huayu’s coastline by N40° W–N50° W trending intermediate (dacite/granodiorite) and felsic (rhyolite/granite) dikes with a dip angle greater than \(80^\circ\) (Yang et al. 2008). This paper treats these dikes as vertically dipped structures with irregular shapes.

Huayu’s plateau-like topography makes it distinct from most dome-shaped islands. The elevation contours in Fig. 2 show that Huayu’s mean elevation is \(32.1\,{\text{m}}\), with the highest elevation of \(53.3\,{\text{m}}\) occurring approximately \(250\,{\text{m}}\) east to the islet center. Using Huayu’s digital surface model can verify that 65% of Huayu’s topography has a small-to-mild slope, with the high-slope area (> \(25^\circ\)) occurring near the coastline. This unique topography thus becomes one of the geologic factors to study its effect on the groundwater flow in Huayu. Secondly, like other offshore islands of Taiwan, Huayu is severely short of freshwater resources because of its low annual precipitation. Therefore, the relationship between Huayu’s water resources and hydrogeology is another interesting topic.

Fig. 2
figure 2

The location and the geologic map of Huayu

As demonstrated in Fig. 3, the high weathering resistance of rhyolite dikes can be proved by their extrusion of the ground surface compared to the surrounding andesite. However, transforming dike properties into a numerical scheme is challenging because dikes are heterogeneous in geometry, intensity, spatial distribution, and permeability. Therefore, practical simulation procedures are proposed in Sect. 2.3 to handle this numerical issue.

Fig. 3
figure 3

 A photo demonstrating the weathering resistance of dikes in Huayu

2.2 Simulation tools

Besides TOUGH3-EOS7, several tools are applied to achieve various meshing, property setting, or data visualization objectives, including three commercial packages: ArcGIS®, SpaceClaim®, and CFD-VisCART®, one open-source application: ParaView, and three self-developed tools: MyMeshView, MyNastranH8, and MyDeCodeTxEOS7.

ArcGIS® is used in this study to compile surface geological information such as the topography and the outcrop locations of faults and dikes. The compiled information could be output from ArcGIS® in the “Stereolithography’ (or ‘stl’) format. SpaceClaim® then processes this ‘stl’ file to produce a 3D geological model in the ‘Standard ACIS Text’ (or ‘sat’) format. Finally, output from SpaceClaim® is further processed via CFD-VisCART® to produce a 3D unstructured mesh in the Nastran-Hexa (or ‘nas’) data format. ParaView, an open-source application developed by the Sandia National Laboratory (Utkarsh 2019), is used in this study to visualize the output results from TOUGH3-EOS7 after some necessary post-processing efforts done by MyDeCodeTxEOS7.

MyMeshView, a cross-platform application incorporating libraries from C++, Qt, and VTK, was developed to visualize the 3D unstructured mesh and quickly glimpse the generated mesh to inspect undiscovered errors. It is featured by its high computational efficiency, which can visualize any unstructured mesh with millions of cells. This tool has a convenient graphical user interface (GUI) to show (by panning, zooming, or rotating) the entire mesh or the selected sub-mesh, reveal the internal mesh structure by transparentizing or truncating overlying cells, zoom in on selected cells, and show the properties of a selected geological structure. MyMeshView also provides several clipping options to show the mesh in a user-defined region, including the simple clip, crinkle clip, and clip within a geometric object (sphere, box, or cylinder).

MyNastranH8 and MyDeCodeTxEOS7, written with the C++ language, were developed to complete the pre-processing of mesh data and post-processing of the simulation results. MyNastranH8 creates mesh-related input files necessary for executing TOUGH3-EOS7 simulations. Data in these input files include the unique identification number of each cell, connection relationships among cells, a particular property identification (PID) to identify each cell’s geologic attribute, and the cell’s initial and boundary conditions. Then, MyDeCodeTxEOS7 combines the input files and output files from TOUGH3-EOS7 to produce a Comma-Separated Values (or ‘csv’) text file that saves the simulated results in each cell, including the primary variables, e.g., temperature and pressure, and secondary variables, e.g., the components of Darcy velocity and pore velocity. This csv-format text file is then fed into ParaView to visualize the groundwater flow field and to implement the particle tracking (PT) calculations.

2.3 Simulation setups

In the trilogy’s first process, site geological data, including topographical digital elevation model (DEM), lithology, and geologic structures (Chen et al. 2010; Yang et al. 2008), are processed via ArcGIS® and then SpaceClaim® to produce a 3D geologic model. In the second process, CFD-VisCART® is utilized to convert the 3D geologic model into an unstructured mesh composed of cubes of various cell sizes. MyNastranH8 then converts the refined mesh file into the one that follows the IFD format, assigns the initial condition and boundary condition in each cell, and produces the input files for TOUGH3-EOS7. After the groundwater flow simulation is done, MyDeCodeTxEOS7 can edit the output files to produce a text file used by ParaView for visualization and calculating PT results. The entire workflow is illustrated in Fig. 1.

The pivotal issue in generating Huayu’s mesh is how realistic the resulting mesh represents the in-situ geology. Mesh resolution is another crucial factor because a fine mesh can mimic the geology but at the cost of high computational time for groundwater flow simulations. On the contrary, using a coarse mesh can reduce the computational burden but compromise the precision. A tradeoff is needed to balance the mesh resolution and precision.

2.3.1 Method of mesh refinement

As seen in Fig. 3, the rhyolite dike stands out from the andesite host rock due to its high weathering resistance. Despite the lack of field or laboratory measurement of Huayu’s dike permeability, this field observation provides indirect evidence that dike permeability is significantly lower than the andesite host rock. Although using a coarse mesh can estimate the hydraulic gradient at locations far from the contact of two media with permeabilities of distinct magnitudes, a fine mesh can better unravel the significant change of hydraulic gradient across the permeability contact but at the cost of reduced computational efficiency. Therefore, this paper applies the cell refinement algorithm developed in CFD-VisCART® to create an unstructured mesh that can balance numerical accuracy and computational efficiency.

Building an unstructured Cartesian mesh is based on the grid hierarchy concept. This concept controls the mesh resolution such that the cell size is reduced near a geologic structure. In the refinement stage (see the next paragraph for the algorithm), each cell is assigned an integer cell refinement level (CRL) so that the larger the CRL, the smaller the cell size and the closer the cell to a geologic structure. Therefore, cells within and close to a geologic structure have the smallest cell size but the largest CRL after refinement. By doing so, a mesh can be recursively refined or coarsened depending on CRL values.

CFD-VisCART® uses the octree algorithm (Frey and George 2008) to rank the grid hierarchy. Let \({l}_{i}\) and \({l}_{j}\) be the cell sizes of two cells having CRLs as \(i\) and \(j\), the octree algorithm requires that the ratio of \({l}_{i}\) to \({l}_{j}\) must be \({2}^{j-i}\). The meaning of this constraint is two-folded. First, two cells having the same CRL, i.e., \(i=j\), should have the same cell size because \({2}^{j-i}={2}^{0}=1\). On the other hand, a cell with a larger CRL must have a smaller cell size than the one with a smaller CRL. According to the octree algorithm, the mesh with a larger maximum CRL, \({\text{C}\text{R}\text{L}}_{max}\) for short, can discretize a geologic structure into more cells than the one with a smaller \({\text{C}\text{R}\text{L}}_{max}\).

Figure 4 can better explain the octree algorithm, in which a mesh with \({\text{C}\text{R}\text{L}}_{max}\) of 5 is illustrated. For simplicity, a two-dimensional (2D) mesh is shown in this figure, with a red-shaded rectangle representing a geologic structure and red characters representing CRL values. It is evident in Fig. 4 that cells with CRL = n have a size that is half of those with CRL = n − 1, i.e., \({l}_{n}=0.5{l}_{n-1}\). For example, if \(n=2\), Fig. 4 indicates that \({l}_{2}=0.5{l}_{1}\). For a 2D mesh, therefore, a cell with a CRL of \(n-1\) can contact at least two cells with a CRL of \(n\). Similarly, for 3D meshes, the minimum number of adjacent cells is 4 when the difference of cell CRLs is one.

Fig. 4
figure 4

The relationship between the cell refinement level and the cell size in the octree algorithm

It is worth noting that the octree algorithm can seek a balance between the number of cells and the description of the geometry of an irregular object. Let us take a fictitious example of a fan-like object, see Fig. 5a, to explain the concept and imagine that the fan object has distinct hydrogeological properties compared to the surrounding grey region. It is expected that the finer the mesh near the fan boundary, the more accurate the geometric characteristics be represented and, thus, the higher the solution accuracy. For example, Fig. 5b shows a mesh with a uniform cell size of \(2\,{\text{m}}\) with a total of 251,810 cells, noting a unnecessarily fine mesh in the region away from the fan. However, if the octree algorithm is used, Fig. 5c shows a recursively coarse-fine-coarse mesh with 201,612 cells and the minimum cell size as 1 m. Note that the total number of cells and the minimum cell size can be controlled by the cell size with CRL = 1 and the maximum CRL value.

Fig. 5
figure 5

An example of a hierarchical mesh for a domain having an object with irregular geometry. The fictitious fan-shaped object is shown in a, and two different meshes are shown in b and c. The minimum cell sizes in b and c are 2 m and 1 m, corresponding to the total numbers of cells as 250,810 and 201,612, respectively

2.3.2 Groundwater flow simulations

As aforementioned, TOUGH3 codes use the IFD scheme to simulate the non-isothermal transport of multi-component and multiphase fluids in porous or fractured media. To do this, TOUGH3 writes the governing mass-balance equations in the following integral form (Pruess et al. 2012):

$$\frac{d}{dt}{\int }_{{V}_{n}}{M}^{\kappa }d{V}_{n}={\int }_{{{\Gamma }}_{n}}{\mathbf{F}}^{\kappa }\cdot \mathbf{n}d{{\Gamma }}_{n}+{\int }_{{V}_{n}}{q}^{\kappa }d{V}_{n}, \kappa =1, \dots, nk$$
(1)

in which \({M}^{\kappa }\) represents the fluid mass of component \(\kappa\) or heat in the grid \({V}_{n}\), \({\mathbf{F}}^{\kappa }\) is the mass or heat flux across the interface \({{\Gamma }}_{\text{n}}\) that is the boundary surface of \({V}_{n}\), \(\mathbf{n}\) is the inward unit normal vector on \({{\Gamma }}_{n}\), \({q}^{\kappa }\) is the sink/source term of the fluid component \(\kappa\) or heat, \(t\) is time, and \(nk\) is the total number of fluid components in the system.

This paper uses TOUGH3’s EOS7 module to simulate the isothermal flow of the three-component fluid (water, brine, and air) in two phases (gas and liquid). EOS7 uses four primary variables to calculate the fluid mass and mass flux: pressure \(\left(P\right)\), brine mass fraction \(\left({X}_{b}\right)\), air mass fraction \(\left({X}_{a}\right)\), and temperature \(\left(T\right)\). The condition of phase change is denoted by adding or subtracting 10 to \({X}_{a}\) so that a new gas phase (air) appears with saturation \(\left({S}_{g}\right)\) of \({X}_{a}-10\) if \({X}_{a}\) is greater than 10; otherwise, the air is dissolved in the liquid phase. For isothermal simulations, the temperature in each grid block is fixed.

In addition to the primary variables, other hydrogeological parameters, the so-called secondary variables in TOUGH3, are also needed to complete Eq. (1). Let \(\varphi\) be the porosity, \(\beta\) be the phase index which can be \(l\) (liquid phase) or \(g\) (gas phase), and \(R\) be the solid (or rock) phase index, \({S}_{\beta }\) be the \(\beta\) phase saturation, \({\rho }_{\beta }\) be the \(\beta\) phase density, \({\rho }_{l}\) be the liquid phase density, \({\rho }_{R}\) be the rock density, \({X}_{\beta }^{\kappa }\) be the mass fraction of the fluid component \(\kappa\) in the \(\beta\) phase, \(np\) be the total number of phases, \({K}_{d}\) be the liquid phase distribution coefficient. Therefore, \({M}^{\kappa }\) in Eq. (1) is written as

$${M}^{\kappa }=\varphi {\sum }_{\beta =1}^{np}{S}_{\beta }{\rho }_{\beta }{X}_{\beta }^{\kappa }+\left(1-\varphi \right){\rho }_{R}{\rho }_{l}{X}_{l}^{\kappa }{K}_{d}$$
(2)

TOUGH3 separates the flux term into advective and diffusive fluxes. Individual phase fluxes, \({\mathbf{F}}_{\beta }\), are given by the multiphase version of Darcy’s law. Let \({\mathbf{u}}_{{\upbeta }}\) be the Darcy velocity vector of phase \(\beta\), \(k\) be the absolute permeability, \({k}_{r\beta }\) be the relative permeability to phase \(\beta\), \({\mu }_{\beta }\) be the dynamic viscosity to phase \(\beta\), \({P}_{\beta }\) be the \(\beta\) phase pressure, and \(\mathbf{g}\) be the vector of gravitational acceleration, \({\mathbf{F}}_{\beta }\) are written as:

$${\mathbf{F}}_{\beta }={\rho }_{\beta }{\mathbf{u}}_{\beta }=-k\frac{{k}_{r\beta }{\rho }_{\beta }}{{\mu }_{\beta }}(\nabla {P}_{\beta }-{\rho }_{\beta }\mathbf{g})$$
(3)

Note that \({P}_{\beta }\) is the sum of a reference phase (usually the gas phase) and capillary pressure. Therefore, for component \(\kappa\), its advective flux is the sum of fractional phase fluxes:

$${\left.{\mathbf{F}}^{\kappa }\right|}_{adv}={\sum }_{\beta =1}^{np}{X}_{\beta }^{\kappa }{\mathbf{F}}_{\beta }$$
(4)

Diffusive flux in TOUGH3 is formulated similarly to Fick’s first law of diffusion. Due to the complications of multiple-component diffusion in a multiphase flow system, an effective diffusion coefficient is adopted in TOUGH3, which depends on the molecular diffusion coefficient (\({d}_{\beta }^{\kappa }\)) and a tortuosity factor. A pragmatic tortuosity model is used in TOUGH3 to describe the dependence of tortuosity on porous medium properties \(\left({\tau }_{0}\right)\) and phase saturation \(\left({\tau }_{\beta }\right)\). For component \(\kappa\) in phase \(\beta\), this effective diffusion coefficient is written as \(\varphi {\tau }_{0}{\tau }_{\beta }{\rho }_{\beta }{d}_{\beta }^{\kappa }\). Two options for the tortuosity model are provided in TOUGH3: the Millington–Quirk and the constant phase saturation. Then, the total diffusive flux of component \(\kappa\), \({\mathbf{f}}^{\kappa }\), is the sum of gas and liquid phase diffusive fluxes, i.e.,

$${\mathbf{f}}^{\kappa }=-\varphi {\tau }_{0}{\tau }_{\beta }{\rho }_{l}{d}_{l}^{\kappa }\nabla {X}_{l}^{\kappa }-\varphi {\tau }_{0}{\tau }_{\beta }{\rho }_{g}{d}_{g}^{\kappa }\nabla {X}_{g}^{\kappa }$$
(5)

Three mathematical solvers are available in TOUGH3 to solve Eq. (1), including TOUGH2’s serial solvers improved with a new sorting algorithm, parallel solvers from TOUGH2-MP’s Aztec solvers, and the new PETSc solver in TOUGH3. This paper uses the Aztec solver for all groundwater flow simulations.

The initial condition for all simulations is the presence of single-phase fluids in the hydrostatic condition with the ambient atmospheric pressure of 1 bar \(({10}^{5}\,{\text{Pa}})\). The geothermal gradient \((\nabla T)\) and the ground temperature \(\left({T}_{g}\right)\) are assumed to be \(1.7\, {^\circ}\text{C}/100\,{\text{m}}\) and \(23.5\,{^\circ}{\text{C}}\), respectively. Note that the depth-dependent temperature distribution is used only for obtaining correct thermodynamic fluid properties, but this paper considers only isothermal groundwater flow simulations. Fresh water and brine exist in the rock pore space above and below the mean sea level (MSL). The initial densities of fresh water \(\left({{\uprho }}_{w,0}\right)\) and brine \(\left({\rho }_{b,0}\right)\) are assumed as \(1000\,{\text{kg}}/{\text{m}}^{3}\) and \(1025\,{\text{kg}}/{\text{m}}^{3},\) respectively.

Boundary conditions at the top, bottom, and lateral boundaries are as follows. At the ground surface, the two-phase Dirichlet condition with \(100\%\)relative humidity is assumed by imposing \(P=1\) bar, \({X}_{b}=0\), \({X}_{a}=10.90\) (or \({S}_{g}=0.9\)), and \(T={T}_{g}\). The no-flow boundary condition is assumed at the bottom boundary plane, where a single-phase brine \(({X}_{b}=1, {X}_{a}=0)\) is present with hydrostatic brine pressure and the temperature is calculated according to the depth, \({\rho }_{b,0}\), \({T}_{g}\), and \(\nabla T\). The domain’s perimeter has constant hydrogeological conditions, with fully saturated single-phase brine \(({X}_{b}=1, {X}_{a}=0)\) under hydrostatic pressure and depth-dependent temperature. Note that there is no need to adjust the cell volume to impose the default no-flow boundary condition. However, an infinitely large volume (e.g., \({10}^{50}\,{\text{m}}^{3}\)) needs to be specified in grid cells of constant boundary conditions.

3 Results

3.1 Geologic model of Huayu

The preliminary hydrogeological conceptual model (HCM) of Huayu is built by following the trilogy outlined in Fig. 1. Huayu’s DEM and its digital topographic map are shown in Fig. 6a, b, respectively. Then, all the geometric data (points, lines, and surfaces) shown in Fig. 6b are combined and converted by SpaceClaim® to produce the 3D geologic model, Fig. 6c, with a model area of \(1.5\,{\text{km}}^{2}\). In Fig. 6c, the top boundary follows Huayu’s DEM but truncates to \(59\,{\text{m}}\) above the MSL, and the bottom boundary is a horizontal plane \(1\,{\text{km}}\) below MSL. Seabed elevation is not considered owing to the lack of data.

Fig. 6
figure 6

Huayu’s topography: a DEM, b Digital topography processed by ArcGIS®, c 3D geological model generated by SpaceClaim®

From the geologic map in Fig. 2, Huayu’s rock units are classified into three fundamental structures: andesite lava flow (ANDES), dacite dike (DDA), and rhyolite dike (DR). A total of 49 dike units are identified in Fig. 2, including 31 DDAs (Fig. 7a) and 18 DRs (Fig. 7b), and the remaining rock formation is classified as ANDES, Fig. 7c. The DRs are further divided into one DR1 and seventeen DR2, with DR1 the irregular rhyolite dike located in northeastern Huayu (see Fig. 2), and DR2 the regular structures represented as leptosomatic hexahedrons with a uniform width of \(3\,{\text{m}}\). Besides these structures, about 50% of Huayu is covered by weathered caprock (Chen et al. 2010). Therefore, a total of 50 geologic structures (1 ANDES, 31 DDAs, 1 DR1, and 17 DR2s) are contained in the preliminary HCM, and, without loss of generality, all geologic structures are assumed as homogeneous and isotropic porous media as the aim of this study is to demonstrate the workflow feasibility but not the simulator’s capability to handle heterogeneity.

Fig. 7
figure 7

Rock units used in Huayu’s geological model: a 3D dacite dikes, b 3D rhyolite dikes, and c andesite lava flow without dikes

Two more steps further modify the preliminary HCM to become the intermediate HCM. First, Huayu is split into two rock domains, the upper one representing the regolith with a uniform depth of \(70\,{\text{m}}\) and the lower one the fresh rock body, resulting in a total of eight rock units. Secondly, geologic structures of the same rock type are classified as only one of the eight homogeneous rock units, with each unit representing the geologic structures within or below the regolith. Hereafter, each rock unit is abbreviated as a five-character symbol using the regolith as the rock domain delimitation. A symbol starting with the prefix ‘Re’ represents the rock unit in the regolith, for example, ReAND, ReDDA, ReDR1, and ReDR2; whereas all rock units below the regolith end with the suffix ‘XX,’ except the andesite lava flow abbreviated as ANDES as before, for example, ANDES, DDAXX, DR1XX, and DR2XX. Note that the fifty geologic structures are still considered in the final HCM, but each rock unit contains at least one geologic structure; for example, DR2XX represents the 17 DR2s below the regolith.

It assumes that hydrogeological parameters in Huayu’s regolith are the same as those in the regolith of Kinman, a granitic island 210 \(\text{km}\) to the west of Taiwan (Liou et al. 2010). Note that this paper does not investigate the effects of heterogeneity and anisotropy on the resulting groundwater flow field. Therefore, all four rock units in the regolith use the same hydrogeologic parameters for simplicity, with the density, porosity, and permeability as \({2000}\,\text{kg}/{\text{m}}^{3}\), 0.2, and \({10}^{-14}\,{\text{m}}^{2}\), respectively.

Field evidence, see Fig. 3, indicates that the light-colored, fine- to medium-grained, compact dacite and rhyolite dikes in Huayu have high weathering resistance than the andesite host rock, implying that dacite and rhyolite dikes in the fresh rock are less permeable than andesite. Therefore, the permeability of DDAXX, DR1XX, and DR2XX is assumed to be \({10}^{-16}\,{\text{m}}^{2}\) which is one order of magnitude smaller than that of ANDES \(\left({10}^{-15}\,{\text{m}}^{2}\right)\).

The porosity of ANDES, DR1XX, and DR2XX is assumed to be \(8\times {10}^{-3}\) (Heap et al. 2018). The values of rock density are taken from Gudmundsson (2020) that ANDES density is set as \({2650}\,{\text{kg}}/{\text{m}}^{3}\), while the density of both DR1XX and DR2XX is set as \({2500}\,{\text{kg}}/{\text{m}}^{3}\). The density of DDAXX is set as \({2650}\,{\text{kg}}/{\text{m}}^{3}\) (del Potro et al. 2013). A low net infiltration rate of \(35\,\text{mm}/\text{year}\) is assumed because Taiwan’s offshore islands generally have higher evapotranspiration than precipitation (Liou et al. 2010). Detailed hydrogeologic parameters of the eight rock units are listed in Table 1.

Table 1 Hydrogeologic parameters of the eight rock units considered in the HCM

It is shown in Fig. 2 that, unlike DR2s trending N40° W–N50° W, DR1 is nearly East-West trended, making it intersect one DDA and one DR2. This dike intersection, plus DR1’s irregular shape, has made mesh construction very difficult because, for better delineating DR1’s geometry, cell size needs to vary with the complex geometry near the dike intersection and along DR1’s perimeter. Besides the geometric concerns, the permeability contrast between the andesite and dikes inevitably precludes using a coarse mesh because some averaging technique needs to be applied to handle the grid that includes two different rock types. On the other hand, using a globally fine mesh is a tentative solution but at the cost of the computational burden. Therefore, the intermediate HCM needs to be further modified, see the next section, to address the above concerns.

3.2 Hierarchical unstructured mesh of Huayu

To build Huayu’s unstructured Cartesian mesh, it needs to specify the minimum cell size, \({r}_{min}\), and calculate \({\text{C}\text{R}\text{L}}_{max}\) according to the size of the bounding box. The value of \({r}_{min}\) depends on the geologic structure’s irregularity and the desired mesh resolution, so that the smaller the \({r}_{min}\) (or the larger the \(\text{C}\text{R}{\text{L}}_{\text{m}\text{a}\text{x}}\)), the higher the resolution of delineating an irregular geologic structure. It needs to clarify that \({\text{C}\text{R}\text{L}}_{max}\) is the smallest CRL such that CFD-VisCART® can determine a cubic bounding box covering the entire simulation domain. It is worth mentioning that mesh resolution depends strongly on \({\text{C}\text{R}\text{L}}_{max}\). For example, Fig. 8 compares three meshes extracted from a plane at \(z=500\,{\text{m}}\), with \({\text{C}\text{R}\text{L}}_{max }\)as 5, 8, or 10. Using \({\text{C}\text{R}\text{L}}_{max}=5\) results in a larger \({r}_{min}\) but all geologic structures become blurred and cannot be differentiated from the host rock. Increasing \({\text{C}\text{R}\text{L}}_{max}\) from \(5\) to \(8\) improves the resolution, see Fig. 8b, such that the perimeter of all geologic structures becomes clear. If \({\text{C}\text{R}\text{L}}_{max}\) is further increased to 10, Fig. 8c shows that DR1 can be deciphered entirely at the expense of having more grid cells.

Fig. 8
figure 8

Variation of meshing results with \({\text{C}\text{R}\text{L}}_{max}\): a \({\text{C}\text{R}\text{L}}_{max}=5\) with 63,309 cells, b \({\text{C}\text{R}\text{L}}_{max}=8\) with 3,964,003 cells, c \({\text{C}\text{R}\text{L}}_{max}=10\) with 51,258,089 cells

The above grid hierarchy concept is implemented by CFD-VisCART® with an un-favored outcome that empty cells are created in the vicinity of cell refinement. Such empty cells are not allowed for flow simulations if they represent the physical rock formation. Therefore, one of MyNastranH8’s functions is to handle this situation by re-assigning an empty cell to an appropriate geologic structure.

Once a 3D unstructured mesh is available, MyMeshView provides a convenient GUI to view or dissect the mesh such that the overall or the internal structure of a mesh can be instantly revealed. MyMeshView’s GUI is illustrated in Fig. 9 with a simplified mesh considering only 12 dike units. Input to MyMeshView is a mesh text file in the ‘csv’ format, while MyMeshView can output the mesh file in either ‘nas,’ ‘vtu,’ or ‘vtk’ format.

Fig. 9
figure 9

MyMeshView’s user-friendly GUI

MyMeshView contains four panels: ‘Items,’ ‘Properties,’ ‘View,’ and ‘Clipper’ to allow users to select the geometric object of interest, explore the properties of the selected object, change the view angle and lighting attributes, and clip the mesh. MyMeshView’s clipper provides two types of clipping mechanisms: clip by a plane or clip by a volumetric 3D object. For both clippings, users can select the simple clip or crinkle clip to visualize the clipping result. Once a clipping is done, more clipping can be added to the existing clipped mesh, meaning the clipping sequence affects the final clipping result.

3.3 Groundwater flow simulations in Huayu

The initial and boundary conditions specified in Sect. 2.3.2 are the base case scenario. Usually, assigning grid properties corresponding to initial and boundary conditions for a simulation scenario containing millions of unstructured grid cells would be arduous. Fortunately, this paper applies the self-developed tool MyNastranH8 to accomplish this job automatically so that manual efforts can be significantly reduced.

For the base case, the minimum cell size of \(2.5\,{\text{m}}\times 2.5\,{\text{m}}\times 10.0\,{\text{m}}\) was used, and the horizontal cell size varied from \(2\) to \(10\,{\text{m}}\) depending on the cell’s proximity to the geologic structure. Therefore, the maximum cell size changes to \(10.0\,{\text{m}}\times 10.0\,{\text{m}}\times 10.0\,{\text{m}}\). The total number of cells in the base case is \(\text{3,817,330}\).

Figure 10a shows the simulated brine mass fraction for the base case near the fresh water and brine interface (FWBI). Note that grid cells above the FWBI with \({X}_{b}<0.01\) are hidden in Fig. 10a to reveal the bowl-like shape of the FWBI more clearly. For the vertical \(A-A^{\prime }\) profile indicated in the lower-left corner, Fig. 10b shows the simulated brine mass fraction and the groundwater flow field, with the small arrowheads representing the detailed groundwater flow direction and the large yellow arrows the regional flow direction. Two isolated flow regimes are formed above and below the FWBI so that, near the FWBI, fresh water and brine flow without mixing and move parallel to the FWBI. This non-mixing flow behavior is because of the density difference between the fresh water and brine, which is consistent with the result predicted by the famous Henry’s problem (Henry 1964; Simpson and Clement 2004). The freshwater regime has a radiation flow pattern such that the buoyancy-driven flow near the FWBI eventually replaces the gravity-driven downward flow of fresh water. In contrast, owing to the non-mixing mechanism and the no-flow boundary condition, brine circulates upward from the bottom boundary and steeply exits the coastline.

Fig. 10
figure 10

Groundwater flow and particle tracking simulation results: a base case with the minimum cell size of \(10\,{\text{m}}\) and a two-phase top boundary condition with a fully saturated (100% relative humidity) atmosphere; b variant 1 with the minimum cell size increased to \(40\,{\text{m}}\); and c variant 2 with the single-phase fresh water at the top boundary

This paper implemented PT simulations, using ParaView given the pore velocity calculated from TOUGH3-EOS7 simulation results, for characterizing transport properties in the two regimes. For PT simulations, one hundred particles were released from the bottom of the FWBI at the intersection of the \(AA^{\prime }\) and \(BB^{\prime }\)profiles (see Fig. 10b), with the releasing depth at \(265\,{\text{m}}\). Figure 10a shows that, in the freshwater regime, particles first move with the downward flowing fresh water, and once they get close to the FWBI, they move parallel to the FWBI and finally exit the coastline. In contrast, in the brine regime, particles move with the upward-flowing brine, then are diverted by the FBWI, and finally, move towards the coastline. In Fig. 10a, some particles do not reach the coastline because dikes, characterized by their low permeability and, thus, low groundwater flow velocity, stop them. Besides, particles released close to the FWBI generally travel faster than those released above or below the FWBI.

It needs to point out that no borehole data are available to calibrate the simulation results shown in Fig. 10. However, the general features of the variable density flow in Fig. 10 are consistent with those predicted by the Henry model (Henry 1964).

4 Discussion

Conventional code benchmarking is to have all teams run the same test problem and execute a comprehensive inter-comparison of simulation results. It is noted that, even if the same code is used, the comparison of simulation results should be based on the same mesh and boundary conditions because the simulation precision depends on these factors. Therefore, this section considers two more variants to evaluate the effects of mesh size and boundary conditions on groundwater flow simulation results. The coarse-mesh variant, called variant 1 for short, reduces the total number of cells to \(\text{2,334,475}\) by increasing the cell size from \(5\) to \(40\,{\text{m}}\). The rest of the settings are the same as those in the base case. Simulation results for variant 1 are shown in Fig. 10c, d. The second variant, variant 2 for short, changes the boundary condition on the ground surface from two-phase to single-phase, with simulation results in Fig. 10e, f. Both the base case and variant 2 used the same mesh.

For all PT simulations in the three cases, one hundred particles are released from the bottom of the FWBI at the intersection of the \(AA^{\prime }\) and \(BB^{\prime }\) profiles (see Fig. 10b), but at different release depths. This paper uses log-transformed particle travel time (in years), \({\text{log}}_{10}t\), to compare transport characteristics obtained from the three cases. Travel time statistics are summarized in Table 2.

Table 2 Statistics of log-transform travel time, \({\text{log}}_{10}t\), of the three cases considered in this paper

4.1 The effect of mesh size

It is seen from Fig. 10c, d that the shape and extent of FWBI and particle trajectories are distinct for the base case and variant 1. Some particles that reach the coastline for the base case (with a fine mesh) are no longer present in variant 1 (with a coarse mesh) because of the change of the flow direction, explained in the next paragraph. Besides, near the coastline, variant 1 no longer shows the steeply upward movement of a particle to the ground surface. The deformed FWBI may jeopardize the objectives of studies such as saltwater intrusion, in which the exact location of FWBI is needed to evaluate the completeness of the considered mixing mechanisms and the robustness of the proposed numerical scheme. As a result, the FWBI predicted from a coarse mesh numerical simulation may not give a conclusive evaluation due to the low FWBI resolution.

Comparing Fig. 10b and d indicates that the simulated groundwater flow field depends on the level of mesh refinement. If a coarser mesh is used, the white boxes labeled \(\left(1\right)\) and \(\left({1}^{{\prime }}\right)\) indicate that groundwater may skip certain areas in \(AA^{\prime }\). Moreover, the groundwater flow vectors may turn from inclined to vertical in certain areas beneath the FWBI, see the white boxes labeled \(\left(2\right)\) and \((2^{\prime})\) in Fig. 10b, d. The altered groundwater flow direction is related to poor numerical precision due to the coarse mesh. It is noted that if the groundwater flux on a designated control plane is needed in studies such as parameter sensitivity or parameter estimation, groundwater flow simulation using a fine mesh is needed to provide reliable predictions of the groundwater flux.

Besides the imprecise simulation result of the groundwater flow field, comparing Fig. 10b and d shows that a thicker transition zone between saltwater and freshwater is formed if a coarser mesh is used. This phenomenon is illustrated in Fig. 10d where a larger brine mass fraction is present in grid blocks close to the FWBI. The increased transition zone thickness wrongly indicates that the denser saltwater can migrate further above the FWBI. In other words, this unphysical simulation result overestimates the significance of mixing, which should be less critical.

The difference in groundwater flow direction leads to significant variation in the PT results as particles travel along different flow paths and thus have different travel times. Statistical plots of \({\text{log}}_{10}t\) are shown in Fig. 11, including boxplot, cumulative distribution function (CDF), and histogram with best-fit probability density function (pdf). The Median, mean, and outliers are represented in a boxplot as the orange bar, green triangle, and hollow circle, respectively. It is clear from Fig. 11a that all three cases have noticeable outliers above the third quartile (\(Q3\)), and variant 1 has an outlier below the first quartile (\(Q1\)). The presence of outliers beyond \(Q3\) manifests the complexity of the travel path even if all rock formations are homogeneous and isotropic, while the outlier below \(Q1\) is due to the pre-matured termination of PT simulation in variant 1. In particular, Fig. 10a, c show that some particles do not reach the coastline because of the low end-point velocity as they encounter low-permeability dikes.

Fig. 11
figure 11

Statistical plots of the travel time for the three cases considered in this paper, including, from top to bottom, boxplot, breakthrough curve, and histogram with best-fit pdf

Due to the presence of extreme outliers, Table 2 shows that the mean, standard deviation, skewness, and \(IQR\) for the base case are significantly greater than those in variant 1, noting that the skewness for variant 1 is only 34% of that for the base case.

The phenomena of reduced flow path heterogeneity and fast flow path can be seen by the CDF, pdf, and statistics of \({\text{log}}_{10}t\). It is shown in Fig. 11b that the CDF of variant 1 is steeper than that of the base case. Consequently, Fig. 11c shows that variant 1’s pdf is narrower than the base case’s right-skewed pdf. As shown in Table 2, the maximum \({\text{log}}_{10}t\) for the base case, 2.24, is significantly larger than 0.66 for variant 1. Besides, Table 2 shows that the standard deviation of \({\text{log}}_{10}t\) for variant 1 is \(0.21\) compared to \(0.57\) for the base case. Converting the standard deviation of \({\text{log}}_{10}t\) back to travel time, the standard deviation of travel time for variant 1 is only \(2\%\) of that for the base case. Hence, a coarse mesh simulation significantly reduces the underlying small-scale flow path heterogeneity.

In summary, inconsistent groundwater flow and transport mechanisms are obtained from simulation results using different mesh refinement levels, even if the same simulator (TOUGH3-EOS7) is applied in all simulations. It is noted that disparate and contradictory interpretations can be produced if different simulators are applied to meshes with different refinement levels. Therefore, using the same benchmark mesh is suggested for comparing simulation results using different simulators. On the other hand, an upper limit of the minimum cell size should be specified to predict groundwater flow mechanisms correctly. Take Huayu’s case as an example, the appropriate minimum cell size should be no more than \(5\,{\text{m}}\).

4.2 The effect of boundary condition settings

Comparing Fig. 10a and c shows that the FWBI is significantly lowered for variant 2. Therefore, the FWBI shape is no longer a bowl-like shape shown in Fig. 10a but a bucket-like one in Fig. 10e. The unphysical simulation result for variant 2 is a direct consequence of using an improper boundary condition by changing the two-phase condition to a single-phase one.

For variant 2, both the CDF and pdf of \({\text{log}}_{10}t\) have long tails compared to those for the base case. The mean, standard deviation, skewness, and maximum of \({\text{log}}_{10}t\) for variant 2 are all larger than those for the base case. One reason for this increased travel time is the increased FWBI bottom depth, from \(265\) to \(400\,{\text{m}}\), resulting in the increased total travel length. Note that the maximum time for variant 2 is nearly twice that for the base case, meaning the maximum particle travel time for variant 2 is two orders of magnitude larger than that for the base case. In contrast to the fast flow path effect in variant 1, using an improper boundary condition may result in particularly slow flow paths that should be absent in the field. This result thus demonstrates the importance of using a proper boundary condition.

5 Conclusion

This paper established a general-purpose trilogy workflow that is anticipated to be used as a protocol to investigate groundwater flow and solute transport characteristics of a study area. Each process in the workflow uses commercial software, self-developed codes, or academic simulators to complete its designated objective and produces data files complying with a specific state-of-the-art data format. To evaluate the robustness of the developed workflow, Huayu Islet, a non-basaltic island to the west of a basaltic archipelago, was considered to study its two-phase flow of the fresh water and brine mixture.

To fully represent Huayu’s complicated geologic structures, a series of data processing is necessary to produce a mesh that accurately represents Huayu’s geological conditions. The critical step is to vary CRLs in the neighborhood of a geologic structure to make the generated unstructured mesh compatible with Huayu’s geologic characteristics. The self-developed user-friendly GUI, MyMeshView, can easily display the internal architecture of the unstructured mesh and convert the mesh text file (in ‘csv’) into a binary file (in ‘nas,’ ‘vtu,’ or ‘vtk’). More importantly, the produced mesh is seamlessly linked with TOUGH3-EOS7 by using the self-developed utility MyNastranH8 to a text file complying with the IFD format. TOUGH3-EOS7 output can then be converted, via MyDeCodeTxEOS7, to a text file in ‘csv’ format for visualizing simulation results using the open-source application ParaView.

Comparing simulation results obtained by different mesh resolution and boundary conditions conclude that a fine mesh and a two-phase Dirichlet boundary condition at the ground surface are needed to capture the small-scale flow field heterogeneity and the shape of FWBI for Huayu’s case. In addition, groundwater flow travel time tends to be significantly underestimated using a coarse mesh.

Huayu’s case can serve as a practicable paradigm for future groundwater flow simulations in a geologically complicated domain. All utilities developed in this paper can sufficiently reduce manual labor during mesh generation and groundwater flow simulation. Although Huayu was used as one example, the same workflow can be applied to other sites with different field conditions as long as sufficient site characterization data are available.