Skip to content

Commit

Permalink
Store surface heat flux in ghost cell
Browse files Browse the repository at this point in the history
The kinematic heat flux SFS_hfx3_lev now has dual uses.

- The surface value (at k=-1) is used when calculating the diffusive z-flux at
  k=0 (zflux is staggered in z). This is the modeled flux that comes from
  MOSTStress when applying BCs.

- When using Deardorff, the interior values are the subgrid heat fluxes that go
  into the buoyancy term. These are based on resolved temperature gradients and
  modeled eddy diffusivity.
  • Loading branch information
ewquon committed Mar 11, 2024
1 parent fec84af commit bb39143
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/BoundaryConditions/ABLMost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ ABLMost::compute_most_bcs (const int& lev,
}
#ifdef ERF_EXPLICIT_MOST_STRESS
else if ((k == klo-1) && vbx.contains(i,j,k)) {
hfx_arr(i,j,klo) = Tflux;
hfx_arr(i,j,klo-1) = Tflux;
}
#endif
});
Expand Down
8 changes: 4 additions & 4 deletions Source/Diffusion/DiffusionSrcForState_N.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
- 3. * cell_prim(i, j, k , prim_index)
+ (1./3.) * cell_prim(i, j, k+1, prim_index) ) * dz_inv;
} else if (most_on_zlo && (qty_index == RhoTheta_comp)) {
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * (cell_prim(i, j, k, prim_index) - cell_prim(i, j, k-1, prim_index)) * dz_inv;
}
Expand Down Expand Up @@ -291,7 +291,7 @@ DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
+ (1./3.) * cell_prim(i, j, k+1, prim_index) ) * dz_inv;
} else if (most_on_zlo && (qty_index == RhoTheta_comp)) {
Real rhoFace = 0.5 * ( cell_data(i, j, k, Rho_comp) + cell_data(i, j, k-1, Rho_comp) );
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * (cell_prim(i, j, k, prim_index) - cell_prim(i, j, k-1, prim_index)) * dz_inv;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
- 3. * cell_prim(i, j, k , prim_index)
+ (1./3.) * cell_prim(i, j, k+1, prim_index) ) * dz_inv;
} else if (most_on_zlo && (qty_index == RhoTheta_comp)) {
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * (cell_prim(i, j, k, prim_index) - cell_prim(i, j, k-1, prim_index)) * dz_inv;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ DiffusionSrcForState_N (const amrex::Box& bx, const amrex::Box& domain,
+ (1./3.) * cell_prim(i, j, k+1, prim_index) ) * dz_inv;
} else if (most_on_zlo && (qty_index == RhoTheta_comp)) {
Real rhoFace = 0.5 * ( cell_data(i, j, k, Rho_comp) + cell_data(i, j, k-1, Rho_comp) );
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * (cell_prim(i, j, k, prim_index) - cell_prim(i, j, k-1, prim_index)) * dz_inv;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Diffusion/DiffusionSrcForState_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,

if (most_on_zlo && (qty_index == RhoTheta_comp)) {
// set the exact value from MOST, don't need finite diff
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * GradCz / met_h_zeta;
}
Expand Down Expand Up @@ -349,7 +349,7 @@ DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,
if (most_on_zlo && (qty_index == RhoTheta_comp)) {
// set the exact value from MOST, don't need finite diff
Real rhoFace = 0.5 * ( cell_data(i, j, k, Rho_comp) + cell_data(i-1, j, k, Rho_comp) );
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * GradCz / met_h_zeta;
}
Expand Down Expand Up @@ -426,7 +426,7 @@ DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,

if (most_on_zlo && (qty_index == RhoTheta_comp)) {
// set the exact value from MOST, don't need finite diff
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * GradCz / met_h_zeta;
}
Expand Down Expand Up @@ -501,7 +501,7 @@ DiffusionSrcForState_T (const amrex::Box& bx, const amrex::Box& domain,
if (most_on_zlo && (qty_index == RhoTheta_comp)) {
// set the exact value from MOST, don't need finite diff
Real rhoFace = 0.5 * ( cell_data(i, j, k, Rho_comp) + cell_data(i-1, j, k, Rho_comp) );
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,k);
zflux(i,j,k,qty_index) = -rhoFace * hfx_z(i,j,-1);
} else {
zflux(i,j,k,qty_index) = rhoAlpha * GradCz / met_h_zeta;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ERF_make_new_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ ERF::update_diffusive_arrays (int lev, const BoxArray& ba, const DistributionMap
}
SFS_hfx1_lev[lev] = std::make_unique<MultiFab>( ba , dm, 1, IntVect(1,1,0) );
SFS_hfx2_lev[lev] = std::make_unique<MultiFab>( ba , dm, 1, IntVect(1,1,0) );
SFS_hfx3_lev[lev] = std::make_unique<MultiFab>( ba , dm, 1, IntVect(1,1,0) );
SFS_hfx3_lev[lev] = std::make_unique<MultiFab>( ba , dm, 1, IntVect(1,1,1) );
SFS_diss_lev[lev] = std::make_unique<MultiFab>( ba , dm, 1, IntVect(1,1,0) );
SFS_hfx1_lev[lev]->setVal(0.);
SFS_hfx2_lev[lev]->setVal(0.);
Expand Down

0 comments on commit bb39143

Please sign in to comment.