Computational Parallel on Simulation of Wave Attenuation by Mangrove Forest

Coastal ecosystems, specifically mangrove trees, safeguard coastal regions against natural disasters like erosion, floods, and tsunamis. Numerical simulations employing the Shallow Water Equation (SWE), encompassing mass and momentum conservation equations, are used to comprehend how mangroves attenuate wave energy. The SWE incorporates Manning's friction term, which is directly influenced by mangrove forests. However, the SWE's complexity and sensitivity to initial conditions hinder analytical solutions. Despite its increasing computational demands, we utilize the robust staggered grid method to address this challenge. Our study examines mangroves' wave-attenuating effects and introduces a parallel computational model using OpenMP to expedite computations. Findings reveal that mangroves can reduce wave amplitudes by up to 33% when employing a Manning's coefficient of 0.3 within confined basin simulations. Furthermore, our parallel computing experiments demonstrate substantial computation speed enhancements; the speedup improves up to a point, with a notable 7.26-fold acceleration observed when utilizing eight threads compared to a single line. Moreover, more than a 10-fold acceleration is observed when the number of threads is greater than 16. This underscores the significance of parallelization in exploring mangrove contributions to coastal protection.


Introduction
Mangrove forests are vital as natural protective barriers against coastal calamities, particularly in tropical areas susceptible to cyclones, hurricanes, and tsunamis [1]- [5].The area's extensive root systems and heavy vegetation serve as effepracticalural barriers, mitigating the adverse effects of storm surges and high waves during severe weather events.Das and Vincent (2009) [6] conducted a study that emphasized the crucial significance of mangroves in mitigating damage caused by the Indian Ocean tsunami in 2004.Their findings revealed that coastal regions with preserved mangrove forests encountered substantially reduced damage and fewer casualties.The findings underscore the efficacy of mangroves in mitigating the risks associated with natural disasters by virtue of their capacity to absorb and disperse wave energy, hence protecting adjacent communities and infrastructure [2].Furthermore, mangrove forests play a crucial role in acting as inherent coastal fortifications through their ability to stabilize shorelines and mitigate coastal erosion.The root systems of these plants effectively capture sediments, thus mitigating the erosion of coastal land and preserving the integrity of coastal habitats.The protective role of mangroves ensures the safety of human settlements and the preservation of the theological integrity of significant ecosystems.Hence, the conservation and rehabilitation of mangrove forests are imperative approaches in the context of disaster preparedness and the promotion of resilience among coastal people [7].Mangroves serve as a green infrastructure solution, significantly mitigating vulnerability to disasters and promoting the overall sustainability of coastal regions.
The shallow water equation (SWE) is a foundational system of partial differential equations employed to represent fluid flow dynamics in shallow water situations [8], [9].Comprehending various natural phenomena, such as ocean tides, storm surges, river flows, and tsunamis, necessitates thoroughly understanding these equations.The SWE comprises two fundamental elements: the continuity equation, which governs mass preservation, and the momentum equation, which elucidates the preservation of momentum in the horizontal axis.These equations are employed by researchers and engineers in numerical simulations to acquire a deeper understanding of the dynamic characteristics of shallow water systems and to make predictions about real-world phenomena such as flood forecasting or coastal erosion [10].
A commonly utilized approach in numerical simulations of the SWE involves the implementation of a staggered grid numerical technique [10]- [14].The methodology entails discretizing several variables, such as water height and velocity components, at discrete spatial grid points or staggered places.The utilization of the staggered grid system offers notable advantages due to its ability to uphold essential conservation principles, including the conservation of mass and momentum [14].Numerical methods such as finite difference or finite volume schemes can effectively capture the intricate interactions present in shallow water systems by deliberately arranging variables in a staggered manner [11].This approach serves to mitigate the occurrence of undesirable numerical artifacts and enhances the overall stability and reliability of simulations.The utilization of the staggered grid numerical scheme has been prevalent and proven to be an efficient method for solving SWE in a multitude of applications, ranging from hydraulic engineering to coastal modeling [12], [15], [16].
The significance of parallel computing in numerical simulation lies in its capacity to significantly enhance the efficiency and speed of intricate calculations [17].In numerical simulations, complex mathematical models frequently necessitate a substantial volume of computations, rendering reliance on conventional sequential processing time-consuming or even unfeasible.Parallel computing involves the distribution of calculations across numerous processors or cores, hence facilitating the simultaneous execution of simulations [18], [19].This approach not only accelerates the simulation procedure but also facilitates the investigation of broader ranges of parameters, hence improving the precision and authenticity of the outcomes.In addition, parallel computing enables the effective usage of high-performance computing resources, such as supercomputers and GPU clusters, which play a crucial role in addressing extensive simulations that challenge the limits of computational capabilities [20].
Moreover, parallel computing is imperative to tackling real-world challenges requiring prompt analysis and well-informed decision-making.Numerical simulations are crucial in various domains, including climate modeling, drug development, and aeronautical engineering [21].These fields heavily depend on simulations to evaluate potential hazards, optimize design, and forecast future outcomes.Parallel computing is a computational approach that effectively decreases the time required to gain valuable insights [22].This capability empowers researchers and engineers to promptly adapt to dynamic circumstances or make informed judgments based on data in urgent scenarios.Parallel computing is a crucial component of contemporary numerical simulations, serving as a pivotal factor that empowers researchers to address increasingly intricate challenges and expedite scientific exploration and technological progress in many fields of study [23]- [25].
The main objective of this study is to perform simulations to examine the impact of mangrove forests on reducing water wave amplitudes.The SWE will be utilized as the modeling framework for this investigation.By using SWE, this study seeks to understand how mangrove ecosystems impact the transmission and dissipation of water waves in coastal regions.This investigation aims to provide insights into the crucial role played by mangroves in bolstering coastal resilience and safeguarding against potential threats.To effectively tackle the inherent computational complexity associated with these simulations, the project will integrate parallel computing approaches, notably leveraging OpenMP, to enhance computational efficiency and minimize computational expenditure [26]- [32].Integrating numerical modeling and parallel computing promises valuable insights into the dynamic interactions between mangrove trees and ocean waves, with potential implications for coastal management and disaster risk reduction strategies.
The structure of this paper is given as follows: in Section 2, SWE and staggered grid algorithms are explained.Section 3 elaborates on the results of this research from several OpenMP experiments.Moreover, this paper is concluded in Section 4.

