/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 void read_inputs(const utils::ActParser&) = 0;
43
44 virtual void determine_influenced_procs() = 0;
45
46 virtual void determine_root_proc(amrex::Vector<int>&) = 0;
47
48 virtual void init_actuator_source() = 0;
49
50 virtual int num_velocity_points() const = 0;
51
52 virtual void update_positions(VecSlice&) = 0;
53
54 virtual void update_fields(const VecSlice&, const RealSlice&) = 0;
55
56 virtual void compute_forces() = 0;
57
58 virtual void compute_source_term(
59 const int lev,
60 const amrex::MFIter& mfi,
61 const amrex::Geometry& geom) = 0;
62
63 virtual void prepare_outputs(const std::string&) = 0;
64
65 virtual void write_outputs() = 0;
66};
67
82template <typename ActTrait, typename SrcTrait = ActSrcLine>
83class ActModel : public ActuatorModel::Register<ActModel<ActTrait, SrcTrait>>
84{
85private:
87 typename ActTrait::DataType m_data;
88
91
94
95public:
96 static std::string identifier()
97 {
98 return ActTrait::identifier() + SrcTrait::identifier();
99 }
100
106 ActModel(CFDSim& sim, const std::string& label, const int id)
108 {}
109
111 const std::string& label() const override { return m_data.info().label; }
112
114 int id() const override { return m_data.info().id; }
115
117 const ActInfo& info() const override { return m_data.info(); }
118
120 const auto& meta() const { return m_data.meta(); }
121
122 void read_inputs(const utils::ActParser& pp) override
123 {
125 m_out_op.read_io_options(pp);
126 }
127
132
133 void determine_root_proc(amrex::Vector<int>& act_proc_count) override;
134
135 int num_velocity_points() const override;
136
137 void update_positions(VecSlice& pos) override
138 {
140 const auto& vpos = m_data.grid().vel_pos;
141 std::copy(vpos.begin(), vpos.end(), pos.begin());
142 }
143
144 void update_fields(const VecSlice& vel, const RealSlice& density) override
145 {
146 std::copy(vel.begin(), vel.end(), m_data.grid().vel.begin());
147 std::copy(
148 density.begin(), density.end(), m_data.grid().density.begin());
150 }
151
152 void compute_forces() override
153 {
155 m_src_op.setup_op();
156 }
157
159 const int lev,
160 const amrex::MFIter& mfi,
161 const amrex::Geometry& geom) override
162 {
163 m_src_op(lev, mfi, geom);
164 }
165
166 void prepare_outputs(const std::string& out_dir) override
167 {
168 m_out_op.prepare_outputs(out_dir);
169 }
170
171 void write_outputs() override { m_out_op.write_outputs(); }
172
173 void init_actuator_source() override
174 {
176 m_src_op.initialize();
177 }
178};
179
180template <typename ActTrait, typename SrcTrait>
182 amrex::Vector<int>& act_proc_count)
183{
184 ops::determine_root_proc<ActTrait>(m_data, act_proc_count);
185 {
186 // Sanity checks
187 const auto& linfo = m_data.info();
188 const auto& plist = linfo.procs;
189 AMREX_ALWAYS_ASSERT(linfo.root_proc > -1);
190 AMREX_ALWAYS_ASSERT(plist.find(linfo.root_proc) != plist.end());
191 }
192}
193
194template <typename ActTrait, typename SrcTrait>
196{
197 const auto& linfo = m_data.info();
198 auto& grid = m_data.grid();
199
200 return (linfo.sample_vel_in_proc) ? grid.vel.size() : 0;
201}
202
203} // namespace actuator
204} // namespace amr_wind
205
206#endif /* ACTUATORMODEL_H */
Definition CFDSim.H:47
Definition ActuatorModel.H:84
const auto & meta() const
Return the meta info object for this actuator instance.
Definition ActuatorModel.H:120
void write_outputs() override
Definition ActuatorModel.H:171
void compute_forces() override
Definition ActuatorModel.H:152
void compute_source_term(const int lev, const amrex::MFIter &mfi, const amrex::Geometry &geom) override
Definition ActuatorModel.H:158
ops::ProcessOutputsOp< ActTrait, SrcTrait > m_out_op
Outputs processor.
Definition ActuatorModel.H:93
int num_velocity_points() const override
Definition ActuatorModel.H:195
void prepare_outputs(const std::string &out_dir) override
Definition ActuatorModel.H:166
int id() const override
Return the unique tag (integer ID) for this instance.
Definition ActuatorModel.H:114
void determine_influenced_procs() override
Definition ActuatorModel.H:128
const std::string & label() const override
Return the unique identifier (name) for this instance.
Definition ActuatorModel.H:111
void read_inputs(const utils::ActParser &pp) override
Definition ActuatorModel.H:122
void determine_root_proc(amrex::Vector< int > &act_proc_count) override
Definition ActuatorModel.H:181
ActTrait::DataType m_data
Instance that holds all data related to a particular actuator type.
Definition ActuatorModel.H:87
void init_actuator_source() override
Definition ActuatorModel.H:173
void update_fields(const VecSlice &vel, const RealSlice &density) override
Definition ActuatorModel.H:144
ActModel(CFDSim &sim, const std::string &label, const int id)
Definition ActuatorModel.H:106
static std::string identifier()
Definition ActuatorModel.H:96
void update_positions(VecSlice &pos) override
Definition ActuatorModel.H:137
ops::ActSrcOp< ActTrait, SrcTrait > m_src_op
Source computation operator.
Definition ActuatorModel.H:90
const ActInfo & info() const override
Return the core info object for this actuator instance.
Definition ActuatorModel.H:117
Definition ActuatorModel.H:30
virtual const std::string & label() const =0
virtual void update_positions(VecSlice &)=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