The main structure is tested. functons like execute and write are added and tested.
other components are left
This commit is contained in:
parent
ab7f700ead
commit
162cfd3b6a
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
set(SourceFiles
|
|
||||||
fieldsDataBase/fieldsDataBase.cpp
|
|
||||||
|
|
||||||
postprocessComponent/postprocessComponent.cpp
|
|
||||||
postprocessComponent/PostprocessComponents.cpp
|
|
||||||
|
|
||||||
operation/postprocessOperation.cpp
|
|
||||||
operation/PostprocessOperationSum.cpp
|
|
||||||
|
|
||||||
|
|
||||||
postprocessData.cpp
|
|
||||||
|
|
||||||
postprocessComponent/postprocessComponent.cpp
|
|
||||||
postprocessComponent/PostprocessComponents.cpp
|
|
||||||
postprocessComponent/particleProbePostprocessComponent.cpp
|
|
||||||
|
|
||||||
operation/includeMask/includeMask.cpp
|
|
||||||
operation/includeMask/IncludeMasks.cpp
|
|
||||||
operation/postprocessOperation.cpp
|
|
||||||
operation/PostprocessOperationSum.cpp
|
|
||||||
|
|
||||||
region/regionPoints/sphereRegionPoints.cpp
|
|
||||||
region/regionPoints/regionPoints.cpp
|
|
||||||
region/regionPoints/lineRegionPoints.cpp
|
|
||||||
region/regionPoints/centerPointsRegionPoints.cpp
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
set(link_libs Kokkos::kokkos phasicFlow Particles)
|
|
||||||
|
|
||||||
pFlow_add_library_install(PostProcessData SourceFiles link_libs)
|
|
||||||
|
|
||||||
add_subdirectory(testPostprocess)
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
#include "particleProbePostprocessComponent.hpp"
|
|
||||||
|
|
||||||
pFlow::particleProbePostprocessComponent::particleProbePostprocessComponent
|
|
||||||
(
|
|
||||||
const dictionary &dict,
|
|
||||||
fieldsDataBase &fieldsDB,
|
|
||||||
const baseTimeControl &defaultTimeControl
|
|
||||||
)
|
|
||||||
:
|
|
||||||
postprocessComponent(dict, fieldsDB, defaultTimeControl),
|
|
||||||
regionPointsPtr_
|
|
||||||
(
|
|
||||||
makeUnique<centerPointsRegionPoints>(dict, fieldsDB)
|
|
||||||
),
|
|
||||||
name_(dict.name())
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool pFlow::particleProbePostprocessComponent::execute
|
|
||||||
(
|
|
||||||
const timeInfo &ti,
|
|
||||||
bool forceExecute
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
set(SourceFiles
|
||||||
|
# Main postprocess data
|
||||||
|
postprocessData/postprocessData.cpp
|
||||||
|
|
||||||
|
# Fields database
|
||||||
|
fieldsDataBase/fieldsDataBase.cpp
|
||||||
|
|
||||||
|
# Regions
|
||||||
|
region/regionPoints/regionPoints/regionPoints.cpp
|
||||||
|
region/regionPoints/sphereRegionPoints/sphereRegionPoints.cpp
|
||||||
|
region/regionPoints/lineRegionPoints/lineRegionPoints.cpp
|
||||||
|
region/regionPoints/centerPointsRegionPoints/centerPointsRegionPoints.cpp
|
||||||
|
|
||||||
|
# Postprocess components
|
||||||
|
postprocessComponent/postprocessComponent/postprocessComponent.cpp
|
||||||
|
postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp
|
||||||
|
postprocessComponent/PostprocessComponent/PostprocessComponents.cpp
|
||||||
|
|
||||||
|
# Operations
|
||||||
|
operation/postprocessOperation/postprocessOperation.cpp
|
||||||
|
operation/PostprocessOperation/PostprocessOperationSum.cpp
|
||||||
|
operation/includeMask/includeMask.cpp
|
||||||
|
operation/includeMask/IncludeMasks.cpp
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
set(link_libs Kokkos::kokkos phasicFlow Particles)
|
||||||
|
|
||||||
|
pFlow_add_library_install(PostprocessData SourceFiles link_libs)
|
|
@ -465,19 +465,22 @@ pFlow::span<pFlow::real> pFlow::fieldsDataBase::updateFieldReal
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the original type is uint32, and no funciton, cast to real
|
// if the original type is uint32, and no funciton, cast to real
|
||||||
if( originalType == getTypeName<uint32>() && func == Functions::None )
|
if( originalType == getTypeName<uint32>())
|
||||||
{
|
{
|
||||||
auto sp = updateField<uint32>(fieldName, forceUpdate);
|
if(func == Functions::None)
|
||||||
auto spReal = createOrGetRealField(fieldName+".real");
|
{
|
||||||
funcCast(sp, spReal);
|
auto sp = updateField<uint32>(fieldName, forceUpdate);
|
||||||
return spReal;
|
auto spReal = createOrGetRealField(fieldName+".real");
|
||||||
}
|
funcCast(sp, spReal);
|
||||||
else
|
return spReal;
|
||||||
{
|
}
|
||||||
fatalErrorInFunction<<"No function can be applied to field of type uint32. "<<
|
else
|
||||||
" The field is: "<< compoundName<<endl;
|
{
|
||||||
return span<real>(nullptr, 0);
|
fatalErrorInFunction<<"No function can be applied to field of type uint32. "<<
|
||||||
fatalExit;
|
" The field is: "<< compoundName<<endl;
|
||||||
|
return span<real>(nullptr, 0);
|
||||||
|
fatalExit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( originalType == getTypeName<real>() )
|
if( originalType == getTypeName<real>() )
|
||||||
|
@ -606,27 +609,30 @@ pFlow::allPointFieldTypes pFlow::fieldsDataBase::updateFieldAll
|
||||||
bool forceUpdate
|
bool forceUpdate
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
word originalType, typeAfterFunction;
|
|
||||||
|
word originalType, typeAfterFunction, fieldName;
|
||||||
|
Functions func;
|
||||||
|
|
||||||
if( !getPointFieldType(compoundName, originalType, typeAfterFunction))
|
if( !getPointFieldType(compoundName, fieldName, originalType, typeAfterFunction, func))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<< "Error in getting the type name of field: "<<
|
fatalErrorInFunction<< "Error in getting the type name of field: "<<
|
||||||
compoundName<<", with type name: "<< originalType <<endl;
|
compoundName<<", with type name: "<< originalType <<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
return span<real>(nullptr,0);
|
return span<real>(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( typeAfterFunction== getTypeName<realx3>() )
|
if( typeAfterFunction== getTypeName<realx3>() )
|
||||||
{
|
{
|
||||||
return updateField<realx3>(compoundName, forceUpdate);
|
return updateFieldRealx3(compoundName, forceUpdate);
|
||||||
}
|
}
|
||||||
else if( typeAfterFunction == getTypeName<realx4>() )
|
else if( typeAfterFunction == getTypeName<realx4>() )
|
||||||
{
|
{
|
||||||
return updateField<realx4>(compoundName, forceUpdate);
|
return updateFieldRealx4(compoundName, forceUpdate);
|
||||||
}
|
}
|
||||||
else if( typeAfterFunction == getTypeName<real>() )
|
else if( typeAfterFunction == getTypeName<real>() )
|
||||||
{
|
{
|
||||||
return updateField<real>(compoundName, forceUpdate);
|
return updateFieldReal(compoundName, forceUpdate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
|
@ -51,19 +51,21 @@ bool pFlow::PostprocessOperationSum::execute
|
||||||
const auto& regP = regPoints();
|
const auto& regP = regPoints();
|
||||||
bool dbVol = divideByVolume();
|
bool dbVol = divideByVolume();
|
||||||
|
|
||||||
|
processedRegField_ = makeUnique<processedRegFieldType>
|
||||||
std::visit([&](auto&& field)->processedRegFieldType
|
(
|
||||||
{
|
std::visit([&](auto&& field)->processedRegFieldType
|
||||||
return executeSumOperation(
|
{
|
||||||
procName,
|
return executeSumOperation(
|
||||||
field,
|
procName,
|
||||||
regP,
|
field,
|
||||||
dbVol,
|
regP,
|
||||||
weights,
|
dbVol,
|
||||||
phi,
|
weights,
|
||||||
mask);
|
phi,
|
||||||
},
|
mask);
|
||||||
allField);
|
},
|
||||||
|
allField)
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -37,14 +37,7 @@ class PostprocessOperationSum
|
||||||
public postprocessOperation
|
public postprocessOperation
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using processedRegFieldType = std::variant
|
|
||||||
<
|
|
||||||
regionField<real>,
|
|
||||||
regionField<realx3>,
|
|
||||||
regionField<realx4>
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// Pointer to the include mask used for masking operations.
|
/// Pointer to the include mask used for masking operations.
|
||||||
uniquePtr<processedRegFieldType> processedRegField_ = nullptr;
|
uniquePtr<processedRegFieldType> processedRegField_ = nullptr;
|
||||||
|
|
||||||
|
@ -66,6 +59,11 @@ public:
|
||||||
dictionary
|
dictionary
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const processedRegFieldType& processedField()const override
|
||||||
|
{
|
||||||
|
return processedRegField_();
|
||||||
|
}
|
||||||
|
|
||||||
bool execute(const std::vector<span<real>>& weights) override;
|
bool execute(const std::vector<span<real>>& weights) override;
|
||||||
|
|
||||||
};
|
};
|
|
@ -31,6 +31,7 @@ Licence:
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
regionField<T> executeSumOperation
|
regionField<T> executeSumOperation
|
||||||
(
|
(
|
||||||
|
@ -54,7 +55,7 @@ regionField<T> executeSumOperation
|
||||||
uint n = 0;
|
uint n = 0;
|
||||||
for(auto index:partIndices)
|
for(auto index:partIndices)
|
||||||
{
|
{
|
||||||
if( mask( index ))
|
if( index!= -1 && mask( index ))
|
||||||
{
|
{
|
||||||
sum += w[n] * field[index]* phi[index];
|
sum += w[n] * field[index]* phi[index];
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ regionField<T> executeAverageOperation
|
||||||
uint n = 0;
|
uint n = 0;
|
||||||
for(auto index:partIndices)
|
for(auto index:partIndices)
|
||||||
{
|
{
|
||||||
if( mask( index ))
|
if( index!= -1 && mask( index ))
|
||||||
{
|
{
|
||||||
sumNum += w[n] * field[index]* phi[index];
|
sumNum += w[n] * field[index]* phi[index];
|
||||||
}
|
}
|
||||||
|
@ -114,4 +115,4 @@ regionField<T> executeAverageOperation
|
||||||
|
|
||||||
} // namespace pFlow
|
} // namespace pFlow
|
||||||
|
|
||||||
#endif //__fieldFunctions_hpp__
|
#endif //__fieldFunctions_hpp__
|
|
@ -18,10 +18,72 @@ Licence:
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "Time.hpp"
|
||||||
#include "postprocessOperation.hpp"
|
#include "postprocessOperation.hpp"
|
||||||
#include "regionPoints.hpp"
|
#include "regionPoints.hpp"
|
||||||
#include "fieldsDataBase.hpp"
|
#include "fieldsDataBase.hpp"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline
|
||||||
|
bool writeField
|
||||||
|
(
|
||||||
|
iOstream& os,
|
||||||
|
timeValue t,
|
||||||
|
const regionField<T> field,
|
||||||
|
uint32 threshold,
|
||||||
|
const T& defValue=T{}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const auto& regPoints = field.regPoints();
|
||||||
|
const uint32 n = field.size();
|
||||||
|
os<<t<<tab;
|
||||||
|
for(uint32 i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
auto numPar = regPoints.indices(i).size();
|
||||||
|
if(numPar >= threshold)
|
||||||
|
{
|
||||||
|
if constexpr(std::is_same_v<T,realx3>)
|
||||||
|
{
|
||||||
|
os<<field[i].x()<<' '<<field[i].y()<<' '<<field[i].z()<<tab;
|
||||||
|
}
|
||||||
|
else if constexpr( std::is_same_v<T,realx4>)
|
||||||
|
{
|
||||||
|
os << field[i].x() << ' ' << field[i].y() << ' ' << field[i].z() << ' ' << field[i].w() << tab;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os<<field[i]<<tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if constexpr(std::is_same_v<T,realx3>)
|
||||||
|
{
|
||||||
|
os<<defValue.x()<<' '<<defValue.y()<<' '<<defValue.z()<<tab;
|
||||||
|
}
|
||||||
|
else if constexpr( std::is_same_v<T,realx4>)
|
||||||
|
{
|
||||||
|
os << defValue.x() << ' ' << defValue.y() << ' ' << defValue.z() << ' ' << defValue.w() << tab;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os<<defValue<<tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
os<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pFlow::postprocessOperation::postprocessOperation
|
pFlow::postprocessOperation::postprocessOperation
|
||||||
(
|
(
|
||||||
const dictionary &opDict,
|
const dictionary &opDict,
|
||||||
|
@ -67,13 +129,43 @@ pFlow::postprocessOperation::postprocessOperation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::uniquePtr<pFlow::postprocessOperation>
|
const pFlow::Time& pFlow::postprocessOperation::time() const
|
||||||
pFlow::postprocessOperation::create
|
{
|
||||||
|
return database_.time();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::postprocessOperation::write(const fileSystem &parDir) const
|
||||||
|
{
|
||||||
|
auto ti = time().TimeInfo();
|
||||||
|
|
||||||
|
if(!osPtr_)
|
||||||
|
{
|
||||||
|
fileSystem path = parDir+(
|
||||||
|
processedFieldName() + ".Start_" + ti.prevTimeName());
|
||||||
|
osPtr_ = makeUnique<oFstream>(path);
|
||||||
|
|
||||||
|
regPoints().write(osPtr_());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& field = processedField();
|
||||||
|
|
||||||
|
std::visit
|
||||||
(
|
(
|
||||||
const dictionary &opDict,
|
[&](auto&& arg)->bool
|
||||||
const regionPoints& regPoints,
|
{
|
||||||
fieldsDataBase &fieldsDB
|
return writeField(osPtr_(), ti.t(), arg, threshold_);
|
||||||
)
|
},
|
||||||
|
field
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::uniquePtr<pFlow::postprocessOperation>
|
||||||
|
pFlow::postprocessOperation::create(
|
||||||
|
const dictionary &opDict,
|
||||||
|
const regionPoints ®Points,
|
||||||
|
fieldsDataBase &fieldsDB)
|
||||||
{
|
{
|
||||||
word func = opDict.getVal<word>("function");
|
word func = opDict.getVal<word>("function");
|
||||||
word method = angleBracketsNames("PostprocessOperation", func);
|
word method = angleBracketsNames("PostprocessOperation", func);
|
|
@ -20,18 +20,28 @@ Licence:
|
||||||
#ifndef __postprocessOperation_hpp__
|
#ifndef __postprocessOperation_hpp__
|
||||||
#define __postprocessOperation_hpp__
|
#define __postprocessOperation_hpp__
|
||||||
|
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
#include "virtualConstructor.hpp"
|
#include "virtualConstructor.hpp"
|
||||||
#include "Logical.hpp"
|
#include "Logical.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
#include "span.hpp"
|
#include "span.hpp"
|
||||||
|
#include "oFstream.hpp"
|
||||||
|
#include "regionField.hpp"
|
||||||
#include "includeMask.hpp"
|
#include "includeMask.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using processedRegFieldType = std::variant
|
||||||
|
<
|
||||||
|
regionField<real>,
|
||||||
|
regionField<realx3>,
|
||||||
|
regionField<realx4>
|
||||||
|
>;
|
||||||
|
|
||||||
class fieldsDataBase;
|
class fieldsDataBase;
|
||||||
class regionPoints;
|
class Time;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Base class for post-processing operations.
|
* @brief Base class for post-processing operations.
|
||||||
|
@ -69,10 +79,12 @@ private:
|
||||||
word fieldType_;
|
word fieldType_;
|
||||||
|
|
||||||
/// Name of the phi field to be processed.
|
/// Name of the phi field to be processed.
|
||||||
word phiFieldName_;
|
word phiFieldName_;
|
||||||
|
|
||||||
/// Pointer to the include mask used for masking operations.
|
/// Pointer to the include mask used for masking operations.
|
||||||
uniquePtr<includeMask> includeMask_ = nullptr;
|
uniquePtr<includeMask> includeMask_ = nullptr;
|
||||||
|
|
||||||
|
mutable uniquePtr<oFstream> osPtr_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -111,6 +123,8 @@ public:
|
||||||
return database_;
|
return database_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Time& time()const;
|
||||||
|
|
||||||
word processedFieldName()const
|
word processedFieldName()const
|
||||||
{
|
{
|
||||||
return operationDict_.name();
|
return operationDict_.name();
|
||||||
|
@ -150,10 +164,18 @@ public:
|
||||||
return includeMask_().getMask();
|
return includeMask_().getMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
const processedRegFieldType& processedField()const=0;
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
bool execute(const std::vector<span<real>>& weights) = 0;
|
bool execute(const std::vector<span<real>>& weights) = 0;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool write(const fileSystem &parDir)const;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool write(iOstream& os)const {return true;}
|
||||||
|
|
||||||
static
|
static
|
||||||
uniquePtr<postprocessOperation> create(
|
uniquePtr<postprocessOperation> create(
|
||||||
const dictionary& opDict,
|
const dictionary& opDict,
|
|
@ -61,22 +61,31 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
|
||||||
bool forceUpdate
|
bool forceUpdate
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if( !forceUpdate && !timeControl().eventTime(ti))
|
||||||
if( !timeControl().eventTime(ti))
|
|
||||||
{
|
{
|
||||||
executed_ = false;
|
executed_ = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update processing methods
|
// update processing methods
|
||||||
|
auto& regPoints = this->regPoints();
|
||||||
|
|
||||||
auto centers = this->regPoints().centers();
|
if(!regPoints.update())
|
||||||
const uint32 n = centers.size();
|
{
|
||||||
auto points = this->database().updatePoints();
|
fatalErrorInFunction
|
||||||
|
<< "regionPoints update failed for "
|
||||||
|
<< operationDicts_.globalName()
|
||||||
|
<< endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto centers = regPoints.centers();
|
||||||
|
const uint32 n = centers.size();
|
||||||
|
auto points = this->database().updatePoints();
|
||||||
|
|
||||||
for(uint32 i=0; i<n; i++)
|
for(uint32 i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
auto indices = this->regPoints().indices(i);
|
auto indices = regPoints.indices(i);
|
||||||
regionsProcessMethod_[i].updateWeights(
|
regionsProcessMethod_[i].updateWeights(
|
||||||
centers[i],
|
centers[i],
|
||||||
indices,
|
indices,
|
||||||
|
@ -93,7 +102,7 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
|
||||||
|
|
||||||
for(auto& op:operatios_)
|
for(auto& op:operatios_)
|
||||||
{
|
{
|
||||||
if( op->execute(weights) )
|
if( !op->execute(weights) )
|
||||||
{
|
{
|
||||||
fatalErrorInFunction
|
fatalErrorInFunction
|
||||||
<<"error occured in executing operatoin defined in dict "
|
<<"error occured in executing operatoin defined in dict "
|
||||||
|
@ -105,5 +114,39 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
|
||||||
|
|
||||||
executed_ = true;
|
executed_ = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename RegionType, typename ProcessMethodType>
|
||||||
|
inline
|
||||||
|
bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::write
|
||||||
|
(
|
||||||
|
const fileSystem &parDir
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if(!executed_) return true;
|
||||||
|
|
||||||
|
if(regionPointsPtr_().writeToSameTimeFile())
|
||||||
|
{
|
||||||
|
for(auto& operation:operatios_)
|
||||||
|
{
|
||||||
|
if(!operation->write(parDir))
|
||||||
|
{
|
||||||
|
fatalErrorInFunction
|
||||||
|
<<"Error occurred in writing operation defined in dict "
|
||||||
|
<< operation->operationDict()
|
||||||
|
<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notImplementedFunction;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -106,10 +106,12 @@ public:
|
||||||
return executed_;
|
return executed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool write(const fileSystem& parDir)const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "PostprocessComponent.cpp"
|
#include "PostprocessComponent.cpp"
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __PostprocessComponentArithmetic_hpp__
|
||||||
|
#define __PostprocessComponentArithmetic_hpp__
|
||||||
|
|
||||||
|
#include "PostprocessComponent.hpp"
|
||||||
|
#include "arithmetic.hpp"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename RegionType>
|
||||||
|
class PostprocessComponentArithmetic
|
||||||
|
:
|
||||||
|
public PostprocessComponent<RegionType, arithmetic>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// type info
|
||||||
|
TypeInfoTemplate12("PostprocessComponent", RegionType, arithmetic);
|
||||||
|
|
||||||
|
PostprocessComponentArithmetic
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
fieldsDataBase& fieldsDB,
|
||||||
|
const baseTimeControl& defaultTimeControl
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PostprocessComponent<RegionType, arithmetic>(dict, fieldsDB, defaultTimeControl)
|
||||||
|
{
|
||||||
|
/// initializes the arithmetic distribution for all elements of region
|
||||||
|
//const uint32 n = this->regPoints().size();
|
||||||
|
auto d = this->regPoints().eqDiameters();
|
||||||
|
auto c = this->regPoints().centers();
|
||||||
|
auto& regs = this->regionProecessMethod();
|
||||||
|
const uint32 n = d.size();
|
||||||
|
for(uint32 i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
regs[i] = arithmetic(); // Changed from uniformDistribution() to arithmetic()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the virtual constructor
|
||||||
|
add_vCtor(
|
||||||
|
postprocessComponent,
|
||||||
|
PostprocessComponentArithmetic,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__PostprocessComponentArithmetic_hpp__
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __PostprocessComponentUniform_hpp__
|
||||||
|
#define __PostprocessComponentUniform_hpp__
|
||||||
|
|
||||||
|
#include "PostprocessComponent.hpp"
|
||||||
|
#include "uniformDistribution.hpp"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename RegionType>
|
||||||
|
class PostprocessComponentUniform
|
||||||
|
:
|
||||||
|
public PostprocessComponent<RegionType, uniformDistribution>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// type info
|
||||||
|
TypeInfoTemplate12("PostprocessComponent", RegionType, uniformDistribution);
|
||||||
|
|
||||||
|
PostprocessComponentUniform
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
fieldsDataBase& fieldsDB,
|
||||||
|
const baseTimeControl& defaultTimeControl
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PostprocessComponent<RegionType,uniformDistribution>(dict, fieldsDB, defaultTimeControl)
|
||||||
|
{
|
||||||
|
/// initializes the Uniform distribution for all elements of region
|
||||||
|
//const uint32 n = this->regPoints().size();
|
||||||
|
auto d = this->regPoints().eqDiameters();
|
||||||
|
auto c = this->regPoints().centers();
|
||||||
|
auto& regs = this->regionProecessMethod();
|
||||||
|
const uint32 n = d.size();
|
||||||
|
for(uint32 i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
regs[i] = uniformDistribution();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the virtual constructor
|
||||||
|
add_vCtor(
|
||||||
|
postprocessComponent,
|
||||||
|
PostprocessComponentUniform,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__PostprocessComponentUniform_hpp__
|
|
@ -19,16 +19,15 @@ Licence:
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "PostprocessComponentGaussian.hpp"
|
#include "PostprocessComponentGaussian.hpp"
|
||||||
|
#include "PostprocessComponentUniform.hpp"
|
||||||
|
#include "PostprocessComponentArithmetic.hpp"
|
||||||
|
|
||||||
// region types
|
// region types
|
||||||
#include "sphereRegionPoints.hpp"
|
#include "sphereRegionPoints.hpp"
|
||||||
|
|
||||||
|
|
||||||
// methods
|
|
||||||
#include "GaussianDistribution.hpp"
|
|
||||||
#include "uniformDistribution.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
template class pFlow::PostprocessComponentGaussian<pFlow::sphereRegionPoints>;
|
template class pFlow::PostprocessComponentGaussian<pFlow::sphereRegionPoints>;
|
||||||
|
template class pFlow::PostprocessComponentUniform<pFlow::sphereRegionPoints>;
|
||||||
|
template class pFlow::PostprocessComponentArithmetic<pFlow::sphereRegionPoints>;
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
#include "particleProbePostprocessComponent.hpp"
|
||||||
|
#include "Time.hpp"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline
|
||||||
|
regionField<T> porbeExecute
|
||||||
|
(
|
||||||
|
const word& regFieldName,
|
||||||
|
const span<T>& field,
|
||||||
|
const regionPoints& regPoints
|
||||||
|
)
|
||||||
|
{
|
||||||
|
regionField<T> processedField(regFieldName, regPoints, T{});
|
||||||
|
auto partIndices = regPoints.indices(0);
|
||||||
|
|
||||||
|
uint n = 0;
|
||||||
|
for(auto index:partIndices)
|
||||||
|
{
|
||||||
|
if(index != -1)
|
||||||
|
{
|
||||||
|
processedField[n] = field[index];
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return processedField;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline bool writeField
|
||||||
|
(
|
||||||
|
iOstream& os,
|
||||||
|
timeValue t,
|
||||||
|
const regionField<T>& field,
|
||||||
|
const regionPoints& regPoints,
|
||||||
|
const T& invalidVal = T{}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto indices = regPoints.indices(0);
|
||||||
|
const uint32 s= field.size();
|
||||||
|
os<< t <<tab;
|
||||||
|
for(uint32 i=0; i<s; i++)
|
||||||
|
{
|
||||||
|
if constexpr(std::is_same_v<T,realx3>)
|
||||||
|
{
|
||||||
|
os<<field[i].x()<<' '<<field[i].y()<<' '<<field[i].z()<<tab;
|
||||||
|
}
|
||||||
|
else if constexpr( std::is_same_v<T,realx4> )
|
||||||
|
{
|
||||||
|
os<<field[i].x()<<' '<<field[i].y()<<' '<<field[i].z()<<tab<<field[i].w()<<tab;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os<<field[i]<<tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os<<endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::particleProbePostprocessComponent::particleProbePostprocessComponent
|
||||||
|
(
|
||||||
|
const dictionary &dict,
|
||||||
|
fieldsDataBase &fieldsDB,
|
||||||
|
const baseTimeControl &defaultTimeControl
|
||||||
|
)
|
||||||
|
:
|
||||||
|
postprocessComponent(dict, fieldsDB, defaultTimeControl),
|
||||||
|
regionPointsPtr_
|
||||||
|
(
|
||||||
|
makeUnique<centerPointsRegionPoints>(dict, fieldsDB)
|
||||||
|
),
|
||||||
|
fieldName_
|
||||||
|
(
|
||||||
|
dict.getVal<word>("field")
|
||||||
|
),
|
||||||
|
name_(dict.name())
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool pFlow::particleProbePostprocessComponent::execute
|
||||||
|
(
|
||||||
|
const timeInfo &ti,
|
||||||
|
bool forceExecute
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if( !forceExecute && !timeControl().eventTime(ti))
|
||||||
|
{
|
||||||
|
executed_ = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!regionPointsPtr_().update())
|
||||||
|
{
|
||||||
|
fatalErrorInFunction
|
||||||
|
<< "regionPoints update for "<< name_ << " failed. \n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto field = database().updateFieldAll(fieldName_);
|
||||||
|
auto pFieldName = name_;
|
||||||
|
|
||||||
|
processedField_ = makeUnique<processedRegFieldType>
|
||||||
|
(
|
||||||
|
std::visit(
|
||||||
|
[&](auto&& f) -> processedRegFieldType
|
||||||
|
{
|
||||||
|
return porbeExecute(
|
||||||
|
pFieldName,
|
||||||
|
f,
|
||||||
|
regionPointsPtr_());
|
||||||
|
},
|
||||||
|
field)
|
||||||
|
);
|
||||||
|
|
||||||
|
executed_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool pFlow::particleProbePostprocessComponent::write(const fileSystem& parDir)const
|
||||||
|
{
|
||||||
|
if(! executed_ ) return true;
|
||||||
|
|
||||||
|
const auto ti = database().time().TimeInfo();
|
||||||
|
|
||||||
|
if( !osPtr_)
|
||||||
|
{
|
||||||
|
// file is not open yet
|
||||||
|
fileSystem path = parDir + (name_+".Start_"+ti.prevTimeName());
|
||||||
|
osPtr_ = makeUnique<oFstream>(path);
|
||||||
|
regionPointsPtr_().write(osPtr_());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::visit
|
||||||
|
([&](auto&& arg)->bool
|
||||||
|
{
|
||||||
|
return writeField(osPtr_(), ti.t(), arg, regionPointsPtr_());
|
||||||
|
},
|
||||||
|
processedField_()
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -25,10 +25,12 @@ Licence:
|
||||||
#include "fieldsDataBase.hpp"
|
#include "fieldsDataBase.hpp"
|
||||||
#include "centerPointsRegionPoints.hpp"
|
#include "centerPointsRegionPoints.hpp"
|
||||||
#include "regionField.hpp"
|
#include "regionField.hpp"
|
||||||
|
#include "oFstream.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class particleProbePostprocessComponent
|
class particleProbePostprocessComponent
|
||||||
:
|
:
|
||||||
public postprocessComponent
|
public postprocessComponent
|
||||||
|
@ -48,8 +50,12 @@ private:
|
||||||
|
|
||||||
uniquePtr<processedRegFieldType> processedField_ = nullptr;
|
uniquePtr<processedRegFieldType> processedField_ = nullptr;
|
||||||
|
|
||||||
|
word fieldName_;
|
||||||
|
|
||||||
word name_;
|
word name_;
|
||||||
|
|
||||||
|
mutable uniquePtr<oFstream> osPtr_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypeInfo("PostprocessComponent<centerPoints,particleProbe>");
|
TypeInfo("PostprocessComponent<centerPoints,particleProbe>");
|
||||||
|
@ -63,6 +69,12 @@ public:
|
||||||
|
|
||||||
~particleProbePostprocessComponent()override = default;
|
~particleProbePostprocessComponent()override = default;
|
||||||
|
|
||||||
|
add_vCtor
|
||||||
|
(
|
||||||
|
postprocessComponent,
|
||||||
|
particleProbePostprocessComponent,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
word name()const override
|
word name()const override
|
||||||
{
|
{
|
||||||
|
@ -74,7 +86,6 @@ public:
|
||||||
return regionPointsPtr_();
|
return regionPointsPtr_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const regionPoints& regPoints() const override
|
const regionPoints& regPoints() const override
|
||||||
{
|
{
|
||||||
return regionPointsPtr_();
|
return regionPointsPtr_();
|
||||||
|
@ -87,6 +98,8 @@ public:
|
||||||
return executed_;
|
return executed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool write(const fileSystem& parDir)const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -101,6 +101,9 @@ public:
|
||||||
virtual
|
virtual
|
||||||
bool executed()const = 0;
|
bool executed()const = 0;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool write(const fileSystem& parDir)const = 0;
|
||||||
|
|
||||||
static
|
static
|
||||||
uniquePtr<postprocessComponent> create(
|
uniquePtr<postprocessComponent> create(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
|
@ -23,6 +23,7 @@ Licence:
|
||||||
#include "systemControl.hpp"
|
#include "systemControl.hpp"
|
||||||
#include "postprocessData.hpp"
|
#include "postprocessData.hpp"
|
||||||
#include "fileDictionary.hpp"
|
#include "fileDictionary.hpp"
|
||||||
|
#include "postprocessGlobals.hpp"
|
||||||
#include "postprocessComponent.hpp"
|
#include "postprocessComponent.hpp"
|
||||||
|
|
||||||
pFlow::postprocessData::postprocessData(const systemControl &control)
|
pFlow::postprocessData::postprocessData(const systemControl &control)
|
||||||
|
@ -42,6 +43,8 @@ pFlow::postprocessData::postprocessData(const systemControl &control)
|
||||||
),
|
),
|
||||||
componentsDicts_(readDictList("components", dict_))
|
componentsDicts_(readDictList("components", dict_))
|
||||||
{
|
{
|
||||||
|
postProcessGlobals::defaultDir__ = CWD()/pFlow::postProcessGlobals::defaultRelDir__;
|
||||||
|
|
||||||
// if dictionary is not provided, no extra action is required.
|
// if dictionary is not provided, no extra action is required.
|
||||||
if( !dict_.fileExist() )
|
if( !dict_.fileExist() )
|
||||||
{
|
{
|
||||||
|
@ -81,7 +84,6 @@ pFlow::postprocessData::postprocessData(const systemControl &control)
|
||||||
|
|
||||||
bool pFlow::postprocessData::execute()
|
bool pFlow::postprocessData::execute()
|
||||||
{
|
{
|
||||||
|
|
||||||
const auto& ti = time_.TimeInfo();
|
const auto& ti = time_.TimeInfo();
|
||||||
|
|
||||||
for(auto& component:postprocesses_)
|
for(auto& component:postprocesses_)
|
||||||
|
@ -96,4 +98,23 @@ bool pFlow::postprocessData::execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::postprocessData::write() const
|
||||||
|
{
|
||||||
|
for(auto& component:postprocesses_)
|
||||||
|
{
|
||||||
|
if(!component->executed())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!component->write(postProcessGlobals::defaultDir__/component->name()))
|
||||||
|
{
|
||||||
|
fatalErrorInFunction
|
||||||
|
<<"Error occured in writing postprocess component: "
|
||||||
|
<<component->name()<<endl;
|
||||||
|
fatalExit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -91,10 +91,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool wirte()const override
|
bool write()const override;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __postProcessGlobals_hpp__
|
||||||
|
#define __postProcessGlobals_hpp__
|
||||||
|
|
||||||
|
#include "fileSystem.hpp"
|
||||||
|
|
||||||
|
namespace pFlow::postProcessGlobals
|
||||||
|
{
|
||||||
|
|
||||||
|
static fileSystem defaultDir__;
|
||||||
|
inline const word defaultRelDir__ = "VTK/postprocessData";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __postProcessGlobals_hpp__
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*------------------------------- phasicFlow ---------------------------------
|
||||||
|
O C enter of
|
||||||
|
O O E ngineering and
|
||||||
|
O O M ultiscale modeling of
|
||||||
|
OOOOOOO F luid flow
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Copyright (C): www.cemf.ir
|
||||||
|
email: hamid.r.norouzi AT gmail.com
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
Licence:
|
||||||
|
This file is part of phasicFlow code. It is a free software for simulating
|
||||||
|
granular and multiphase flows. You can redistribute it and/or modify it under
|
||||||
|
the terms of GNU General Public License v3 or any other later versions.
|
||||||
|
|
||||||
|
phasicFlow is distributed to help others in their research in the field of
|
||||||
|
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef __arithmetic_hpp__
|
||||||
|
#define __arithmetic_hpp__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "types.hpp"
|
||||||
|
#include "typeInfo.hpp"
|
||||||
|
#include "span.hpp"
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
class dictionary;
|
||||||
|
|
||||||
|
class arithmetic
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<real> weight_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// type info
|
||||||
|
TypeInfoNV("arithmetic");
|
||||||
|
|
||||||
|
arithmetic()
|
||||||
|
{}
|
||||||
|
|
||||||
|
arithmetic(const arithmetic&) = default;
|
||||||
|
|
||||||
|
arithmetic(arithmetic&&) = default;
|
||||||
|
|
||||||
|
arithmetic& operator=(const arithmetic&) = default;
|
||||||
|
|
||||||
|
arithmetic& operator=(arithmetic&&) = default;
|
||||||
|
|
||||||
|
~arithmetic()=default;
|
||||||
|
|
||||||
|
|
||||||
|
bool updateWeights
|
||||||
|
(
|
||||||
|
const realx3& center,
|
||||||
|
const span<uint32>& indices,
|
||||||
|
const span<realx3>& points
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return updateWeights(indices.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool updateWeights(uint32 n)
|
||||||
|
{
|
||||||
|
n = max(n, 1u);
|
||||||
|
weight_.assign(n, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
real getWeight(uint32 i)const
|
||||||
|
{
|
||||||
|
return weight_[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
span<real> getWeights()
|
||||||
|
{
|
||||||
|
return span<real>(weight_.data(), weight_.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //__arithmetic_hpp__
|
|
@ -21,6 +21,8 @@ Licence:
|
||||||
#ifndef __uniformDistribution_hpp__
|
#ifndef __uniformDistribution_hpp__
|
||||||
#define __uniformDistribution_hpp__
|
#define __uniformDistribution_hpp__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "typeInfo.hpp"
|
#include "typeInfo.hpp"
|
||||||
#include "span.hpp"
|
#include "span.hpp"
|
||||||
|
@ -55,11 +57,14 @@ public:
|
||||||
~uniformDistribution()=default;
|
~uniformDistribution()=default;
|
||||||
|
|
||||||
|
|
||||||
bool updateWeights(const realx3& center, const span<realx3>& points)
|
bool updateWeights
|
||||||
|
(
|
||||||
|
const realx3& center,
|
||||||
|
const span<uint32>& indices,
|
||||||
|
const span<realx3>& points
|
||||||
|
)
|
||||||
{
|
{
|
||||||
uint32 n = max(points.size(), 1u);
|
return updateWeights(indices.size());
|
||||||
weight_.assign(n, 1.0/n);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateWeights(uint32 n)
|
bool updateWeights(uint32 n)
|
|
@ -57,6 +57,11 @@ public:
|
||||||
|
|
||||||
~regionField() = default;
|
~regionField() = default;
|
||||||
|
|
||||||
|
const regionPoints& regPoints() const
|
||||||
|
{
|
||||||
|
return regionPoints_;
|
||||||
|
}
|
||||||
|
|
||||||
/// get the field value
|
/// get the field value
|
||||||
T& operator[] (const uint32 i)
|
T& operator[] (const uint32 i)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +80,16 @@ public:
|
||||||
return field_.name();
|
return field_.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto size()const
|
||||||
|
{
|
||||||
|
return field_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty()const
|
||||||
|
{
|
||||||
|
return field_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief write the field to a file
|
/// @brief write the field to a file
|
||||||
/// @param os output file stream
|
/// @param os output file stream
|
||||||
/// @return true if successful and false if fails
|
/// @return true if successful and false if fails
|
|
@ -37,7 +37,7 @@ bool pFlow::centerPointsRegionPoints::selectIds()
|
||||||
diameter_.resize(ids_.size(),1.0);
|
diameter_.resize(ids_.size(),1.0);
|
||||||
center_.resize(ids_.size(), realx3(0,0,0));
|
center_.resize(ids_.size(), realx3(0,0,0));
|
||||||
selectedPoints_.resize(ids_.size(), -1);
|
selectedPoints_.resize(ids_.size(), -1);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
|
pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
|
||||||
|
@ -46,19 +46,7 @@ pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
|
||||||
: regionPoints(dict, fieldsDataBase),
|
: regionPoints(dict, fieldsDataBase),
|
||||||
idName_(dict.getValOrSet<word>("idName", "id")),
|
idName_(dict.getValOrSet<word>("idName", "id")),
|
||||||
probDict_(dict)
|
probDict_(dict)
|
||||||
{
|
{}
|
||||||
auto idList = dict.getVal<uint32List>("ids");
|
|
||||||
Set<uint32> uniqueIds;
|
|
||||||
|
|
||||||
uniqueIds.insert(idList.begin(), idList.end());
|
|
||||||
|
|
||||||
for(auto& id:uniqueIds)
|
|
||||||
{
|
|
||||||
ids_.push_back(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedPoints_.resize(ids_.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pFlow::centerPointsRegionPoints::update()
|
bool pFlow::centerPointsRegionPoints::update()
|
||||||
{
|
{
|
||||||
|
@ -81,6 +69,27 @@ bool pFlow::centerPointsRegionPoints::update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::centerPointsRegionPoints::write(iOstream &os) const
|
||||||
|
{
|
||||||
|
if(firstTimeUpdate_)
|
||||||
|
{
|
||||||
|
fatalErrorInFunction
|
||||||
|
<<"Write operation should be done before executing the update. \n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
os <<"# Probing particles for selected ids\n";
|
||||||
|
|
||||||
|
os << "# SelectedId: ";
|
||||||
|
|
||||||
|
for(auto& id: ids_)
|
||||||
|
{
|
||||||
|
os << id << tab;
|
||||||
|
}
|
||||||
|
os << endl;
|
||||||
|
os << "time"<<endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -106,6 +106,12 @@ public:
|
||||||
/// @return true if the operation is successful
|
/// @return true if the operation is successful
|
||||||
bool update() override;
|
bool update() override;
|
||||||
|
|
||||||
|
bool writeToSameTimeFile()const override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write(iOstream& os)const override;
|
||||||
|
|
||||||
}; // class centerPointsRegionPoints
|
}; // class centerPointsRegionPoints
|
||||||
|
|
|
@ -81,3 +81,20 @@ bool pFlow::lineRegionPoints::update()
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::lineRegionPoints::write(iOstream &os) const
|
||||||
|
{
|
||||||
|
os <<"# Spheres along a straight line \n";
|
||||||
|
os <<"# No."<<tab <<"centerPoint" << tab <<"diameter"<<endl;
|
||||||
|
for(uint32 i=0; i< sphereRegions_.size(); ++i)
|
||||||
|
{
|
||||||
|
os <<"# "<<i<<tab<<sphereRegions_[i].center() << tab <<diameters_[i] << '\n';
|
||||||
|
}
|
||||||
|
os<<"time/No. ";
|
||||||
|
for(uint32 i=0; i< sphereRegions_.size(); ++i)
|
||||||
|
{
|
||||||
|
os <<i<<tab;
|
||||||
|
}
|
||||||
|
os <<endl;
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -92,6 +92,12 @@ public:
|
||||||
|
|
||||||
bool update() override;
|
bool update() override;
|
||||||
|
|
||||||
|
bool writeToSameTimeFile()const override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write(iOstream& os) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ Licence:
|
||||||
#ifndef __regionPoints_hpp__
|
#ifndef __regionPoints_hpp__
|
||||||
#define __regionPoints_hpp__
|
#define __regionPoints_hpp__
|
||||||
|
|
||||||
|
#include "iOstream.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
#include "pointStructure.hpp"
|
#include "pointStructure.hpp"
|
||||||
|
|
||||||
|
@ -88,8 +89,11 @@ public:
|
||||||
virtual
|
virtual
|
||||||
bool update() = 0;
|
bool update() = 0;
|
||||||
|
|
||||||
/*virtual
|
virtual
|
||||||
bool write()const=0;*/
|
bool writeToSameTimeFile()const = 0;
|
||||||
|
|
||||||
|
virtual
|
||||||
|
bool write(iOstream& os)const=0;
|
||||||
|
|
||||||
/*static
|
/*static
|
||||||
uniquePtr<regionPoints> create(
|
uniquePtr<regionPoints> create(
|
|
@ -27,5 +27,15 @@ bool pFlow::sphereRegionPoints::update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::sphereRegionPoints::write(iOstream &os) const
|
||||||
|
{
|
||||||
|
os <<"# Single sphere\n";
|
||||||
|
os <<"# center point: "<<sphereRegion_.center()<<endl;
|
||||||
|
os <<"# diameter: "<< diameter_ << endl;
|
||||||
|
os <<"time"<< tab <<"value"<<endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
|
@ -90,6 +90,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update()override;
|
bool update()override;
|
||||||
|
|
||||||
|
bool writeToSameTimeFile()const override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write(iOstream& os)const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue