/home/runner/work/amr-wind/amr-wind/amr-wind/physics/multiphase/hydrostatic_ops.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/physics/multiphase/hydrostatic_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
hydrostatic_ops.H
Go to the documentation of this file.
1#ifndef HYDROSTATIC_OPS_H
2#define HYDROSTATIC_OPS_H
3#include <AMReX_MultiFabUtil.H>
5
7
8static void define_rho0(
9 amr_wind::Field& rho0,
10 const amrex::Real rho1,
11 const amrex::Real rho2,
12 const amrex::Real wlev,
13 const amrex::Vector<amrex::Geometry>& geom)
14{
15 for (int lev = 0; lev < rho0.repo().num_active_levels(); ++lev) {
16 const auto& dx = geom[lev].CellSizeArray();
17 const auto& problo = geom[lev].ProbLoArray();
18 for (amrex::MFIter mfi(rho0(lev)); mfi.isValid(); ++mfi) {
19 amrex::Box const& bx = mfi.validbox();
20 auto rho0_arr = rho0(lev).array(mfi);
21 amrex::ParallelFor(
22 bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
23 const amrex::Real zbtm = problo[2] + k * dx[2];
24 const amrex::Real vof =
25 amrex::max(amrex::min(1.0, (wlev - zbtm) / dx[2]), 0.0);
26 rho0_arr(i, j, k) = vof * rho1 + (1.0 - vof) * rho2;
27 });
28 }
29 }
30}
31
32static void define_p0(
34 const amrex::Real rho1,
35 const amrex::Real rho2,
36 const amrex::Real wlev,
37 const amrex::Real grav_z,
38 const amrex::Vector<amrex::Geometry>& geom)
39{
40 for (int lev = 0; lev < p0.repo().num_active_levels(); ++lev) {
41 const auto& dx = geom[lev].CellSizeArray();
42 const auto& problo = geom[lev].ProbLoArray();
43 const auto& probhi = geom[lev].ProbHiArray();
44 for (amrex::MFIter mfi(p0(lev)); mfi.isValid(); ++mfi) {
45 amrex::Box const& nbx = mfi.grownnodaltilebox();
46 auto p0_arr = p0(lev).array(mfi);
47 amrex::ParallelFor(
48 nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
49 const amrex::Real z = problo[2] + k * dx[2];
50 // Integrated (top-down in z) phase heights to pressure node
51 amrex::Real ih_g = amrex::max(
52 0.0, amrex::min(probhi[2] - wlev, probhi[2] - z));
53 amrex::Real ih_l =
54 amrex::max(0.0, amrex::min(wlev - z, wlev - problo[2]));
55 // Integrated rho at pressure node
56 const amrex::Real irho = rho1 * ih_l + rho2 * ih_g;
57
58 // Add term to reference pressure
59 p0_arr(i, j, k) = -irho * grav_z;
60 });
61 }
62 }
63}
64
65} // namespace amr_wind::hydrostatic
66
67#endif
Definition Field.H:116
FieldRepo & repo() const
FieldRepo instance that manages this field.
Definition Field.H:159
Definition hydrostatic_ops.H:6
static void define_p0(amr_wind::Field &p0, const amrex::Real rho1, const amrex::Real rho2, const amrex::Real wlev, const amrex::Real grav_z, const amrex::Vector< amrex::Geometry > &geom)
Definition hydrostatic_ops.H:32
static void define_rho0(amr_wind::Field &rho0, const amrex::Real rho1, const amrex::Real rho2, const amrex::Real wlev, const amrex::Vector< amrex::Geometry > &geom)
Definition hydrostatic_ops.H:8