IAMReX

Contents:

  • Introduction
  • Getting Started
  • Validation Cases
  • Algorithm and Software Details
  • Acknowledgements

References:

  • References
  • API
    • Direct forcing IBM
    • Particle Collision
    • Navier Stokes
      • NavierStokes
        • initData()
        • advance()
        • advance_semistaggered_twophase_ls()
        • advance_semistaggered_twophase_phasefield()
        • scalar_advection()
        • scalar_diffusion_update()
      • NavierStokesBase
        • define_workspace()
        • checkPoint()
        • computeInitialDt()
        • computeNewDt()
        • steadyState()
        • computeGradP()
        • fill_allgts()
        • reinit()
        • reinitialization_sussman()
        • reinitialization_consls()
        • phi_to_sgn0()
        • get_phi_half_time()
        • rk_first_reinit()
        • rk_second_reinit()
        • mass_fix()
        • calc_mut_LES()
        • time_average()
        • advance_cleanup()
        • incrRhoAvg()
        • incrRhoAvg()
        • initial_velocity_diffusion_update()
        • level_sync()
        • make_rho_prev_time()
        • make_rho_curr_time()
        • post_init_state()
        • sync_setup()
        • velocity_advection()
        • velocity_update()
        • velocity_advection_update()
        • avgDown_StatePress()
        • printMaxVel()
        • printMaxGp()
        • printMaxValues()
        • buildMetrics()
        • incrPAvg()
        • initOldFromNew()
        • initRhoAvg()
IAMReX
  • API
  • Navier Stokes
  • View page source

Navier Stokes

group fluid parameters and function

introduction for Navier stokes

class NavierStokes : public NavierStokesBase
#include <NavierStokes.H>

Public Functions

void initData() override

Initialize grid data at problem start-up.

This function sets up initial conditions for the Navier-Stokes equations including velocity, pressure, and scalar fields.

amrex::Real advance(amrex::Real time, amrex::Real dt, int iteration, int ncycle) override

Advance grids at this level in time using the Navier-Stokes solver.

Parameters:
  • time – Current simulation time

  • dt – Time step size

  • iteration – Current iteration number

  • ncycle – Total number of cycles for this level

Returns:

Estimated optimal timestep for next iteration

amrex::Real advance_semistaggered_twophase_ls(amrex::Real time, amrex::Real dt, int iteration, int ncycle)

Advance grids using semi-staggered two-phase level set method.

This function implements the level set method for two-phase flow simulations.

Parameters:
  • time – Current simulation time

  • dt – Time step size

  • iteration – Current iteration number

  • ncycle – Total number of cycles for this level

Returns:

Estimated optimal timestep for next iteration

amrex::Real advance_semistaggered_twophase_phasefield(amrex::Real time, amrex::Real dt, int iteration, int ncycle)

Advance grids using semi-staggered two-phase phase field method.

This function implements the phase field method for two-phase flow simulations.

Parameters:
  • time – Current simulation time

  • dt – Time step size

  • iteration – Current iteration number

  • ncycle – Total number of cycles for this level

Returns:

Estimated optimal timestep for next iteration

void scalar_advection(amrex::Real dt, int fscalar, int lscalar)

Advect scalar quantities using the chosen advection scheme.

Parameters:
  • dt – Time step size

  • fscalar – First scalar component index

  • lscalar – Last scalar component index

void scalar_diffusion_update(amrex::Real dt, int first_scalar, int last_scalar)

Update scalar quantities with diffusion terms.

Parameters:
  • dt – Time step size

  • first_scalar – First scalar component index

  • last_scalar – Last scalar component index

class NavierStokesBase : public AmrLevel
#include <NavierStokesBase.H>

Subclassed by NavierStokes

Public Functions

void define_workspace()

Define workspace and initialize data structures required for computation.

This function sets up grid geometry information, allocates memory space, and prepares necessary arrays for subsequent calculations.

void checkPoint(const std::string &dir, std::ostream &os, amrex::VisMF::How how = amrex::VisMF::OneFilePerCPU, bool dump_old = true) override

Save checkpoint data to specified directory.

Parameters:
  • dir – Directory path for saving checkpoint data

  • os – Output stream object for writing checkpoint information

  • how – File output method, defaults to one file per CPU

  • dump_old – Whether to save old timestep data, defaults to true

