Peano 4
Loading...
Searching...
No Matches
VTKTextFileWriter_CellDataWriter.cpp
Go to the documentation of this file.
2
3#include <limits>
4#include <iomanip>
5
7 const std::string& dataIdentifier, VTKTextFileWriter& writer, int recordsPerCell
8):
9 _identifier(dataIdentifier),
10 _lastWriteCommandCellNumber(-1),
11 _myWriter(writer),
12 _out(),
13 _recordsPerCell(recordsPerCell),
14 _minValue(std::numeric_limits<double>::max()),
15 _maxValue(std::numeric_limits<double>::min()) {
17
18 _out << std::setprecision(_myWriter._precision);
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 _out << value << " ";
107 for (int i=1; i<_recordsPerCell; i++) {
108 _out << 0.0 << " ";
109 }
110
111 _out << std::endl;
112
113 if (value<_minValue) _minValue = value;
114 if (value>_maxValue) _maxValue = value;
115}
116
117
119 assertion(_lastWriteCommandCellNumber>=-1);
120 assertion(2<=_recordsPerCell);
121
122 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
123 assertion1( value(0) == value(0), value(0) ); // test for not a number
124
125 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
126 assertion1( value(1) == value(1), value(1) ); // test for not a number
127
128 while (_lastWriteCommandCellNumber<index-1) {
129 plotCell(_lastWriteCommandCellNumber+1,0.0);
130 }
131
132 _lastWriteCommandCellNumber = index;
133 _out << value(0) << " ";
134 _out << value(1) << " ";
135 for (int i=2; i<_recordsPerCell; i++) {
136 _out << 0.0 << " ";
137 }
138 _out << std::endl;
139
140 if (value(0)<_minValue) _minValue = value(0);
141 if (value(0)>_maxValue) _maxValue = value(0);
142 if (value(1)<_minValue) _minValue = value(1);
143 if (value(1)>_maxValue) _maxValue = value(1);
144}
145
146
148 assertion(_lastWriteCommandCellNumber>=-1);
149 assertion(3<=_recordsPerCell);
150
151 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
152 assertion1( value(0) == value(0), value(0) ); // test for not a number
153
154 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
155 assertion1( value(1) == value(1), value(1) ); // test for not a number
156
157 assertion1( value(2) != std::numeric_limits<double>::infinity(), value(2) );
158 assertion1( value(2) == value(2), value(2) ); // test for not a number
159
160 while (_lastWriteCommandCellNumber<index-1) {
161 plotCell(_lastWriteCommandCellNumber+1,0.0);
162 }
163
164 _lastWriteCommandCellNumber = index;
165 _out << value(0) << " ";
166 _out << value(1) << " ";
167 _out << value(2) << " ";
168 for (int i=3; i<_recordsPerCell; i++) {
169 _out << 0.0 << " ";
170 }
171 _out << std::endl;
172
173 if (value(0)<_minValue) _minValue = value(0);
174 if (value(0)>_maxValue) _maxValue = value(0);
175 if (value(1)<_minValue) _minValue = value(1);
176 if (value(1)>_maxValue) _maxValue = value(1);
177 if (value(2)<_minValue) _minValue = value(2);
178 if (value(2)>_maxValue) _maxValue = value(2);
179}
180
181
183 assertion(_lastWriteCommandCellNumber>=-1);
184 assertion(numberOfValues<=_recordsPerCell);
185
186 for( int i=0; i<numberOfValues; i++) {
187 assertion1( values[i] != std::numeric_limits<double>::infinity(), values[i] );
188 assertion1( values[i] == values[i], values[i] ); // test for not a number
189 }
190
191 while (_lastWriteCommandCellNumber<index-1) {
192 plotCell(_lastWriteCommandCellNumber+1,0.0);
193 }
194
195 _lastWriteCommandCellNumber = index;
196 for( int i=0; i<numberOfValues; i++) {
197 _out << values[i] << " ";
198 }
199 for (int i=numberOfValues; i<_recordsPerCell; i++) {
200 _out << 0.0 << " ";
201 }
202 _out << std::endl;
203
204 for( int i=0; i<numberOfValues; i++) {
205 if (values[i]<_minValue) _minValue = values[i];
206 if (values[i]>_maxValue) _maxValue = values[i];
207 }
208}
209
210
214
215
#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
virtual void plotCell(int index, double value) override
Write data for one cell.
CellDataWriter(const std::string &dataIdentifier, VTKTextFileWriter &writer, int recordsPerCell)
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.
Simple vector class.
Definition Vector.h:134