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 "fields/grid2d.hpp"
#include "pde/scalar_field_2d.hpp"
#include "plot/plot.hpp"
#include "spatial/grid3d.hpp"
#include <algorithm>
#include <cmath>
#include <vector>

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)
 Periodic second-order 2D Laplacian stencil.
 
template<typename T >
void num::laplacian_stencil_2d_4th (const BasicVector< T > &x, BasicVector< T > &y, int N)
 Fourth-order 2D Laplacian cross stencil.
 
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)
 Apply a mutable 1D operation to each column fiber.
 
template<typename T , typename F >
void num::row_fiber_sweep (BasicVector< T > &data, int N, F &&f)
 Apply a mutable 1D operation to each row fiber.
 
template<typename F >
void num::fill_grid (Vector &u, int N, double h, F &&f)
 Fill grid values at \(x_i=(i+1)h,\ y_j=(j+1)h\).
 
Series num::row_slice (const Vector &u, int N, double h, int row)
 Extract one row as \((x_j,u_j)\) plot data.
 
Series num::col_slice (const Vector &u, int N, double h, int col)
 Extract one column as \((y_i,u_i)\) plot data.
 
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)
 
void num::neg_laplacian_3d (const Vector &x, Vector &y, int nx, int ny, int nz, double inv_dx2)
 Compute \(-\Delta_h x\) on a 3D grid.
 
void num::gradient_3d (const Grid3D &phi, Grid3D &gx, Grid3D &gy, Grid3D &gz)
 Compute \(\nabla\phi\) with central differences.
 
void num::divergence_3d (const Grid3D &fx, const Grid3D &fy, const Grid3D &fz, Grid3D &out)
 Compute \(\nabla\cdot f\) with central differences.
 
void num::curl_3d (const Grid3D &ax, const Grid3D &ay, const Grid3D &az, Grid3D &bx, Grid3D &by, Grid3D &bz)
 Compute \(\nabla\times A\) with central differences.
 

Detailed Description

Higher-order stencil and grid-sweep utilities.

The second-order 2D stencil stores \(h^2\Delta_h u\):

\[ y_{ij}=u_{i+1,j}+u_{i-1,j}+u_{i,j+1}+u_{i,j-1}-4u_{ij}. \]

Definition in file stencil.hpp.