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

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

#include "core/vector.hpp"
#include "plot/plot.hpp"
#include "spatial/grid3d.hpp"
#include "fields/grid2d.hpp"
#include "pde/scalar_field_2d.hpp"
#include <vector>
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Namespaces

namespace  num
 
namespace  num::plt
 

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 >
void num::laplacian_stencil_2d_4th (const BasicVector< T > &x, BasicVector< T > &y, int N)
 
real num::sample_2d_periodic (const Vector &field, idx N, real h, real px, real py, real ox, real oy)
 
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)
 
template<typename F >
void num::fill_grid (Vector &u, int N, double h, F &&f)
 
Series num::row_slice (const Vector &u, int N, double h, int row)
 
Series num::col_slice (const Vector &u, int N, double h, int col)
 
template<typename F >
void num::fill_grid (ScalarField2D &g, F &&f)
 
Series num::row_slice (const ScalarField2D &g, int row)
 
Series num::col_slice (const ScalarField2D &g, int col)
 
void num::laplacian_stencil_2d_periodic (const ScalarField2D &x, ScalarField2D &y)
 
void num::laplacian_stencil_2d_4th (const ScalarField2D &x, ScalarField2D &y)
 
real num::sample_2d_periodic (const ScalarField2D &g, real px, real py, real ox=0.0, real oy=0.0)
 
void num::plt::heatmap (const ScalarField2D &g, double vmin=0.0, double vmax=1.0)
 Heatmap overload for ScalarField2D – no need to pass N or h separately.
 
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 = (sum of 4 nbrs) - 4x, Dirichlet laplacian_stencil_2d_periodic – same, periodic wrap (boundary-peeled for vectorization) sample_2d_periodic – bilinear interpolation with stagger offset 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 = -Lap(x) (Dirichlet: boundary rows = identity) gradient_3d – (gx,gy,gz) = grad(phi) divergence_3d – div f = d(fx)/dx + d(fy)/dy + d(fz)/dz curl_3d – curl(A)

Definition in file stencil.hpp.