Skip to content
Draft
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ed8c26e
make pressure initialization available
mbkuhn Sep 12, 2024
b1785a1
tweaks to interface_band
mbkuhn Sep 18, 2024
effb1d0
incorporate iblank_to_mask_vof
mbkuhn Sep 18, 2024
b72ae79
zero velocities inside objects
mbkuhn Sep 18, 2024
ff7449f
make vof-dependent node mask when nodal_proj coupling not disabled
mbkuhn Sep 18, 2024
d8ca057
correcting arguments
mbkuhn Sep 18, 2024
dbc4552
Merge remote-tracking branch 'upstream/main' into init_pressure
mbkuhn Jul 9, 2025
4a634b1
getting pressure changes back in
mbkuhn Jul 9, 2025
72a0098
add improvements to sharpening that do not involve overset interface
mbkuhn Jul 16, 2025
6c391ba
adding (partially) disable option
mbkuhn Jul 16, 2025
4426119
try something
mbkuhn Jul 16, 2025
8222222
remove for now
mbkuhn Jul 16, 2025
e0b8f33
put it back
mbkuhn Jul 16, 2025
6655cd9
trying out old normal calc
mbkuhn Jul 16, 2025
5f51542
Revert "trying out old normal calc"
mbkuhn Jul 16, 2025
b679c5a
add ability to turn off modified masking of mac projection
mbkuhn Jul 16, 2025
f7ed394
Merge remote-tracking branch 'upstream/main' into init_pressure_sharp…
mbkuhn Jul 16, 2025
897dd75
correcting things after merge
mbkuhn Jul 16, 2025
5349331
formatting
mbkuhn Jul 16, 2025
86989d8
formatting again
mbkuhn Jul 16, 2025
8578503
fix one unit test
mbkuhn Jul 16, 2025
9f5e180
fixing the other unit test
mbkuhn Jul 16, 2025
ff3aaaf
removing unnecessary line
mbkuhn Jul 16, 2025
3ac00d5
cpu ci
mbkuhn Jul 17, 2025
1c79f10
to go with last commit
mbkuhn Jul 17, 2025
e4cdc0f
for cuda
mbkuhn Jul 17, 2025
d4e1ab4
GpuArray instead of DeviceVector
mbkuhn Jul 17, 2025
8d4326e
add const and move things around
mbkuhn Jul 17, 2025
38a3610
accident
mbkuhn Jul 17, 2025
3911cf9
skip sharpening when there is nothing to do
mbkuhn Jul 18, 2025
7253dda
Merge branch 'main' into init_pressure_sharpen_improve
mbkuhn Jul 23, 2025
1ca03ec
Merge branch 'main' into init_pressure_sharpen_improve
mbkuhn Jul 24, 2025
1c2c6bc
correct comment
mbkuhn Jul 29, 2025
20243c7
start with consistency across levels
mbkuhn Jul 29, 2025
5dc9f8d
get number of components right, include density too
mbkuhn Jul 29, 2025
14a6c80
do consistency stuff afterward, remove average down for fluxes
mbkuhn Jul 29, 2025
509afbe
try averaging down pressure too
mbkuhn Jul 30, 2025
81dc55e
try averaging down first, too
mbkuhn Jul 30, 2025
5e8de3c
average down to start; average fluxes as well
mbkuhn Jul 30, 2025
8fe8331
average down within loop
mbkuhn Jul 30, 2025
53267ae
mask covered levels when calculating pseudo dt
mbkuhn Jul 30, 2025
07ddd12
remove some average_downs
mbkuhn Jul 30, 2025
9fbb0e4
add unit test back
mbkuhn Jul 30, 2025
a5f7ae8
remove commented code
mbkuhn Aug 7, 2025
693a089
sloshing tank physics: keep other changes in main, just do the const …
mbkuhn Aug 7, 2025
a4746d6
avoid modifying pressures that are not iblank = -1
mbkuhn Aug 7, 2025
f582a0d
ensure vof bounds, ptfac bounds
mbkuhn Aug 12, 2025
1ec222f
Merge branch 'main' into init_pressure_sharpen_improve
mbkuhn Aug 15, 2025
2edc8fa
Merge branch 'main' into init_pressure_sharpen_improve
mbkuhn Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions amr-wind/equation_systems/icns/icns_advection.H
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private:
#endif
MLMGOptions m_options;
bool m_has_overset{false};
bool m_disable_mphase_overset_ops{false};
bool m_need_init{true};
bool m_variable_density{false};
bool m_mesh_mapping{false};
Expand Down
11 changes: 8 additions & 3 deletions amr-wind/equation_systems/icns/icns_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ MacProjOp::MacProjOp(
pp.query("use_fft", m_use_fft);
}
#endif

