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.Configure — Type
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}}: ForVectortype, it represents the range of the velocity space. For 2D case, it should be aligned as[umin,umax,vmin,vmax]. Implicit requirement: the originv = 0must lie on a velocity-grid corner, i.e. for every dimension(0 - min)/(max - min)*vs_trees_nummust be an integer (checked at construction bycheck_vs_setting). This keeps the upwinding split atv·n = 0unambiguous and is easy to satisfy — e.g. a symmetric range[-a, a]with an evenvs_trees_num. TheAbstractQuadraturetype 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 withquadratureit must place the originv = 0on a root-grid corner (seequadrature; checked bycheck_vs_setting).IC::AbstractInitCond: Initial condition defined byAbstractInitCond.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 byDomain.IB::Vector{AbstractBoundary}: Immersed boundary. Multiple boundaries are supported. The element type is defined byAbstractBoundarygas::Gas: Properties of the simulated gas defined byGas.solver::Solver: Setup of the solver defined bySolver.output::Output: Setup of the output form defined byOutput.user_defined::UDF: Functions defined by users, including some criteria.
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_setting — Function
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.
KitAMR.Solver — Type
struct Solver{DIM, NDF}Structure of solver configuration.
Fields
CFL::Float64: Courant-Friedrichs-Lewy number. Default is0.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 toAMR_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 istrue.VS_DYNAMIC_AMR::Bool: Dynamic AMR in velocity space is open or not. Default istrue.ADAPT_COEFFI_PS::Float64: Criterion of AMR in L"ohner criterion of physical space. Default is0.2.ADAPT_COEFFI_VS_GLOBAL::Float64: Redundancy coefficient of AMR in velocity space. Default is0.125.ADAPT_COEFFI_VS_LOCAL::Float64: Proportion that a refinement-required velocity cell contributes to the macroscopic quantities in a local physical cell. Default is0.01.ADAPT_COEFFI_VS_INIT::Float64: Threshold of the analytic Maxwellian quadrature-error criterion used during initial velocity-space refinement. Default is0.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;:lohneruses the moment-weighted Löhner indicator withlocal_contribution_*as a relative mass/energy floor;:contributionuses 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 whenADAPT_VS_MODE == :lohner. Default is0.6.ADAPT_COEFFI_VS_LSR::Float64: Threshold of the local linear least-squares residual indicator (in[0,1]) for velocity-space refinement whenADAPT_VS_MODE == :lsr. Default is0.16.ADAPT_COEFFI_VS_LSR_FLOOR::Float64: Minimum relative local mass/energy/heat-flux contribution required before the:lsrresidual is allowed to refine a velocity cell. Default is2e-4.TOLERANCE::Float64: Tolerance for convergence judgement. Default is1e-6.ST_CHECK_INTERVAL::Int64: Number of steps between two checks of status. Default is100.REDUNDANT_STEPS_NUM::Int64: Number of redundant steps after convergence criterion has been satisfied. Default is100.max_sim_time::Float64: Simulation termination time (dimensionless). The main loop runs untilsim_timereaches this value, and the last time step is shrunk to land exactly on it (seelimit_Δt!/reached_max_time). Default isInf(no time limit; terminate by convergence).
KitAMR.UDF — Type
mutable struct UDFContainer 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 insideinitialize). Signaturestatic_ps_refine_flag(midpoint::Vector{Float64}, ds::Vector{Float64}, kinfo::KInfo, level::Int) -> Boolmidpoint/dsare the candidate cell's centre/size,levelits current refinement level. Returntrueto 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. Signaturedynamic_ps_refine_flag(ps_data::AbstractPsData, level::Int, ka::KA) -> BoolReturn
falseto forbid dynamic refinement ofps_data(e.g. to freeze the mesh outside a region of interest);truelets 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.