Research Methods
To investigate the impact of mangroves on coastal wave dynamics, we employ a robust research methodology centered on the Shallow Water Equation (SWE) model coupled with a staggered grid numerical scheme.This approach allows us to comprehensively analyze the wave attenuation effects of mangrove ecosystems in coastal regions.This comprehensive approach will enable us to understand better the protective function of mangroves and their potential implications for coastal management and disaster risk reduction strategies.The shallow water equation (SWE) is a system of equations to describe water movement, which consists of mass and momentum equations [10] and [11].The mass equation is used to describe the changing of water depth over time and is written as (1), where ℎ() is the water depth and (, ) is the average water velocity.The momentum equation is used to describe the changing of water flux over time and is written as (2), Where (, ) = ℎ(, ) − () is the water surface elevation, () is the sea bottom or topography function,  is the gravitational force of constant, and  is the friction term.In the case of the presence of a mangrove area, Manning's friction is used to describe the effect of mangroves.Formula (3) gives the Manning's friction, where  is called Manning's coefficient.The illustration of SWE can be seen in Figure 1.There are several methods to solve (1) and ( 2), as shown in [10] and [11].This research uses a staggered scheme to approximate (1) and ( 2) because of the simplicity.The staggered scheme uses uncollocated grids for discretized (1) and ( 2).The water depth and elevation are discretized in the full grids; meanwhile, the velocity is in the half grids [11]  Based on the staggered grids in Figure 2, the discretization of ( 1) is given as ( 4), where where, Moreover, the discretization of ( 2) is given as follows: A detailed explanation of ( 4)-( 6) can be found in [10].If mangroves are present in the numerical simulation, then the friction term   can be activated in the mangrove forest area.Meanwhile, the friction term is zero when the area is no mangrove (  = 0).Finally, the steps for computing staggered grids can be drawn in the following Algorithm As explained in Section 1, Introduction, the staggered scheme can be applied in parallel computing framework.As shown in Algorithm 1, the computation in mass and momentum equations are independent.Therefore, parallel computing can be applied when the number of grids is increased significantly to reduce computational cost.In this research, OpenMP parallel computing is used for its benefit of interoperability.OpenMP is a portable standard program using shared memory architecture [17], [26], [31].The application program interface of OpenMP provides a package of library routines, environmental variables, and compiler directives.The compiler directives are widely extended to several programming languages such as Fortran, C, C++, cPython, etc. OpenMP uses a single program multiple data (SPMD) mode in parallel execution.Moreover, it also supports shared and private data in data management.
In this research, Algorithm 1 is implemented using C programming language and includes an OpenMP package to perform much faster calculations.OpenMP is a widely used parallel programming framework designed to simplify the creation of multithreaded applications.OpenMP offers a powerful means to accelerate numerical simulations when applied to parallelize the iteration of the staggered grid approach for solving the Shallow Water Equation (SWE).Generally, an OpenMP directive in C is written in parallel region as following code [17]: Clauses are the parameters that influence the behavior of directives.For instance, a clause can be a set of shared or private variables.The code block in the parallel region will be executed by several unique threads, starting from zero to the maximum number of processors in the computer.The important directive in OpenMP is a parallel loop, which consists of high computational tasks and repetition.The parallel loop is written as the following code: #pragma omp for [clauses] for(int i= initial; i<= conditions; increment) { //loop iterate } Figure 3 shows the parallelism mechanism that works for Algorithm 1.The parallel mechanism using OpenMP for the given algorithm involves breaking it into parallelizable sections.It specifies the number of threads to use and then enters a time-stepping loop.In this loop, threads work in parallel to compute mass conservation, including   +1 and ℎ  +1 using equations ( 4) and ( 5).Afterward, a function sets ba bboundary mass condition The next step parallelizes the computation of momentum conservation, where threads calculate  +1/2 +1 using equation ( 6) and synchronize their computations.Another function defines boundary momentum conditions.Finally, threads update the variables ℎ and  in parallel and synchronize again.This strategy leverages multi-core processors, optimizing computation and ensuring data consistency and thread safety throughout the process.As shown in Algorithm 1, a staggered grid scheme has multiple repletion of loops in a time loop.Thus, parallel computing can be applied to all loops inside the time loop.Based on the OpenMP directive in C, Algorithm 1 can be modified into the following Algorithm 2. In Algorithm 2, the modification is applied by adding #pragma code above the loop commands.This pragma syntax indicates the parallel computing activated when the loop process is executed.The position of #pragma above the loop for computing mass and momentum equations is essential because the operation inside the loop has a high computational cost.

