Peano 4
Loading...
Searching...
No Matches
VTKBinaryFileWriter_CellDataWriter.cpp
Go to the documentation of this file.
3
4#include <limits>
5#include <iomanip>
6
8 const std::string& dataIdentifier, VTKBinaryFileWriter& writer, int recordsPerCell
9):
10 _identifier(dataIdentifier),
11 _lastWriteCommandCellNumber(-1),
12 _myWriter(writer),
13 _out(),
14 _recordsPerCell(recordsPerCell),
15 _minValue(std::numeric_limits<double>::max()),
16 _maxValue(std::numeric_limits<double>::min()) {
18
19 if (_recordsPerCell!=3) {
20 _out << "SCALARS " << dataIdentifier << " " << _myWriter._doubleOrFloat << " " << _recordsPerCell << std::endl
21 << "LOOKUP_TABLE default" << std::endl;
22 }
23 else {
24 _out << "VECTORS " << dataIdentifier << " " << _myWriter._doubleOrFloat << " " << std::endl;
25 }
26}
27
28
30 if (_lastWriteCommandCellNumber>=-1) {
31 close();
32 }
33}
34
35
38 _lastWriteCommandCellNumber <= _myWriter._numberOfCells-1,
39 _lastWriteCommandCellNumber, _myWriter._numberOfCells,
40 _identifier,
41 "please call close on the cell/vertex writer before"
42 );
43
44 while (_lastWriteCommandCellNumber<_myWriter._numberOfCells-1) {
45 plotCell(_lastWriteCommandCellNumber+1,0.0);
46 }
47}
48
49
51 if (_myWriter._numberOfCells==0 && _lastWriteCommandCellNumber!=0) {
52 logWarning( "close()", "writer " << _identifier << " is closed though underlying grid writer does not hold any vertices/cells. Ensure you call close() on the vertex/cell writer before" );
53 }
55 _lastWriteCommandCellNumber>-2,
56 _identifier,
57 "closed twice"
58 );
60 _lastWriteCommandCellNumber==_myWriter._numberOfCells-1,
61 "one record has to be written per cell on writer " << _identifier <<
62 " (cell entries written=" << _lastWriteCommandCellNumber <<
63 ", cell entries expected=" << _myWriter._numberOfCells << ")"
64 );
65 assertionMsg( _myWriter.isOpen(), "Maybe you forgot to call close() or assignRemainingCellsDefaultValues() on a data writer before you destroy your writer?" );
66
67 if (_lastWriteCommandCellNumber>=-1) {
68 _out << std::endl;
69 _myWriter._cellDataDescription << _out.str();
70 }
71 _lastWriteCommandCellNumber = -2;
72}
73
74
76 assertion(_lastWriteCommandCellNumber>=-1);
77 assertion(1<=_recordsPerCell);
78
80 value != std::numeric_limits<double>::infinity(),
81 value,
82 _lastWriteCommandCellNumber,
83 _recordsPerCell,
84 _minValue,
85 _maxValue,
86 _identifier
87 );
88
89
90 // test for not a number
92 value == value,
93 value,
94 _lastWriteCommandCellNumber,
95 _recordsPerCell,
96 _minValue,
97 _maxValue,
98 _identifier
99 );
100
101 while (_lastWriteCommandCellNumber<index-1) {
102 plotCell(_lastWriteCommandCellNumber+1,0.0);
103 }
104
105 _lastWriteCommandCellNumber = index;
106 if (_myWriter._precision < 7){
107 float tmp;
108 tmp = value;
110 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
111 tmp = 0.0;
112 for (int i=1; i<_recordsPerCell; i++) {
114 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
115 }
116 } else {
117 double tmp;
118 tmp = value;
120 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
121 tmp = 0.0;
122 for (int i=1; i<_recordsPerCell; i++) {
124 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
125 }
126 }
127
128 if (value<_minValue) _minValue = value;
129 if (value>_maxValue) _maxValue = value;
130}
131
132
134 assertion(_lastWriteCommandCellNumber>=-1);
135 assertion(2<=_recordsPerCell);
136
137 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
138 assertion1( value(0) == value(0), value(0) ); // test for not a number
139
140 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
141 assertion1( value(1) == value(1), value(1) ); // test for not a number
142
143 while (_lastWriteCommandCellNumber<index-1) {
144 plotCell(_lastWriteCommandCellNumber+1,0.0);
145 }
146
147 _lastWriteCommandCellNumber = index;
148
149 if (_myWriter._precision < 7){
150 float tmp;
151 tmp = value(0);
153 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
154 tmp = value(1);
156 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
157 tmp = 0.0;
158 for (int i=2; i<_recordsPerCell; i++) {
160 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
161 }
162 } else {
163 double tmp;
164 tmp = value(0);
166 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
167 tmp = value(1);
169 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
170 tmp = 0.0;
171 for (int i=2; i<_recordsPerCell; i++) {
173 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
174 }
175 }
176
177 if (value(0)<_minValue) _minValue = value(0);
178 if (value(0)>_maxValue) _maxValue = value(0);
179 if (value(1)<_minValue) _minValue = value(1);
180 if (value(1)>_maxValue) _maxValue = value(1);
181}
182
183
185 assertion(_lastWriteCommandCellNumber>=-1);
186 assertion(3<=_recordsPerCell);
187
188 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
189 assertion1( value(0) == value(0), value(0) ); // test for not a number
190
191 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
192 assertion1( value(1) == value(1), value(1) ); // test for not a number
193
194 assertion1( value(2) != std::numeric_limits<double>::infinity(), value(2) );
195 assertion1( value(2) == value(2), value(2) ); // test for not a number
196
197 while (_lastWriteCommandCellNumber<index-1) {
198 plotCell(_lastWriteCommandCellNumber+1,0.0);
199 }
200
201 _lastWriteCommandCellNumber = index;
202 if (_myWriter._precision < 7){
203 float tmp;
204 tmp = value(0);
206 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
207 tmp = value(1);
209 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
210 tmp = value(2);
212 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
213 tmp = 0.0;
214 for (int i=3; i<_recordsPerCell; i++) {
216 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
217 }
218 } else {
219 double tmp;
220 tmp = value(0);
222 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
223 tmp = value(1);
225 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
226 tmp = value(2);
228 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
229 tmp = 0.0;
230 for (int i=3; i<_recordsPerCell; i++) {
232 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
233 }
234 }
235
236 if (value(0)<_minValue) _minValue = value(0);
237 if (value(0)>_maxValue) _maxValue = value(0);
238 if (value(1)<_minValue) _minValue = value(1);
239 if (value(1)>_maxValue) _maxValue = value(1);
240 if (value(2)<_minValue) _minValue = value(2);
241 if (value(2)>_maxValue) _maxValue = value(2);
242}
243
244
246 assertion(_lastWriteCommandCellNumber>=-1);
247 assertion(numberOfValues<=_recordsPerCell);
248
249 for( int i=0; i<numberOfValues; i++) {
250 assertion1( values[i] != std::numeric_limits<double>::infinity(), values[i] );
251 assertion1( values[i] == values[i], values[i] ); // test for not a number
252 }
253
254 while (_lastWriteCommandCellNumber<index-1) {
255 plotCell(_lastWriteCommandCellNumber+1,0.0);
256 }
257
258 _lastWriteCommandCellNumber = index;
259
260 if (_myWriter._precision < 7){
261 float tmp;
262 for( int i=0; i<numberOfValues; i++) {
263 tmp = values[i];
265 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
266 }
267 tmp = 0.0;
268 for (int i=numberOfValues; i<_recordsPerCell; i++) {
270 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
271 }
272 } else {
273 double tmp;
274 for( int i=0; i<numberOfValues; i++) {
275 tmp = values[i];
277 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
278 }
279 tmp = 0.0;
280 for (int i=numberOfValues; i<_recordsPerCell; i++) {
282 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
283 }
284 }
285
286 for( int i=0; i<numberOfValues; i++) {
287 if (values[i]<_minValue) _minValue = values[i];
288 if (values[i]>_maxValue) _maxValue = values[i];
289 }
290}
291
292
296
297
#define assertion2(expr, param0, param1)
#define assertion4(expr, param0, param1, param2, param3)
#define assertion1(expr, param)
#define assertionMsg(expr, message)
#define assertion(expr)
#define assertion6(expr, param0, param1, param2, param3, param4, param5)
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ our matrix elements will nabla phi_i dx f By this will be a sparse as these basis functions are chosen to not overlap with each other almost everywhere In other they have only local support We can read off the right hand side values
#define logWarning(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:440
CellDataWriter(const std::string &dataIdentifier, VTKBinaryFileWriter &writer, int recordsPerCell)
virtual void plotCell(int index, double value) override
Write data for one cell.
virtual void close() override
If you close your writer, each cell/vertex has to be assigned a value, i.e.
const std::string _doubleOrFloat
either "float" or "double" depending on _precision
STL namespace.
InType byteSwapForParaviewBinaryFiles(const InType inVal)
Conditional swap.
Definition ByteSwap.cpph:20
Simple vector class.
Definition Vector.h:134