-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actuator source passive scalar and tagging (#1170)
- Loading branch information
Showing
10 changed files
with
311 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef ACTUATORSOURCETAGGING_H | ||
#define ACTUATORSOURCETAGGING_H | ||
|
||
#include "amr-wind/core/Physics.H" | ||
#include "amr-wind/core/Field.H" | ||
#include "amr-wind/core/IntField.H" | ||
|
||
namespace amr_wind { | ||
|
||
/** Tracer Tagging physics | ||
* \ingroup physics | ||
*/ | ||
class ActuatorSourceTagging : public Physics::Register<ActuatorSourceTagging> | ||
{ | ||
public: | ||
static std::string identifier() { return "ActuatorSourceTagging"; } | ||
|
||
explicit ActuatorSourceTagging(CFDSim& sim); | ||
|
||
~ActuatorSourceTagging() override = default; | ||
|
||
void initialize_fields(int level, const amrex::Geometry& geom) override; | ||
|
||
void post_init_actions() override; | ||
|
||
void post_regrid_actions() override {} | ||
|
||
void pre_advance_work() override {} | ||
|
||
void post_advance_work() override; | ||
|
||
private: | ||
const FieldRepo& m_repo; | ||
Field* m_act_src{nullptr}; | ||
IntField* m_iblank{nullptr}; | ||
Field* m_tracer{nullptr}; | ||
amrex::Real m_src_threshold{0.1}; | ||
bool m_tag_hole{false}; | ||
bool m_tag_fringe{true}; | ||
bool m_has_act_src{false}; | ||
bool m_has_iblank{false}; | ||
}; | ||
|
||
} // namespace amr_wind | ||
|
||
#endif /* ACTUATORSOURCETAGGING_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include "amr-wind/CFDSim.H" | ||
#include "amr-wind/physics/ActuatorSourceTagging.H" | ||
#include "AMReX_ParmParse.H" | ||
|
||
namespace amr_wind { | ||
|
||
ActuatorSourceTagging::ActuatorSourceTagging(CFDSim& sim) : m_repo(sim.repo()) | ||
{ | ||
auto& pseqn = sim.pde_manager().register_transport_pde("PassiveScalar"); | ||
m_tracer = &(pseqn.fields().field); | ||
|
||
amrex::ParmParse pp("ActuatorSourceTagging"); | ||
pp.query("actuator_source_threshold", m_src_threshold); | ||
} | ||
|
||
void ActuatorSourceTagging::initialize_fields( | ||
int level, const amrex::Geometry& /*geom*/) | ||
{ | ||
(*m_tracer)(level).setVal(0.0); | ||
} | ||
|
||
void ActuatorSourceTagging::post_init_actions() | ||
{ | ||
m_has_act_src = m_repo.field_exists("actuator_src_term"); | ||
m_has_iblank = m_repo.field_exists("iblank_cell"); | ||
|
||
if (m_has_act_src) { | ||
m_act_src = &(m_repo.get_field("actuator_src_term")); | ||
} | ||
|
||
if (m_has_iblank) { | ||
m_iblank = &(m_repo.get_int_field("iblank_cell")); | ||
} | ||
} | ||
|
||
void ActuatorSourceTagging::post_advance_work() | ||
{ | ||
if (!m_has_act_src && !m_has_iblank) { | ||
amrex::Print() | ||
<< "Warning ActuatorSourceTagging activated but neither actuators " | ||
"or overset are being used" | ||
<< std::endl; | ||
return; | ||
} | ||
|
||
const amrex::Real src_threshold = m_src_threshold; | ||
for (int lev = 0; lev <= m_repo.mesh().finestLevel(); ++lev) { | ||
|
||
const auto& tracer_arrs = (*m_tracer)(lev).arrays(); | ||
if (m_has_act_src) { | ||
const auto& src_arrs = (*m_act_src)(lev).const_arrays(); | ||
amrex::ParallelFor( | ||
(*m_tracer)(lev), m_tracer->num_grow(), | ||
[=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept { | ||
const auto src = src_arrs[nbx]; | ||
const amrex::Real srcmag = std::sqrt( | ||
src(i, j, k, 0) * src(i, j, k, 0) + | ||
src(i, j, k, 1) * src(i, j, k, 1) + | ||
src(i, j, k, 2) * src(i, j, k, 2)); | ||
|
||
if (srcmag > src_threshold) { | ||
tracer_arrs[nbx](i, j, k) = 1.0; | ||
} | ||
}); | ||
} | ||
|
||
if (m_has_iblank) { | ||
const auto& iblank_arrs = (*m_iblank)(lev).const_arrays(); | ||
const bool tag_fringe = m_tag_fringe; | ||
const bool tag_hole = m_tag_hole; | ||
amrex::ParallelFor( | ||
(*m_tracer)(lev), m_tracer->num_grow(), | ||
[=] AMREX_GPU_DEVICE(int nbx, int i, int j, int k) noexcept { | ||
const auto ib = iblank_arrs[nbx](i, j, k); | ||
if ((tag_fringe && (ib == -1)) || (tag_hole && (ib == 0))) { | ||
tracer_arrs[nbx](i, j, k) = 1.0; | ||
} | ||
}); | ||
} | ||
} | ||
amrex::Gpu::synchronize(); | ||
} | ||
|
||
} // namespace amr_wind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.