Skip to content

Commit 53e6d6a

Browse files
special functions for postprocessing: bulkDensity and solidVolFraction
1 parent ee8c545 commit 53e6d6a

10 files changed

+264
-100
lines changed

src/PostprocessData/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ set(SourceFiles
2525
operation/PostprocessOperation/PostprocessOperationSum.cpp
2626
operation/PostprocessOperation/PostprocessOperationAverage.cpp
2727
operation/PostprocessOperation/PostprocessOperationAvMassVelocity.cpp
28-
28+
operation/PostprocessOperation/PostprocessOperationSolidVolFraction.cpp
29+
operation/PostprocessOperation/PostprocessOperationBulkDensity.cpp
30+
2931
operation/includeMask/includeMask.cpp
3032
operation/includeMask/IncludeMasks.cpp
3133

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAvMassVelocity.hpp

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -23,106 +23,10 @@
2323

2424
/*!
2525
* @class PostprocessOperationAvMassVelocity
26-
* @brief A class for averaging field values within specified regions during post-processing.
26+
* @brief Calculates mass-weighted average velocity of particles in the regions
2727
*
28-
* @details
29-
* The PostprocessOperationAvMassVelocity class is a specialized post-processing operation that
30-
* calculates the average of field values within specified regions. It inherits from the
31-
* postprocessOperation base class and implements a weighted averaging operation that
32-
* can be applied to scalar (real), vector (realx3), and tensor (realx4) fields.
33-
*
34-
* The average operation follows the mathematical formula:
35-
* \f[
36-
* \text{result} = \frac{\sum_{j \in \text{includeMask}} w_j \cdot \phi_j \cdot \text{field}_j}
37-
* {\sum_{i \in \text{processRegion}} w_i \cdot \phi_i}
38-
* \f]
39-
*
40-
* Where:
41-
* - \f$ i \f$ represents all particles within the specified processing region
42-
* - \f$ j \f$ belongs to a subset of \f$ i \f$ based on an includeMask
43-
* - \f$ w_i \f$ is the weight factor for particle \f$ i \f$
44-
* - \f$ \phi_i \f$ is the value from the phi field for particle \f$ i \f$
45-
* - \f$ \text{field}_j \f$ is the value from the target field for particle \f$ j \f$
46-
*
47-
* The calculation can optionally be divided by the region volume (when divideByVolume is set to yes),
48-
* which allows calculating normalized averages:
49-
* \f[
50-
* \text{result} = \frac{1}{V_{\text{region}}} \frac{\sum_{j \in \text{includeMask}} w_j \cdot \phi_j \cdot \text{field}_j}
51-
* {\sum_{i \in \text{processRegion}} w_i \cdot \phi_i}
52-
* \f]
53-
*
54-
* The averaging can be further filtered using an includeMask to selectively include only
55-
* specific particles that satisfy certain criteria.
56-
*
57-
* This class supports the following field types:
58-
* - real (scalar values)
59-
* - realx3 (vector values)
60-
* - realx4 (tensor values)
61-
*
62-
* @section usage Usage Example
63-
* Below is a sample dictionary showing how to configure and use this class:
64-
*
65-
* ```
66-
* processMethod arithmetic; // method of performing the sum (arithmetic, uniformDistribution, GaussianDistribution)
67-
* processRegion sphere; // type of region on which processing is performed
68-
*
69-
* sphereInfo
70-
* {
71-
* radius 0.01;
72-
* center (-0.08 -0.08 0.015);
73-
* }
74-
*
75-
* timeControl default;
76-
*
77-
* /// all the post process operations to be done
78-
* operations
79-
* (
80-
* // computes the arithmetic mean of particle velocity
81-
* averageVel
82-
* {
83-
* function average;
84-
* field velocity;
85-
* dividedByVolume no; // default is no
86-
* threshold 3; // default is 1
87-
* includeMask all; // include all particles in the calculation
88-
* }
89-
*
90-
* // computes the fraction of par1 in the region
91-
* par1Fraction
92-
* {
93-
* function average;
94-
* field one; // the "one" field is special - all members have value 1.0
95-
* phi one; // default is "one"
96-
* dividedByVolume no;
97-
* includeMask lessThan;
98-
*
99-
* // diameter of par1 is 0.003, so these settings
100-
* // will select only particles of type par1
101-
* lessThanInfo
102-
* {
103-
* field diameter;
104-
* value 0.0031;
105-
* }
106-
* }
107-
* );
108-
* ```
109-
*
110-
* @section defaults Default Behavior
111-
* - By default, `phi` is set to the field named "one" which contains value 1.0 for all entries
112-
* - `dividedByVolume` is set to "no" by default
113-
* - `threshold` is set to 1 by default
114-
* - `includeMask` can be set to various filters, with "all" being the default to include all particles
115-
*
116-
* @section special Special Fields
117-
* The field named "one" is a special field where all members have the value 1.0. This makes it
118-
* particularly useful for calculating:
119-
*
120-
* 1. Volume or number fractions (as shown in the par1Fraction example)
121-
* 2. Simple counts when used with an appropriate mask
122-
* 3. Normalizing values by particle count
12328
*
124-
* @see postprocessOperation
125-
* @see executeAverageOperation
29+
* @see PostprocessOperationAverage
12630
*/
12731

12832
#include <variant>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "PostprocessOperationBulkDensity.hpp"
2+
3+
namespace pFlow::postprocessData
4+
{
5+
6+
PostprocessOperationBulkDensity::PostprocessOperationBulkDensity
7+
(
8+
const dictionary &opDict,
9+
const regionPoints &regPoints,
10+
fieldsDataBase &fieldsDB
11+
)
12+
:
13+
PostprocessOperationSum
14+
(
15+
opDict,
16+
"mass",
17+
"one",
18+
"all",
19+
regPoints,
20+
fieldsDB
21+
)
22+
{
23+
}
24+
25+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*------------------------------- phasicFlow ---------------------------------
2+
O C enter of
3+
O O E ngineering and
4+
O O M ultiscale modeling of
5+
OOOOOOO F luid flow
6+
------------------------------------------------------------------------------
7+
Copyright (C): www.cemf.ir
8+
email: hamid.r.norouzi AT gmail.com
9+
------------------------------------------------------------------------------
10+
Licence:
11+
This file is part of phasicFlow code. It is a free software for simulating
12+
granular and multiphase flows. You can redistribute it and/or modify it under
13+
the terms of GNU General Public License v3 or any other later versions.
14+
15+
phasicFlow is distributed to help others in their research in the field of
16+
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
19+
-----------------------------------------------------------------------------*/
20+
21+
#ifndef __PostprocessOperationBulkDensity_hpp__
22+
#define __PostprocessOperationBulkDensity_hpp__
23+
24+
/*!
25+
* @class PostprocessOperationBulkDensity
26+
* @brief Calculates bulk density in the regions
27+
*
28+
*
29+
* @see PostprocessOperationSum
30+
*/
31+
32+
#include "PostprocessOperationSum.hpp"
33+
34+
namespace pFlow::postprocessData
35+
{
36+
37+
class PostprocessOperationBulkDensity
38+
:
39+
public PostprocessOperationSum
40+
{
41+
42+
public:
43+
44+
TypeInfo("PostprocessOperation<bulkDensity>");
45+
46+
/// @brief Constructs average operation processor
47+
/// @param opDict Operation parameters dictionary
48+
/// @param regPoints Region points data
49+
/// @param fieldsDB Fields database
50+
PostprocessOperationBulkDensity(
51+
const dictionary& opDict,
52+
const regionPoints& regPoints,
53+
fieldsDataBase& fieldsDB);
54+
55+
/// destructor
56+
~PostprocessOperationBulkDensity() override = default;
57+
58+
/// add this virtual constructor to the base class
59+
add_vCtor
60+
(
61+
postprocessOperation,
62+
PostprocessOperationBulkDensity,
63+
dictionary
64+
);
65+
66+
bool divideByVolume()const override
67+
{
68+
return true;
69+
}
70+
71+
};
72+
73+
}
74+
75+
#endif //__PostprocessOperationSolidVolFraction_hpp__
76+
77+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "PostprocessOperationSolidVolFraction.hpp"
2+
3+
namespace pFlow::postprocessData
4+
{
5+
6+
PostprocessOperationSolidVolFraction::PostprocessOperationSolidVolFraction
7+
(
8+
const dictionary &opDict,
9+
const regionPoints &regPoints,
10+
fieldsDataBase &fieldsDB
11+
)
12+
:
13+
PostprocessOperationSum
14+
(
15+
opDict,
16+
"volume",
17+
"one",
18+
"all",
19+
regPoints,
20+
fieldsDB
21+
)
22+
{
23+
}
24+
25+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*------------------------------- phasicFlow ---------------------------------
2+
O C enter of
3+
O O E ngineering and
4+
O O M ultiscale modeling of
5+
OOOOOOO F luid flow
6+
------------------------------------------------------------------------------
7+
Copyright (C): www.cemf.ir
8+
email: hamid.r.norouzi AT gmail.com
9+
------------------------------------------------------------------------------
10+
Licence:
11+
This file is part of phasicFlow code. It is a free software for simulating
12+
granular and multiphase flows. You can redistribute it and/or modify it under
13+
the terms of GNU General Public License v3 or any other later versions.
14+
15+
phasicFlow is distributed to help others in their research in the field of
16+
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
19+
-----------------------------------------------------------------------------*/
20+
21+
#ifndef __PostprocessOperationSolidVolFraction_hpp__
22+
#define __PostprocessOperationSolidVolFraction_hpp__
23+
24+
/*!
25+
* @class PostprocessOperationSolidVolFraction
26+
* @brief Calculates solid volume fraction in the regions
27+
*
28+
*
29+
* @see PostprocessOperationSum
30+
*/
31+
32+
#include "PostprocessOperationSum.hpp"
33+
34+
namespace pFlow::postprocessData
35+
{
36+
37+
class PostprocessOperationSolidVolFraction
38+
:
39+
public PostprocessOperationSum
40+
{
41+
42+
public:
43+
44+
TypeInfo("PostprocessOperation<solidVolFraction>");
45+
46+
/// @brief Constructs average operation processor
47+
/// @param opDict Operation parameters dictionary
48+
/// @param regPoints Region points data
49+
/// @param fieldsDB Fields database
50+
PostprocessOperationSolidVolFraction(
51+
const dictionary& opDict,
52+
const regionPoints& regPoints,
53+
fieldsDataBase& fieldsDB);
54+
55+
/// destructor
56+
~PostprocessOperationSolidVolFraction() override = default;
57+
58+
/// add this virtual constructor to the base class
59+
add_vCtor
60+
(
61+
postprocessOperation,
62+
PostprocessOperationSolidVolFraction,
63+
dictionary
64+
);
65+
66+
bool divideByVolume()const override
67+
{
68+
return true;
69+
}
70+
71+
};
72+
73+
}
74+
75+
#endif //__PostprocessOperationSolidVolFraction_hpp__
76+
77+

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,49 @@ PostprocessOperationSum::PostprocessOperationSum
4141
}
4242
}
4343

44+
PostprocessOperationSum::PostprocessOperationSum
45+
(
46+
const dictionary &opDict,
47+
const word &fieldName,
48+
const word &phiName,
49+
const word &includeName,
50+
const regionPoints &regPoints,
51+
fieldsDataBase &fieldsDB
52+
)
53+
:
54+
postprocessOperation(
55+
opDict,
56+
fieldName,
57+
phiName,
58+
includeName,
59+
regPoints,
60+
fieldsDB)
61+
{
62+
if( fieldType() == getTypeName<real>() )
63+
{
64+
processedRegField_ = makeUnique<processedRegFieldType>(
65+
regionField(processedFieldName(), regPoints, real(0)));
66+
}
67+
else if( fieldType() == getTypeName<realx3>() )
68+
{
69+
processedRegField_ = makeUnique<processedRegFieldType>(
70+
regionField(processedFieldName(), regPoints, realx3(0)));
71+
}
72+
else if( fieldType() == getTypeName<realx4>() )
73+
{
74+
processedRegField_ = makeUnique<processedRegFieldType>(
75+
regionField(processedFieldName(), regPoints, realx4(0)));
76+
}
77+
else
78+
{
79+
fatalErrorInFunction<<" in dictionary "<< opDict.globalName()
80+
<< " field type is not supported for sum operation"
81+
<< " field type is "<< fieldType()
82+
<< endl;
83+
fatalExit;
84+
}
85+
}
86+
4487
/// Performs weighted sum of field values within each region
4588
bool PostprocessOperationSum::execute
4689
(

src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ class PostprocessOperationSum
154154
const regionPoints& regPoints,
155155
fieldsDataBase& fieldsDB);
156156

157+
PostprocessOperationSum(
158+
const dictionary& opDict,
159+
const word& fieldName,
160+
const word& phiName,
161+
const word& includeName,
162+
const regionPoints& regPoints,
163+
fieldsDataBase& fieldsDB);
164+
157165
/// destructor
158166
~PostprocessOperationSum() override = default;
159167

0 commit comments

Comments
 (0)