// Always off for single-phase flows, this can turn off multiphase overset
// operations for all cases
amrex::ParmParse pp_o("Overset");
pp_o.query("disable_mphase_ops", m_disable_mphase_overset_ops);
}

void MacProjOp::enforce_inout_solvability(
Expand All @@ -78,7 +83,7 @@ void MacProjOp::enforce_inout_solvability(
void MacProjOp::init_projector(const MacProjOp::FaceFabPtrVec& beta) noexcept
{
// Prepare masking for projection
if (m_has_overset) {
if (m_has_overset && !m_disable_mphase_overset_ops) {
amr_wind::overset_ops::prepare_mask_cell_for_mac(m_repo);
}

Expand Down Expand Up @@ -107,7 +112,7 @@ void MacProjOp::init_projector(const MacProjOp::FaceFabPtrVec& beta) noexcept
void MacProjOp::init_projector(const amrex::Real beta) noexcept
{
// Prepare masking for projection
if (m_has_overset) {
if (m_has_overset && !m_disable_mphase_overset_ops) {
amr_wind::overset_ops::prepare_mask_cell_for_mac(m_repo);
}

Expand Down Expand Up @@ -365,7 +370,7 @@ void MacProjOp::operator()(const FieldState fstate, const amrex::Real dt)
}

// Prepare masking for remainder of algorithm
if (m_has_overset) {
if (m_has_overset && !m_disable_mphase_overset_ops) {
amr_wind::overset_ops::revert_mask_cell_after_mac(m_repo);
}

Expand Down
142 changes: 101 additions & 41 deletions amr-wind/equation_systems/vof/volume_fractions.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
#include <cmath>
#include "amr-wind/utilities/constants.H"

namespace {

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int
idx(const int i_off, const int j_off, const int k_off)
{
return (k_off + 1) + 3 * (j_off + 1) + 9 * (i_off + 1);
}

} // namespace

namespace amr_wind::multiphase {

/** Young's finite-difference gradient scheme.
Expand Down Expand Up @@ -70,56 +80,106 @@ youngs_finite_difference_normal_neumann(
const int i,
const int j,
const int k,
const int ibdy,
const int jbdy,
const int kbdy,
amrex::Array4<int const> const& iblank,
amrex::Array4<amrex::Real const> const& volfrac,
amrex::Real& mx,
amrex::Real& my,
amrex::Real& mz) noexcept
{
// Do neumann condition via indices
const int im1 = ibdy == -1 ? i : i - 1;
const int jm1 = jbdy == -1 ? j : j - 1;
const int km1 = kbdy == -1 ? k : k - 1;
const int ip1 = ibdy == +1 ? i : i + 1;
const int jp1 = jbdy == +1 ? j : j + 1;
const int kp1 = kbdy == +1 ? k : k + 1;

amrex::Real mm1 = volfrac(im1, jm1, km1) + volfrac(im1, jm1, kp1) +
volfrac(im1, jp1, km1) + volfrac(im1, jp1, kp1) +
2.0 * (volfrac(im1, jm1, k) + volfrac(im1, jp1, k) +
volfrac(im1, j, km1) + volfrac(im1, j, kp1)) +
4.0 * volfrac(im1, j, k);
amrex::Real mm2 = volfrac(ip1, jm1, km1) + volfrac(ip1, jm1, kp1) +
volfrac(ip1, jp1, km1) + volfrac(ip1, jp1, kp1) +
2.0 * (volfrac(ip1, jm1, k) + volfrac(ip1, jp1, k) +
volfrac(ip1, j, km1) + volfrac(ip1, j, kp1)) +
4.0 * volfrac(ip1, j, k);
// Do neumann condition using iblank array
// Cells that are not iblank == -1 get calculated with extrapolation using
// the average of all valid (relying only on iblank == -1 cells) gradients
const int ibl_c = iblank(i, j, k);
amrex::GpuArray<amrex::Real, 6> dvf{0., 0., 0., 0., 0., 0.};
const amrex::IntVect iv{i, j, k};
for (int ddir = 0; ddir < 3; ++ddir) {
int ct_0 = 0;
int ct_1 = 0;
const int odir0 = (ddir + 1) % 3;
const int odir1 = (ddir + 2) % 3;
for (int n0 = -1; n0 <= 1; ++n0) {
for (int n1 = -1; n1 <= 1; ++n1) {
amrex::IntVect iv_c = iv;
iv_c[odir0] += n0;
iv_c[odir1] += n1;
amrex::IntVect iv_p = iv_c;
amrex::IntVect iv_m = iv_c;
iv_p[ddir] += 1;
iv_m[ddir] += -1;
if (iblank(iv_m) == iblank(iv_c) && iblank(iv_m) == ibl_c) {
dvf[ddir] += volfrac(iv_c) - volfrac(iv_m);
ct_0++;
}
if (iblank(iv_p) == iblank(iv_c) && iblank(iv_p) == ibl_c) {
dvf[ddir + 3] += volfrac(iv_p) - volfrac(iv_c);
ct_1++;
}
}
}
dvf[ddir] /= (amrex::Real)ct_0 + constants::EPS;
dvf[ddir + 3] /= (amrex::Real)ct_1 + constants::EPS;
}

amrex::GpuArray<amrex::Real, 27> vf;
vf.fill(0.);
for (int n0 = -1; n0 <= 1; ++n0) {
for (int n1 = -1; n1 <= 1; ++n1) {
for (int n2 = -1; n2 <= 1; ++n2) {
amrex::IntVect iv_l = iv;
iv_l[0] += n0;
iv_l[1] += n1;
iv_l[2] += n2;
vf[idx(n0, n1, n2)] =
iblank(iv_l) == ibl_c
? volfrac(iv_l)
: std::max(
0.,
std::min(
1., volfrac(iv) +
(amrex::Real)n0 *
dvf[0 + 3 * std::max(0, n0)] +
(amrex::Real)n1 *
dvf[1 + 3 * std::max(0, n1)] +
(amrex::Real)n2 *
dvf[2 + 3 * std::max(0, n2)]));
}
}
}

amrex::Real mm1 = vf[idx(-1, -1, -1)] + vf[idx(-1, -1, 1)] +
vf[idx(-1, 1, -1)] + vf[idx(-1, 1, 1)] +
2.0 * (vf[idx(-1, -1, 0)] + vf[idx(-1, 1, 0)] +
vf[idx(-1, 0, -1)] + vf[idx(-1, 0, 1)]) +
4.0 * vf[idx(-1, 0, 0)];
amrex::Real mm2 = vf[idx(1, -1, -1)] + vf[idx(1, -1, 1)] +
vf[idx(1, 1, -1)] + vf[idx(1, 1, 1)] +
2.0 * (vf[idx(1, -1, 0)] + vf[idx(1, 1, 0)] +
vf[idx(1, 0, -1)] + vf[idx(1, 0, 1)]) +
4.0 * vf[idx(1, 0, 0)];
mx = mm1 - mm2;

mm1 = volfrac(im1, jm1, km1) + volfrac(im1, jm1, kp1) +
volfrac(ip1, jm1, km1) + volfrac(ip1, jm1, kp1) +
2.0 * (volfrac(im1, jm1, k) + volfrac(ip1, jm1, k) +
volfrac(i, jm1, km1) + volfrac(i, jm1, kp1)) +
4.0 * volfrac(i, jm1, k);
mm2 = volfrac(im1, jp1, km1) + volfrac(im1, jp1, kp1) +
volfrac(ip1, jp1, km1) + volfrac(ip1, jp1, kp1) +
2.0 * (volfrac(im1, jp1, k) + volfrac(ip1, jp1, k) +
volfrac(i, jp1, km1) + volfrac(i, jp1, kp1)) +
4.0 * volfrac(i, jp1, k);
mm1 = vf[idx(-1, -1, -1)] + vf[idx(-1, -1, 1)] + vf[idx(1, -1, -1)] +
vf[idx(1, -1, 1)] +
2.0 * (vf[idx(-1, -1, 0)] + vf[idx(1, -1, 0)] + vf[idx(0, -1, -1)] +
vf[idx(0, -1, 1)]) +
4.0 * vf[idx(0, -1, 0)];
mm2 = vf[idx(-1, 1, -1)] + vf[idx(-1, 1, 1)] + vf[idx(1, 1, -1)] +
vf[idx(1, 1, 1)] +
2.0 * (vf[idx(-1, 1, 0)] + vf[idx(1, 1, 0)] + vf[idx(0, 1, -1)] +
vf[idx(0, 1, 1)]) +
4.0 * vf[idx(0, 1, 0)];
my = mm1 - mm2;

mm1 = volfrac(im1, jm1, km1) + volfrac(im1, jp1, km1) +
volfrac(ip1, jm1, km1) + volfrac(ip1, jp1, km1) +
2.0 * (volfrac(im1, j, km1) + volfrac(ip1, j, km1) +
volfrac(i, jm1, km1) + volfrac(i, jp1, km1)) +
4.0 * volfrac(i, j, km1);
mm2 = volfrac(im1, jm1, kp1) + volfrac(im1, jp1, kp1) +
volfrac(ip1, jm1, kp1) + volfrac(ip1, jp1, kp1) +
2.0 * (volfrac(im1, j, kp1) + volfrac(ip1, j, kp1) +
volfrac(i, jm1, kp1) + volfrac(i, jp1, kp1)) +
4.0 * volfrac(i, j, kp1);
mm1 = vf[idx(-1, -1, -1)] + vf[idx(-1, 1, -1)] + vf[idx(1, -1, -1)] +
vf[idx(1, 1, -1)] +
2.0 * (vf[idx(-1, 0, -1)] + vf[idx(1, 0, -1)] + vf[idx(0, -1, -1)] +
vf[idx(0, 1, -1)]) +
4.0 * vf[idx(0, 0, -1)];
mm2 = vf[idx(-1, -1, 1)] + vf[idx(-1, 1, 1)] + vf[idx(1, -1, 1)] +
vf[idx(1, 1, 1)] +
2.0 * (vf[idx(-1, 0, 1)] + vf[idx(1, 0, 1)] + vf[idx(0, -1, 1)] +
vf[idx(0, 1, 1)]) +
4.0 * vf[idx(0, 0, 1)];
mz = mm1 - mm2;
}

Expand Down
6 changes: 6 additions & 0 deletions amr-wind/overset/OversetOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ private:
// Check for multiphase sim
bool m_vof_exists{false};

// Option to turn off all multiphase-specific treatments (for testing and
// comparison)
bool m_disable_mphase_ops{false};

// Coupling options
bool m_replace_gradp_postsolve{true};

Expand All @@ -40,6 +44,8 @@ private:
amrex::Real m_relative_length_scale = 1.5;
amrex::Real m_upw_margin = 0.1;
amrex::Real m_target_cutoff = 0.0; // proc_tgvof_tol
// Maximum pseudoCFL
amrex::Real m_pCFL = 1.0;

// Tolerance for VOF-related bound checks
const amrex::Real m_vof_tol = 1e-12;
Expand Down
Loading
Loading