pyxfem.fluidmechanics.euler2d_finite_volume module
Created on Thu Mar 7 11:17:17 2024 @author: nchevaug 2D Explicit Lagrangian Finite Volume Solver (GLACE Scheme).
Philosophy & Architecture: This module implements the Godunov-type Lagrangian Scheme for Compressible Euler equations (GLACE). It computes the evolution of a fluid on an unstructured 2D triangular mesh moving with the fluid velocity (Lagrangian framework).
The solver features a dual-execution architecture: 1. Pure NumPy (Fallback): Fully vectorized array operations. 2. Numba JIT (HPC Mode): Aggressively optimized loop-level parallelism
(prange), avoiding heap allocations and leveraging hardware registers for the nodal Riemann solver.
- class pyxfem.fluidmechanics.euler2d_finite_volume.ConservationLawManager_Euler(gazlaw, nbdata)[source]
Bases:
ConservativeLawManager
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_bc_set_external_pressure(vids: NDArray[int64], ps: NDArray[float64], mesh: GELEES_MeshStruct, out_vA: NDArray[float64], out_vb: NDArray[float64]) None[source]
Applies external pressure directly to the RHS vectors $b_{jr}$ of boundary nodes.
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_bc_set_sliding_wall(vids: NDArray[int64], NxN: NDArray[float64], ImNxN: NDArray[float64], vA: NDArray[float64], vb: NDArray[float64]) None[source]
Applies a sliding wall (slip) boundary condition to the global nodal linear system.
This function modifies the assembled $A_r$ matrices and $b_r$ vectors in-place for the nodes located on a sliding wall. It ensures that the velocity vector resulting from the linear system solver will have zero component normal to the wall ($u cdot n = 0$).
The algebraic modification projects the system onto the tangent plane: $A_{new} = (I - n otimes n) A_r (I - n otimes n) + mathrm{Tr}(A_r)(n otimes n)$ $b_{new} = (I - n otimes n) b_r$
Adding the trace back to the normal component ensures the modified matrix remains strictly invertible and well-conditioned.
- Parameters:
vids (npt.NDArray[np.uint64]) – 1D array of length (n_boundary_nodes). The global indices of the vertices located on the sliding wall.
NxN (FloatArray) – 3D array of shape (n_boundary_nodes, 2, 2). The dyadic tensor product of the normal vectors ($n otimes n$) at each boundary node.
ImNxN (FloatArray) – 3D array of shape (n_boundary_nodes, 2, 2). The tangent projection matrix ($I - n otimes n$) at each boundary node.
vA (FloatArray) – 3D array of shape (nverts, 2, 2). The global assembled $A_r$ matrices for all nodes in the mesh. Modified in-place.
vb (FloatArray) – 2D array of shape (nverts, 2). The global assembled $b_r$ vectors for all nodes in the mesh. Modified in-place.
- Returns:
The global vA and vb arrays are modified in-place to reflect the boundary constraints.
- Return type:
None
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_bulk_vertices_loop_numba(vids, mesh, W, dt, xy, vu)[source]
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_cell_loop(dt, msh, vu, U, W, pfunc, cfunc, fluidlaw_data)[source]
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_getAbj(rhoj: float64, uj: Tuple[float64, float64], pj: float64, cj: float64, Cjr: Tuple[float64, float64]) Tuple[Tuple[float64, float64, float64], Tuple[float64, float64]][source]
compute Ajr and bjr which ar part of the node k of cellj linear systeme to solve at node jr
- pyxfem.fluidmechanics.euler2d_finite_volume.GELEES_specialized_vertices_loop(vids, mesh, W, dt, box_f_v, box_f_vc, data_v, data_vc, out_xy, out_vu)[source]
- class pyxfem.fluidmechanics.euler2d_finite_volume.GlaceExplicitLagrangian_EulerEquationSolver(xy: NDArray[float64], tris: NDArray[int64], boundary_conditions: Dict[str, Any], use_numba: bool = True)[source]
Bases:
GlaceExplicitLagrangianBaseSolverA 2D Explicit Lagrangian Finite Volume Solver for the Euler Equations using the GLACE (Godunov-type Lagrangian Scheme for Compressible Euler) scheme.
This class manages the mesh topology, physical state variables, boundary conditions, and time integration (both in pure NumPy and Numba JIT modes).
- critical_timestep() float[source]
Computes the maximum allowable critical time step for the entire mesh based on the CFL condition (acoustic wave speeds).
- Returns:
dtmax – The critical time step (dt).
- Return type:
float
- set_initial_state(density: Callable[[NDArray[float64]], NDArray[float64]], velocity: Callable[[NDArray[float64]], NDArray[float64]], pressure: Callable[[NDArray[float64]], NDArray[float64]]) None[source]
Sets the initial macroscopic state of the fluid for all cells.
- densityCallable[[FloatArray], FloatArray]
A function taking cell center coordinates (N, 2) and returning an array of initial cu, cp = self.conservation_law.get_primal_variable([“u”, “p”]) cp_ = np.expand_dims(cp, axis = (1,2)) # b_jr = p * Cjr + A_jr * u self.cvb[:] = cvC*cp_ + self.cvA[…,0]*cu[:, np.newaxis, np.newaxis, 0] + self.cvA[…,1]*cu[:, np.newaxis, np.newaxis, 1]
- densities (N,).
- velocityCallable[[FloatArray], FloatArray]
A function taking cell center coordinates (N, 2) and returning an array of initial velocity vectors (N, 2).
- pressureCallable[[FloatArray], FloatArray]
A function taking cell center coordinates (N, 2) and returning an array of initial pressures (N,).
- step(dt: float) float[source]
Advances the simulation by one time step dt.
Notes
This method is dynamically routed at runtime. Depending on the use_numba flag provided during the solver’s initialization, calling step() will execute either: - step_numba() : The heavily optimized JIT-compiled solver. - step_np() : The pure vectorized NumPy solver.
- Parameters:
dt (float) – The duration of the time step.
- Returns:
dtnew – The new computed critical time step for the next iteration.
- Return type:
float
- step_np(dt: float) float[source]
Advances the simulation by one time step dt using the pure NumPy solver.
- Parameters:
dt (float) – The duration of the time step.
- Returns:
dtcnew – The new computed critical time step for the next iteration.
- Return type:
float
- pyxfem.fluidmechanics.euler2d_finite_volume.apply_bc_v(ptr_box, Ar, br, data)[source]
Cache la misère du [0] pour les noeuds
- pyxfem.fluidmechanics.euler2d_finite_volume.apply_bc_vc(ptr_box, Aj, bj, Cjr, data)[source]
Cache la misère du [0] pour les coins
- pyxfem.fluidmechanics.euler2d_finite_volume.as_numba_pointer(func, signature)[source]
Encapsule une fonction Python dans une liste typée Numba. C’est un hack nécessaire pour forcer Numba à utiliser un pointeur générique (First-Class Function) et éviter de casser le cache JIT.