mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
PostprocessData update
Modifications on fieldsDataBase to work both during simulation and post-simulation Some bug fixes and changes to the code based Correction for region volume
This commit is contained in:
@ -128,7 +128,7 @@ Licence:
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "postprocessOperation.hpp"
|
||||
#include "PostprocessOperationAverage.hpp"
|
||||
#include "regionField.hpp"
|
||||
#include "includeMask.hpp"
|
||||
|
||||
@ -138,7 +138,7 @@ namespace pFlow
|
||||
|
||||
class PostprocessOperationAvMassVelocity
|
||||
:
|
||||
public postprocessOperation
|
||||
public PostprocessOperationAverage
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "PostprocessOperationAverage.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "fieldFunctions.hpp"
|
||||
#include "operationFunctions.hpp"
|
||||
|
||||
/// Constructs average processor and initializes result field based on input field type
|
||||
pFlow::PostprocessOperationAverage::PostprocessOperationAverage
|
||||
@ -80,7 +80,8 @@ pFlow::PostprocessOperationAverage::PostprocessOperationAverage
|
||||
/// Performs weighted average of field values within each region
|
||||
bool pFlow::PostprocessOperationAverage::execute
|
||||
(
|
||||
const std::vector<span<real>>& weights
|
||||
const std::vector<span<real>>& weights,
|
||||
const regionField<real>& volFactor
|
||||
)
|
||||
{
|
||||
auto allField = database().updateFieldAll(fieldName());
|
||||
@ -99,7 +100,7 @@ bool pFlow::PostprocessOperationAverage::execute
|
||||
return executeAverageOperation(
|
||||
procName,
|
||||
field,
|
||||
regP,
|
||||
volFactor,
|
||||
dbVol,
|
||||
weights,
|
||||
phi,
|
||||
@ -124,6 +125,7 @@ bool pFlow::PostprocessOperationAverage::execute
|
||||
procName,
|
||||
field,
|
||||
std::get<regionField<T>>(processedRegField),
|
||||
volFactor,
|
||||
dbVol,
|
||||
weights,
|
||||
mask);
|
||||
|
@ -193,7 +193,9 @@ public:
|
||||
/// @brief Execute average operation on field values
|
||||
/// @param weights Weight factors for particles
|
||||
/// @return True if successful
|
||||
bool execute(const std::vector<span<real>>& weights) override;
|
||||
bool execute(
|
||||
const std::vector<span<real>>& weights,
|
||||
const regionField<real>& volFactor) override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "PostprocessOperationSum.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "fieldFunctions.hpp"
|
||||
#include "operationFunctions.hpp"
|
||||
|
||||
/// Constructs sum processor and initializes result field based on input field type
|
||||
pFlow::PostprocessOperationSum::PostprocessOperationSum
|
||||
@ -41,7 +41,8 @@ pFlow::PostprocessOperationSum::PostprocessOperationSum
|
||||
/// Performs weighted sum of field values within each region
|
||||
bool pFlow::PostprocessOperationSum::execute
|
||||
(
|
||||
const std::vector<span<real>>& weights
|
||||
const std::vector<span<real>>& weights,
|
||||
const regionField<real>& volFactor
|
||||
)
|
||||
{
|
||||
auto allField = database().updateFieldAll(fieldName());
|
||||
@ -60,7 +61,7 @@ bool pFlow::PostprocessOperationSum::execute
|
||||
return executeSumOperation(
|
||||
procName,
|
||||
field,
|
||||
regP,
|
||||
volFactor,
|
||||
dbVol,
|
||||
weights,
|
||||
phi,
|
||||
|
@ -175,7 +175,9 @@ public:
|
||||
/// @brief Execute sum operation on field values
|
||||
/// @param weights Weight factors for particles
|
||||
/// @return True if successful
|
||||
bool execute(const std::vector<span<real>>& weights) override;
|
||||
bool execute(
|
||||
const std::vector<span<real>>& weights,
|
||||
const regionField<real>& volFactor) override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -18,8 +18,8 @@ Licence:
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __fieldFunctions_hpp__
|
||||
#define __fieldFunctions_hpp__
|
||||
#ifndef __operationFunctions_hpp__
|
||||
#define __operationFunctions_hpp__
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -36,13 +36,14 @@ regionField<T> executeSumOperation
|
||||
(
|
||||
const word& regFieldName,
|
||||
const span<T>& field,
|
||||
const regionPoints& regPoints,
|
||||
const regionField<real>& volFactor,
|
||||
const bool devideByVol,
|
||||
const std::vector<span<real>>& weights,
|
||||
const span<real>& phi,
|
||||
const includeMask::Mask& mask
|
||||
)
|
||||
{
|
||||
const auto& regPoints = volFactor.regPoints();
|
||||
regionField<T> processedField(regFieldName, regPoints, T{});
|
||||
auto vols = regPoints.volumes();
|
||||
|
||||
@ -63,7 +64,7 @@ regionField<T> executeSumOperation
|
||||
}
|
||||
if(devideByVol)
|
||||
{
|
||||
processedField[reg] = sum/vols[reg];
|
||||
processedField[reg] = sum/(volFactor[reg] * vols[reg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,13 +81,15 @@ regionField<T> executeAverageOperation
|
||||
(
|
||||
const word& regFieldName,
|
||||
const span<T>& field,
|
||||
const regionPoints& regPoints,
|
||||
const bool devideByVol,
|
||||
const regionField<real>& volFactor,
|
||||
const bool devideByVol,
|
||||
const std::vector<span<real>>& weights,
|
||||
const span<real>& phi,
|
||||
const includeMask::Mask& mask
|
||||
)
|
||||
{
|
||||
|
||||
const auto& regPoints = volFactor.regPoints();
|
||||
regionField<T> processedField(regFieldName, regPoints, T{});
|
||||
auto vols = regPoints.volumes();
|
||||
|
||||
@ -113,7 +116,7 @@ regionField<T> executeAverageOperation
|
||||
|
||||
if(devideByVol)
|
||||
{
|
||||
processedField[reg] = sumNum / max(sumDen, smallValue) / vols[reg];
|
||||
processedField[reg] = sumNum / max(sumDen, smallValue) / (volFactor[reg] * vols[reg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -131,7 +134,8 @@ regionField<T> executeFluctuation2Operation
|
||||
(
|
||||
const word& regFieldName,
|
||||
const span<T>& field,
|
||||
const regionField<T>& fieldAvg,
|
||||
const regionField<T>& fieldAvg,
|
||||
const regionField<real>& volFactor,
|
||||
const bool devideByVol,
|
||||
const std::vector<span<real>>& weights,
|
||||
const includeMask::Mask& mask
|
||||
@ -145,7 +149,7 @@ regionField<T> executeFluctuation2Operation
|
||||
{
|
||||
auto partIndices = regPoints.indices(reg);
|
||||
auto w = weights[reg];
|
||||
auto vol = vols[reg];
|
||||
auto vol = volFactor[reg] * vols[reg];
|
||||
T avField{};
|
||||
if(devideByVol)
|
||||
{
|
||||
@ -188,4 +192,4 @@ regionField<T> executeFluctuation2Operation
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#endif //__fieldFunctions_hpp__
|
||||
#endif //__operationFunctions_hpp__
|
@ -154,11 +154,34 @@ public:
|
||||
).getVal<word>("field"))
|
||||
{}
|
||||
|
||||
IncludeMask(
|
||||
const word& type,
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& feildsDB)
|
||||
:
|
||||
includeMask(type, dict, feildsDB),
|
||||
operator_(dict.subDict(operatorName()+"Info")),
|
||||
fieldName_(
|
||||
dict.subDict
|
||||
(
|
||||
operatorName()+"Info"
|
||||
).getVal<word>("field"))
|
||||
{}
|
||||
|
||||
/// Add virtual constructor pattern for creating instances
|
||||
add_vCtor(
|
||||
add_vCtor
|
||||
(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
dictionary
|
||||
);
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
word
|
||||
);
|
||||
|
||||
/// Returns the mask for filtering elements (updates the mask if necessary)
|
||||
Mask getMask() override
|
||||
@ -203,20 +226,40 @@ public:
|
||||
|
||||
TypeInfoTemplate12("IncludeMask", T, allOp<int8>);
|
||||
|
||||
IncludeMask(
|
||||
const dictionary& opDict,
|
||||
IncludeMask(
|
||||
const dictionary& opDict,
|
||||
fieldsDataBase& feildsDB)
|
||||
:
|
||||
includeMask(opDict, feildsDB)
|
||||
{
|
||||
:
|
||||
includeMask(opDict, feildsDB)
|
||||
{
|
||||
span<realx3> s = database().updatePoints();
|
||||
mask_.resize(s.size(), true);
|
||||
}
|
||||
}
|
||||
|
||||
add_vCtor(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
IncludeMask(
|
||||
const word& type,
|
||||
const dictionary& opDict,
|
||||
fieldsDataBase& feildsDB)
|
||||
:
|
||||
includeMask(type, opDict, feildsDB)
|
||||
{
|
||||
span<realx3> s = database().updatePoints();
|
||||
mask_.resize(s.size(), true);
|
||||
}
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary
|
||||
);
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
word
|
||||
);
|
||||
|
||||
Mask getMask()override
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ pFlow::uniquePtr<pFlow::includeMask> pFlow::includeMask::create
|
||||
auto& maskDict = opDict.subDict(mask+"Info");
|
||||
word maskField = maskDict.getVal<word>("field");
|
||||
|
||||
if( !fieldsDB.getPointFieldType(maskField, fieldType) )
|
||||
if( !fieldsDB.getFieldType(maskField, fieldType) )
|
||||
{
|
||||
fatalErrorInFunction<<"Error in retriving the type of field"
|
||||
<< maskField <<" from dictionary "
|
||||
@ -111,7 +111,7 @@ pFlow::uniquePtr<pFlow::includeMask>
|
||||
auto& maskDict = opDict.subDict(type+"Info");
|
||||
word maskField = maskDict.getVal<word>("field");
|
||||
|
||||
if( !fieldsDB.getPointFieldType(maskField, fieldType) )
|
||||
if( !fieldsDB.getFieldType(maskField, fieldType) )
|
||||
{
|
||||
fatalErrorInFunction<<"Error in retriving the type of field"
|
||||
<< maskField <<" from dictionary "
|
||||
@ -143,7 +143,7 @@ pFlow::uniquePtr<pFlow::includeMask>
|
||||
method << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
wordvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
|
@ -117,7 +117,7 @@ pFlow::postprocessOperation::postprocessOperation
|
||||
),
|
||||
divideByVolume_
|
||||
(
|
||||
opDict.getValOrSet<Logical>("dividedByVolume", Logical(false))
|
||||
opDict.getValOrSet<Logical>("divideByVolume", Logical(false))
|
||||
),
|
||||
regionPoints_
|
||||
(
|
||||
@ -141,7 +141,7 @@ pFlow::postprocessOperation::postprocessOperation
|
||||
)
|
||||
{
|
||||
|
||||
if(!fieldsDB.getPointFieldType(fieldName_, fieldType_))
|
||||
if(!fieldsDB.getFieldType(fieldName_, fieldType_))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
@ -159,7 +159,7 @@ bool pFlow::postprocessOperation::write(const fileSystem &parDir) const
|
||||
if(!osPtr_)
|
||||
{
|
||||
fileSystem path = parDir+(
|
||||
processedFieldName() + ".Start_" + ti.prevTimeName());
|
||||
processedFieldName() + ".Start_" + ti.timeName());
|
||||
osPtr_ = makeUnique<oFstream>(path);
|
||||
|
||||
regPoints().write(osPtr_());
|
||||
|
@ -246,7 +246,10 @@ public:
|
||||
|
||||
/// execute the operation
|
||||
/// @param weights Vector of weights for the operation.
|
||||
virtual bool execute(const std::vector<span<real>>& weights) = 0;
|
||||
/// @param volFactor a factor to be multiplied by the volume of the region
|
||||
virtual bool execute(
|
||||
const std::vector<span<real>>& weights,
|
||||
const regionField<real>& volFactor) = 0;
|
||||
|
||||
/// write the result to a file
|
||||
/// @param parDir Parent directory for the output file.
|
||||
|
Reference in New Issue
Block a user