forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VectorPostprocessorData.h
197 lines (164 loc) · 7.01 KB
/
VectorPostprocessorData.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
// MOOSE includes
#include "MooseTypes.h"
#include "Restartable.h"
// libMesh includes
#include "libmesh/parallel_object.h"
#include <map>
// Forwad declarations
class FEProblemBase;
class VectorPostprocessorData : public Restartable, public libMesh::ParallelObject
{
public:
static InputParameters validParams();
/**
* Class constructor
*/
VectorPostprocessorData(FEProblemBase & fe_problem);
/**
* Initialization method, sets the current and old value to 0.0 for this postprocessor
*/
void init(const std::string & name);
/// VectorPostprocessorState (2 containers for values (see MooseTypes.h)
struct VectorPostprocessorState
{
VectorPostprocessorValue * current = nullptr;
VectorPostprocessorValue * old = nullptr;
ScatterVectorPostprocessorValue scatter_current;
ScatterVectorPostprocessorValue scatter_old;
/// Whether or not this vector needs to be broadcast
bool needs_broadcast = false;
/// Whether or not this vector needs to be scatterd
bool needs_scatter = false;
};
/**
* Initialization method, sets the current and old value to 0.0 for this
* VectorPostprocessor
*
* @param vpp_name The name of the VectorPostprocessor
* @param vector_name The name of the vector
* @param contains_complete_history True if the vector will naturally contain the complete time
* history of the values
* @param is_broadcast True if the vector will already be replicated by the VPP. This prevents
* unnecessary broadcasting by MOOSE.
*/
VectorPostprocessorValue & declareVector(const std::string & vpp_name,
const std::string & vector_name,
bool contains_complete_history,
bool is_broadcast,
bool is_distributed);
/**
* Returns a true value if the VectorPostprocessor exists
*/
bool hasVectorPostprocessor(const std::string & name);
/**
* Return the value for the post processor
* @param vpp_name The name of the VectorPostprocessor
* @param vector_name The name of the vector
* @param needs_broadcast Whether or not the vector needs to be broadcast
* @return The reference to the current value
*/
VectorPostprocessorValue & getVectorPostprocessorValue(const VectorPostprocessorName & vpp_name,
const std::string & vector_name,
bool needs_broadcast);
/**
* The the old value of an post-processor
* @param vpp_name The name of the VectorPostprocessor
* @param vector_name The name of the vector
* @param needs_broadcast Whether or not the vector needs to be broadcast
* @return The reference to the old value
*/
VectorPostprocessorValue &
getVectorPostprocessorValueOld(const VectorPostprocessorName & vpp_name,
const std::string & vector_name,
bool needs_broadcast);
/**
* Return the scatter value for the post processor
* @param vpp_name The name of the VectorPostprocessor
* @param vector_name The name of the vector
* @return The reference to the current scatter value
*/
ScatterVectorPostprocessorValue &
getScatterVectorPostprocessorValue(const VectorPostprocessorName & vpp_name,
const std::string & vector_name);
/**
* Return the scatter value for the post processor
* @param vpp_name The name of the VectorPostprocessor
* @param vector_name The name of the vector
* @return The reference to the old scatter value
*/
ScatterVectorPostprocessorValue &
getScatterVectorPostprocessorValueOld(const VectorPostprocessorName & vpp_name,
const std::string & vector_name);
/**
* Check to see if a VPP has any vectors at all
*/
bool hasVectors(const std::string & vpp_name) const;
/**
* Returns a Boolean indicating whether the specified VPP vectors contain complete history.
*/
bool containsCompleteHistory(const std::string & name) const;
/**
* Returns a Boolean indicating whether the specified VPP vectors are distributed
*/
bool isDistributed(const std::string & name) const;
/**
* Get the map of vectors for a particular VectorPostprocessor
* @param vpp_name The name of the VectorPostprocessor
*/
const std::vector<std::pair<std::string, VectorPostprocessorState>> &
vectors(const std::string & vpp_name) const;
/**
* Broadcast and scatter vectors associated with vpp_name
*
* @param vpp_name The name of the vector to broadcast/scatter vectors for
*/
void broadcastScatterVectors(const std::string & vpp_name);
/**
* Copy the current post-processor values into old (i.e. shift it "back in time") as needed
*/
void copyValuesBack();
private:
VectorPostprocessorState & getVectorPostprocessorHelper(const VectorPostprocessorName & vpp_name,
const std::string & vector_name,
bool get_current = true,
bool contains_complete_history = false,
bool is_broadcast = false,
bool is_distributed = false,
bool needs_broadcast = false,
bool needs_scatter = false);
/**
* Vector of pairs representing the declared vectors (vector name, vector DS)
* The vector DS is a data structure containing a current and old container (vector of Reals)
*/
struct VectorPostprocessorVectors
{
VectorPostprocessorVectors();
///@{
// Default move constructors
VectorPostprocessorVectors(VectorPostprocessorVectors &&) = default;
VectorPostprocessorVectors & operator=(VectorPostprocessorVectors &&) = default;
///@}
std::vector<std::pair<std::string, VectorPostprocessorState>> _values;
/// Boolean indicating whether these vectors contain complete history (append mode)
bool _contains_complete_history;
/// Boolean indicating whether the vector will already be replicated in parallel by the VPP
bool _is_broadcast;
/// Boolean indicating whether any old vectors have been requested.
bool _needs_old;
/// Flag if data is distributed
bool _is_distributed;
};
/// The VPP data store in a map: VPP Name to vector storage
std::map<std::string, VectorPostprocessorVectors> _vpp_data;
std::set<std::string> _requested_items;
std::set<std::string> _supplied_items;
};