## 2 Materials and Methods
### Implementation Using PINNs
#### 2.2.3 PINN Architecture with Hard Enforcement of Boundary Conditions  
To construct a one-dimensional adaptive computational grid, a PINN architecture is implemented in which the diffusion equation is directly embedded into the loss function. A key feature of the model is the hard enforcement of Dirichlet boundary conditions--without introducing additional penalty terms in the loss. The boundary conditions are enforced by embedding a special smooth mask \(\phi(x)\) into the architecture, which vanishes at the boundaries \(x=0\) and \(x=1\) and remains positive inside the interval. The model output is defined as follows:  
\[s(x)=x+\phi(x)\cdot\delta(x), \tag{6}\]  
where \(\delta(x)\) is the neural network output responsible for the internal adaptation of the grid, and \(\phi(x)\) suppresses this output at the domain boundaries. The mask \(\phi(x)\) is defined as the product of two approximate distance functions to the ends of the interval:  
\[\phi(x)=\phi_{1}(x)\cdot\phi_{2}(x), \tag{7}\]  
where each function \(\phi_{1}(x),\phi_{2}(x)\) is constructed as follows:  
\[\phi_{i}(x)=\sqrt{d^{2}+\left(\frac{\sqrt{t^{2}+d^{4}}-t}{2}\right)^{2}},i=1,2, \tag{8}\]  
with \(d(x)=\frac{x-x}{L}\) being the normalized distance to the boundary, and  
\[t(x)=\frac{1}{L}\left(\left(\frac{L}{2}\right)^{2}-(x-x_{i})^{2}\right) \tag{9}\]  
defining a truncated influence region centered in the middle of the interval. This mask construction is smooth and differentiable, which is crucial for stable training with automatic differentiation in PINNs.  
This approach guarantees the strict satisfaction of boundary conditions during prediction, avoiding the need for the manual tuning of boundary weights in the loss function and ensuring the physical consistency of the results.  
A schematic of the implemented architecture is shown in Figure 2, illustrating the computational flow from input \(\xi\), through the modified output block with the mask \(\phi(\xi)\), to the evaluation of the loss based on the diffusion equation.  
Figure 2: PINN architecture with embedded mask \(\phi(\xi)\) for hard enforcement of boundary conditions in adaptive grid generation.  
Since the boundary conditions in this architecture are enforced directly at the output level, the final loss function contains only the component associated with satisfying the differential equation, that is, \(\mathcal{L_{PDE}}\) without any coefficient.  
The proposed approach of the hard enforcement of boundary conditions using a built-in mask function is especially promising for extension to two-dimensional adaptive mesh generation. In 2D settings, local refinement often leads to distortion near boundaries, causing grid lines along the domain edges to bend or deviate from their intended positions. This is particularly problematic when boundary shapes must remain fixed or aligned with the physical geometry. The architecture presented in this work, which guarantees the strict satisfaction of boundary conditions at the neural network output level, offers a robust solution to this issue. By construction, the boundary nodes remain fixed, regardless of internal adaptation, making this method well suited for accurate and geometry-preserving adaptive meshing in higher-dimensional problems.