void computeInitialDt(int finest_level, int sub_cycle, amrex::Vector<int> &n_cycle, const amrex::Vector<amrex::IntVect> &ref_ratio, amrex::Vector<amrex::Real> &dt_level, amrex::Real stop_time) override

Compute initial timestep for all levels in the AMR hierarchy.

Parameters:
  • finest_level – Index of the finest level in the hierarchy

  • sub_cycle – Number of sub-cycles for fine levels

  • n_cycle – Vector storing number of cycles for each level

  • ref_ratio – Vector of refinement ratios between levels

  • dt_level – Vector storing timestep for each level

  • stop_time – Final simulation time

void computeNewDt(int finest_level, int sub_cycle, amrex::Vector<int> &n_cycle, const amrex::Vector<amrex::IntVect> &ref_ratio, amrex::Vector<amrex::Real> &dt_min, amrex::Vector<amrex::Real> &dt_level, amrex::Real stop_time, int post_regrid_flag) override

Compute new timestep for all levels after a timestep or regridding.

Parameters:
  • finest_level – Index of the finest level in the hierarchy

  • sub_cycle – Number of sub-cycles for fine levels

  • n_cycle – Vector storing number of cycles for each level

  • ref_ratio – Vector of refinement ratios between levels

  • dt_min – Vector storing minimum allowed timestep for each level

  • dt_level – Vector storing computed timestep for each level

  • stop_time – Final simulation time

  • post_regrid_flag – Flag indicating if this is called after regridding

virtual int steadyState()

Check whether simulation has reached steady state.

Returns:

1 if steady state is reached (change below threshold), 0 otherwise

void computeGradP(amrex::Real time)

Compute pressure gradient data and fill ghost cells.

Parameters:

time – Current simulation time for which to compute pressure gradient

void fill_allgts(amrex::MultiFab &mf, int type, int scomp, int ncomp, amrex::Real time)

Fill ghost cells for level set function with appropriate boundary conditions.

Parameters:
  • mf – MultiFab containing the level set function

  • type – State type identifier

  • scomp – Starting component index

  • ncomp – Number of components to fill

  • time – Current simulation time

void reinit()

Perform level set reinitialization to maintain signed distance property.

This function ensures the level set function remains a signed distance function by solving the reinitialization equation.

void reinitialization_sussman(amrex::Real dt, int loop_iter)

Perform Sussman reinitialization of level set function.

Parameters:
  • dt – Time step size for reinitialization

  • loop_iter – Number of reinitialization iterations

void reinitialization_consls(amrex::Real dt, int loop_iter, amrex::Real epsG, amrex::Real epsG2)

Perform conservative level set reinitialization.

Parameters:
  • dt – Time step size for reinitialization

  • loop_iter – Number of reinitialization iterations

  • epsG – Epsilon parameter for conservative level set

  • epsG2 – Second epsilon parameter for conservative level set

void phi_to_sgn0(amrex::MultiFab &phi)

Convert level set function phi to sign function (sgn0).

Parameters:

phi – MultiFab containing the level set function

amrex::MultiFab &get_phi_half_time()

Get level set function at half time step.

Returns:

Reference to MultiFab containing level set function at t+dt/2

void rk_first_reinit(amrex::MultiFab &phi_ctime, amrex::MultiFab &phi2, amrex::MultiFab &phi3, amrex::MultiFab &sgn0, amrex::MultiFab &G0, amrex::Real dt, amrex::MultiFab &phi_ori)

First stage of Runge-Kutta reinitialization scheme.

Parameters:
  • phi_ctime – Current time level set function

  • phi2 – Second stage level set function

  • phi3 – Third stage level set function

  • sgn0 – Sign function

  • G0 – Gradient magnitude function

  • dt – Time step size

  • phi_ori – Original level set function

void rk_second_reinit(amrex::MultiFab &phi_ctime, amrex::MultiFab &phi2, amrex::MultiFab &phi3, amrex::MultiFab &sgn0, amrex::MultiFab &G0, amrex::Real dt, amrex::MultiFab &phi_ori)

Second stage of Runge-Kutta reinitialization scheme.

Parameters:
  • phi_ctime – Current time level set function

  • phi2 – Second stage level set function

  • phi3 – Third stage level set function

  • sgn0 – Sign function

  • G0 – Gradient magnitude function

  • dt – Time step size

  • phi_ori – Original level set function

