/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 const auto& rho0_arrs = rho0(lev).arrays();
19 amrex::ParallelFor(
20 rho0(lev),
21 [=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
22 const amrex::Real zbtm = problo[2] + k * dx[2];
23 const amrex::Real vof =
24 amrex::max(amrex::min(1.0, (wlev - zbtm) / dx[2]), 0.0);
25 rho0_arrs[nbx](i, j, k) = vof * rho1 + (1.0 - vof) * rho2;
26 });
27 }
28 amrex::Gpu::streamSynchronize();
29}
30
31static void define_p0(
33 const amrex::Real rho1,
34 const amrex::Real rho2,
35 const amrex::Real wlev,
36 const amrex::Real grav_z,
37 const amrex::Vector<amrex::Geometry>& geom)
38{
39 for (int lev = 0; lev < p0.repo().num_active_levels(); ++lev) {
40 const auto& dx = geom[lev].CellSizeArray();
41 const auto& problo = geom[lev].ProbLoArray();
42 const auto& probhi = geom[lev].ProbHiArray();
43 auto p0_arrs = p0(lev).arrays();
44 amrex::ParallelFor(
45 p0(lev), p0.num_grow(),
46 [=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept {
47 const amrex::Real z = problo[2] + k * dx[2];
48 // Integrated (top-down in z) phase heights to pressure node
49 const amrex::Real ih_g = amrex::max(
50 0.0, amrex::min(probhi[2] - wlev, probhi[2] - z));
51 const amrex::Real ih_l =
52 amrex::max(0.0, amrex::min(wlev - z, wlev - problo[2]));
53 // Integrated rho at pressure node
54 const amrex::Real irho = rho1 * ih_l + rho2 * ih_g;
55
56 // Add term to reference pressure
57 p0_arrs[nbx](i, j, k) = -irho * grav_z;
58 });
59 }
60 amrex::Gpu::streamSynchronize();
61}
62
63} // namespace amr_wind::hydrostatic
64
65#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: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:31
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