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

2-D incompressible Navier-Stokes, periodic MAC grid More...

#include "core/vector.hpp"
#include "linalg/solvers/cg.hpp"
#include <functional>
#include <chrono>
#include <cmath>

Go to the source code of this file.

Classes

struct  ns::Stats
 
class  ns::NSSolver
 

Namespaces

namespace  ns
 

Detailed Description

2-D incompressible Navier-Stokes, periodic MAC grid

Algorithm: Chorin projection method

  1. Semi-Lagrangian advection -> u*, v*
  2. Build RHS: rhs = -div(u*)/dt
  3. CG pressure solve: (-Delta)p = rhs (positive-definite, Backend::omp inner products)
  4. Project: u = u* - dt*gradp

Grid (NxN cells, domain [0,1]^2): u[i,j] – x-velocity at face (i*h, (j+1/2)*h) i,j in [0,N) v[i,j] – y-velocity at face ((i+1/2)*h, j*h) i,j in [0,N) p[i,j] – pressure at centre ((i+1/2)*h, (j+1/2)*h)

Storage: row-major, index = i*N + j. All boundaries are periodic.

Definition in file ns_solver.hpp.