Configuration

To simulate a problem using KitAMR, user is required to define the problem. Most of the user-provided information is collected in Configure struct.

KitAMR.ConfigureType
struct Configure{DIM, NDF} <: KitAMR.AbstractConfig{DIM, NDF}

Structure of problem configuration. DIM and NDF represent the dimension number of the problem and the number of the distribution function. This struct plays an key role in the solution process.

Fields

  • geometry::Vector{Float64}: Range of the simulated domain. As an example, for 2D case, it should be aligned as [xmin,xmax,ymin,ymax].

  • trees_num::Vector{Int64}: Number of tree roots for each dimension. For 2D case, it should be aligned as [xnum,ynum]

  • quadrature::Union{KitAMR.AbstractQuadrature, Vector{Float64}}: For Vector type, it represents the range of the velocity space. For 2D case, it should be aligned as [umin,umax,vmin,vmax]. Implicit requirement: the origin v = 0 must lie on a velocity-grid corner, i.e. for every dimension (0 - min)/(max - min)*vs_trees_num must be an integer (checked at construction by check_vs_setting). This keeps the upwinding split at v·n = 0 unambiguous and is easy to satisfy — e.g. a symmetric range [-a, a] with an even vs_trees_num. The AbstractQuadrature type is reserved for other quadrature rules like Gauss-Hermite.

  • vs_trees_num::Vector{Int64}: Number of tree roots for each dimension in velocity space. Together with quadrature it must place the origin v = 0 on a root-grid corner (see quadrature; checked by check_vs_setting).

  • IC::AbstractInitCond: Initial condition defined by AbstractInitCond.

  • domain::Vector{Domain}: Types of the domain boundary. For 2D case, the vector should catain 4 elements corresponding to the 4 domain boundaries. The element type is defined by Domain.

  • IB::Vector{AbstractBoundary}: Immersed boundary. Multiple boundaries are supported. The element type is defined by AbstractBoundary

  • gas::Gas: Properties of the simulated gas defined by Gas.

  • solver::Solver: Setup of the solver defined by Solver.

  • output::Output: Setup of the output form defined by Output.

  • user_defined::UDF: Functions defined by users, including some criteria.

source
Velocity-space origin must be on a grid corner

The Cartesian velocity space carries an implicit requirement: the origin v = 0 must lie on a velocity-grid corner (a root-cell vertex), never inside a cell. This keeps the upwinding split at v·n = 0 unambiguous, and since refinement only bisects cells, 0 then stays on a corner at every level. Concretely, for each dimension (0 - min)/(max - min)*vs_trees_num must be an integer — easiest with a symmetric range [-a, a] and an even vs_trees_num. Satisfying it is left to the user (it is trivial); the setting is validated when a Configure is constructed, and an informative error is thrown if it is violated.

KitAMR.check_vs_settingFunction
check_vs_setting(quadrature, vs_trees_num, DIM::Integer)

Validate the Cartesian velocity-space setting (quadrature range + vs_trees_num).

The kinetic scheme carries an implicit requirement: the origin v = 0 must lie on a velocity-grid corner (a root-cell vertex), never inside a cell. This keeps the upwinding split at v·n = 0 unambiguous (no cell whose centre is exactly v = 0) and, because refinement only bisects cells, guarantees 0 stays on a corner at every level. Equivalently, for each dimension (0 - min)/(max - min) * vs_trees_num must be an integer in 0:vs_trees_num.

The requirement is left to the user to satisfy through a sensible choice of range and root count — it is trivial, e.g. a symmetric range [-a, a] with an even vs_trees_num. This function only checks it, throwing an ErrorException that names the offending dimension when violated. It is a no-op for a non-Cartesian AbstractQuadrature.

source
KitAMR.SolverType
struct Solver{DIM, NDF}

Structure of solver configuration.

