Skip to content

Commit 42315d2

Browse files
bug fix for issue #241, precision in output file
1 parent c340040 commit 42315d2

6 files changed

Lines changed: 51 additions & 3 deletions

File tree

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,15 @@ bool PostprocessOperationAverage::write(const fileSystem &parDir) const
161161
fileSystem path = parDir+(
162162
processedFieldName()+"_prime2" + ".Start_" + ti.timeName());
163163
os2Ptr_ = makeUnique<oFstream>(path);
164-
164+
165+
if(regPoints().scientific())
166+
{
167+
// set output format to scientific notation
168+
os2Ptr_().stdStream()<<std::scientific;
169+
}
170+
171+
os2Ptr_().precision(regPoints().precision());
172+
165173
regPoints().write(os2Ptr_());
166174
}
167175

src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ bool postprocessOperation::write(const fileSystem &parDir) const
107107
processedFieldName() + ".Start_" + ti.timeName());
108108
osPtr_ = makeUnique<oFstream>(path);
109109

110+
if(regPoints().scientific())
111+
{
112+
// set output format to scientific notation
113+
osPtr_().stdStream()<<std::scientific;
114+
}
115+
116+
osPtr_().precision(regPoints().precision());
117+
110118
regPoints().write(osPtr_());
111119
}
112120

src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ bool pFlow::postprocessData::PostprocessComponent<RegionType, ProcessMethodType>
157157

158158
auto osPtr = makeUnique<oFstream>(file);
159159

160+
// set output format to scientific notation
161+
if(regPoints().scientific())
162+
{
163+
osPtr->stdStream() << std::scientific;
164+
}
165+
166+
osPtr().precision(regPoints().precision());
167+
160168
regPoints().write(osPtr());
161169

162170
for(auto& operation:operatios_)

src/PostprocessData/postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ bool pFlow::postprocessData::particleProbePostprocessComponent::write(const file
157157
// file is not open yet
158158
fileSystem path = parDir + (name_+".Start_"+ti.timeName());
159159
osPtr_ = makeUnique<oFstream>(path);
160+
161+
if(regionPointsPtr_().scientific())
162+
{
163+
osPtr_().stdStream() << std::scientific;
164+
}
165+
osPtr_().precision(regionPointsPtr_().precision());
160166
regionPointsPtr_().write(osPtr_());
161167
}
162168

src/PostprocessData/region/regionPoints/regionPoints/regionPoints.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ regionPoints::regionPoints
1212
)
1313
:
1414
fieldsDataBase_(fieldsDataBase)
15-
{}
15+
{
16+
precision_ = dict.getValOrSet<int>("precision", 6);
17+
scientific_ = dict.getValOrSet<Logical>("scientific", Logical(true));
18+
}
1619

1720
const Time& regionPoints::time() const
1821
{

src/PostprocessData/region/regionPoints/regionPoints/regionPoints.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ class regionPoints
5252
using PointsTypeHost = typename pointStructure::PointsTypeHost;
5353

5454
/// Reference to the fields database containing simulation data
55-
fieldsDataBase& fieldsDataBase_;
55+
fieldsDataBase& fieldsDataBase_;
56+
57+
/// default precision for output
58+
int precision_ = 6;
59+
60+
/// if scientific notation is used for output
61+
Logical scientific_;
5662

5763
public:
5864

@@ -74,7 +80,16 @@ class regionPoints
7480

7581
/// Returns non-const reference to the fields database
7682
fieldsDataBase& database();
83+
84+
int precision() const
85+
{
86+
return precision_;
87+
}
7788

89+
bool scientific()const
90+
{
91+
return scientific_();
92+
}
7893
/// @brief size of elements
7994
virtual
8095
uint32 size()const = 0;

0 commit comments

Comments
 (0)