numerics
Loading...
Searching...
No Matches
stencil.hpp File Reference

Higher-order stencil and grid-sweep utilities. More...

#include "core/vector.hpp"
#include "spatial/grid3d.hpp"
#include <vector>
#include <algorithm>

Go to the source code of this file.

Namespaces

namespace  num
 

Functions

template<typename T >
void num::laplacian_stencil_2d (const BasicVector< T > &x, BasicVector< T > &y, int N)
 
template<typename T >
void num::laplacian_stencil_2d_periodic (const BasicVector< T > &x, BasicVector< T > &y, int N)
 
template<typename T , typename F >
void num::col_fiber_sweep (BasicVector< T > &data, int N, F &&f)
 
template<typename T , typename F >
void num::row_fiber_sweep (BasicVector< T > &data, int N, F &&f)
 
void num::neg_laplacian_3d (const Vector &x, Vector &y, int nx, int ny, int nz, double inv_dx2)
 
void num::gradient_3d (const Grid3D &phi, Grid3D &gx, Grid3D &gy, Grid3D &gz)
 
void num::divergence_3d (const Grid3D &fx, const Grid3D &fy, const Grid3D &fz, Grid3D &out)
 
void num::curl_3d (const Grid3D &ax, const Grid3D &ay, const Grid3D &az, Grid3D &bx, Grid3D &by, Grid3D &bz)
 

Detailed Description

Higher-order stencil and grid-sweep utilities.

2D (NxN grid, row-major storage: index = i*N + j, Dirichlet or periodic BC): laplacian_stencil_2d – y = (Σ4 nbrs) - 4x, Dirichlet laplacian_stencil_2d_periodic – same, periodic wrap (boundary-peeled for vectorization) col_fiber_sweep – for each column j: extract fiber, call f, write back row_fiber_sweep – for each row i: extract fiber, call f, write back

3D (Grid3D, central-difference, one-sided at boundaries): neg_laplacian_3d – y = -∆x (Dirichlet: boundary rows = identity) gradient_3d – (gx,gy,gz) = ∇φ divergence_3d – div f = ∂fx/∂x + ∂fy/∂y + ∂fz/∂z curl_3d – ∇×A

Definition in file stencil.hpp.