Skip to content

Commit

Permalink
ugh redo a bunch
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf committed Dec 20, 2024
1 parent 4a31060 commit 587eaa3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ void ABLMeanBoussinesq::operator()(
{
const auto& problo = m_mesh.Geom(lev).ProbLoArray();
const auto& dx = m_mesh.Geom(lev).CellSizeArray();
amrex::FArrayBox beta_fab(
bx, 1, amrex::The_Async_Arena());
amrex::Array4<amrex::Real> const& beta_arr =
beta_fab.array();
m_transport.beta(beta_arr);

const auto& beta = (*m_beta)(lev).const_array(mfi);
const auto& ref_theta = (*m_ref_theta)(lev).const_array(mfi);
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> gravity{
Expand Down
48 changes: 29 additions & 19 deletions amr-wind/transport_models/ConstTransport.H
Original file line number Diff line number Diff line change
Expand Up @@ -164,33 +164,43 @@ public:
inline std::unique_ptr<ScratchField> beta() const override
{
auto beta = m_repo.create_scratch_field(1, 1);
for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) {
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
for (amrex::MFIter mfi(beta(lev), mfi_info); mfi.isValid();
++mfi) {
const auto& bx = mfi.tilebox();
const auto& beta_arr = (*beta)(lev).array(mfi);
beta(lev, mfi, bx, beta_arr);
}
}
return beta;
}

//! Compute the thermal expansion coefficient
inline void beta(const int lev, const const amrex::MFIter& mfi,
const amrex::Box& bx, const amrex::Array4<amrex::Real>& beta) const override{

const amrex::Real beta_val = (m_reference_temperature > 0.0)
? 1.0 / m_reference_temperature
: m_constant_beta;

for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) {
(*beta)(lev).setVal(beta_val);
}

beta.setVal(beta_val);
if (m_repo.field_exists("vof")) {
const auto& vof = m_repo.get_field("vof");
for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) {
const auto& beta_arrs = (*beta)(lev).arrays();
const auto& vof_arrs = vof(lev).const_arrays();
amrex::ParallelFor(
(*beta)(lev), beta->num_grow(),
[=] AMREX_GPU_DEVICE(
int nbx, int i, int j, int k) noexcept {
if (vof_arrs[nbx](i, j, k) > constants::TIGHT_TOL) {
beta_arrs[nbx](i, j, k) = 0.0;
}
});
}
const auto& vof_arr = vof(lev).const_array(mfi);
amrex::ParallelFor(
bx, beta->num_grow(),
[=] AMREX_GPU_DEVICE(
int i, int j, int k) noexcept {
if (vof_arr(i, j, k) > constants::TIGHT_TOL) {
beta(i, j, k) = 0.0;
}
});
}

}

return beta;
}

inline amrex::Real reference_temperature() const override
{
Expand Down
5 changes: 4 additions & 1 deletion amr-wind/transport_models/TransportModel.H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef TRANSPORTMODEL_H
\#ifndef TRANSPORTMODEL_H
#define TRANSPORTMODEL_H

#include "amr-wind/core/Factory.H"
Expand Down Expand Up @@ -46,6 +46,9 @@ public:
//! Thermal expansion coefficient
virtual std::unique_ptr<ScratchField> beta() const = 0;

//! Thermal expansion coefficient
virtual void beta(const amrex::Array4<amrex::Real>& beta) const = 0;

//! Reference temperature
virtual amrex::Real reference_temperature() const = 0;

Expand Down

0 comments on commit 587eaa3

Please sign in to comment.