/home/runner/work/amr-wind/amr-wind/amr-wind/turbulence/TurbModelBase.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/turbulence/TurbModelBase.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
TurbModelBase.H
Go to the documentation of this file.
1#ifndef TURBMODELBASE_H
2#define TURBMODELBASE_H
3
7
8namespace amr_wind::turbulence {
9
10namespace turb_base_impl {
11
12// For transport model with constant properties implement specializations that
13// avoid creation of an intermediate scratch buffer.
14
15template <
16 typename Transport,
17 std::enable_if_t<Transport::constant_properties>* = nullptr>
18inline void visc_update(Field& evisc, Field& tvisc, Transport& transport)
19{
20 evisc.setVal(transport.viscosity());
22 evisc, 1.0, tvisc, 0, 0, evisc.num_comp(), evisc.num_grow());
23}
24
25template <
26 typename Transport,
27 std::enable_if_t<Transport::constant_properties>* = nullptr>
28inline void alpha_update(Field& evisc, Field& tvisc, Transport& transport)
29{
30 evisc.setVal(transport.thermal_diffusivity());
32 evisc, 1.0 / transport.turbulent_prandtl(), tvisc, 0, 0,
33 evisc.num_comp(), evisc.num_grow());
34}
35
36template <
37 typename Transport,
38 std::enable_if_t<Transport::constant_properties>* = nullptr>
39inline void scal_diff_update(
40 Field& evisc, Field& tvisc, Transport& transport, const std::string& name)
41{
42 evisc.setVal(transport.viscosity() / transport.laminar_schmidt(name));
44 evisc, 1.0 / transport.turbulent_schmidt(name), tvisc, 0, 0,
45 evisc.num_comp(), evisc.num_grow());
46}
47
48template <
49 typename Transport,
50 std::enable_if_t<!Transport::constant_properties>* = nullptr>
51inline void visc_update(Field& evisc, Field& tvisc, Transport& transport)
52{
53 auto lam_mu = transport.mu();
55 evisc, 1.0, *lam_mu, 0, 1.0, tvisc, 0, 0, evisc.num_comp(),
56 evisc.num_grow());
57}
58
59template <
60 typename Transport,
61 std::enable_if_t<!Transport::constant_properties>* = nullptr>
62inline void alpha_update(Field& evisc, Field& tvisc, Transport& transport)
63{
64 auto lam_alpha = transport.alpha();
66 evisc, 1.0, *lam_alpha, 0, 1.0 / transport.turbulent_prandtl(), tvisc,
67 0, 0, evisc.num_comp(), evisc.num_grow());
68}
69
70template <
71 typename Transport,
72 std::enable_if_t<!Transport::constant_properties>* = nullptr>
73inline void scal_diff_update(
74 Field& evisc, Field& tvisc, Transport& transport, const std::string& name)
75{
76 auto lam_mu = transport.mu();
78 evisc, 1.0 / transport.laminar_schmidt(name), *lam_mu, 0,
79 1.0 / transport.turbulent_schmidt(name), tvisc, 0, 0, evisc.num_comp(),
80 evisc.num_grow());
81}
82
83} // namespace turb_base_impl
84
94template <typename Transport>
95class TurbModelBase : public TurbModel<Transport>
96{
97public:
98 explicit TurbModelBase(CFDSim& sim)
99 : TurbModel<Transport>(sim)
100 , m_mu_turb(sim.repo().declare_field("mu_turb", 1, 1, 1))
101 {
102 this->m_sim.io_manager().register_io_var("mu_turb");
103
104 // Effective viscosity field for output
105 auto& fields = this->m_sim.pde_manager().icns().fields();
106 this->m_sim.io_manager().register_io_var(fields.mueff.name());
107
108 // Effective diffusive parameter fields for scalars
109 for (auto& sc_eqn : this->m_sim.pde_manager().scalar_eqns()) {
110 this->m_sim.io_manager().register_output_var(
111 sc_eqn->fields().mueff.name());
112 }
113
114 m_mu_turb.set_default_fillpatch_bc(this->m_sim.time());
115 }
116
118 Field& mu_turb() override { return m_mu_turb; }
119
121 Field& alpha_turb() override
122 {
123 AMREX_ASSERT(m_alpha_turb != nullptr);
124 return *m_alpha_turb;
125 }
126
127 // clang-format off
128
135 void update_mueff(Field& mueff) override
136 {
138 }
139
150
152 void update_scalar_diff(Field& deff, const std::string& name) override
153 {
155 }
156
157 // clang-format on
158
159protected:
162
165};
166
167} // namespace amr_wind::turbulence
168
169#endif /* TURBMODELBASE_H */
Definition CFDSim.H:47
IOManager & io_manager()
Definition CFDSim.H:83
pde::PDEMgr & pde_manager()
Definition CFDSim.H:65
Definition Field.H:116
const amrex::IntVect & num_grow() const
Ghost cells.
Definition Field.H:137
void set_default_fillpatch_bc(const SimTime &time, const amrex::BCType::mathematicalBndryTypes bctype=amrex::BCType::hoextrap) noexcept
Definition Field.cpp:377
int num_comp() const
Number of components for this field.
Definition Field.H:134
void setVal(amrex::Real value) noexcept
Set the field to a constant value at all levels.
Definition Field.cpp:343
TypeVector & scalar_eqns()
Definition PDEBase.H:148
Definition TurbModelBase.H:96
Field & alpha_turb() override
Return the turbulent thermal diffusivity field.
Definition TurbModelBase.H:121
Field & mu_turb() override
Return the turbulent viscosity field.
Definition TurbModelBase.H:118
Field * m_alpha_turb
Reference to thermal diffusivity field.
Definition TurbModelBase.H:164
void update_alphaeff(Field &alphaeff) override
Definition TurbModelBase.H:146
TurbModelBase(CFDSim &sim)
Definition TurbModelBase.H:98
void update_scalar_diff(Field &deff, const std::string &name) override
Interface to update scalar diffusivity based on Schmidt number.
Definition TurbModelBase.H:152
void update_mueff(Field &mueff) override
Definition TurbModelBase.H:135
Field & m_mu_turb
Reference to the turbulent viscosity field.
Definition TurbModelBase.H:161
Definition TurbModel.H:18
CFDSim & m_sim
Definition TurbModel.H:60
Field & mueff() override
Return the effective dynamic viscosity field.
Definition TurbModel.H:47
Field & alphaeff() override
Return the effective thermal diffusivity field.
Definition TurbModel.H:53
Transport m_transport
Transport properties instance.
Definition TurbModel.H:63
void saxpy(T1 &dst, const amrex::Real a, const T2 &src, const int srccomp, const int dstcomp, const int numcomp, const amrex::IntVect &nghost)
Definition field_ops.H:202
void lincomb(T1 &dst, const amrex::Real a, const T2 &x, const int xcomp, const amrex::Real b, const T3 &y, const int ycomp, const int dstcomp, const int numcomp, const amrex::IntVect &nghost)
Definition field_ops.H:317
void visc_update(Field &evisc, Field &tvisc, Transport &transport)
Definition TurbModelBase.H:18
void alpha_update(Field &evisc, Field &tvisc, Transport &transport)
Definition TurbModelBase.H:28
void scal_diff_update(Field &evisc, Field &tvisc, Transport &transport, const std::string &name)
Definition TurbModelBase.H:39
Definition CFDSim.H:23