selah_kernels_constraint
SELAH, L1: the box kernel of the inequality constraints on a step's result.
A component may have to stay non-negative (a density, a concentration), positive, non-positive or negative. After the stages of a step, before finish_step, the kernel reads the step's result u = q + dt sum_k b_k R_k at each cell (q and the residual registers only read, nothing written) and returns the smallest ratio r of the step that keeps every constrained component admissible, the solution moving along u(r) = q + r (u - q):
- admissible: 1;
- u past the bound and q inside it: q / (q - u), where the straight path crosses the bound;
- u = 0 for a strict constraint (> 0, < 0): 1/2 (no crossing to locate);
- q itself not admissible: 0.
The caller reduces it (a min over its boxes and ranks), rejects the step when it is below 1 and redoes it with dt times the ratio times a safety factor below 1 (the step's path is not straight). The constraint of component v is cons(v) = CONSTRAINT_NONE (0), CONSTRAINT_NONNEGATIVE (1), CONSTRAINT_POSITIVE (2), CONSTRAINT_NONPOSITIVE (-1) or CONSTRAINT_NEGATIVE (-2), v counted from the field's first component; cons is device resident. No mask.
Source: src/lib/selah_kernels_constraint.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
CONSTRAINT_NONE | integer(kind=I4P) | parameter | No constraint. |
CONSTRAINT_NONNEGATIVE | integer(kind=I4P) | parameter | u >= 0. |
CONSTRAINT_POSITIVE | integer(kind=I4P) | parameter | u > 0. |
CONSTRAINT_NONPOSITIVE | integer(kind=I4P) | parameter | u <= 0. |
CONSTRAINT_NEGATIVE | integer(kind=I4P) | parameter | u < 0. |
Subroutines
step_constraint_box
The smallest admissible ratio of the step over the box, u = q + dt sum_{k=1..n} coef(k) regs(k).
subroutine step_constraint_box(bx, n, dt, coef, regs, q, cons, ratio)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bx | type(box) | in | Box. | |
n | integer(kind=I4P) | in | Registers summed. | |
dt | real(kind=R_P) | in | Time step. | |
coef | real(kind=R_P) | in | The weights b [n or more]. | |
regs | real(kind=R_P) | in | Residual registers [..., n or more]. | |
q | real(kind=R_P) | in | Solution, q^n. | |
cons | integer(kind=I4P) | in | Constraint per component. | |
ratio | real(kind=R_P) | out | Smallest admissible ratio (1: every cell admissible). |
Call graph