Skip to content

Commit

Permalink
promote transport
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf committed Nov 27, 2024
1 parent cf59c7b commit ad49681
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 24 deletions.
15 changes: 15 additions & 0 deletions amr-wind/CFDSim.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class OversetManager;
class ExtSolverMgr;
class HelicsStorage;

namespace transport {
class TransportModel;
}

namespace turbulence {
class TurbulenceModel;
}
Expand Down Expand Up @@ -74,6 +78,12 @@ public:
return m_physics_mgr.objects();
}

transport::TransportModel& transport_model() { return *m_transport; }
const transport::TransportModel& transport_model() const
{
return *m_transport;
}

turbulence::TurbulenceModel& turbulence_model() { return *m_turbulence; }
const turbulence::TurbulenceModel& turbulence_model() const
{
Expand Down Expand Up @@ -103,6 +113,9 @@ public:

bool has_overset() const;

//! Instantiate the transport model based on user inputs
void create_transport_model();

//! Instantiate the turbulence model based on user inputs
void create_turbulence_model();

Expand Down Expand Up @@ -130,6 +143,8 @@ private:

PhysicsMgr m_physics_mgr;

std::unique_ptr<transport::TransportModel> m_transport;

std::unique_ptr<turbulence::TurbulenceModel> m_turbulence;

std::unique_ptr<IOManager> m_io_mgr;
Expand Down
12 changes: 12 additions & 0 deletions amr-wind/CFDSim.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "amr-wind/CFDSim.H"
#include "amr-wind/transport_models/TransportModel.H"
#include "amr-wind/turbulence/TurbulenceModel.H"
#include "amr-wind/utilities/IOManager.H"
#include "amr-wind/utilities/PostProcessing.H"
Expand All @@ -22,6 +23,17 @@ CFDSim::CFDSim(amrex::AmrCore& mesh)

CFDSim::~CFDSim() = default;

void CFDSim::create_transport_model()
{
std::string transport_model_name = "ConstTransport";
{
amrex::ParmParse pp("transport");
pp.query("model", transport_model_name);
}
m_transport =
transport::TransportModel::create(transport_model_name, *this);
}

void CFDSim::create_turbulence_model()
{
std::string transport_model_name = "ConstTransport";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private:
amrex::Real m_ref_theta{300.0};

//! Transport model
std::unique_ptr<transport::TransportModel> m_transport;
const transport::TransportModel& m_transport;

//! Thermal expansion coefficient
std::unique_ptr<ScratchField> m_beta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ namespace amr_wind::pde::icns {
* - `read_temperature_profile`
* - `tprofile_filename`
*/
ABLMeanBoussinesq::ABLMeanBoussinesq(const CFDSim& sim) : m_mesh(sim.mesh())
ABLMeanBoussinesq::ABLMeanBoussinesq(const CFDSim& sim)
: m_mesh(sim.mesh()), m_transport(sim.transport_model())

{

const auto& abl = sim.physics_manager().get<amr_wind::ABL>();
Expand All @@ -26,13 +28,7 @@ ABLMeanBoussinesq::ABLMeanBoussinesq(const CFDSim& sim) : m_mesh(sim.mesh())
amrex::ParmParse pp_boussinesq_buoyancy("BoussinesqBuoyancy");
pp_boussinesq_buoyancy.get("reference_temperature", m_ref_theta);

std::string transport_model_name = "ConstTransport";
{
amrex::ParmParse pp("transport");
pp.query("model", transport_model_name);
}
m_transport = transport::TransportModel::create(transport_model_name, sim);
m_beta = m_transport->beta();
m_beta = m_transport.beta();

// gravity in `incflo` namespace
amrex::ParmParse pp_incflo("incflo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ private:
const Field& m_temperature;

amrex::Vector<amrex::Real> m_gravity{0.0, 0.0, -9.81};

//! Transport model
std::unique_ptr<transport::TransportModel> m_transport;
const transport::TransportModel& m_transport;

//! Thermal expansion coefficient
std::unique_ptr<ScratchField> m_beta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ namespace amr_wind::pde::icns {
*/
BoussinesqBuoyancy::BoussinesqBuoyancy(const CFDSim& sim)
: m_temperature(sim.repo().get_field("temperature"))
, m_transport(sim.transport_model())
{
std::string transport_model_name = "ConstTransport";
{
amrex::ParmParse pp("transport");
pp.query("model", transport_model_name);
}
m_transport = transport::TransportModel::create(transport_model_name, sim);
m_beta = m_transport->beta();
m_beta = m_transport.beta();

// gravity in `incflo` namespace
amrex::ParmParse pp_incflo("incflo");
Expand All @@ -39,7 +34,7 @@ void BoussinesqBuoyancy::operator()(
const FieldState fstate,
const amrex::Array4<amrex::Real>& src_term) const
{
const amrex::Real T0 = m_transport->reference_temperature();
const amrex::Real T0 = m_transport.reference_temperature();
const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> gravity{
m_gravity[0], m_gravity[1], m_gravity[2]};

Expand Down
1 change: 1 addition & 0 deletions amr-wind/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ void incflo::init_physics_and_pde()
amrex::ParmParse pp("incflo");
pp.query("prescribe_velocity", m_prescribe_vel);
}
m_sim.create_transport_model();
m_sim.create_turbulence_model();

// Initialize the refinement criteria
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/transport_models/ConstTransport.H
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public:
}

//! Return the thermal expansion coefficient
inline std::unique_ptr<ScratchField> beta() override
inline std::unique_ptr<ScratchField> beta() const override
{
auto beta = m_repo.create_scratch_field(1, 1);

Expand Down Expand Up @@ -184,7 +184,7 @@ public:
return beta;
}

inline amrex::Real reference_temperature() override
inline amrex::Real reference_temperature() const override
{
return m_reference_temperature;
}
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/transport_models/TransportModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public:
scalar_diffusivity(const std::string& scalar_name) = 0;

//! Thermal expansion coefficient
virtual std::unique_ptr<ScratchField> beta() = 0;
virtual std::unique_ptr<ScratchField> beta() const = 0;

//! Reference temperature
virtual amrex::Real reference_temperature() = 0;
virtual amrex::Real reference_temperature() const = 0;
};
} // namespace amr_wind::transport

Expand Down
4 changes: 2 additions & 2 deletions amr-wind/transport_models/TwoPhaseTransport.H
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public:
}

//! Return the thermal expansion coefficient
inline std::unique_ptr<ScratchField> beta() override
inline std::unique_ptr<ScratchField> beta() const override
{
auto beta = m_repo.create_scratch_field(1, 1);

Expand Down Expand Up @@ -341,7 +341,7 @@ public:
return beta;
}

inline amrex::Real reference_temperature() override
inline amrex::Real reference_temperature() const override
{
return m_reference_temperature;
}
Expand Down
1 change: 1 addition & 0 deletions unit_tests/offshore_wind/test_abloffshore_src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ TEST_F(ABLOffshoreMeshTest, boussinesq)
pde_mgr.register_icns();
pde_mgr.register_transport_pde("Temperature");
sim().init_physics();
sim().create_transport_model();
auto& mphase = sim().physics_manager().get<amr_wind::MultiPhase>();
// Make sure to read water level
mphase.post_init_actions();
Expand Down
2 changes: 2 additions & 0 deletions unit_tests/wind_energy/test_abl_src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ TEST_F(ABLMeshTest, boussinesq)
pde_mgr.register_icns();
pde_mgr.register_transport_pde("Temperature");
sim().init_physics();
sim().create_transport_model();

amr_wind::pde::icns::BoussinesqBuoyancy bb(sim());

Expand Down Expand Up @@ -582,6 +583,7 @@ TEST_F(ABLMeshTest, boussinesq_nph)
pde_mgr.register_icns();
pde_mgr.register_transport_pde("Temperature");
sim().init_physics();
sim().create_transport_model();

amr_wind::pde::icns::BoussinesqBuoyancy bb(sim());

Expand Down

0 comments on commit ad49681

Please sign in to comment.