Peano 4
Loading...
Searching...
No Matches
VTUTextFileWriter_CellDataWriter.cpp
Go to the documentation of this file.
2
3#include <limits>
4#include <iomanip>
5
7 const std::string& dataIdentifier, VTUTextFileWriter& writer, int recordsPerCell, std::string dataType
8):
9 _dataType(dataType),
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 _out << " <DataArray type=\""
20 << _dataType << "\" Name=\"" << _identifier
21 << "\" format=\"ascii\""
22 << " NumberOfComponents=\"" << _recordsPerCell << "\" >"
23 << std::endl;
24
25 _myWriter._parallelCellDataDescription += "<PDataArray type=\""
26 + _dataType
27 + "\" Name=\""
29 + "\" NumberOfComponents=\""
30 + std::to_string(_recordsPerCell)
31 + "\"/>";
32}
33
34
36 if (_lastWriteCommandCellNumber>=-1) {
37 close();
38 }
39}
40
41
44 _lastWriteCommandCellNumber <= _myWriter._numberOfCells-1,
45 _lastWriteCommandCellNumber, _myWriter._numberOfCells,
46 _identifier,
47 "please call close on the cell/vertex writer before"
48 );
49
50 while (_lastWriteCommandCellNumber<_myWriter._numberOfCells-1) {
51 plotCell(_lastWriteCommandCellNumber+1,0.0);
52 }
53}
54
55
57 if (_myWriter._numberOfCells==0 && _lastWriteCommandCellNumber>0 ) {
58 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" );
59 }
61 _lastWriteCommandCellNumber>-2,
62 _identifier,
63 "closed twice"
64 );
66 _lastWriteCommandCellNumber==_myWriter._numberOfCells-1,
67 "one record has to be written per cell on writer " << _identifier <<
68 " (cell entries written=" << _lastWriteCommandCellNumber <<
69 ", cell entries expected=" << _myWriter._numberOfCells << ")"
70 );
71 assertionMsg( _myWriter.isOpen(), "Maybe you forgot to call close() or assignRemainingCellsDefaultValues() on a data writer before you destroy your writer?" );
72
73 if (_lastWriteCommandCellNumber>=-1) {
74 _out << "</DataArray>" << std::endl;
75 _myWriter._cellDataDescription += _out.str();
76 }
77 _lastWriteCommandCellNumber = -2;
78}
79
80
82 assertion(_lastWriteCommandCellNumber>=-1);
83 assertion(1<=_recordsPerCell);
84
86 value != std::numeric_limits<double>::infinity(),
87 value,
88 _lastWriteCommandCellNumber,
89 _recordsPerCell,
90 _minValue,
91 _maxValue,
92 _identifier
93 );
94
95
96 // test for not a number
98 value == value,
99 value,
100 _lastWriteCommandCellNumber,
101 _recordsPerCell,
102 _minValue,
103 _maxValue,
104 _identifier
105 );
106
107 while (_lastWriteCommandCellNumber<index-1) {
108 plotCell(_lastWriteCommandCellNumber+1,0.0);
109 }
110
111 _lastWriteCommandCellNumber = index;
112 _out << value << " ";
113 for (int i=1; i<_recordsPerCell; i++) {
114 _out << 0.0 << " ";
115 }
116
117 _out << std::endl;
118
119 if (value<_minValue) _minValue = value;
120 if (value>_maxValue) _maxValue = value;
121}
122
123
125 assertion(_lastWriteCommandCellNumber>=-1);
126 assertion(2<=_recordsPerCell);
127
128 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
129 assertion1( value(0) == value(0), value(0) ); // test for not a number
130
131 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
132 assertion1( value(1) == value(1), value(1) ); // test for not a number
133
134 while (_lastWriteCommandCellNumber<index-1) {
135 plotCell(_lastWriteCommandCellNumber+1,0.0);
136 }
137
138 _lastWriteCommandCellNumber = index;
139 _out << value(0) << " ";
140 _out << value(1) << " ";
141 for (int i=2; i<_recordsPerCell; i++) {
142 _out << 0.0 << " ";
143 }
144 _out << std::endl;
145
146 if (value(0)<_minValue) _minValue = value(0);
147 if (value(0)>_maxValue) _maxValue = value(0);
148 if (value(1)<_minValue) _minValue = value(1);
149 if (value(1)>_maxValue) _maxValue = value(1);
150}
151
152
154 assertion(_lastWriteCommandCellNumber>=-1);
155 assertion(3<=_recordsPerCell);
156
157 assertion1( value(0) != std::numeric_limits<double>::infinity(), value(0) );
158 assertion1( value(0) == value(0), value(0) ); // test for not a number
159
160 assertion1( value(1) != std::numeric_limits<double>::infinity(), value(1) );
161 assertion1( value(1) == value(1), value(1) ); // test for not a number
162
163 assertion1( value(2) != std::numeric_limits<double>::infinity(), value(2) );
164 assertion1( value(2) == value(2), value(2) ); // test for not a number
165
166 while (_lastWriteCommandCellNumber<index-1) {
167 plotCell(_lastWriteCommandCellNumber+1,0.0);
168 }
169
170 _lastWriteCommandCellNumber = index;
171 _out << value(0) << " ";
172 _out << value(1) << " ";
173 _out << value(2) << " ";
174 for (int i=3; i<_recordsPerCell; i++) {
175 _out << 0.0 << " ";
176 }
177 _out << std::endl;
178
179 if (value(0)<_minValue) _minValue = value(0);
180 if (value(0)>_maxValue) _maxValue = value(0);
181 if (value(1)<_minValue) _minValue = value(1);
182 if (value(1)>_maxValue) _maxValue = value(1);
183 if (value(2)<_minValue) _minValue = value(2);
184 if (value(2)>_maxValue) _maxValue = value(2);
185}
186
187
189 assertion(_lastWriteCommandCellNumber>=-1);
190 assertion(numberOfValues<=_recordsPerCell);
191
192 for( int i=0; i<numberOfValues; i++) {
193 assertion1( values[i] != std::numeric_limits<double>::infinity(), values[i] );
194 assertion1( values[i] == values[i], values[i] ); // test for not a number
195 }
196
197 while (_lastWriteCommandCellNumber<index-1) {
198 plotCell(_lastWriteCommandCellNumber+1,0.0);
199 }
200
201 _lastWriteCommandCellNumber = index;
202 for( int i=0; i<numberOfValues; i++) {
203 _out << values[i] << " ";
204 }
205 for (int i=numberOfValues; i<_recordsPerCell; i++) {
206 _out << 0.0 << " ";
207 }
208 _out << std::endl;
209
210 for( int i=0; i<numberOfValues; i++) {
211 if (values[i]<_minValue) _minValue = values[i];
212 if (values[i]>_maxValue) _maxValue = values[i];
213 }
214}
215
216
220
221
#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 close() override
If you close your writer, each cell/vertex has to be assigned a value, i.e.
virtual void plotCell(int index, double value) override
Write data for one cell.
CellDataWriter(const std::string &dataIdentifier, VTUTextFileWriter &writer, int recordsPerCell, std::string dataType)
STL namespace.
Simple vector class.
Definition Vector.h:134