/home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/PDE.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/PDE.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
PDE.H
Go to the documentation of this file.
1#ifndef PDE_H
2#define PDE_H
3
4#include <string>
5#include "amr-wind/CFDSim.H"
10
11namespace amr_wind::pde {
12
25template <typename PDE, typename Scheme>
26class PDESystem : public PDEBase::Register<PDESystem<PDE, Scheme>>
27{
28public:
29 using PDEType = PDE;
30 using SchemeType = Scheme;
31
34 static std::string identifier()
35 {
36 return PDE::pde_name() + "-" + Scheme::scheme_name();
37 }
38
42 explicit PDESystem(CFDSim& sim)
43 : m_sim(sim)
44 , m_time(sim.time())
45 , m_repo(sim.repo())
46 , m_fields(FieldRegOp<PDE, Scheme>(m_sim)(m_time))
51 {
52 m_bc_op.init_bcs();
53 }
54
56 void initialize() override
57 {
58 if (PDE::has_diffusion) {
59 BL_PROFILE("amr-wind::" + this->identifier() + "::initialize");
62 m_turb_op.reset(
64 }
65
66 const bool variable_density =
67 (!m_sim.pde_manager().constant_density() ||
68 m_sim.physics_manager().contains("MultiPhase"));
69
71 m_sim, m_fields, m_sim.has_overset(), variable_density,
73 m_src_op.init_source_terms(m_sim);
74
75 // Post-solve operations should also apply after initialization
77 }
78
80 void post_regrid_actions() override
81 {
82 if (PDE::has_diffusion) {
83 BL_PROFILE(
84 "amr-wind::" + this->identifier() + "::post_regrid_actions");
87 }
88
89 const bool variable_density =
90 (!m_sim.pde_manager().constant_density() ||
91 m_sim.physics_manager().contains("MultiPhase"));
92
94 m_sim, m_fields, m_sim.has_overset(), variable_density,
96
97 // Post-solve operations should also apply after a regrid
99 }
100
102 PDEFields& fields() override { return m_fields; }
103 const PDEFields& fields() const override { return m_fields; }
104
105 void compute_source_term(const FieldState fstate) override
106 {
107 BL_PROFILE("amr-wind::" + this->identifier() + "::compute_source_term");
109 }
110
111 void compute_mueff(const FieldState /*unused*/) override
112 {
113 if (PDE::has_diffusion) {
114 BL_PROFILE("amr-wind::" + this->identifier() + "::compute_mueff");
115 (*m_turb_op)();
116 }
117 }
118
119 void compute_diffusion_term(const FieldState fstate) override
120 {
121 if (PDE::has_diffusion) {
122 BL_PROFILE(
123 "amr-wind::" + this->identifier() + "::compute_diffusion_term");
124 m_bc_op.apply_bcs(fstate);
125 m_diff_op->compute_diff_term(fstate);
126 }
127 }
128
129 void compute_advection_term(const FieldState fstate) override
130 {
131 BL_PROFILE(
132 "amr-wind::" + this->identifier() + "::compute_advection_term");
133 (*m_adv_op)(fstate, m_time.delta_t());
134 }
135
136 void pre_advection_actions(const FieldState fstate) override
137 {
138 BL_PROFILE(
139 "amr-wind::" + this->identifier() + "::pre_advection_actions");
140 m_adv_op->preadvect(fstate, m_time.delta_t(), m_time.current_time());
141 }
142
143 void compute_predictor_rhs(const DiffusionType difftype) override
144 {
145 BL_PROFILE(
146 "amr-wind::" + this->identifier() + "::compute_predictor_rhs");
147 m_rhs_op.predictor_rhs(
148 difftype, m_time.delta_t(), m_sim.has_mesh_mapping());
149 }
150
151 void compute_corrector_rhs(const DiffusionType difftype) override
152 {
153 BL_PROFILE(
154 "amr-wind::" + this->identifier() + "::compute_corrector_rhs");
155 m_rhs_op.corrector_rhs(
156 difftype, m_time.delta_t(), m_sim.has_mesh_mapping());
157 }
158
159 void solve(const amrex::Real dt) override
160 {
161 if (PDE::has_diffusion) {
162 BL_PROFILE("amr-wind::" + this->identifier() + "::linsys_solve");
163 m_bc_op.apply_bcs(FieldState::New);
164 m_diff_op->linsys_solve(dt);
165 }
166 }
167
169
170protected:
173
176
179
181
184
186 std::unique_ptr<AdvectionOp<PDE, Scheme>> m_adv_op;
187
190
192 std::unique_ptr<DiffusionOp<PDE, Scheme>> m_diff_op;
193
195 std::unique_ptr<TurbulenceOp<PDE>> m_turb_op;
196
198
200};
201
202} // namespace amr_wind::pde
203
204#endif /* PDE_H */
Definition CFDSim.H:47
turbulence::TurbulenceModel & turbulence_model()
Definition CFDSim.H:77
PhysicsMgr & physics_manager()
Definition CFDSim.H:68
bool has_mesh_mapping() const
Definition CFDSim.H:118
bool is_anelastic() const
Definition CFDSim.cpp:76
bool has_overset() const
Definition CFDSim.cpp:63
pde::PDEMgr & pde_manager()
Definition CFDSim.H:65
bool contains(const std::string &key) const
Query if an object exists using the lookup key.
Definition CollMgr.H:55
Definition FieldRepo.H:86
Definition SimTime.H:30
AMREX_FORCE_INLINE amrex::Real new_time() const
Definition SimTime.H:108
AMREX_FORCE_INLINE amrex::Real delta_t() const
Definition SimTime.H:84
AMREX_FORCE_INLINE amrex::Real current_time() const
Definition SimTime.H:102
Definition PDE.H:27
static std::string identifier()
Definition PDE.H:34
std::unique_ptr< DiffusionOp< PDE, Scheme > > m_diff_op
Diffusion term computation operator.
Definition PDE.H:192
void initialize() override
Perform initialization actions after the mesh is created.
Definition PDE.H:56
const PDEFields & fields() const override
Definition PDE.H:103
PDEFields & fields() override
Return the object holding the fields necessary for solving this PDE.
Definition PDE.H:102
PDESystem(CFDSim &sim)
Definition PDE.H:42
PostSolveOp< PDE > m_post_solve_op
Definition PDE.H:199
SrcTermOp< PDE > m_src_op
Source term computation operator.
Definition PDE.H:183
CFDSim & m_sim
CFD simulation controller instance.
Definition PDE.H:172
FieldRepo & m_repo
Field repository.
Definition PDE.H:178
ComputeRHSOp< PDE, Scheme > m_rhs_op
RHS computation operator.
Definition PDE.H:189
const SimTime & m_time
Time controls instance.
Definition PDE.H:175
void compute_predictor_rhs(const DiffusionType difftype) override
Definition PDE.H:143
void compute_source_term(const FieldState fstate) override
Definition PDE.H:105
void compute_mueff(const FieldState) override
Definition PDE.H:111
void post_solve_actions() override
Definition PDE.H:168
void pre_advection_actions(const FieldState fstate) override
Definition PDE.H:136
std::unique_ptr< TurbulenceOp< PDE > > m_turb_op
Turbulence operator.
Definition PDE.H:195
PDEFields m_fields
Definition PDE.H:180
PDE PDEType
Definition PDE.H:29
void compute_diffusion_term(const FieldState fstate) override
Definition PDE.H:119
BCOp< PDE > m_bc_op
Definition PDE.H:197
void compute_corrector_rhs(const DiffusionType difftype) override
Definition PDE.H:151
void compute_advection_term(const FieldState fstate) override
Definition PDE.H:129
void solve(const amrex::Real dt) override
Definition PDE.H:159
std::unique_ptr< AdvectionOp< PDE, Scheme > > m_adv_op
Advection term computation operator.
Definition PDE.H:186
Scheme SchemeType
Definition PDE.H:30
void post_regrid_actions() override
Perform update actions after a regrid is performed.
Definition PDE.H:80
FieldState
Definition FieldDescTypes.H:14
@ New
Same as FieldState::NP1.
DiffusionType
Definition incflo_enums.H:4
Definition AdvOp_Godunov.H:16
Definition PDEOps.H:168
Definition PDEOps.H:198
Definition CompRHSOps.H:18
Definition PDEOps.H:172
Definition PDEOps.H:35
Definition PDEFields.H:27
Definition PDEOps.H:205
Definition PDEOps.H:162
Definition PDEOps.H:179