/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#include "AMReX_REAL.H"
6
7using namespace amrex::literals;
8
10
11static void define_rho0(
12 amr_wind::Field& rho0,
13 const amrex::Real rho1,
14 const amrex::Real rho2,
15 const amrex::Real wlev,
16 const amrex::Vector<amrex::Geometry>& geom)
17{
18 for (int lev = 0; lev < rho0.repo().num_active_levels(); ++lev) {
19 const auto& dx = geom[lev].CellSizeArray();
20 const auto& problo = geom[lev].ProbLoArray();
21 const auto& rho0_arrs = rho0(lev).arrays();
22 amrex::ParallelFor(
23 rho0(lev),
24 [=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
25 const amrex::Real zbtm = problo[2] + k * dx[2];
26 const amrex::Real vof = amrex::max<amrex::Real>(
27 amrex::min<amrex::Real>(1.0_rt, (wlev - zbtm) / dx[2]),
28 0.0_rt);
29 rho0_arrs[nbx](i, j, k) = vof * rho1 + (1.0_rt - vof) * rho2;
30 });
31 }
32 amrex::Gpu::streamSynchronize();
33}
34
35static void define_p0(
37 const amrex::Real rho1,
38 const amrex::Real rho2,
39 const amrex::Real wlev,
40 const amrex::Real grav_z,
41 const amrex::Vector<amrex::Geometry>& geom)
42{
43 for (int lev = 0; lev < p0.repo().num_active_levels(); ++lev) {
44 const auto& dx = geom[lev].CellSizeArray();
45 const auto& problo = geom[lev].ProbLoArray();
46 const auto& probhi = geom[lev].ProbHiArray();
47 auto p0_arrs = p0(lev).arrays();
48 amrex::ParallelFor(
49 p0(lev), p0.num_grow(),
50 [=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
51 const amrex::Real z = problo[2] + k * dx[2];
52 // Integrated (top-down in z) phase heights to pressure node
53 const amrex::Real ih_g = amrex::max<amrex::Real>(
54 0.0_rt, amrex::min(probhi[2] - wlev, probhi[2] - z));
55 const amrex::Real ih_l = amrex::max<amrex::Real>(
56 0.0_rt,
57 amrex::min<amrex::Real>(wlev - z, wlev - problo[2]));
58 // Integrated rho at pressure node
59 const amrex::Real irho = rho1 * ih_l + rho2 * ih_g;
60
61 // Add term to reference pressure
62 p0_arrs[nbx](i, j, k) = -irho * grav_z;
63 });
64 }
65 amrex::Gpu::streamSynchronize();
66}
67
68} // namespace amr_wind::hydrostatic
69
70#endif
Definition Field.H:116
const amrex::IntVect & num_grow() const
Ghost cells.
Definition Field.H:137
FieldRepo & repo() const
FieldRepo instance that manages this field.
Definition Field.H:159
Definition hydrostatic_ops.H:9
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:35
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:11