suanPan
Recorder.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2017-2022 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 = 1;
47 
48 public:
49  Recorder(unsigned, // tag
50  uvec&&, // object tags
51  OutputType, // recorder type
52  unsigned, // interval
53  bool, // if to record time
54  bool // if to use hdf5
55  );
56  Recorder(const Recorder&) = delete;
57  Recorder(Recorder&&) = delete; // move forbidden
58  Recorder& operator=(const Recorder&) = delete; // assign forbidden
59  Recorder& operator=(Recorder&&) = delete; // assign forbidden
60  ~Recorder() override;
61 
62  virtual void initialize(const shared_ptr<DomainBase>&);
63 
64  void set_object_tag(const uvec&);
65  [[nodiscard]] const uvec& get_object_tag() const;
66 
68  [[nodiscard]] const OutputType& get_variable_type() const;
69 
70  [[nodiscard]] bool if_hdf5() const;
71  [[nodiscard]] bool if_record_time() const;
72 
73  void insert(double);
74  void insert(const std::vector<vec>&, unsigned);
75 
76  [[nodiscard]] const std::vector<std::vector<std::vector<vec>>>& get_data_pool() const;
77  [[nodiscard]] const std::vector<double>& get_time_pool() const;
78 
79  virtual void record(const shared_ptr<DomainBase>&) = 0;
80 
81  virtual void save();
82 
83  void print() override;
84 };
85 
86 #endif
87 
OutputType
Definition: OutputType.h:21
The DomainBase class is a template.
Definition: DomainBase.h:90
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:59
const OutputType & get_variable_type() const
Definition: Recorder.cpp:55
void set_variable_type(OutputType)
Definition: Recorder.cpp:53
const unsigned interval
Definition: Recorder.h:45
unsigned counter
Definition: Recorder.h:46
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
void set_object_tag(const uvec &)
Definition: Recorder.cpp:49
virtual void initialize(const shared_ptr< DomainBase > &)
Definition: Recorder.cpp:47
~Recorder() override
Definition: Recorder.cpp:45
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:51
Recorder(Recorder &&)=delete
bool if_hdf5() const
Definition: Recorder.cpp:57
Recorder & operator=(const Recorder &)=delete
void print() override
Definition: Recorder.cpp:155
A base Tag class.
Definition: Tag.h:38