suanPan
Recorder.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2017-2023 Theodore Chang
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  ******************************************************************************/
27 #ifndef RECORDER_H
28 #define RECORDER_H
29 
30 #include <Domain/Tag.h>
31 #include <Recorder/OutputType.h>
32 
33 class DomainBase;
34 
35 class Recorder : public Tag {
36  uvec object_tag;
37  OutputType variable_type;
38  std::vector<double> time_pool; // recorded data
39  std::vector<std::vector<std::vector<vec>>> data_pool; // recorded data
40 
41  const bool record_time;
42  const bool use_hdf5;
43 
44 protected:
45  const unsigned interval;
46  unsigned counter = 0;
47 
48  bool if_perform_record();
49 
50 public:
51  Recorder(
52  unsigned, // tag
53  uvec&&, // object tags
54  OutputType, // recorder type
55  unsigned, // interval
56  bool, // if to record time
57  bool // if to use hdf5
58  );
59  Recorder(const Recorder&) = delete;
60  Recorder(Recorder&&) = delete; // move forbidden
61  Recorder& operator=(const Recorder&) = delete; // assign forbidden
62  Recorder& operator=(Recorder&&) = delete; // assign forbidden
63  ~Recorder() override = default;
64 
65  virtual void initialize(const shared_ptr<DomainBase>&);
66 
67  void set_object_tag(uvec&&);
68  [[nodiscard]] const uvec& get_object_tag() const;
69 
71  [[nodiscard]] const OutputType& get_variable_type() const;
72 
73  [[nodiscard]] bool if_hdf5() const;
74  [[nodiscard]] bool if_record_time() const;
75 
76  void insert(double);
77  void insert(const std::vector<vec>&, unsigned);
78 
79  [[nodiscard]] const std::vector<std::vector<std::vector<vec>>>& get_data_pool() const;
80  [[nodiscard]] const std::vector<double>& get_time_pool() const;
81 
82  virtual void record(const shared_ptr<DomainBase>&) = 0;
83 
84  virtual void save();
85 
86  void print() override;
87 };
88 
89 #endif
90 
OutputType
Definition: OutputType.h:23
The DomainBase class is a template.
Definition: DomainBase.h:104
A Recorder class.
Definition: Recorder.h:35
const std::vector< double > & get_time_pool() const
Definition: Recorder.cpp:67
bool if_record_time() const
Definition: Recorder.cpp:57
const OutputType & get_variable_type() const
Definition: Recorder.cpp:53
void set_variable_type(OutputType)
Definition: Recorder.cpp:51
const unsigned interval
Definition: Recorder.h:45
unsigned counter
Definition: Recorder.h:46
void set_object_tag(uvec &&)
Definition: Recorder.cpp:47
Recorder & operator=(Recorder &&)=delete
virtual void record(const shared_ptr< DomainBase > &)=0
Recorder(unsigned, uvec &&, OutputType, unsigned, bool, bool)
ctor
Definition: Recorder.cpp:36
void insert(double)
Definition: Recorder.cpp:61
Recorder(const Recorder &)=delete
virtual void save()
Definition: Recorder.cpp:69
virtual void initialize(const shared_ptr< DomainBase > &)
Definition: Recorder.cpp:45
bool if_perform_record()
Definition: Recorder.cpp:59
const std::vector< std::vector< std::vector< vec > > > & get_data_pool() const
Definition: Recorder.cpp:65
const uvec & get_object_tag() const
Definition: Recorder.cpp:49
Recorder(Recorder &&)=delete
bool if_hdf5() const
Definition: Recorder.cpp:55
~Recorder() override=default
Recorder & operator=(const Recorder &)=delete
void print() override
Definition: Recorder.cpp:141
A base Tag class.
Definition: Tag.h:38