void mass_fix(amrex::MultiFab &phi_ctime, amrex::MultiFab &phi_original, amrex::MultiFab &phi2, amrex::MultiFab &phi3, amrex::MultiFab &ld, amrex::MultiFab &lambdad, amrex::MultiFab &deltafunc_alias, amrex::Real delta_t, int loop_iter)

Apply mass conservation fix for level set reinitialization.

Parameters:
  • phi_ctime – Current time level set function

  • phi_original – Original level set function

  • phi2 – Second stage level set function

  • phi3 – Third stage level set function

  • ld – Lagrange multiplier for mass conservation

  • lambdad – Lagrange multiplier derivative

  • deltafunc_alias – Delta function alias

  • delta_t – Time step size

  • loop_iter – Current iteration number

void calc_mut_LES(amrex::MultiFab *mu_LES[AMREX_SPACEDIM], amrex::Real time)

Calculate turbulent viscosity for Large Eddy Simulation (LES).

Parameters:
  • mu_LES – Array of MultiFab pointers for turbulent viscosity in each direction

  • time – Current simulation time

void time_average(amrex::Real &time_avg, amrex::Real &time_avg_fluct, amrex::Real &dt_avg, const amrex::Real &dt_level)

Compute time-averaged quantities for statistics.

Parameters:
  • time_avg – Time-averaged value (output)

  • time_avg_fluct – Time-averaged fluctuation (output)

  • dt_avg – Time-averaged time step (output)

  • dt_level – Current time step size

void advance_cleanup(int iteration, int ncycle)

Clean up after advance step completion.

Parameters:
  • iteration – Current iteration number

  • ncycle – Total number of cycles

void incrRhoAvg(amrex::Real alpha)

Increment density average with given weight.

Parameters:

alpha – Weight factor for averaging

void incrRhoAvg(const amrex::MultiFab &rho_incr, int sComp, amrex::Real alpha)

Increment density average with MultiFab input.

Parameters:
  • rho_incr – MultiFab containing density increment

  • sComp – Starting component index

  • alpha – Weight factor for averaging

void initial_velocity_diffusion_update(amrex::Real dt)

Update initial velocity with diffusion terms.

Parameters:

dt – Time step size

void level_sync(int crse_iteration)

Compute level synchronization correction.

Parameters:

crse_iteration – Coarse level iteration number

void make_rho_prev_time()

Make density at previous time step.

void make_rho_curr_time()

Make density at current time step.

void post_init_state()

Ensure state is consistent after initialization.

This function makes sure velocity field is non-divergent, coarse level data are averages of fine level data, and pressure is zero.

void sync_setup(amrex::MultiFab *&DeltaSsync)

Set up synchronization data structures.

Parameters:

DeltaSsync – Pointer to MultiFab for sync correction (output)

void velocity_advection(amrex::Real dt)

Advect velocities using the chosen advection scheme.

Parameters:

dt – Time step size

void velocity_update(amrex::Real dt)

Update velocities with advection and diffusion terms.

Parameters:

dt – Time step size

void velocity_advection_update(amrex::Real dt)

Update velocities with advection terms only.

Parameters:

dt – Time step size

void avgDown_StatePress()

Average down State_Type and Press_Type data from fine to coarse level.

void printMaxVel(bool new_data = true)

Print maximum velocity values for diagnostics.

Parameters:

new_data – Whether to use new time data (true) or old time data (false)

void printMaxGp(bool new_data = true)

Print maximum pressure gradient values for diagnostics.

Parameters:

new_data – Whether to use new time data (true) or old time data (false)

void printMaxValues(bool new_data = true)

Print maximum values of all state variables for diagnostics.

Parameters:

new_data – Whether to use new time data (true) or old time data (false)

void buildMetrics()

Build 1-D metric arrays for RZ (radial-axial) geometry.

void incrPAvg()

Increment pressure average for time-averaged statistics.

void initOldFromNew(int type, int lev = -1)

Initialize old time data with new time data.

Parameters:
  • type – State type to initialize

  • lev – Level index (-1 for current level)

void initRhoAvg(amrex::Real alpha)

Initialize density average with given weight.

Parameters:

alpha – Weight factor for averaging

Previous

© Copyright 2025, IAMReX Team.

Built with Sphinx using a theme provided by Read the Docs.