Skip to content

Commit c90f775

Browse files
rectMesh postProcess revisited
1 parent b7f051e commit c90f775

14 files changed

Lines changed: 399 additions & 55 deletions

File tree

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,26 @@ bool PostprocessOperationAverage::write(const fileSystem &parDir) const
178178
return true;
179179
}
180180

181+
bool PostprocessOperationAverage::write(iOstream &os) const
182+
{
183+
if(! postprocessOperation::write(os))
184+
{
185+
return false;
186+
}
187+
if(!calculateFluctuation2_())
188+
{
189+
return true;
190+
}
191+
192+
return
193+
std::visit
194+
(
195+
[&](auto&& arg)->bool
196+
{
197+
return arg.writeFieldToVtk(os);
198+
},
199+
fluctuation2FieldPtr_()
200+
);
201+
}
202+
181203
} // namespace pFlow::postprocessData

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ class PostprocessOperationAverage
195195
/// write to os stream
196196
bool write(const fileSystem &parDir)const override;
197197

198+
bool write(iOstream& os)const override;
199+
198200

199201
/// @brief Execute average operation on field values
200202
/// @param weights Weight factors for particles

src/PostprocessData/operation/PostprocessOperation/operationFunctions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ regionField<T> executeFluctuation2Operation
142142
)
143143
{
144144
const auto& regPoints = fieldAvg.regPoints();
145-
regionField<T> processedField(regFieldName, regPoints, T{});
145+
regionField<T> processedField(regFieldName+"_fluctuation2", regPoints, T{});
146146
auto vols = regPoints.volumes();
147147

148148
for(uint32 reg =0; reg<regPoints.size(); reg++)

src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,25 @@ bool postprocessOperation::write(const fileSystem &parDir) const
124124
return true;
125125
}
126126

127+
bool postprocessOperation::write(iOstream& os)const
128+
{
129+
if(!regPoints().writeToSameTimeFile())
130+
{
131+
const auto& field = processedField();
132+
133+
return
134+
std::visit
135+
(
136+
[&](auto&& arg)->bool
137+
{
138+
return arg.writeFieldToVtk(os);
139+
},
140+
field
141+
);
142+
}
143+
return false;
144+
}
145+
127146
uniquePtr<postprocessOperation> postprocessOperation::create
128147
(
129148
const dictionary &opDict,

src/PostprocessData/operation/postprocessOperation/postprocessOperation.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class postprocessOperation
9999
private:
100100

101101
/// Dictionary containing operation-specific parameters.
102-
pFlow::dictionary operationDict_;
102+
pFlow::dictionary operationDict_;
103103

104104
/// This Threshold is used to exclude the regions which contain
105105
/// fewer than this value.
@@ -255,7 +255,7 @@ class postprocessOperation
255255
/// write the result to output stream (possibly a file)
256256
/// @param os Output stream to write the result.
257257
virtual
258-
bool write(iOstream& os)const {return true;}
258+
bool write(iOstream& os)const;
259259

260260
/// Create the polymorphic object using the virtual constructor.
261261
/// @param opDict Dictionary containing operation-specific parameters.

src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,25 @@ bool pFlow::postprocessData::PostprocessComponent<RegionType, ProcessMethodType>
152152
}
153153
else
154154
{
155-
notImplementedFunction;
156-
return false;
157-
}
158-
155+
word chNum = real2FixedStripZeros(database().time().currentTime() *1000000, 0);
156+
fileSystem file = parDir + (name() +"-"+chNum+".vtk");
157+
158+
auto osPtr = makeUnique<oFstream>(file);
159159

160+
regPoints().write(osPtr());
161+
162+
for(auto& operation:operatios_)
163+
{
164+
if(!operation->write(osPtr()))
165+
{
166+
fatalErrorInFunction
167+
<<"Error occurred in writing operation defined in dict "
168+
<< operation->operationDict()
169+
<<endl;
170+
return false;
171+
}
172+
}
173+
}
160174

161175
return true;
162176
}

src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PostprocessComponent
5353

5454
regionField<real> volumeFactor_;
5555

56-
bool executed_{false};
56+
bool executed_{false};
5757

5858
dictionaryList operationDicts_;
5959

@@ -122,8 +122,6 @@ class PostprocessComponent
122122

