Peano 4
Loading...
Searching...
No Matches
VTKBinaryFileWriter_VertexDataWriter.cpp
Go to the documentation of this file.
3
4#include <limits>
5#include <iomanip>
6
8 const std::string& identifier, VTKBinaryFileWriter& writer, int recordsPerVertex
9):
10 _lastWriteCommandVertexNumber(-1),
11 _myWriter(writer),
12 _out(),
13 _recordsPerVertex(recordsPerVertex),
14 _minValue(std::numeric_limits<double>::max()),
15 _maxValue(std::numeric_limits<double>::min()),
16 _identifier(identifier) {
18
19 if (_recordsPerVertex!=3) {
20 _out << "SCALARS " << _identifier << " " << _myWriter._doubleOrFloat << " " << _recordsPerVertex << std::endl
21 << "LOOKUP_TABLE default" << std::endl;
22 }
23 else {
24 _out << "VECTORS " << _identifier << " " << _myWriter._doubleOrFloat << " " << std::endl;
25 }
26}
27
28
30 if (_lastWriteCommandVertexNumber>=-1) {
31 close();
32 }
33}
34
35
38 _lastWriteCommandVertexNumber <= _myWriter._numberOfCells-1,
39 _lastWriteCommandVertexNumber, _myWriter._numberOfCells,
40 _identifier,
41 "please call close on the vertex writer before"
42 );
43
44 while (_lastWriteCommandVertexNumber<_myWriter._numberOfCells-1) {
45 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
46 }
47}
48
49
51 if (_myWriter._numberOfVertices==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 _lastWriteCommandVertexNumber>-2,
56 _identifier,
57 "closed twice"
58 );
60 _lastWriteCommandVertexNumber==_myWriter._numberOfVertices-1,
61 "one record has to be written per cell on writer " << _identifier <<
62 " (vertex entries written=" << _lastWriteCommandVertexNumber <<
63 ", vertex entries expected=" << _myWriter._numberOfVertices << ")"
64 );
65 assertionMsg( _myWriter.isOpen(), "Maybe you forgot to call close() or assignRemainingVerticesDefaultValues() on a data writer before you destroy your writer for value " << _identifier );
66
67 if (_lastWriteCommandVertexNumber>=-1) {
68 _out << std::endl;
69 _myWriter._vertexDataDescription << _out.str();
70 }
71 _lastWriteCommandVertexNumber = -2;
72}
73
74
76 assertion(_lastWriteCommandVertexNumber>=-1);
77 assertion(1<=_recordsPerVertex);
78
79 assertion3( value != std::numeric_limits<double>::infinity(), index, value, _identifier);
80 assertion3( value == value, index, value, _identifier); // test for not a number
81
82 while (_lastWriteCommandVertexNumber<index-1) {
83 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
84 }
85
86 _lastWriteCommandVertexNumber = index;
87
88 if (_myWriter._precision < 7){
89 float tmp;
90 tmp = value;
92 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
93 tmp = 0.0;
94 for (int i=1; i<_recordsPerVertex; i++) {
96 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
97 }
98 } else {
99 double tmp;
100 tmp = value;
102 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
103 tmp = 0.0;
104 for (int i=1; i<_recordsPerVertex; i++) {
106 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
107 }
108 }
109
110 if (value<_minValue) _minValue = value;
111 if (value>_maxValue) _maxValue = value;
112}
113
114
116 assertion(_lastWriteCommandVertexNumber>=-1);
117 assertion(2<=_recordsPerVertex);
118
119 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
120 assertion1( value(0) == value(0), value(0) ); // test for not a number
121
122 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
123 assertion1( value(1) == value(1), value(1) ); // test for not a number
124
125 while (_lastWriteCommandVertexNumber<index-1) {
126 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
127 }
128
129 _lastWriteCommandVertexNumber = index;
130
131 if (_myWriter._precision < 7){
132 float tmp;
133 tmp = value(0);
135 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
136 tmp = value(1);
138 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
139 tmp = 0.0;
140 for (int i=2; i<_recordsPerVertex; i++) {
142 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
143 }
144 } else {
145 double tmp;
146 tmp = value(0);
148 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
149 tmp = value(1);
151 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
152 tmp = 0.0;
153 for (int i=2; i<_recordsPerVertex; i++) {
155 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
156 }
157 }
158
159 if (value(0)<_minValue) _minValue = value(0);
160 if (value(0)>_maxValue) _maxValue = value(0);
161 if (value(1)<_minValue) _minValue = value(1);
162 if (value(1)>_maxValue) _maxValue = value(1);
163}
164
165
167 assertion(_lastWriteCommandVertexNumber>=-1);
168 assertion(3<=_recordsPerVertex);
169
170 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
171 assertion1( value(0) == value(0), value(0) ); // test for not a number
172
173 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
174 assertion1( value(1) == value(1), value(1) ); // test for not a number
175
176 assertion1( value(2) != std::numeric_limits<double>::infinity(), value(2) );
177 assertion1( value(2) == value(2), value(2) ); // test for not a number
178
179 while (_lastWriteCommandVertexNumber<index-1) {
180 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
181 }
182
183 _lastWriteCommandVertexNumber = index;
184
185 if (_myWriter._precision < 7){
186 float tmp;
187 tmp = value(0);
189 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
190 tmp = value(1);
192 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
193 tmp = value(2);
195 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
196 tmp = 0.0;
197 for (int i=3; i<_recordsPerVertex; i++) {
199 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
200 }
201 } else {
202 double tmp;
203 tmp = value(0);
205 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
206 tmp = value(1);
208 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
209 tmp = value(2);
211 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
212 tmp = 0.0;
213 for (int i=3; i<_recordsPerVertex; i++) {
215 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
216 }
217 }
218
219 if (value(0)<_minValue) _minValue = value(0);
220 if (value(0)>_maxValue) _maxValue = value(0);
221 if (value(1)<_minValue) _minValue = value(1);
222 if (value(1)>_maxValue) _maxValue = value(1);
223 if (value(2)<_minValue) _minValue = value(2);
224 if (value(2)>_maxValue) _maxValue = value(2);
225}
226
227
229 assertion(_lastWriteCommandVertexNumber>=-1);
230 assertion(numberOfValues<=_recordsPerVertex);
231
232 for( int i=0; i<numberOfValues; i++) {
233 assertion1( values[i] != std::numeric_limits<double>::infinity(), values[i] );
234 assertion1( values[i] == values[i], values[i] ); // test for not a number
235 }
236
237 while (_lastWriteCommandVertexNumber<index-1) {
238 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
239 }
240
241 _lastWriteCommandVertexNumber = index;
242
243 if (_myWriter._precision < 7){
244 float tmp;
245 for( int i=0; i<numberOfValues; i++) {
246 tmp = values[i];
248 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
249 }
250 tmp = 0.0;
251 for (int i=numberOfValues; i<_recordsPerVertex; i++) {
253 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
254 }
255 } else {
256 double tmp;
257 for( int i=0; i<numberOfValues; i++) {
258 tmp = values[i];
260 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
261 }
262 tmp = 0.0;
263 for (int i=numberOfValues; i<_recordsPerVertex; i++) {
265 _out.write( reinterpret_cast<char*>(&tmp) , sizeof(tmp));
266 }
267 }
268
269 for( int i=0; i<numberOfValues; i++) {
270 if (values[i]<_minValue) _minValue = values[i];
271 if (values[i]>_maxValue) _maxValue = values[i];
272 }
273}
274
275
279
280
#define assertion2(expr, param0, param1)
#define assertion4(expr, param0, param1, param2, param3)
#define assertion3(expr, param0, param1, param2)
#define assertion1(expr, param)
#define assertionMsg(expr, message)
#define assertion(expr)
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
virtual void plotVertex(int index, double value) override
Write data for one cell.
VertexDataWriter(const std::string &dataIdentifier, VTKBinaryFileWriter &writer, int recordsPerVertex)
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