Result and Discussion
This section shows the results of two experiments to answer research questions.The first experiment describes the simulation of wave attenuation because of mangrove effects.The second experiment elaborates on the performance of OpenMP in solving computational time.
Here, the speedup and efficiency of computer threads are shown as the performance in parallel computing.

Simulation of wave attenuation
In this section, the numerical simulation of wave attenuation is presented.Here, the simulation area with mangroves is described in Figure 4.  Here, several Manning's coefficients (0, 0.1, 0.2, 0.3) are used to see the ability of mangrove forests to attenuate waves.In real-life situations, the Manning's coefficient is determined by using the Morison equation based on field observation of mangroves [21].The denser the mangrove forest as a wave absorber, the greater the coefficient value used in the simulation, and vice versa.The results of this numerical simulation with a final time of 30 seconds can be seen in Figure 5. Figure 5 (a) shows the initial water which is generated by using Eq. ( 7).As seen in Figure 5 (b), the waves, after 30 seconds shown, move to the mangrove area because of the momentum and gravitation.When Manning's coefficient  = 0.1, water in the mangrove area damped into 10%.Meanwhile, water elevation in mangrove areas decreases by around 20% using Manning's coefficient  = 0.2.Moreover, when Manning's coefficient is  = 0.3, water elevation attenuated up to 33%.In actual conditions, the more significant number of Manning's coefficient kappa means mangrove trees are very dense in the forest.Overall, this numerical simulation successfully shows the effect of mangrove areas able to withstand waves, which depend on the density of the mangrove trees.
To validate the performance of the simulation, here is a comparison with an analytical solution for the linearized problem, and kappa equals 0 s is conducted.Follows [33], an explanation of the problem can be written as, In this section, the results of parallel computing using OpenMP are presented.The experiment uses the computer specifications, as shown in Table 1.OpenMP's speedup and efficiency performances in this simulation are presented, as shown in Figure 8.In Figure 8 (a), the speedup is shown to increase along with the increasing number of threads.Using eight threads makes the speedup 7.26 times faster than using one thread.This means the computational time using eight threads is faster than using a single thread.In the experiment using 32 threads, the speedup slightly slowed due to external factors such as communications data or hardware problems.However, the speedup will remain under 15 times even if the number of threads increases.This is because the efficiency is low, as shown in Figure 8  Figure 8 (b) shows the computational efficiency based on the number of threads.Overall, the efficiency is decreasing along with the increasing number of threads.When the simulation uses eight threads, the efficiency drops to 90.72%.This means that the use of resources (number of threads) is larger than the complexity of computational tasks.Additionally, decreasing efficiency can be observed using more threads, as shown in Figure 8 (b).

