suanPan
Loading...
Searching...
No Matches
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
33class DomainBase;
34
35class 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
44protected:
45 const unsigned interval;
46 unsigned counter = 0;
47
48 bool if_perform_record();
49
50public:
51 Recorder(unsigned, // tag
52 uvec&&, // object tags
53 OutputType, // recorder type
54 unsigned, // interval
55 bool, // if to record time
56 bool // if to use hdf5
57 );
58 Recorder(const Recorder&) = delete;
59 Recorder(Recorder&&) = delete; // move forbidden
60 Recorder& operator=(const Recorder&) = delete; // assign forbidden
61 Recorder& operator=(Recorder&&) = delete; // assign forbidden
62 ~Recorder() override = default;
63
64 virtual void initialize(const shared_ptr<DomainBase>&);
65
66 void set_object_tag(const uvec&);
67 [[nodiscard]] const uvec& get_object_tag() const;
68
70 [[nodiscard]] const OutputType& get_variable_type() const;
71
72 [[nodiscard]] bool if_hdf5() const;
73 [[nodiscard]] bool if_record_time() const;
74
75 void insert(double);
76 void insert(const std::vector<vec>&, unsigned);
77
78 [[nodiscard]] const std::vector<std::vector<std::vector<vec>>>& get_data_pool() const;
79 [[nodiscard]] const std::vector<double>& get_time_pool() const;
80
81 virtual void record(const shared_ptr<DomainBase>&) = 0;
82
83 virtual void save();
84
85 void print() override;
86};
87
88#endif
89
OutputType
Definition OutputType.h:21
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
virtual void record(const shared_ptr< DomainBase > &)=0
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:47
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 & operator=(const Recorder &)=delete
~Recorder() override=default
Recorder & operator=(Recorder &&)=delete
void print() override
Definition Recorder.cpp:155
A base Tag class.
Definition Tag.h:38