/home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/ActuatorModel.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/actuator/ActuatorModel.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
ActuatorModel.H
Go to the documentation of this file.
1#ifndef ACTUATORMODEL_H
2#define ACTUATORMODEL_H
3
11
12namespace amr_wind {
13
14class CFDSim;
15
16namespace actuator {
17
29 : public Factory<ActuatorModel, CFDSim&, const std::string&, const int>
30{
31public:
32 static std::string base_identifier() { return "ActuatorModel"; }
33
34 ~ActuatorModel() override = default;
35
36 virtual const std::string& label() const = 0;
37
38 virtual int id() const = 0;
39
40 virtual const ActInfo& info() const = 0;
41
42 virtual ActInfo& info() = 0;
43
44 virtual void read_inputs(const utils::ActParser&) = 0;
45
46 virtual void determine_influenced_procs() = 0;
47
48 virtual void determine_root_proc(amrex::Vector<int>&) = 0;
49
50 virtual void init_actuator_source() = 0;
51
52 virtual int num_velocity_points() const = 0;
53
54 virtual void update_positions(VecSlice&) = 0;
55
56 virtual void update_fields(const VecSlice&, const RealSlice&) = 0;
57
58 virtual void compute_forces() = 0;
59
60 virtual void compute_source_term(
61 const int lev,
62 const amrex::MFIter& mfi,
63 const amrex::Geometry& geom) = 0;
64
65 virtual void prepare_outputs(const std::string&) = 0;
66
67 virtual void write_outputs() = 0;
68};
69
84template <typename ActTrait, typename SrcTrait = ActSrcLine>
85class ActModel : public ActuatorModel::Register<ActModel<ActTrait, SrcTrait>>
86{
87private:
89 typename ActTrait::DataType m_data;
90
93
96
97public:
98 static std::string identifier()
99 {
100 return ActTrait::identifier() + SrcTrait::identifier();
101 }
102
108 ActModel(CFDSim& sim, const std::string& label, const int id)
110 {}
111
113 const std::string& label() const override { return m_data.info().label; }
114
116 int id() const override { return m_data.info().id; }
117
119 const ActInfo& info() const override { return m_data.info(); }
120
122 ActInfo& info() override { return m_data.info(); }
123
125 const auto& meta() const { return m_data.meta(); }
126
127 void read_inputs(const utils::ActParser& pp) override
128 {
130 m_out_op.read_io_options(pp);
131 }
132
137
138 void determine_root_proc(amrex::Vector<int>& act_proc_count) override;
139
140 int num_velocity_points() const override;
141
142 void update_positions(VecSlice& pos) override
143 {
145 const auto& vpos = m_data.grid().vel_pos;
146 std::copy(vpos.begin(), vpos.end(), pos.begin());
147 }
148
149 void update_fields(const VecSlice& vel, const RealSlice& density) override
150 {
151 std::copy(vel.begin(), vel.end(), m_data.grid().vel.begin());
152 std::copy(
153 density.begin(), density.end(), m_data.grid().density.begin());
155 }
156
157 void compute_forces() override
158 {
160 m_src_op.setup_op();
161 }
162
164 const int lev,
165 const amrex::MFIter& mfi,
166 const amrex::Geometry& geom) override
167 {
168 m_src_op(lev, mfi, geom);
169 }
170
171 void prepare_outputs(const std::string& out_dir) override
172 {
173 m_out_op.prepare_outputs(out_dir);
174 }
175
176 void write_outputs() override { m_out_op.write_outputs(); }
177
178 void init_actuator_source() override
179 {
181 m_src_op.initialize();
182 }
183};
184
185template <typename ActTrait, typename SrcTrait>
187 amrex::Vector<int>& act_proc_count)
188{
189 ops::determine_root_proc<ActTrait>(m_data, act_proc_count);
190 {
191 // Sanity checks
192 const auto& linfo = m_data.info();
193 const auto& plist = linfo.procs;
194 AMREX_ALWAYS_ASSERT(linfo.root_proc > -1);
195 AMREX_ALWAYS_ASSERT(plist.find(linfo.root_proc) != plist.end());
196 }
197}
198
199template <typename ActTrait, typename SrcTrait>
201{
202 const auto& linfo = m_data.info();
203 auto& grid = m_data.grid();
204
205 return (linfo.sample_vel_in_proc) ? grid.vel.size() : 0;
206}
207
208} // namespace actuator
209} // namespace amr_wind
210
211#endif /* ACTUATORMODEL_H */
Definition CFDSim.H:47
Definition ActuatorModel.H:86
const auto & meta() const
Return the meta info object for this actuator instance.
Definition ActuatorModel.H:125
void write_outputs() override
Definition ActuatorModel.H:176
void compute_forces() override
Definition ActuatorModel.H:157
void compute_source_term(const int lev, const amrex::MFIter &mfi, const amrex::Geometry &geom) override
Definition ActuatorModel.H:163
ops::ProcessOutputsOp< ActTrait, SrcTrait > m_out_op
Outputs processor.
Definition ActuatorModel.H:95
int num_velocity_points() const override
Definition ActuatorModel.H:200
void prepare_outputs(const std::string &out_dir) override
Definition ActuatorModel.H:171
int id() const override
Return the unique tag (integer ID) for this instance.
Definition ActuatorModel.H:116
void determine_influenced_procs() override
Definition ActuatorModel.H:133
const std::string & label() const override
Return the unique identifier (name) for this instance.
Definition ActuatorModel.H:113
void read_inputs(const utils::ActParser &pp) override
Definition ActuatorModel.H:127
void determine_root_proc(amrex::Vector< int > &act_proc_count) override
Definition ActuatorModel.H:186
ActTrait::DataType m_data
Instance that holds all data related to a particular actuator type.
Definition ActuatorModel.H:89
void init_actuator_source() override
Definition ActuatorModel.H:178
void update_fields(const VecSlice &vel, const RealSlice &density) override
Definition ActuatorModel.H:149
ActModel(CFDSim &sim, const std::string &label, const int id)
Definition ActuatorModel.H:108
static std::string identifier()
Definition ActuatorModel.H:98
ActInfo & info() override
Return the core info object for this actuator instance.
Definition ActuatorModel.H:122
void update_positions(VecSlice &pos) override
Definition ActuatorModel.H:142
ops::ActSrcOp< ActTrait, SrcTrait > m_src_op
Source computation operator.
Definition ActuatorModel.H:92
const ActInfo & info() const override
Return the core info object for this actuator instance.
Definition ActuatorModel.H:119
Definition ActuatorModel.H:30
virtual const std::string & label() const =0
virtual void update_positions(VecSlice &)=0
virtual ActInfo & info()=0
virtual void compute_source_term(const int lev, const amrex::MFIter &mfi, const amrex::Geometry &geom)=0
virtual const ActInfo & info() const =0
virtual void prepare_outputs(const std::string &)=0
virtual int num_velocity_points() const =0
virtual void determine_root_proc(amrex::Vector< int > &)=0
~ActuatorModel() override=default
virtual void determine_influenced_procs()=0
virtual void init_actuator_source()=0
virtual void read_inputs(const utils::ActParser &)=0
virtual int id() const =0
static std::string base_identifier()
Definition ActuatorModel.H:32
virtual void update_fields(const VecSlice &, const RealSlice &)=0
Definition actuator_ops.H:68
Definition MultiParser.H:18
void determine_root_proc(typename T::DataType &, amrex::Vector< int > &)
Definition actuator_opsI.H:32
void determine_influenced_procs(typename T::DataType &)
Definition actuator_opsI.H:12
Definition BCInterface.cpp:7
Definition Factory.H:65
Definition actuator_types.H:144
Definition actuator_ops.H:61
Definition actuator_ops.H:32
Definition actuator_ops.H:71
Definition actuator_ops.H:19
Definition actuator_ops.H:43
Definition actuator_ops.H:54
AMREX_GPU_HOST_DEVICE iterator end()
Definition Slice.H:56
AMREX_GPU_HOST_DEVICE iterator begin()
Definition Slice.H:55
iterator begin() noexcept
Definition vector.H:141