/home/runner/work/amr-wind/amr-wind/amr-wind/utilities/averaging/TimeAveraging.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/averaging/TimeAveraging.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
TimeAveraging.H
Go to the documentation of this file.
1#ifndef TIMEAVERAGING_H
2#define TIMEAVERAGING_H
3
6
7#include "AMReX_Vector.H"
8
9#include <limits>
10#include <memory>
11#include <string>
12#include <map>
13
14namespace amr_wind {
15
16class CFDSim;
17class SimTime;
18class Field;
19
20namespace averaging {
21
27 : public Factory<FieldTimeAverage, CFDSim&, const std::string&>
28{
29public:
30 static std::string base_identifier() { return "FieldTimeAverage"; }
31
32 ~FieldTimeAverage() override = default;
33
40 virtual void operator()(
41 const SimTime& time,
42 const amrex::Real filter_width,
43 const amrex::Real elapsed_time) = 0;
44
45 virtual const std::string& average_field_name() = 0;
46};
47
50class TimeAveraging : public PostProcessBase::Register<TimeAveraging>
51{
52public:
53 static std::string identifier() { return "TimeAveraging"; }
54
55 TimeAveraging(CFDSim& /*sim*/, std::string /*label*/);
56
57 ~TimeAveraging() override;
58
60 void pre_init_actions() override;
61
62 void initialize() override;
63
64 void post_advance_work() override;
65
66 void post_regrid_actions() override {}
67
68 const std::string& add_averaging(
69 const std::string& field_name,
70 const std::string& avg_type = "ReAveraging");
71
72private:
74
75 const std::string m_label;
76
78 amrex::Vector<std::unique_ptr<FieldTimeAverage>> m_averages;
79
81 std::map<std::string, FieldTimeAverage*> m_registered;
82
84 amrex::Real m_start_time{0.0};
85
87 amrex::Real m_stop_time{std::numeric_limits<amrex::Real>::max()};
88
90 amrex::Real m_filter{0.0};
91};
92
93} // namespace averaging
94} // namespace amr_wind
95
96#endif /* TIMEAVERAGING_H */
Definition CFDSim.H:47
Definition SimTime.H:30
Definition TimeAveraging.H:28
virtual const std::string & average_field_name()=0
static std::string base_identifier()
Definition TimeAveraging.H:30
virtual void operator()(const SimTime &time, const amrex::Real filter_width, const amrex::Real elapsed_time)=0
Definition TimeAveraging.H:51
void initialize() override
Definition TimeAveraging.cpp:59
const std::string m_label
Definition TimeAveraging.H:75
std::map< std::string, FieldTimeAverage * > m_registered
Fields registered so far to avoid duplication.
Definition TimeAveraging.H:81
const std::string & add_averaging(const std::string &field_name, const std::string &avg_type="ReAveraging")
Definition TimeAveraging.cpp:61
TimeAveraging(CFDSim &, std::string)
Definition TimeAveraging.cpp:12
void post_regrid_actions() override
Definition TimeAveraging.H:66
amrex::Real m_start_time
Time to start averaging the fields.
Definition TimeAveraging.H:84
CFDSim & m_sim
Definition TimeAveraging.H:73
amrex::Real m_stop_time
Time to stop averaging the fields.
Definition TimeAveraging.H:87
amrex::Real m_filter
Time averaging window (in seconds)
Definition TimeAveraging.H:90
static std::string identifier()
Definition TimeAveraging.H:53
amrex::Vector< std::unique_ptr< FieldTimeAverage > > m_averages
Vector containing all registered field averagers.
Definition TimeAveraging.H:78
void pre_init_actions() override
Perform actions before mesh is created.
Definition TimeAveraging.cpp:18
void post_advance_work() override
Definition TimeAveraging.cpp:78
Definition BCInterface.cpp:7
Definition Factory.H:65