Peano 4
Loading...
Searching...
No Matches
VTKTextFileWriter_VertexDataWriter.cpp
Go to the documentation of this file.
2
3#include <limits>
4#include <iomanip>
5
7 const std::string& identifier, VTKTextFileWriter& writer, int recordsPerVertex
8):
9 _lastWriteCommandVertexNumber(-1),
10 _myWriter(writer),
11 _out(),
12 _recordsPerVertex(recordsPerVertex),
13 _minValue(std::numeric_limits<double>::max()),
14 _maxValue(std::numeric_limits<double>::min()),
15 _identifier(identifier) {
17
18 _out << std::setprecision(_myWriter._precision);
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
52 _lastWriteCommandVertexNumber>-2,
53 _identifier,
54 "closed twice"
55 );
57 _lastWriteCommandVertexNumber==_myWriter._numberOfVertices-1,
58 "one record has to be written per vertex on writer " << _identifier <<
59 " (vertex entries written=" << _lastWriteCommandVertexNumber <<
60 ", vertex entries expected=" << _myWriter._numberOfVertices << ")"
61 );
62 assertionMsg( _myWriter.isOpen(), "Maybe you forgot to call close() or assignRemainingVerticesDefaultValues() on a data writer before you destroy your writer for value " << _identifier );
63
64 if (_lastWriteCommandVertexNumber>=-1) {
65 _out << std::endl;
66 _myWriter._vertexDataDescription += _out.str();
67 }
68 _lastWriteCommandVertexNumber = -2;
69}
70
71
73 assertion(_lastWriteCommandVertexNumber>=-1);
74 assertion(1<=_recordsPerVertex);
75
76 assertion3( value != std::numeric_limits<double>::infinity(), index, value, _identifier);
77 assertion3( value == value, index, value, _identifier); // test for not a number
78
79 while (_lastWriteCommandVertexNumber<index-1) {
80 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
81 }
82
83 _lastWriteCommandVertexNumber = index;
84 _out << value << " ";
85 for (int i=1; i<_recordsPerVertex; i++) {
86 _out << 0.0 << " ";
87 }
88
89 _out << std::endl;
90
91 if (value<_minValue) _minValue = value;
92 if (value>_maxValue) _maxValue = value;
93}
94
95
97 assertion(_lastWriteCommandVertexNumber>=-1);
98 assertion(2<=_recordsPerVertex);
99
100 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
101 assertion1( value(0) == value(0), value(0) ); // test for not a number
102
103 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
104 assertion1( value(1) == value(1), value(1) ); // test for not a number
105
106 while (_lastWriteCommandVertexNumber<index-1) {
107 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
108 }
109
110 _lastWriteCommandVertexNumber = index;
111 _out << value(0) << " ";
112 _out << value(1) << " ";
113 for (int i=2; i<_recordsPerVertex; i++) {
114 _out << 0.0 << " ";
115 }
116 _out << std::endl;
117
118 if (value(0)<_minValue) _minValue = value(0);
119 if (value(0)>_maxValue) _maxValue = value(0);
120 if (value(1)<_minValue) _minValue = value(1);
121 if (value(1)>_maxValue) _maxValue = value(1);
122}
123
124
126 assertion(_lastWriteCommandVertexNumber>=-1);
127 assertion(3<=_recordsPerVertex);
128
129 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
130 assertion1( value(0) == value(0), value(0) ); // test for not a number
131
132 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
133 assertion1( value(1) == value(1), value(1) ); // test for not a number
134
135 assertion1( value(2) != std::numeric_limits<double>::infinity(), value(2) );
136 assertion1( value(2) == value(2), value(2) ); // test for not a number
137
138 while (_lastWriteCommandVertexNumber<index-1) {
139 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
140 }
141
142 _lastWriteCommandVertexNumber = index;
143 _out << value(0) << " ";
144 _out << value(1) << " ";
145 _out << value(2) << " ";
146 for (int i=3; i<_recordsPerVertex; i++) {
147 _out << 0.0 << " ";
148 }
149 _out << std::endl;
150
151 if (value(0)<_minValue) _minValue = value(0);
152 if (value(0)>_maxValue) _maxValue = value(0);
153 if (value(1)<_minValue) _minValue = value(1);
154 if (value(1)>_maxValue) _maxValue = value(1);
155 if (value(2)<_minValue) _minValue = value(2);
156 if (value(2)>_maxValue) _maxValue = value(2);
157}
158
159
161 assertion(_lastWriteCommandVertexNumber>=-1);
162 assertion(numberOfValues<=_recordsPerVertex);
163
164 for( int i=0; i<numberOfValues; i++) {
165 assertion1( values[i] != std::numeric_limits<double>::infinity(), values[i] );
166 assertion1( values[i] == values[i], values[i] ); // test for not a number
167 }
168
169 while (_lastWriteCommandVertexNumber<index-1) {
170 plotVertex(_lastWriteCommandVertexNumber+1,0.0);
171 }
172
173 _lastWriteCommandVertexNumber = index;
174
175 for( int i=0; i<numberOfValues; i++) {
176 _out << values[i] << " ";
177 }
178 for (int i=numberOfValues; i<_recordsPerVertex; i++) {
179 _out << 0.0 << " ";
180 }
181
182 for( int i=0; i<numberOfValues; i++) {
183 if (values[i]<_minValue) _minValue = values[i];
184 if (values[i]>_maxValue) _maxValue = values[i];
185 }
186}
187
188
192
193
#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
virtual void plotVertex(int index, double value) override
Write data for one cell.
VertexDataWriter(const std::string &dataIdentifier, VTKTextFileWriter &writer, int recordsPerVertex)
const std::string _doubleOrFloat
either "float" or "double" depending on _precision
STL namespace.
Simple vector class.
Definition Vector.h:134