Peano 4
Loading...
Searching...
No Matches
PeanoTextPatchFileWriter_CellDataWriter.cpp
Go to the documentation of this file.
3
4#include <iomanip>
5
6
8 const std::string& identifier,
9 int unknownsPerAxis,
10 int numberOfUnknowns, const std::string& description,
11 const std::string& metaData,
12 double* mapping,
14):
15 _writer(writer),
16 _identifier(identifier),
17 _numberOfCellsPerAxis(unknownsPerAxis),
18 _numberOfUnknowns(numberOfUnknowns),
19 _entryCounter(0) {
20 _writer._snapshotFileOut << "begin cell-metadata \"" << identifier << "\"" << std::endl
21 << " number-of-unknowns " << _numberOfUnknowns << std::endl
22 << " number-of-dofs-per-axis " << _numberOfCellsPerAxis << std::endl
23 << " description " << description << std::endl;
24
25 _writer.writeMetaData(metaData);
27
28 _writer._snapshotFileOut << "end cell-metadata" << std::endl << std::endl;
29 _out << std::scientific;
30}
31
32
34
35
39
40
42 if (precision>0) {
43 _out << std::setprecision(precision);
44 }
45}
46
47
49 for (int i=0; i<_numberOfUnknowns; i++) {
50 if (std::isnan(value)) {
51 _out << " nan";
52 } else {
53 if ( std::abs(value) < std::numeric_limits<double>::min() ) value = 0.0;
54 if (tarch::la::equals(value,0.0)) {
55 _out << " 0";
56 } else {
57 _out << " " << value;
58 }
59 }
60 _entryCounter++;
61 }
62 flushIfPatchIsComplete();
63}
64
65
67 for (int i=0; i<_numberOfUnknowns; i++) {
68 if (std::isnan(values[i])) {
69 _out << " nan";
70 } else {
71 if ( std::abs(values[i]) < std::numeric_limits<double>::min() ) values[i] = 0.0;
72 if (tarch::la::equals(values[i],0.0)) {
73 _out << " 0";
74 } else {
75 _out << " " << values[i];
76 }
77 }
78 _entryCounter++;
79 }
80 flushIfPatchIsComplete();
81}
82
83
85
86
88 if (_entryCounter>=getCellsPerPatch()*_numberOfUnknowns) {
89 _out << std::flush;
90 _writer._snapshotFileOut << " begin cell-values \"" << _identifier << "\"" << std::endl
91 << " " << _out.rdbuf() << std::endl
92 << " end cell-values" << std::endl;
93 _out.clear();
94 _entryCounter = 0;
95 }
96}
97
98
102
103
#define assertionMsg(expr, message)
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
tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter & _writer
CellDataWriter(const std::string &identifier, int unknownsPerAxis, int numberOfUnknowns, const std::string &description, const std::string &metaData, double *mapping, tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter &writer)
virtual void close() override
If you close your writer, each cell/vertex has to be assigned a value, i.e.
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.
int aPowI(int i, int a)
Computes the i-th power of a in integer arithmetic.