Conclusion
The mangrove forest effect in shallow water equation (SWE) can be used to simulate the attenuating water waves.This research describes the friction effect from mangrove forests as Manning's friction in the momentum equation of SWE.Based on the experiments, the water amplitude can be flatted into 10% using Manning's coefficient of 0.1.The increasing number of Manning's coefficients affects a significant attenuation of waves.From the experiment, the presence of mangrove forests effectively reduces the amplitude of waves.The performance evaluation of OpenMP in this simulation reveals that as the number of threads increases, the speedup improves up to a point, with a notable 7.26-fold acceleration observed when utilizing eight threads compared to a single thread.Overall, computational efficiency decreases as more threads are added, with a drop to 90.72% efficiency followed by eight threads, indicating that allocating resources (i.e., the number of threads) surpasses the complexity of computational tasks.This decline in efficiency persists with higher thread counts, emphasizing the trade-off between speedup and efficiency in OpenMP-based simulations.

Figure 1 .
Figure 1.The illustration of variables in the one-dimensional SWE model.

Figure 2 .
Figure 2. The one-dimensional staggered grids for the SWE model.

Figure 3 .
Figure 3. Parallelization process of a computational algorithm using OpenMP.

Figure 4 .
Figure 4.The scenario of simulation with the mangrove area.As shown in Figure 4, the length of the simulation domain is 200 meters, with the area covered by mangroves is 100 meters.The water depth is 4 meters, with the flat bottom d of x , which () = 0.In this simulation, the Dirichlet boundary condition is used for the velocity function on the left and right domain, where (0, ) = 0 and (200, ) = 0.This boundary condition is known as a wall boundary condition.The initial configurations of water surface and velocity are defined as follows:

Figure 5 .
Figure 5. (a) The initial water level condition with mangrove area on [100,200].(b) the results of wave attenuation by mangrove using several values of manning's coefficients  at final time 30 seconds.

Figure 8 .
Figure 8.(a) The speedup of computational time.(b) The efficiency of computer performance.
Notation: the time.: the spatial position in x-direction.(,): the function of water elevation.ℎ(, ) : the function of water depth.(, ) : the function of average velocity.()

Table 1 .
Computer Specifications for Parallel Computing.