1#ifndef SPLIT_ADVECTION_H_
2#define SPLIT_ADVECTION_H_
5#include <AMReX_FArrayBox.H>
6#include <AMReX_BCRec.H>
16 const amrex::Real dtdx,
17 const amrex::Real velL,
18 const amrex::Real velR,
19 amrex::Array4<amrex::Real const>
const& volfrac,
20 amrex::Array4<amrex::Real>
const& vofL,
21 amrex::Array4<amrex::Real>
const& vofR)
23 using namespace amrex;
25 constexpr Real tiny = 1e-12;
26 Real mx = 0.0, my = 0.0, mz = 0.0, alpha = 0.0;
28 Real aL = velL * dtdx;
29 Real aR = velR * dtdx;
34 if (std::abs(volfrac(i, j, k) - 1.0) <= tiny) {
41 }
else if (volfrac(i, j, k) > tiny) {
42 fit_plane(i, j, k, volfrac, mx, my, mz, alpha);
48 vofL(i, j, k) =
cut_volume(mx, my, mz, alpha, x0, deltax);
53 vofR(i, j, k) =
cut_volume(mx, my, mz, alpha, x0, deltax);
55 }
else if (dir == 1) {
58 vofL(i, j, k) =
cut_volume(my, mz, mx, alpha, x0, deltax);
63 vofR(i, j, k) =
cut_volume(my, mz, mx, alpha, x0, deltax);
65 }
else if (dir == 2) {
68 vofL(i, j, k) =
cut_volume(mz, mx, my, alpha, x0, deltax);
73 vofR(i, j, k) =
cut_volume(mz, mx, my, alpha, x0, deltax);
84 const amrex::Real dxi,
85 const amrex::Real velL,
86 const amrex::Real velR,
87 amrex::Array4<amrex::Real>
const& volfrac,
88 amrex::Array4<amrex::Real const>
const& fluxF,
89 amrex::Array4<amrex::Real const>
const& fluxC)
93 volfrac(i, j, k) += (fluxF(i, j, k) - fluxF(i + 1, j, k)) * dxi +
94 fluxC(i, j, k) * (velR - velL);
95 }
else if (dir == 1) {
96 volfrac(i, j, k) += (fluxF(i, j, k) - fluxF(i, j + 1, k)) * dxi +
97 fluxC(i, j, k) * (velR - velL);
98 }
else if (dir == 2) {
99 volfrac(i, j, k) += (fluxF(i, j, k) - fluxF(i, j, k + 1)) * dxi +
100 fluxC(i, j, k) * (velR - velL);
103 volfrac(i, j, k) = amrex::max<amrex::Real>(
104 0.0, amrex::min<amrex::Real>(1.0, volfrac(i, j, k)));
112 const amrex::Real disp,
113 amrex::Array4<amrex::Real>
const& f_f,
114 amrex::Array4<amrex::Real>
const& vofL,
115 amrex::Array4<amrex::Real>
const& vofR,
116 amrex::Array4<amrex::Real>
const& advalpha_f,
117 amrex::GpuArray<BC, AMREX_SPACEDIM * 2> BCs,
121 auto bclo = BCs[amrex::Orientation(dir, amrex::Orientation::low)];
122 auto bchi = BCs[amrex::Orientation(dir, amrex::Orientation::high)];
129 vofR(domlo - 1, j, k) = 0.0;
130 vofL(domlo, j, k) = 0.0;
136 if (i == domhi + 1) {
137 vofL(domhi + 1, j, k) = 0.0;
138 vofR(domhi, j, k) = 0.0;
143 advalpha_f(i, j, k) = vofR(i - 1, j, k) + vofL(i, j, k);
144 f_f(i, j, k) = advalpha_f(i, j, k) * disp;
147 }
else if (dir == 1) {
151 vofR(i, domlo - 1, k) = 0.0;
152 vofL(i, domlo, k) = 0.0;
157 if (j == domhi + 1) {
158 vofL(i, domhi + 1, k) = 0.0;
159 vofR(i, domhi, k) = 0.0;
162 advalpha_f(i, j, k) = vofR(i, j - 1, k) + vofL(i, j, k);
163 f_f(i, j, k) = advalpha_f(i, j, k) * disp;
164 }
else if (dir == 2) {
168 vofR(i, j, domlo - 1) = 0.0;
169 vofL(i, j, domlo) = 0.0;
174 if (k == domhi + 1) {
175 vofL(i, j, domhi + 1) = 0.0;
176 vofR(i, j, domhi) = 0.0;
179 advalpha_f(i, j, k) = vofR(i, j, k - 1) + vofL(i, j, k);
180 f_f(i, j, k) = advalpha_f(i, j, k) * disp;
184AMREX_GPU_DEVICE AMREX_FORCE_INLINE
void c_mask(
188 amrex::Array4<amrex::Real>
const& volfrac,
189 amrex::Array4<amrex::Real>
const& volfrac_masked)
191 if (volfrac(i, j, k) > 0.5) {
192 volfrac_masked(i, j, k) = 1.0;
194 volfrac_masked(i, j, k) = 0.0;
202 amrex::Array4<amrex::Real>
const& volfrac)
204 amrex::Real small_vof = 1e-6;
205 amrex::Real volFxL = volfrac(i - 1, j, k);
206 amrex::Real volFxR = volfrac(i + 1, j, k);
207 amrex::Real volFyL = volfrac(i, j - 1, k);
208 amrex::Real volFyR = volfrac(i, j + 1, k);
209 amrex::Real volFzL = volfrac(i, j, k - 1);
210 amrex::Real volFzR = volfrac(i, j, k + 1);
212 if (volfrac(i, j, k) > 0.0 && volFxL < small_vof && volFxR < small_vof &&
213 volFyL < small_vof && volFyR < small_vof && volFzL < small_vof &&
214 volFzR < small_vof) {
215 volfrac(i, j, k) = 0.0;
Definition height_functions.H:8
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void fit_plane(const int i, const int j, const int k, amrex::Array4< amrex::Real const > const &volfrac, amrex::Real &mx, amrex::Real &my, amrex::Real &mz, amrex::Real &alpha)
Definition volume_fractions.H:447
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void balance_eulerian_fluxes(const int i, const int j, const int k, const int dir, const amrex::Real dxi, const amrex::Real velL, const amrex::Real velR, amrex::Array4< amrex::Real > const &volfrac, amrex::Array4< amrex::Real const > const &fluxF, amrex::Array4< amrex::Real const > const &fluxC)
Definition split_advection.H:79
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void eulerian_implicit(const int i, const int j, const int k, const int dir, const amrex::Real dtdx, const amrex::Real velL, const amrex::Real velR, amrex::Array4< amrex::Real const > const &volfrac, amrex::Array4< amrex::Real > const &vofL, amrex::Array4< amrex::Real > const &vofR)
Definition split_advection.H:11
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void c_mask(const int i, const int j, const int k, amrex::Array4< amrex::Real > const &volfrac, amrex::Array4< amrex::Real > const &volfrac_masked)
Definition split_advection.H:184
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real cut_volume(const amrex::Real m1, const amrex::Real m2, const amrex::Real m3, const amrex::Real alpha, const amrex::Real r0, const amrex::Real dr0) noexcept
Definition volume_fractions.H:360
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void fluxes_bc_save(const int i, const int j, const int k, const int dir, const amrex::Real disp, amrex::Array4< amrex::Real > const &f_f, amrex::Array4< amrex::Real > const &vofL, amrex::Array4< amrex::Real > const &vofR, amrex::Array4< amrex::Real > const &advalpha_f, amrex::GpuArray< BC, AMREX_SPACEDIM *2 > BCs, const int domlo, const int domhi)
Definition split_advection.H:107
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void remove_vof_debris(const int i, const int j, const int k, amrex::Array4< amrex::Real > const &volfrac)
Definition split_advection.H:198
Definition console_io.cpp:25