/
DetectorsFile.h
135 lines (99 loc) · 5.8 KB
/
DetectorsFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Copyright (C) 2013 Columbia University in the City of New York and others.
//
// Please see the AUTHORS file in the main source directory for a full list
// of contributors.
//
// This file is part of TerraFERMA.
//
// TerraFERMA is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TerraFERMA is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TerraFERMA. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DETECTORS_FILE_H
#define __DETECTORS_FILE_H
#include <cstdio>
#include <fstream>
#include <string>
#include <dolfin.h>
#include "DiagnosticsFile.h"
#include "BoostTypes.h"
namespace buckettools
{
//*****************************************************************|************************************************************//
// predeclarations: a circular dependency between the DetectorsFile class and the Bucket class requires a lot of predeclarations.
//*****************************************************************|************************************************************//
class Bucket;
class SystemBucket;
typedef std::shared_ptr< SystemBucket > SystemBucket_ptr;
class FunctionBucket;
typedef std::shared_ptr< FunctionBucket > FunctionBucket_ptr;
class GenericDetectors;
typedef std::shared_ptr< GenericDetectors > GenericDetectors_ptr;
//*****************************************************************|************************************************************//
// DetectorsFile class:
//
// A derived class from the base statfile class intended for the output of detectors data to file every dump period.
//*****************************************************************|************************************************************//
class DetectorsFile : public DiagnosticsFile
{
//*****************************************************************|***********************************************************//
// Publicly available functions
//*****************************************************************|***********************************************************//
public:
//***************************************************************|***********************************************************//
// Constructors and destructors
//***************************************************************|***********************************************************//
DetectorsFile(const std::string name,
const MPI_Comm &comm,
const Bucket *bucket); // specific constructor
~DetectorsFile(); // default destructor
//***************************************************************|***********************************************************//
// Header writing functions
//***************************************************************|***********************************************************//
void write_header();
//***************************************************************|***********************************************************//
// Data writing functions
//***************************************************************|***********************************************************//
void write_data();
//*****************************************************************|***********************************************************//
// Private functions
//*****************************************************************|***********************************************************//
private:
//***************************************************************|***********************************************************//
// Base data
//***************************************************************|***********************************************************//
std::vector< GenericDetectors_ptr > detectors_;
std::vector< FunctionBucket_ptr > functions_;
//***************************************************************|***********************************************************//
// Header writing functions (continued)
//***************************************************************|***********************************************************//
void header_bucket_();
void header_detector_(const GenericDetectors_ptr d_ptr);
void header_func_(const FunctionBucket_ptr f_ptr);
//***************************************************************|***********************************************************//
// Data writing functions (continued)
//***************************************************************|***********************************************************//
void data_timestep_();
void data_bucket_();
void data_detector_(const GenericDetectors_ptr d_ptr);
void data_func_(const FunctionBucket_ptr f_ptr);
//***************************************************************|***********************************************************//
// Private members
//***************************************************************|***********************************************************//
#ifdef HAS_MPI
MPI_File mpifile_;
MPI_Offset mpiwritelocation_;
#endif
uint mpiwritecount_;
};
typedef std::shared_ptr< DetectorsFile > DetectorsFile_ptr; // define a boost shared ptr type for the class
}
#endif