123123
};
124124

125-
126-
127125
}
128126

129127
#include "PostprocessComponent.cpp"

src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentGaussian.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class PostprocessComponentGaussian
4747
:
4848
PostprocessComponent<RegionType,GaussianDistribution>(dict, fieldsDB, defaultTimeControl)
4949
{
50-
/// initializes the Gaussian distribution for all elements of region
51-
//const uint32 n = this->regPoints().size();
50+
51+
this->regPoints().setRegionExtension(2);
5252
auto d = this->regPoints().eqDiameters();
5353
auto c = this->regPoints().centers();
5454
auto& regs = this->regionProecessMethod();

src/PostprocessData/region/regionFields/regionField.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "types.hpp"
2525
#include "regionPoints.hpp"
2626
#include "Field.hpp"
27+
#include "cellMapper.hpp"
2728

2829
namespace pFlow::postprocessData
2930
{
@@ -101,6 +102,11 @@ class regionField
101102
return field_.size();
102103
}
103104

105+
uint32x3 shape()const
106+
{
107+
return regionPoints_.shape();
108+
}
109+
104110
bool empty()const
105111
{
106112
return field_.empty();

src/PostprocessData/region/regionFields/regionFieldTemplate.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
3+
14
namespace pFlow::postprocessData
25
{
36

@@ -9,6 +12,86 @@ regionField<T>::regionField(
912
:
1013
field_(name, "regionFieldValue", rPoints.size(), rPoints.size(), defaultVal),
1114
regionPoints_(rPoints)
15+
1216
{}
1317

18+
template<typename T>
19+
inline
20+
bool regionField<T>::writeFieldToVtk(iOstream& os)const
21+
{
22+
fatalErrorInFunction<< "This type is not supported for vtk conversion:"<<
23+
field_.typeName()<<endl;
24+
fatalExit;
25+
return false;
26+
}
27+
28+
template<>
29+
inline
30+
bool regionField<real>::writeFieldToVtk(iOstream& os)const
31+
{
32+
os<<"FIELD FieldData 1 " << field_.name() << " 1 "<< field_.size() << " float\n";
33+
34+
35+
const auto mapper = cellMapper{shape()};
36+
37+
for(uint32 k=0; k<mapper.nz(); k++)
38+
{
39+
for(uint32 j=0; j<mapper.ny(); j++)
40+
{
41+
for(uint32 i=0; i<mapper.nx(); i++)
42+
{
43+
os<< field_[ mapper(i,j,k) ]<<'\n';
44+
}
45+
}
46+
}
47+
os<<endl;
48+
return true;
49+
}
50+
51+
template<>
52+
inline
53+
bool regionField<realx3>::writeFieldToVtk(iOstream& os)const
54+
{
55+
os<<"FIELD FieldData 1 " << field_.name() << " 3 "<< field_.size() << " float\n";
56+
57+
58+
const auto mapper = cellMapper{shape()};
59+
60+
for(uint32 k=0; k<mapper.nz(); k++)
61+
{
62+
for(uint32 j=0; j<mapper.ny(); j++)
63+
{
64+
for(uint32 i=0; i<mapper.nx(); i++)
65+
{
66+
os<<field_[mapper(i,j,k)].x()<<' '<<field_[mapper(i,j,k)].y()<<' '<<field_[mapper(i,j,k)].z()<<'\n';
67+
}
68+
}
69+
}
70+
os<<endl;
71+
return true;
72+
}
73+
74+
template<>
75+
inline
76+
bool regionField<uint32>::writeFieldToVtk(iOstream& os)const
77+
{
78+
os<<"FIELD FieldData 1 " << field_.name() << " 1 "<< field_.size() << " int\n";
79+
80+
81+
const auto mapper = cellMapper{shape()} ;
82+
83+
for(uint32 k=0; k<mapper.nz(); k++)
84+
{
85+
for(uint32 j=0; j<mapper.ny(); j++)
86+
{
87+
for(uint32 i=0; i<mapper.nx(); i++)
88+
{
89+
os<< field_[ mapper(i,j,k) ]<<'\n';
90+
}
91+
}
92+
}
93+
os<<endl;
94+
return true;
95+
}
96+
1497
} // End namespace pFlow::postprocessData

0 commit comments

Comments
 (0)