31using namespace amrex::literals;
59 }
else if (mid > hi) {
73 std::acos((pp > 0.0_rt) ?
amrex::Clamp(q / pp, -1.0_rt, 1.0_rt) : 1.0_rt) / 3.0_rt;
75 return p12 * (std::sqrt(3.0_rt * (1.0_rt - cs * cs)) - cs);
88 constexpr amrex::Real tiny = std::numeric_limits<amrex::Real>::epsilon();
91 sort3(b1, b2, b3, m1, m2, m3);
97 const amrex::Real V1 = (pr > 0.0_rt) ? m1 * m1 * m1 / pr : 0.0_rt;
98 const amrex::Real V2 = V1 + 0.5_rt * (m2 - m1) / (m3 + tiny);
103 V3 = (3.0_rt * m3 * (m3 - m1) + m1 * m1 - t2 * t2 * (t2 / m1)) / (6.0_rt * m2 * m3);
105 V3 = 0.5_rt * m12 / (m3 + tiny);
113 alpha = std::cbrt(pr * ch);
114 }
else if (ch < V2) {
115 alpha = 0.5_rt * (m1 + std::sqrt(m1 * m1 + 8.0_rt * m2 * m3 * (ch - V1)));
116 }
else if (ch < V3) {
118 const amrex::Real q = 1.5_rt * m1 * m2 * (m12 - 2.0_rt * m3 * ch);
120 }
else if (m12 < m3) {
121 alpha = m3 * ch + 0.5_rt * m12;
123 const amrex::Real p = m1 * (m2 + m3) + m2 * m3 - 0.25_rt;
124 const amrex::Real q = 1.5_rt * m1 * m2 * m3 * (0.5_rt - ch);
129 alpha = 1.0_rt - alpha;
146 constexpr amrex::Real tiny = std::numeric_limits<amrex::Real>::epsilon();
161 sort3(n1 * dr0, n2, n3, b1, b2, b3);
164 if (b2 < negligible) {
167 if (b1 < negligible) {
178 v = a * a * a / (6.0_rt * b1 * b2 * b3);
180 v = a * (a - b1) / (2.0_rt * b2 * b3) + b1 * b1 / (6.0_rt * b2 * b3);
183 v = (3.0_rt * a * (a - b1) + b1 * b1 - t2 * t2 * (t2 / b1)) / (6.0_rt * b2 * b3);
184 }
else if (b3 < b12) {
187 v = (3.0_rt * a * (a - b1) + b1 * b1 - t2 * t2 * (t2 / b1) - t3 * t3 * (t3 / b1)) /
190 v = (a - 0.5_rt * b12) / b3;
194 return (al <= 0.5_rt) ? v : 1.0_rt - v;
202template <
typename Phi>
209 const int nsub = 8) {
215#if AMREX_SPACEDIM == 3
216 for (
int kk = 0; kk < nsub; ++kk) {
225 for (
int jj = 0; jj < nsub; ++jj) {
229 for (
int ii = 0; ii < nsub; ++ii) {
233 if (phi(x, y, z) > 0.0_rt) {
257 const int idx[3] = {i, j, k};
261 for (
int a = 0; a < AMREX_SPACEDIM; ++a) {
263 alpha -= n[a] * (prob_lo[a] +
static_cast<amrex::Real>(idx[a]) * dx[a]);
264 norm += std::abs(m[a]);
266 if (
norm <= std::numeric_limits<amrex::Real>::min()) {
267 return (alpha >= 0.0_rt) ? 1.0_rt : 0.0_rt;
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_TERM(a, b, c)
__host__ __device__ void Swap(T &t1, T &t2) noexcept
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
__host__ __device__ constexpr T Clamp(const T &v, const T &lo, const T &hi)
Definition hydro_plic.cpp:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real plane_fraction(const int i, const int j, const int k, amrex::GeometryData const &geomdata, const amrex::Real n[AMREX_SPACEDIM], const amrex::Real d)
Exact liquid volume fraction of cell (i,j,k) for the half space n.x <= d (physical coordinates,...
Definition hydro_plic_K.H:249
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real volume_intercept(const amrex::Real b1, const amrex::Real b2, const amrex::Real b3, const amrex::Real volF)
Analytic plane constant alpha such that the region m1*x1 + m2*x2 + m3*x3 <= alpha of the unit cube ha...
Definition hydro_plic_K.H:84
static constexpr amrex::Real pure_tol
Definition hydro_plic_K.H:39
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real cell_fraction(const int i, const int j, const int k, amrex::GeometryData const &geomdata, Phi const &phi, const int nsub=8)
Liquid volume fraction of cell (i,j,k) for an implicit surface phi(x) > 0 inside the liquid,...
Definition hydro_plic_K.H:204
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_mixed(const amrex::Real f) noexcept
Whether a cell with volume fraction f holds the interface.
Definition hydro_plic_K.H:43
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)
Liquid volume fraction of the sub-box [r0, r0+dr0] x [0,1] x [0,1] of the unit cube cut by m1*x1 + m2...
Definition hydro_plic_K.H:140
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real trig_root(const amrex::Real p, const amrex::Real q) noexcept
The root of the cubic of volume_intercept in its two upper volume ranges, in the trigonometric form o...
Definition hydro_plic_K.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void sort3(const amrex::Real a, const amrex::Real b, const amrex::Real c, amrex::Real &lo, amrex::Real &mid, amrex::Real &hi) noexcept
a, b and c in ascending order, as lo <= mid <= hi.
Definition hydro_plic_K.H:48
__host__ __device__ void ignore_unused(const Ts &...)
__host__ __device__ T norm(const GpuComplex< T > &a_z) noexcept
__host__ __device__ const Real * CellSize() const noexcept
__host__ __device__ const Real * ProbLo() const noexcept