Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to multiphase hybrid coupling - nodal projection #1254

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions amr-wind/equation_systems/vof/volume_fractions.H
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,11 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool interface_band(
const int j,
const int k,
amrex::Array4<amrex::Real const> const& volfrac,
const int n_band = 1) noexcept
const int n_band = 1,
const amrex::Real tiny = 1e-12) noexcept
{
// n_band must be <= number of vof ghost cells (3)
constexpr amrex::Real tiny = 1e-12;

// Check if near interface
amrex::Real VOF_max = 0.0;
amrex::Real VOF_min = 1.0;
Expand Down
7 changes: 7 additions & 0 deletions amr-wind/overset/OversetOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ void OversetOps::pre_advance_work()
// Update pressure gradient using sharpened pressure field
update_gradp();
}
if (!m_disable_nodal_proj) {
// Calculate vof-dependent node mask
const auto& iblank = m_sim_ptr->repo().get_int_field("iblank_node");
const auto& vof = m_sim_ptr->repo().get_field("vof");
auto& mask = m_sim_ptr->repo().get_int_field("mask_node");
overset_ops::iblank_to_mask_vof(iblank, vof, mask);
}
}

// If pressure gradient will be replaced, store current pressure gradient
Expand Down
4 changes: 4 additions & 0 deletions amr-wind/overset/overset_ops_routines.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
#include "AMReX_MultiFab.H"
#include "amr-wind/equation_systems/vof/volume_fractions.H"
#include "amr-wind/overset/overset_ops_K.H"
#include "amr-wind/core/FieldRepo.H"

namespace amr_wind::overset_ops {

void iblank_to_mask_vof(
const IntField& iblank, const Field& vof, IntField& maskf);

// Populate approximate signed distance function using vof field
void populate_psi(
amrex::MultiFab& mf_psi,
Expand Down
55 changes: 54 additions & 1 deletion amr-wind/overset/overset_ops_routines.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
#include "amr-wind/overset/overset_ops_routines.H"

namespace amr_wind::overset_ops {

void iblank_to_mask_vof(
const IntField& iblank, const Field& voff, IntField& maskf)
{
const auto& nlevels = iblank.repo().mesh().finestLevel() + 1;
constexpr amrex::Real band_tol = 1e-4;

for (int lev = 0; lev < nlevels; ++lev) {
const auto& ibl = iblank(lev);
const auto& vof = voff(lev);
auto& mask = maskf(lev);

const auto& ibarrs = ibl.const_arrays();
const auto& vofarrs = vof.const_arrays();
const auto& marrs = mask.arrays();
amrex::ParallelFor(
ibl, ibl.n_grow,
[=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
// Default is masking all 0 and -1 iblanks
marrs[nbx](i, j, k) = amrex::max(ibarrs[nbx](i, j, k), 0);
// Check cells neighboring node for being near interface
bool near_interface = false;
for (int ii = i - 1; ii < i + 1; ii++) {
for (int jj = j - 1; jj < j + 1; jj++) {
for (int kk = k - 1; kk < k + 1; kk++) {
near_interface =
near_interface ||
amr_wind::multiphase::interface_band(
ii, jj, kk, vofarrs[nbx], 1, band_tol);
}
}
}
// Check nodes neighboring node for being near solid
bool near_solid = false;
for (int ii = i - 1; ii < i + 2; ii++) {
for (int jj = j - 1; jj < j + 2; jj++) {
for (int kk = k - 1; kk < k + 2; kk++) {
near_solid = ibarrs[nbx](ii, jj, kk) == 0
? true
: near_solid;
}
}
}
// Do mask -1 cells near interface
if (ibarrs[nbx](i, j, k) == -1 &&
(near_interface && !near_solid)) {
marrs[nbx](i, j, k) = 1;
}
});
}
amrex::Gpu::synchronize();
}

// Populate approximate signed distance function using vof field
void populate_psi(
amrex::MultiFab& mf_psi,
Expand Down Expand Up @@ -502,7 +555,7 @@ void replace_gradp(
amrex::ParallelFor(
mf_gp, mf_gp.n_grow,
[=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
if (iblank[nbx](i, j, k) == -1) {
if (iblank[nbx](i, j, k) <= 0) {
gp[nbx](i, j, k, 0) = gp0[nbx](i, j, k, 0);
gp[nbx](i, j, k, 1) = gp0[nbx](i, j, k, 1);
gp[nbx](i, j, k, 2) = gp0[nbx](i, j, k, 2);
Expand Down
Loading