Fields

  • CFL::Float64: Courant-Friedrichs-Lewy number. Default is 0.4.

  • AMR_PS_MAXLEVEL::Int64: Maximum level of the (static) AMR in physical space. Mandatory.

  • AMR_DYNAMIC_PS_MAXLEVEL::Int64: Maximum level of the dynamic AMR in physical space. In most cases, it should be smaller than the static one. Default is equal to AMR_PS_MAXLEVEL.

  • AMR_VS_MAXLEVEL::Int64: Maximum level of the AMR in velocity space. Mandatory.

  • flux::Type{Tf} where Tf<:AbstractFluxType: Numerical flux type. Mandatory.

  • time_marching::Type{Tt} where Tt<:AbstractTimeMarchingType: Time-marching scheme. Mandatory.

  • PS_DYNAMIC_AMR::Bool: Dynamic AMR in physical space is open or not. Default is true.

  • VS_DYNAMIC_AMR::Bool: Dynamic AMR in velocity space is open or not. Default is true.

  • ADAPT_COEFFI_PS::Float64: Criterion of AMR in L"ohner criterion of physical space. Default is 0.2.

  • ADAPT_COEFFI_VS_GLOBAL::Float64: Redundancy coefficient of AMR in velocity space. Default is 0.125.

  • ADAPT_COEFFI_VS_LOCAL::Float64: Proportion that a refinement-required velocity cell contributes to the macroscopic quantities in a local physical cell. Default is 0.01.

  • ADAPT_COEFFI_VS_INIT::Float64: Threshold of the analytic Maxwellian quadrature-error criterion used during initial velocity-space refinement. Default is 0.22.

  • ADAPT_VS_MODE::Symbol: Velocity-space refinement criterion. :lsr (default) uses a dimension-unsplit local linear least-squares residual with a heat-flux-aware contribution floor; :lohner uses the moment-weighted Löhner indicator with local_contribution_* as a relative mass/energy floor; :contribution uses the legacy magnitude/contribution flags.

  • ADAPT_COEFFI_VS_LOHNER::Float64: Threshold of the moment-weighted Löhner indicator (in [0,1]) for velocity-space refinement when ADAPT_VS_MODE == :lohner. Default is 0.6.

  • ADAPT_COEFFI_VS_LSR::Float64: Threshold of the local linear least-squares residual indicator (in [0,1]) for velocity-space refinement when ADAPT_VS_MODE == :lsr. Default is 0.16.

  • ADAPT_COEFFI_VS_LSR_FLOOR::Float64: Minimum relative local mass/energy/heat-flux contribution required before the :lsr residual is allowed to refine a velocity cell. Default is 2e-4.

  • TOLERANCE::Float64: Tolerance for convergence judgement. Default is 1e-6.

  • ST_CHECK_INTERVAL::Int64: Number of steps between two checks of status. Default is 100.

  • REDUNDANT_STEPS_NUM::Int64: Number of redundant steps after convergence criterion has been satisfied. Default is 100.

  • max_sim_time::Float64: Simulation termination time (dimensionless). The main loop runs until sim_time reaches this value, and the last time step is shrunk to land exactly on it (see limit_Δt! / reached_max_time). Default is Inf (no time limit; terminate by convergence).

source
KitAMR.UDFType
mutable struct UDF

Container for the optional user-supplied callbacks that steer adaptive mesh refinement. Construct with UDF(; static_ps_refine_flag = …, dynamic_ps_refine_flag = …); any field left unset defaults to a no-op. See the User-defined functions page for the full convention and worked examples.

Fields

  • static_ps_refine_flag::Function: Static, geometry-driven physical-space refinement flag. Evaluated once during the initial refinement at setup (pre_refine!, called inside initialize). Signature

    static_ps_refine_flag(midpoint::Vector{Float64}, ds::Vector{Float64},
                          kinfo::KInfo, level::Int) -> Bool

    midpoint/ds are the candidate cell's centre/size, level its current refinement level. Return true to force the cell to refine; such cells are also protected from coarsening. Default (null_udf): never force refinement.

  • dynamic_ps_refine_flag::Function: Dynamic, solution-driven physical-space refinement flag. Evaluated every refinement step (adaptive_mesh_refinement!) to gate the Löhner sensor. Signature

    dynamic_ps_refine_flag(ps_data::AbstractPsData, level::Int, ka::KA) -> Bool

    Return false to forbid dynamic refinement of ps_data (e.g. to freeze the mesh outside a region of interest); true lets the sensor decide. Default (unset): always allow.

  • static_vs_refine_flag::Function: Reserved for a static velocity-space refinement flag. Currently unused — the field is stored but never invoked.
source