1. Introduction
In many areas of mathematical physics, solving complex physical problems often requires numerical approaches, especially when analytical solutions are unavailable or impractical. One of the foundational components of these numerical methods is the construction of computational grids, which play a key role in both the accuracy and efficiency of simulations. Fine grids offer more accurate results, particularly in regions where the solution changes rapidly, while coarser grids help reduce the computational cost in smoother regions.
Adaptive mesh generation techniques aim to strike a balance between these two needs by adjusting the grid dynamically, refining it in critical areas and coarsening it where possible. This adaptability is especially valuable in simulations involving sharp gradients or localized phenomena.
Recent advancements in machine learning, particularly physics-informed neural networks (PINNs), have opened new possibilities for solving partial differential equations while incorporating physical laws directly into the learning process. This study explores the application of PINNs to adaptive grid generation for the one-dimensional diffusion equation. By leveraging the equidistribution principle within a neural network framework, we aim to generate grids that respond automatically to the behavior of the solution, providing an efficient and accurate numerical tool for further simulations.
The study in [
1] is dedicated to the numerical modeling of two-dimensional gas flows using adaptive curvilinear grids. The method of equidistribution is applied, allowing for automatic node refinement in regions with high flow gradients, thereby improving calculation accuracy. The studies in [
2,
3] explore the theoretical foundations of grid generation, including solutions to partial differential equations and variational methods. The studies in [
4,
5] propose methods for generating two- and three-dimensional grids by solving elliptic equations and optimizing node distribution. High-performance computing studies in [
6] demonstrate the potential of parallel computations for accelerated grid generation.
Computational grids are generally classified as either structured or unstructured. Structured grids utilize algebraic, differential, and variational methods to maintain a uniform node distribution while adapting to the problem’s physical characteristics [
7]. In unstructured grids, Delaunay triangulation and Voronoi diagrams are employed to achieve efficient and uniform grid generation for complex geometries [
8,
9]. Elliptic methods and adaptive strategies also play a crucial role in optimizing node density based on computational conditions [
7]. Both approaches are actively evolving and widely used in numerical modeling. However, the adaptive modification of grid density remains a challenging task that requires careful consideration of the system’s physical properties.
One of the most powerful approaches to generating such meshes is to formulate the problem as a boundary value problem for a system of differential equations. In particular, inverse diffusion equations, Poisson equations, and especially Beltrami equations have found wide application in this regard [
10]. The use of differential equations in mesh generation differs from their classical application. In typical problems of mathematical physics, differential equations describe physical processes (such as heat conduction, diffusion, and wave propagation), whereas in mesh generation, they are used to define the transformation of coordinates from the computational domain to the physical domain. In this context, the variables in the equations are interpreted as geometric parameters of the mesh (e.g., coordinate functions), and their derivatives represent mesh distortion measures or node density. Thus, the application of differential equations in adaptive mesh generation is not merely a technical tool but rather a fundamental mathematical framework for creating unified and controllable models of computational meshes adapted to the physics of the problem and the geometry of the domain. These approaches have proven effective in computational fluid dynamics and finite element analysis, ensuring high mesh quality and alignment with the physical features of the solution [
11].
One-dimensional computational grids are widely used in various applied problems, such as hydrodynamics, continuum mechanics, and electrodynamics. This study examines the construction of a one-dimensional adaptive computational grid based on the diffusion equation. This equation regulates grid density by refining the node distribution in regions with steep solution gradients. Existing research has employed different approaches to construct adaptive computational grids using the diffusion equation. The study in [
12] presented an unstructured grid generation method using differential techniques, achieving adaptation via the inverse Beltrami equation. The authors proposed using Delaunay triangulation for final grid construction, ensuring the smoothness of the geometric characteristics of grid cells. In [
13], the application of Beltrami and diffusion equations for numerical grid generation was explored, taking into account the physical properties of the modeled medium. Later, [
14] introduced an algorithm for generating three-dimensional adaptive grids, utilizing inverse Beltrami equations to construct grids in multiscale domains. The study in [
15] examined variational and elliptic grid generation methods that optimize node distribution while considering boundary conditions. Additionally, [
16] proposed a fragmented algorithm for adaptive grids, implementing automated computational fragment management in the LuNA system, which efficiently distributes computing resources for complex simulations.
In recent years, PINNs have gained significant attention for solving differential equations, including the diffusion equation. Numerous studies have demonstrated the successful application of PINNs to problems involving heat conduction, mass transport, and other processes described by diffusion-type models [
17,
18,
19]. By embedding physical laws directly into the loss function, such models can produce stable and interpretable solutions, even when data are limited or noisy. The studies in [
20,
21,
22,
23] explore various extensions of PINNs, including hybrid models, variational approaches (VPINN), and Bayesian methods (B-PINN), which improve solution accuracy and stability. In these methods, the network is trained with physical constraints, reducing dependence on large training datasets. The study in [
24] investigates the application of PINNs to solve equidistribution equations for constructing two-dimensional adaptive computational grids. PINNs allows for approximate equation solutions without explicit discretization by integrating physical laws into the loss function. Recent research has utilized neural networks for automated grid generation and adaptation. The study in [
25] applies graph neural networks (GNNs) to predict and optimize grids in hydrodynamics and mechanics. In [
26], a method for generating finite element meshes based on self-organizing Kohonen maps is proposed. The study in [
27] explores the use of GNNs for adaptive grid generation in numerical methods. These studies confirm the potential of machine learning in optimizing grid construction, reducing computational costs, and enhancing simulation accuracy.
However, the use of PINNs specifically for adaptive mesh generation through node distribution control based on the diffusion equation has received little attention in the literature. Existing works on PINNs typically focus on the accuracy of the solution but do not examine the structure of the computational mesh implicitly formed during training. At the same time, the distribution of training points—the implicit “mesh” shaped by loss minimization—has a significant impact on the final model quality. While there are studies that apply PINNs to problems involving geometry and spatial adaptation [
25,
27,
28,
29], a comprehensive approach that directly employs the diffusion equation as a mechanism for mesh adaptation within the PINN framework is currently lacking.
Additionally, the method of solving the diffusion equation and the inverted Beltrami equation provides a continuous mapping from the sample domain to the physical domain, which can be leveraged to enhance the accuracy of PINNs. The key motivation of this research is to integrate, in future, the curvilinear mapping obtained from these equations into the PINN framework itself rather than using it solely for classical numerical grids. By doing so, the PINN method can better adapt to regions with steep gradients, where its accuracy is often compromised due to an insufficient resolution or inadequate sampling. This hybrid approach combines the flexibility of neural networks with the rigorous control of mesh adaptation, offering a promising solution to improve PINN performance in challenging scenarios. The results of this work may pave the way for more robust and accurate physics-informed machine learning models in computational physics and engineering simulations.
An additional objective addressed in this work is the hard enforcement of boundary conditions during adaptive grid generation. In most existing approaches, boundary conditions are implemented through penalty terms in the loss function, which requires the manual tuning of weighting coefficients and may not guarantee strict enforcement at the boundaries. In the proposed approach, boundary values are explicitly fixed through the network architecture by embedding a smooth mask that suppresses the neural network output at the edges of the interval [
30]. This allows for physically consistent results without introducing extra parameters into the loss function.
The proposed method differs from previously published work by combining adaptive grid generation based on the diffusion equation with hard boundary condition enforcement directly within the PINN architecture.
3. Results
This section presents numerical experiments conducted to solve the one-dimensional diffusion equation given in the form (1). The control function plays a key role in forming the adaptive grid, allowing for node clustering in selected regions of the computational domain. In the numerical tests, the following form of the control function is used:
where
are the coordinates of the points near which an increased node density is required,
is the coefficient controlling the intensity of local refinement, and
is a smoothing parameter that prevents singularities and abrupt changes in density. During testing, the positions of
, as well as the values of
and
, are varied to examine how different characteristics of the control function influence grid generation using both the numerical method and the PINN approach.
To evaluate the characteristics of one-dimensional computational grid generation using both the numerical method and the PINN method, tests are conducted with various control function parameters. During the experiments, the parameters (which determines the intensity of node clustering) and (which controls the degree of smoothing of the control function) are varied. A fixed control point at x = 0.5 is used, and the grid coordinates are distributed within the interval .
The tests utilize the following parameter combinations: and . This allows for an evaluation of the impact of each parameter on grid adaptation and differences in node distribution.
The test results are presented as graphs analyzing the node distributions for both methods, spacing between points, coordinate differences between nodes, cumulative curves, and convergence rate of the loss function. Below is a detailed analysis of each of these aspects.
Figure 3 illustrates the impact of parameter
on the node distribution in both the numerical method and the PINN method.
As increases, local node clustering intensifies, which is more pronounced in the numerical method, where the node density near the control points increases significantly. In the PINN method, increasing also affects grid adaptation; however, clustering occurs more smoothly, without abrupt jumps in the distribution. Parameter determines the degree of smoothing of the control function, and its increase leads to a more uniform node distribution in both methods. In the numerical method, this results in reduced sharp step variations, while in the PINNs, smoothing causes less pronounced node density adaptation around the control point, making the distribution more uniform.
Figure 4 presents graphs of the step size between neighboring nodes, illustrating the differences in grid adaptation between the numerical method and PINNs.
In the numerical method, more pronounced step size minima are observed near the control points, corresponding to the given function
. In the PINN method, step size variations occur more smoothly, without abrupt minima, which may be related to the optimization characteristics of the model. The shapes of the graphs in both methods maintain the general trend of step size reduction in the regions of node clustering and increase near the boundaries of the computational domain. However, in the numerical method, the step changes are more abrupt, whereas in the PINNs, the transitions are smoother.
Figure 5 shows a graph of the absolute difference between the node coordinates in the two methods.
It can be seen that the largest discrepancies occur near the region of node clustering. For small values of , the difference between the methods remains insignificant. However, as increases, the numerical method exhibits a sharper change in grid density, leading to greater coordinate deviations. Parameter also affects the nature of the differences between the methods: as increases, the discrepancies decrease since both methods exhibit less pronounced grid clustering. The maximum deviation, depending on the parameters of the control function, ranges from 0.01 to 0.1, and most tests show a difference within 0.03–0.05.
Figure 6 presents a cumulative node curve, which illustrates the overall trend of the node distribution across the computational domain and shows how uniformly the node coordinate changes with respect to its index.
In the numerical method, small segments with changes in the curve’s slope are observed near the control points, corresponding to local grid refinement. In the PINN method, the cumulative curve changes more uniformly, without sharp bends, indicating a smoother variation in the node density. The overall shape of the curves in both methods remains similar; however, the numerical method exhibits more pronounced slope changes, while in the PINNs, the transitions are less abrupt.
Figure 7 presents loss function graphs, illustrating the convergence dynamics of the PINN method depending on the control function parameters.
In all tests, the loss function decreases to 0.001; however, the convergence rate varies. Increasing and decreasing require more iterations to reach the specified error threshold, which may be due to the model’s more complex adaptation to sharp changes in the control function. In tests with and , the error threshold is reached more quickly, whereas for and , significantly more epochs are required for convergence. The results indicate that smoothing the control function positively affects the convergence speed of the PINN method, while increasing the intensity of grid clustering leads to longer training times.
To analyze the adaptation of the computational grid to multiple control points, tests are conducted with parameters and . In this case, node clustering is considered near two control points, and , within the interval . This allows for an evaluation of how effectively the numerical method and the PINN method reproduce the specified grid density distribution when multiple regions with high node concentrations are present. As part of the testing, graphs are generated for the node distribution, step sizes between neighboring points, coordinate differences between the methods, cumulative curves, and convergence rate of the loss function in the PINN method.
Below is a detailed analysis of the obtained results, including a comparison of both methods based on key indicators such as the degree of grid clustering, uniformity of the node distribution, deviations between the numerical method and PINNs, and specific features of neural network model convergence.
Figure 8 shows the node distribution in the numerical method and the PINN method for control points
and
.
In both methods, an increase in the node density is observed near the control points. In the numerical method, node clustering occurs more abruptly, whereas the PINN method exhibits a smoother grid density distribution without sharp jumps. Despite differences in approach, both methods successfully adapt the grid to the given parameters. However, the numerical method produces more pronounced gradients in the node distribution, while the PINN method shows some smoothing in high-density regions.
Figure 9 presents the key grid characteristics, including the step size variation between neighboring nodes, coordinate differences between the methods, cumulative node curves, and loss function.
Both approaches demonstrate the expected node clustering near the control points; however, the numerical method results in more abrupt density variations, whereas the PINN method produces a smoother distribution. The coordinate differences between the nodes indicate that the maximum discrepancy is 0.05, which can be attributed to the smoothing effect of neural network optimization. The cumulative curves of both methods confirm the overall grid adaptation trend, though the numerical method exhibits more pronounced slope changes. The loss function graph shows that the PINN method requires more iterations to achieve an accurate result but ultimately reaches high precision, minimizing the error to 0.000026. These results highlight the characteristics of each method and provide insights into their applicability for adaptive computational grid generation.
Hard Enforcement of Boundary Conditions: Comparison of Approaches
To evaluate the effectiveness of the hard enforcement of boundary conditions using the mask
, a series of numerical experiments are conducted comparing two approaches: implementing boundary conditions through an additional penalty term in the loss function and enforcing them explicitly by modifying the neural network output.
Figure 10a shows the node distribution obtained using the mask
, while
Figure 10b presents the distribution resulting from the loss-based boundary implementation.
Visually, the overall structure of the mesh in both cases is similar, with the node density adapted in the central region of the domain according to the control function. However, the exact boundary values reveal a key difference between the methods. When using the mask, the coordinates at the interval boundaries match the target values precisely: , . In contrast, when boundary conditions are enforced via the loss function, noticeable deviations are observed: , .
These results demonstrate that the use of the mask enables the strict enforcement of Dirichlet boundary conditions with machine precision, without the need to manually tune the penalty weights in the loss function. This is particularly important in problems requiring the exact placement of boundary nodes, such as in simulations with a prescribed geometry or fixed boundary values.
In the future, additional metrics will be used for a more detailed analysis of the differences between the numerical method and the PINN method. Specifically, quantitative grid deviation measures will be considered, such as the root mean square error between node coordinates, a smoothness measure of the node distribution, and PINN convergence indicators depending on various loss function parameters. This will allow for a more objective assessment of the accuracy and efficiency of each approach and help identify potential improvements in adaptive computational grid generation.
This section presents an analysis of the results for constructing a one-dimensional computational grid using both the numerical solution method and the PINN method. Cases with different numbers of control points defining node clustering zones are examined. An analysis of the node distribution, step size between neighboring points, coordinate differences, cumulative curves, and loss function shows that the PINN method produces smoother grids than the numerical method. As the number of control points increases, the differences between the methods become more pronounced. It is also observed that the convergence rate of the PINN method varies depending on the complexity of the problem, but the model successfully adapts to parameter changes. The obtained results provide insights into the applicability of PINNs for adaptive computational grid generation in numerical modeling tasks.
However, it should be noted that the numerical results used for comparison are not an absolute benchmark. The numerical method also contains approximation and discretization errors, which can influence the final node distribution. Therefore, a simple comparison with the numerical method cannot definitively determine the accuracy of the PINN approach but rather provides insight into the differences between the grid generation methods.
4. Conclusions
This study explored the problem of constructing one-dimensional computational grids using two approaches: the traditional numerical method and PINNs. The primary goal was to compare the accuracy, adaptability, and efficiency of these methods in solving the diffusion equation, which is used for adaptive grid generation. Testing was conducted with various control function parameters, allowing for a detailed analysis of the influence of and on the node distribution and the quality of the resulting computational grids.
The results of the numerical method demonstrated high accuracy in defining the grid structure, especially for small values of the parameter , which promoted more pronounced node clustering in regions requiring a detailed analysis. However, this method necessitated an explicit discrete solution of the equation, leading to increased computational costs, particularly as problem complexity grew. Additionally, the grid generated by the numerical method exhibited significant variations in the step size between nodes, which may require additional smoothing.
Conversely, the PINN method demonstrated a smoother node distribution, minimizing abrupt changes in the step size between neighboring points. The use of automatic differentiation in PyTorch enabled the seamless integration of the diffusion equation into the loss function, allowing the neural network model to learn while respecting physical constraints. Testing revealed that the PINN model was capable of adapting to different control function parameters; however, in some cases, deviations from the numerical solution were observed, particularly in regions with sharp gradients.
The convergence speed of the PINN model depends on optimization parameters and problem complexity. In some tests, a significantly higher number of iterations was required to achieve the desired accuracy, highlighting the need for the careful selection of optimal network hyperparameters. Additionally, an analysis of loss function graphs indicated that, as the number of control points increased, the training process became more complex, and the improvement in approximation accuracy was not uniform.
Additionally, this work investigated the implementation of hard boundary condition enforcement within the PINN framework using an embedded smooth mask function . Unlike traditional penalty-based approaches, this method ensures exact boundary values through architectural constraints, eliminating the need for loss weight tuning. Numerical tests confirmed that the use of this masking technique resulted in machine-precision boundary satisfaction, while the conventional loss-based approach led to notable deviations at the interval ends. This architectural enhancement improves physical consistency and can be especially beneficial for problems requiring strict boundary alignment.
Thus, the results of this study demonstrate that the PINN method can be used for adaptive computational grid generation, providing a smooth node distribution and flexible grid density adjustment. However, achieving high accuracy requires the careful selection of model parameters and the loss function. The numerical method remains a reliable tool for precise adaptive grid construction, especially in problems with sharp density variations. In the future, a hybrid approach combining the accuracy of the numerical method with the adaptability and generalization capabilities of neural network models could be developed.