suanPan
Loading...
Searching...
No Matches
Recorder.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2025 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 UniqueTag {
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:
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
60 virtual void initialize(const shared_ptr<DomainBase>&);
61
62 void set_object_tag(uvec&&);
63 [[nodiscard]] const uvec& get_object_tag() const;
64
66 [[nodiscard]] const OutputType& get_variable_type() const;
67
68 [[nodiscard]] bool if_hdf5() const;
69 [[nodiscard]] bool if_record_time() const;
70
71 void insert(double);
72 void insert(const std::vector<vec>&, unsigned);
73
74 [[nodiscard]] const std::vector<std::vector<std::vector<vec>>>& get_data_pool() const;
75 [[nodiscard]] const std::vector<double>& get_time_pool() const;
76
77 virtual void record(const shared_ptr<DomainBase>&) = 0;
78
79 void clear_status();
80
81 virtual void save();
82
83 void print() override;
84};
85
86#endif
87
OutputType
Definition OutputType.h:23
The DomainBase class is a template.
Definition DomainBase.h:102
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
virtual void record(const shared_ptr< DomainBase > &)=0
void insert(double)
Definition Recorder.cpp:61
virtual void save()
Definition Recorder.cpp:74
void clear_status()
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
bool if_hdf5() const
Definition Recorder.cpp:55
void print() override
Definition Recorder.cpp:153
Definition Tag.h:77