include/vecmat/raddiff.h file

Rosseland diffusion coefficient and flux limiter.

The diffusion coefficient is $D = 1/(3\kappa_R)$. The Levermore–Pomraning limiter is $\lambda(R) = (\coth R - 1/R)/R$ with $R = |\nabla E|/(\kappa E)$. In the optically thick limit $\lambda(0) = 1/3$, and $\lambda$ stays in $(0, 1/3]$. The limited coefficient is $D\lambda(R)$.

The variable-D operator fills a caller-owned CSR. Constant $D = 1$ matches the assembled grid Laplacian. The solve stays vm_cg.

Functions

auto vm_raddiff_d(vm_float_t* D, const vm_float_t* kappa, int n) -> bool
Rosseland diffusion coefficient $D = 1/(3\kappa_R)$.
auto vm_raddiff_limiter(vm_float_t R) -> vm_float_t
Levermore–Pomraning flux limiter $\lambda(R)$.
auto vm_raddiff_ratio(vm_float_t grad_e, vm_float_t kappa, vm_float_t E) -> vm_float_t
Dimensionless gradient $R = |\nabla E|/(\kappa E)$.
auto vm_raddiff_residual(vm_float_t* r, const vm_float_t* kappa_a, const vm_float_t* E, const vm_float_t* aT4, int n) -> bool
Gray emission–absorption residual $\kappa_a (E - a T^4)$.
auto vm_raddiff_laplacian(vm_spmat* A, const vm_float_t* D, vm_grid3 g, vm_bc_t bc) -> bool
Fill a caller-owned CSR with $-\nabla\cdot(D\nabla)$.

Function documentation

bool vm_raddiff_d(vm_float_t* D, const vm_float_t* kappa, int n)

Rosseland diffusion coefficient $D = 1/(3\kappa_R)$.

Parameters
D Output coefficient; length n.
kappa Rosseland opacity; length n.
n
Returns false if a pointer is NULL or any opacity is non-positive.

vm_float_t vm_raddiff_limiter(vm_float_t R)

Levermore–Pomraning flux limiter $\lambda(R)$.

Parameters
R Dimensionless gradient $R = |\nabla E|/(\kappa E)$. Negative values are taken in absolute value.
Returns Limiter in $(0, 1/3]$.

$\lambda(0) = 1/3$ and $\lambda$ decreases toward 0 as $R$ grows.

vm_float_t vm_raddiff_ratio(vm_float_t grad_e, vm_float_t kappa, vm_float_t E)

Dimensionless gradient $R = |\nabla E|/(\kappa E)$.

Parameters
grad_e Magnitude of the energy gradient.
kappa Rosseland opacity.
E Energy density.
Returns R, or 0 if the denominator is non-positive.

bool vm_raddiff_residual(vm_float_t* r, const vm_float_t* kappa_a, const vm_float_t* E, const vm_float_t* aT4, int n)

Gray emission–absorption residual $\kappa_a (E - a T^4)$.

Parameters
r Output residual; length n.
kappa_a Absorption opacity; length n.
E Energy density; length n.
aT4 Radiation constant times $T^4$; length n.
n
Returns false if a pointer is NULL.

bool vm_raddiff_laplacian(vm_spmat* A, const vm_float_t* D, vm_grid3 g, vm_bc_t bc)

Fill a caller-owned CSR with $-\nabla\cdot(D\nabla)$.

Parameters
A Output sparse matrix; size vm_grid_ncells(g).
D Cell-centered diffusion coefficient, length vm_grid_ncells(g), or NULL.
g Grid dimensions and spacing.
bc Boundary condition (VM_BC_DIRICHLET or VM_BC_NEUMANN).
Returns false if a pointer is NULL, the grid is invalid, or a coefficient is non-positive.

Same boundary treatment as vm_grid_laplacian. Face coefficient is the arithmetic mean of the two cell values; a domain boundary face uses the cell value. Constant D == 1 matches the assembled Laplacian. NULL D means coefficient 1 everywhere.