numerics
Loading...
Searching...
No Matches
ns::NSSolver Class Reference

#include <ns_solver.hpp>

Public Member Functions

 NSSolver (idx N_, real dt_, real nu_=0.0)
 
void init_shear_layer (real rho=0.05, real delta=0.05)
 
void step ()
 Advance one time step (advect -> pressure -> project).
 
real vorticity (idx i, idx j) const
 Vorticity omega = d_v/d_x - d_u/d_y at grid corner (i*h, j*h).
 
real speed (idx i, idx j) const
 Velocity magnitude averaged to cell centre (i,j).
 
real interp_u (real px, real py) const
 Interpolate x-velocity at physical point (px, py).
 
real interp_v (real px, real py) const
 Interpolate y-velocity at physical point (px, py).
 

Public Attributes

const idx N
 
const real h
 
const real dt
 
const real nu
 
num::Vector u
 
num::Vector v
 
num::Vector p
 velocity faces + cell-centre pressure, N*N each
 
Stats stats
 

Detailed Description

Definition at line 40 of file ns_solver.hpp.

Constructor & Destructor Documentation

◆ NSSolver()

ns::NSSolver::NSSolver ( idx  N_,
real  dt_,
real  nu_ = 0.0 
)
Parameters
N_Grid resolution (NxN cells)
dt_Time step
nu_Kinematic viscosity (0 = inviscid Euler)

Definition at line 15 of file ns_solver.cpp.

Member Function Documentation

◆ init_shear_layer()

void ns::NSSolver::init_shear_layer ( real  rho = 0.05,
real  delta = 0.05 
)

Double shear layer initial condition (Kelvin-Helmholtz instability). Two counter-flowing bands at y~=0.25 and y~=0.75 seed vortex roll-up.

Parameters
rhoShear layer thickness (default 0.05)
deltaPerturbation amplitude (default 0.05)

Definition at line 27 of file ns_solver.cpp.

References h, N, p, u, and v.

Referenced by main().

◆ interp_u()

real ns::NSSolver::interp_u ( real  px,
real  py 
) const

Interpolate x-velocity at physical point (px, py).

Definition at line 254 of file ns_solver.cpp.

References h, N, and u.

◆ interp_v()

real ns::NSSolver::interp_v ( real  px,
real  py 
) const

Interpolate y-velocity at physical point (px, py).

Definition at line 271 of file ns_solver.cpp.

References h, N, and v.

◆ speed()

real ns::NSSolver::speed ( idx  i,
idx  j 
) const

Velocity magnitude averaged to cell centre (i,j).

Definition at line 298 of file ns_solver.cpp.

References u, and v.

◆ step()

void ns::NSSolver::step ( )

Advance one time step (advect -> pressure -> project).

Definition at line 50 of file ns_solver.cpp.

References nu, stats, and ns::Stats::total_ms.

Referenced by main().

◆ vorticity()

real ns::NSSolver::vorticity ( idx  i,
idx  j 
) const

Vorticity omega = d_v/d_x - d_u/d_y at grid corner (i*h, j*h).

Definition at line 289 of file ns_solver.cpp.

References h, u, and v.

Referenced by main().

Member Data Documentation

◆ dt

const real ns::NSSolver::dt

Definition at line 69 of file ns_solver.hpp.

◆ h

const real ns::NSSolver::h

Definition at line 69 of file ns_solver.hpp.

Referenced by init_shear_layer(), interp_u(), interp_v(), and vorticity().

◆ N

const idx ns::NSSolver::N

Definition at line 68 of file ns_solver.hpp.

Referenced by init_shear_layer(), interp_u(), and interp_v().

◆ nu

const real ns::NSSolver::nu

Definition at line 69 of file ns_solver.hpp.

Referenced by step().

◆ p

num::Vector ns::NSSolver::p

velocity faces + cell-centre pressure, N*N each

Definition at line 72 of file ns_solver.hpp.

Referenced by init_shear_layer().

◆ stats

Stats ns::NSSolver::stats

Definition at line 74 of file ns_solver.hpp.

Referenced by main(), and step().

◆ u

num::Vector ns::NSSolver::u

Definition at line 72 of file ns_solver.hpp.

Referenced by init_shear_layer(), interp_u(), speed(), and vorticity().

◆ v

num::Vector ns::NSSolver::v

Definition at line 72 of file ns_solver.hpp.

Referenced by init_shear_layer(), interp_v(), speed(), and vorticity().


The documentation for this class was generated from the following files: