Repository navigation
PLIC: advection_type "PLIC" in HydroUtils - #255
Conversation
d05ddda to
bf07083
Compare
ae7a4fe to
41bf069
Compare
|
Important Corrective u_flux can be multiplied by a downwind edge state — Utils/hydro_compute_edgestate_and_flux.cpp:213
Nits
|
HydroUtils::ComputeFluxesOnBoxFromState advects a volume fraction with advection_type = "PLIC", as any other scalar: the edge states come from PLIC::ComputeEdgeStateAndFluxes with the myc_height reconstruction, and HydroUtils::ComputeFluxes forms the fluxes from them, so u_flux, knownFaceState, area weighting and ComputeConvectiveTerm work unchanged. The boundary conditions are carried by the ghost cells of F, filled with PLIC::FillWallGhosts. "PLIC" aborts with embedded boundaries, for velocities and for more than one component, and ExtrapVelToFaces does not accept it. PLIC::ComputeEdgeStateAndFluxes accepts empty flux arrays, for the edge states only. Tests/PLIC advects through HydroUtils with test.use_hydroutils = 1, with the same shape errors as the direct path and the volume conserved to round-off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TwkdHV9vdS67quGfmN9xjG
- HydroUtils writes the geometric fluxes of PLIC::ComputeEdgeStateAndFluxes when they are formed with u_mac, rather than edge state * u: where shear folds a flux volume the edge state is held to [0,1] and that product is not the liquid that crosses the face. Through HydroUtils the fluxes and edge states are now those of PLIC to the bit (inputs.3d.deform differed at 1e-8). With a corrective u_flux, or knownFaceState, the fluxes are still formed from the edge states. - The PLIC branch is built only with HYDRO_USE_PLIC, which PLIC/Make.package and PLIC/CMakeLists.txt define, so GNUmake codes that do not list PLIC still build; "PLIC" then aborts. - Check iconserv = 1 and that bc_arr is not passed. - One short PLIC note in the ComputeFluxesOnBoxFromState docs, pointing to the PLIC section, rather than five copies. - Tests/PLIC with test.use_hydroutils = 1 checks the HydroUtils fluxes and edge states against PLIC::ComputeEdgeStateAndFluxes, to the bit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The PLIC branch inline in ComputeFluxesOnBoxFromState, without a helper of 21 parameters and a return value with two meanings. - The device check of iconserv = 1 only with AMREX_DEBUG, rather than a kernel launch per box in every build. - HYDRO_USE_PLIC a PRIVATE definition in CMake: only the library reads it. - The flux kernel tests the flux Array4 itself rather than a copy of it. - PLIC.rst says the geometric fluxes need u_flux to be the same Array4 as u_mac (or the overloads without u_flux). - Tests/PLIC: iconserv as a Gpu::DeviceScalar, a synchronous copy of the BCRecs, and the two flux paths as if/else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Check iconserv on the host in every build: 1, or -1 with knownFaceState. The debug-only device check rejected -1 and accepted 0 in release. - Keep PLIC's geometric fluxes whenever u_flux holds the values of u_mac (compared in one reduction when the arrays differ), not only when it is the same Array4. - Pass the real flux arrays to PLIC::ComputeEdgeStateAndFluxes, and revert its empty-flux mode, so the public API again aborts on a missing flux. - ComputeConvectiveTerm aborts on "PLIC" in builds without PLIC, as ComputeFluxesOnBoxFromState does. - Docs: "PLIC" in the bc_arr notes; the HydroUtils section of PLIC.rst as a list of the flux cases, and a note on rebuilding after adding PLIC. - Tests/PLIC: with test.use_hydroutils, also check a copy of u_mac, area-weighted fluxes, a corrective u_flux and knownFaceState with iconserv 1 and -1, all to the bit; share the flux calls between the step and the comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Choose between PLIC's geometric flux (u_flux equal to u_mac) and edge state * u_flux face by face, not box by box: boxes sharing a face could write different fluxes on it when u_flux differs on part of a level. This also drops a reduction, and its wait for the GPU, per box. - Abort in R-Z with knownFaceState too. - Docs: the ghost cells "PLIC" needs, the arguments it does not read, its waits for the GPU per box, and the note on the finest level back under Advection. - Tests/PLIC: a u_flux that differs on part of the level, arrays reset before each call, no device lambda inside a lambda, the comparison every test.hydroutils_int steps (default 10), and inputs.2d.wall_vortex through HydroUtils. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Corrective fluxes: where u_mac is zero or of the other sign to u_flux, take the upwind F of u_flux rather than PLIC's edge state (upwinded by u_mac), so the flux never draws on the downwind cell. Moved to a public PLIC::CorrectiveFluxes, reusing upwind_fraction and FaceArea. - The iconserv check and the per-box Courant check run in CPU and debug builds only; optimized GPU builds rely on PLIC::CheckCourantNumber before the MFIter loop, so the boxes are not serialized. - The EB check for "PLIC" comes before the covered-box early return. - Docs: myc_height is fixed, so FillWallGhosts and SharpFaceDensity must use it too; u_flux is compared with u_mac bit for bit. - Tests: corrective u_flux of the sign of u_mac, reversed, and non-zero where u_mac is zero, without and with area weighting; a NaN edge state no longer hides behind max(); inputs.2d.vortex and inputs.3d.deform also advect through HydroUtils (AMR, periodic, 3D). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41bf069 to
2ed9d8f
Compare
|
Thanks for the review. All addressed in 2ed9d8f (rebased on development): Important: corrective u_flux times a downwind edge state. Fixed. Where u_mac is zero or of the other sign to u_flux, the flux now takes the upwind F of u_flux (held to [0,1]) instead of PLIC's edge state, so it never draws on the downwind cell. Your rest-state case now gives a zero flux. Where the signs agree it is still PLIC's edge state × u_flux, and where u_flux == u_mac bit for bit it is PLIC's geometric flux. The face arrays keep PLIC's edge states. This lives in a new public Nits
|
|
The downwind-edge-state fix does not cover knownFaceState = true (Utils/hydro_compute_edgestate_and_flux.cpp:497). I confirmed this in the code.
|
- knownFaceState: the fluxes get PLIC::CorrectiveFluxes too, so where a corrective u_flux is zero-crossing or reversed relative to u_mac, the flux takes the upwind F of u_flux rather than the given edge state (upwinded by u_mac), as without knownFaceState. With iconserv = -1 the given fluxes are kept. - PLIC::CorrectiveFluxes takes an optional device pointer to iconserv and reads it in its kernel, so HydroUtils needs no wait for the GPU per box; HydroUtils now calls it once for both paths. - PLIC::CorrectiveFluxes checks that the fluxes, edge states, u_mac and u_flux cover the faces of bx, and that F has one ghost cell: with knownFaceState the other schemes read neither F nor u_mac. - Docs: the knownFaceState correction, and that it needs u_mac and F with one ghost cell. - Tests: knownFaceState with the corrective u_flux, with iconserv = 1 (corrected) and -1 (copied). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, you're right: the knownFaceState with a corrective u_flux. The fluxes on that path now go through
|
Following Rudman (IJNMF), the Owkes & Desjardins flux volumes also give the mass and momentum fluxes of each face, from the cuts of the volume fraction with phase densities given as PhaseDensityArray or fields. - ComputeMassMomentumFluxes computes the volume, mass and momentum fluxes in one call, optionally with the face velocity; dt must be positive. - FarFieldMomentumFluxes fills the faces the cuts marked, away from the interface. far_field_mark is a quiet NaN, so that a face left unfilled shows up in the momentum update. - CorrectiveMassMomentumFluxes is the counterpart of CorrectiveFluxes: where a corrective u_flux differs from umac, the mass flux carries the corrected volume fraction flux at the phase densities of the upwind cell, so rho stays the mixture density of F. Both share corrective_fraction. - The mass and momentum entry points take check_courant, as ComputeEdgeStateAndFluxes does, for solvers that check the level once with CheckCourantNumber. - The cut kernels walk the pieces of a flux volume once, and skip the liquid lookup per piece in a flux volume of one phase. The liquid flux kernel captures no momentum arguments. - SharpFaceDensity reads its phase densities as PhaseDensityArray. - New test_momentum (inputs.momentum) with a Translate problem: checks the corrective fluxes, and that the momentum is conserved in every case, relative to one cell of liquid. Ported as one commit onto development after plic-4 (AMReX-Fluids#255) merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V7EH6ZtZUnusy66tyAq5MH
HydroUtils::ComputeFluxesOnBoxFromState advects a volume fraction with advection_type = "PLIC": PLIC::ComputeEdgeStateAndFluxes gives the edge states and the geometric fluxes, with the myc_height reconstruction. Where a corrective u_flux differs from u_mac (bit for bit), the new PLIC::CorrectiveFluxes overwrites the flux with edge state × u_flux. Where u_mac is zero or of the other sign, it uses the upwind F of u_flux instead, so the flux never draws on the downwind cell. knownFaceState works with iconserv = 1 (edge states) or -1 (fluxes). The boundary conditions are carried by the ghost cells of F, filled with PLIC::FillWallGhosts. "PLIC" aborts with EB (whole level, covered boxes included), for velocities and for more than one component, and ExtrapVelToFaces does not accept it. Optimized GPU builds skip the per-box Courant and iconserv checks, so callers check each level with PLIC::CheckCourantNumber before the MFIter loop.
Tests/PLIC advects through HydroUtils with test.use_hydroutils = 1 in inputs.2d.vortex, inputs.2d.wall_vortex and inputs.3d.deform (AMR, periodic and wall boundaries, 3D). It compares with PLIC to the bit, including corrective u_flux cases with and without area weighting, and the volume is conserved to round-off.
🤖 Generated with Claude Code