Skip to content

Commit

Permalink
add temperature bubble initialization for coupling test with ERF
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul1992 committed Sep 9, 2024
1 parent dbfcf1d commit 42f9df8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions amr-wind/wind_energy/ABLFieldInit.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ public:
void init_tke(const amrex::Geometry& geom, amrex::MultiFab& tke) const;

private:
// ABL-with-bubble

//! Initial bubble location
amrex::Vector<amrex::Real> m_bubble_loc{{0.25, 0.25, 0.5}};

//! Initial bubble radius
amrex::Real m_bubble_radius{0.1};

//! Initial bubble
amrex::Real m_bubble_temp_ratio{1.1};

//! Whether or not to have temperature bubble
bool m_use_bubble{0};

//! Initial velocity components
amrex::Vector<amrex::Real> m_vel;

Expand Down
24 changes: 24 additions & 0 deletions amr-wind/wind_energy/ABLFieldInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ void ABLFieldInit::initialize_from_inputfile()
{
amrex::ParmParse pp_abl("ABL");

// ABL-with-bubble
pp_abl.query("use_bubble", m_use_bubble);
if (m_use_bubble) {
amrex::Print() << "Initializing with bubble" << std::endl;
pp_abl.getarr("bubble_loc", m_bubble_loc);
pp_abl.query("bubble_radius", m_bubble_radius);
pp_abl.query("bubble_temp_ratio", m_bubble_temp_ratio);
} else {
amrex::Print() << "Not initializing with bubble" << std::endl;
}

// Temperature variation as a function of height
pp_abl.getarr("temperature_heights", m_theta_heights);
pp_abl.getarr("temperature_values", m_theta_values);
Expand Down Expand Up @@ -219,8 +230,14 @@ void ABLFieldInit::operator()(
const amrex::Real bottom_v_vel = m_bottom_vel[1];
const amrex::Real bottom_w_vel = m_bottom_vel[2];

const amrex::Real bcx = m_bubble_loc[0];
const amrex::Real bcy = m_bubble_loc[1];
const amrex::Real bcz = m_bubble_loc[2];

amrex::ParallelFor(
vbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
const amrex::Real x = problo[0] + (i + 0.5) * dx[0];
const amrex::Real y = problo[1] + (j + 0.5) * dx[1];
const amrex::Real z = problo[2] + (k + 0.5) * dx[2];

density(i, j, k) = rho_init;
Expand All @@ -240,6 +257,13 @@ void ABLFieldInit::operator()(

temperature(i, j, k, 0) += theta;

amrex::Real ratio = 1.0;
if (m_use_bubble) {
amrex::Real radius = std::sqrt((x-bcx)*(x-bcx) + (y-bcy)*(y-bcy) + (z-bcz)*(z-bcz));
ratio = 1.0 + (m_bubble_temp_ratio - 1.0) * exp(-0.5 * radius* radius / (m_bubble_radius * m_bubble_radius));
}
temperature(i, j, k, 0) *= ratio;

if (linear_profile) {
velocity(i, j, k, 0) =
bottom_u_vel + z * (top_u_vel - bottom_u_vel) /
Expand Down

0 comments on commit 42f9df8

Please sign in to comment.