The main structure is tested. functons like execute and write are added and tested.

other components are left
This commit is contained in:
Hamidreza 2025-04-10 21:16:31 +03:30
parent ab7f700ead
commit 162cfd3b6a
45 changed files with 821 additions and 154 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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)

View File

@ -465,19 +465,22 @@ pFlow::span<pFlow::real> pFlow::fieldsDataBase::updateFieldReal
}
// 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);
auto spReal = createOrGetRealField(fieldName+".real");
funcCast(sp, spReal);
return spReal;
}
else
{
fatalErrorInFunction<<"No function can be applied to field of type uint32. "<<
" The field is: "<< compoundName<<endl;
return span<real>(nullptr, 0);
fatalExit;
if(func == Functions::None)
{
auto sp = updateField<uint32>(fieldName, forceUpdate);
auto spReal = createOrGetRealField(fieldName+".real");
funcCast(sp, spReal);
return spReal;
}
else
{
fatalErrorInFunction<<"No function can be applied to field of type uint32. "<<
" The field is: "<< compoundName<<endl;
return span<real>(nullptr, 0);
fatalExit;
}
}
if( originalType == getTypeName<real>() )
@ -606,27 +609,30 @@ pFlow::allPointFieldTypes pFlow::fieldsDataBase::updateFieldAll
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: "<<
compoundName<<", with type name: "<< originalType <<endl;
fatalExit;
return span<real>(nullptr,0);
return span<real>(nullptr, 0);
}
if( typeAfterFunction== getTypeName<realx3>() )
{
return updateField<realx3>(compoundName, forceUpdate);
return updateFieldRealx3(compoundName, forceUpdate);
}
else if( typeAfterFunction == getTypeName<realx4>() )
{
return updateField<realx4>(compoundName, forceUpdate);
return updateFieldRealx4(compoundName, forceUpdate);
}
else if( typeAfterFunction == getTypeName<real>() )
{
return updateField<real>(compoundName, forceUpdate);
return updateFieldReal(compoundName, forceUpdate);
}
else
{

View File

@ -51,19 +51,21 @@ bool pFlow::PostprocessOperationSum::execute
const auto& regP = regPoints();
bool dbVol = divideByVolume();
std::visit([&](auto&& field)->processedRegFieldType
{
return executeSumOperation(
procName,
field,
regP,
dbVol,
weights,
phi,
mask);
},
allField);
processedRegField_ = makeUnique<processedRegFieldType>
(
std::visit([&](auto&& field)->processedRegFieldType
{
return executeSumOperation(
procName,
field,
regP,
dbVol,
weights,
phi,
mask);
},
allField)
);
return true;
}

View File

@ -37,14 +37,7 @@ class PostprocessOperationSum
public postprocessOperation
{
private:
using processedRegFieldType = std::variant
<
regionField<real>,
regionField<realx3>,
regionField<realx4>
>;
/// Pointer to the include mask used for masking operations.
uniquePtr<processedRegFieldType> processedRegField_ = nullptr;
@ -66,6 +59,11 @@ public:
dictionary
);
const processedRegFieldType& processedField()const override
{
return processedRegField_();
}
bool execute(const std::vector<span<real>>& weights) override;
};

View File

@ -31,6 +31,7 @@ Licence:
namespace pFlow
{
template<typename T>
regionField<T> executeSumOperation
(
@ -54,7 +55,7 @@ regionField<T> executeSumOperation
uint n = 0;
for(auto index:partIndices)
{
if( mask( index ))
if( index!= -1 && mask( index ))
{
sum += w[n] * field[index]* phi[index];
}
@ -96,7 +97,7 @@ regionField<T> executeAverageOperation
uint n = 0;
for(auto index:partIndices)
{
if( mask( index ))
if( index!= -1 && mask( index ))
{
sumNum += w[n] * field[index]* phi[index];
}
@ -114,4 +115,4 @@ regionField<T> executeAverageOperation
} // namespace pFlow
#endif //__fieldFunctions_hpp__
#endif //__fieldFunctions_hpp__

View File

@ -18,10 +18,72 @@ Licence:
-----------------------------------------------------------------------------*/
#include "Time.hpp"
#include "postprocessOperation.hpp"
#include "regionPoints.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
(
const dictionary &opDict,
@ -67,13 +129,43 @@ pFlow::postprocessOperation::postprocessOperation
}
}
pFlow::uniquePtr<pFlow::postprocessOperation>
pFlow::postprocessOperation::create
const pFlow::Time& pFlow::postprocessOperation::time() const
{
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,
const regionPoints& regPoints,
fieldsDataBase &fieldsDB
)
[&](auto&& arg)->bool
{
return writeField(osPtr_(), ti.t(), arg, threshold_);
},
field
);
return true;
}
pFlow::uniquePtr<pFlow::postprocessOperation>
pFlow::postprocessOperation::create(
const dictionary &opDict,
const regionPoints &regPoints,
fieldsDataBase &fieldsDB)
{
word func = opDict.getVal<word>("function");
word method = angleBracketsNames("PostprocessOperation", func);

View File

@ -20,18 +20,28 @@ Licence:
#ifndef __postprocessOperation_hpp__
#define __postprocessOperation_hpp__
#include <variant>
#include "virtualConstructor.hpp"
#include "Logical.hpp"
#include "dictionary.hpp"
#include "span.hpp"
#include "oFstream.hpp"
#include "regionField.hpp"
#include "includeMask.hpp"
namespace pFlow
{
using processedRegFieldType = std::variant
<
regionField<real>,
regionField<realx3>,
regionField<realx4>
>;
class fieldsDataBase;
class regionPoints;
class Time;
/*!
* @brief Base class for post-processing operations.
@ -69,10 +79,12 @@ private:
word fieldType_;
/// Name of the phi field to be processed.
word phiFieldName_;
word phiFieldName_;
/// Pointer to the include mask used for masking operations.
uniquePtr<includeMask> includeMask_ = nullptr;
mutable uniquePtr<oFstream> osPtr_ = nullptr;
public:
@ -111,6 +123,8 @@ public:
return database_;
}
const Time& time()const;
word processedFieldName()const
{
return operationDict_.name();
@ -150,10 +164,18 @@ public:
return includeMask_().getMask();
}
virtual
const processedRegFieldType& processedField()const=0;
virtual
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
uniquePtr<postprocessOperation> create(
const dictionary& opDict,

View File

@ -61,22 +61,31 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
bool forceUpdate
)
{
if( !timeControl().eventTime(ti))
if( !forceUpdate && !timeControl().eventTime(ti))
{
executed_ = false;
return true;
}
// update processing methods
auto& regPoints = this->regPoints();
auto centers = this->regPoints().centers();
const uint32 n = centers.size();
auto points = this->database().updatePoints();
if(!regPoints.update())
{
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++)
{
auto indices = this->regPoints().indices(i);
auto indices = regPoints.indices(i);
regionsProcessMethod_[i].updateWeights(
centers[i],
indices,
@ -93,7 +102,7 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
for(auto& op:operatios_)
{
if( op->execute(weights) )
if( !op->execute(weights) )
{
fatalErrorInFunction
<<"error occured in executing operatoin defined in dict "
@ -105,5 +114,39 @@ bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
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;
}

View File

@ -106,10 +106,12 @@ public:
return executed_;
}
bool write(const fileSystem& parDir)const override;
};
}
#include "PostprocessComponent.cpp"

View File

@ -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__

View File

@ -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__

View File

@ -19,16 +19,15 @@ Licence:
-----------------------------------------------------------------------------*/
#include "PostprocessComponentGaussian.hpp"
#include "PostprocessComponentUniform.hpp"
#include "PostprocessComponentArithmetic.hpp"
// region types
#include "sphereRegionPoints.hpp"
// methods
#include "GaussianDistribution.hpp"
#include "uniformDistribution.hpp"
template class pFlow::PostprocessComponentGaussian<pFlow::sphereRegionPoints>;
template class pFlow::PostprocessComponentUniform<pFlow::sphereRegionPoints>;
template class pFlow::PostprocessComponentArithmetic<pFlow::sphereRegionPoints>;

View File

@ -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;
}

View File

@ -25,10 +25,12 @@ Licence:
#include "fieldsDataBase.hpp"
#include "centerPointsRegionPoints.hpp"
#include "regionField.hpp"
#include "oFstream.hpp"
namespace pFlow
{
class particleProbePostprocessComponent
:
public postprocessComponent
@ -48,8 +50,12 @@ private:
uniquePtr<processedRegFieldType> processedField_ = nullptr;
word fieldName_;
word name_;
mutable uniquePtr<oFstream> osPtr_ = nullptr;
public:
TypeInfo("PostprocessComponent<centerPoints,particleProbe>");
@ -63,6 +69,12 @@ public:
~particleProbePostprocessComponent()override = default;
add_vCtor
(
postprocessComponent,
particleProbePostprocessComponent,
dictionary
);
word name()const override
{
@ -74,7 +86,6 @@ public:
return regionPointsPtr_();
}
const regionPoints& regPoints() const override
{
return regionPointsPtr_();
@ -87,6 +98,8 @@ public:
return executed_;
}
bool write(const fileSystem& parDir)const override;
};
}

View File

@ -101,6 +101,9 @@ public:
virtual
bool executed()const = 0;
virtual
bool write(const fileSystem& parDir)const = 0;
static
uniquePtr<postprocessComponent> create(
const dictionary& dict,

View File

@ -23,6 +23,7 @@ Licence:
#include "systemControl.hpp"
#include "postprocessData.hpp"
#include "fileDictionary.hpp"
#include "postprocessGlobals.hpp"
#include "postprocessComponent.hpp"
pFlow::postprocessData::postprocessData(const systemControl &control)
@ -42,6 +43,8 @@ pFlow::postprocessData::postprocessData(const systemControl &control)
),
componentsDicts_(readDictList("components", dict_))
{
postProcessGlobals::defaultDir__ = CWD()/pFlow::postProcessGlobals::defaultRelDir__;
// if dictionary is not provided, no extra action is required.
if( !dict_.fileExist() )
{
@ -81,7 +84,6 @@ pFlow::postprocessData::postprocessData(const systemControl &control)
bool pFlow::postprocessData::execute()
{
const auto& ti = time_.TimeInfo();
for(auto& component:postprocesses_)
@ -96,4 +98,23 @@ bool pFlow::postprocessData::execute()
}
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;
}

View File

@ -91,10 +91,8 @@ public:
bool wirte()const override
{
return false;
}
bool write()const override;
};

View File

@ -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__

View File

@ -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__

View File

@ -21,6 +21,8 @@ Licence:
#ifndef __uniformDistribution_hpp__
#define __uniformDistribution_hpp__
#include <vector>
#include "types.hpp"
#include "typeInfo.hpp"
#include "span.hpp"
@ -55,11 +57,14 @@ public:
~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);
weight_.assign(n, 1.0/n);
return true;
return updateWeights(indices.size());
}
bool updateWeights(uint32 n)

View File

@ -57,6 +57,11 @@ public:
~regionField() = default;
const regionPoints& regPoints() const
{
return regionPoints_;
}
/// get the field value
T& operator[] (const uint32 i)
{
@ -75,6 +80,16 @@ public:
return field_.name();
}
auto size()const
{
return field_.size();
}
bool empty()const
{
return field_.empty();
}
/// @brief write the field to a file
/// @param os output file stream
/// @return true if successful and false if fails

View File

@ -37,7 +37,7 @@ bool pFlow::centerPointsRegionPoints::selectIds()
diameter_.resize(ids_.size(),1.0);
center_.resize(ids_.size(), realx3(0,0,0));
selectedPoints_.resize(ids_.size(), -1);
return false;
return true;
}
pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
@ -46,19 +46,7 @@ pFlow::centerPointsRegionPoints::centerPointsRegionPoints(
: regionPoints(dict, fieldsDataBase),
idName_(dict.getValOrSet<word>("idName", "id")),
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()
{
@ -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;
}

View File

@ -106,6 +106,12 @@ public:
/// @return true if the operation is successful
bool update() override;
bool writeToSameTimeFile()const override
{
return true;
}
bool write(iOstream& os)const override;
}; // class centerPointsRegionPoints

View File

@ -81,3 +81,20 @@ bool pFlow::lineRegionPoints::update()
}
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;
}

View File

@ -92,6 +92,12 @@ public:
bool update() override;
bool writeToSameTimeFile()const override
{
return true;
}
bool write(iOstream& os) const override;
};
}

View File

@ -21,6 +21,7 @@ Licence:
#ifndef __regionPoints_hpp__
#define __regionPoints_hpp__
#include "iOstream.hpp"
#include "dictionary.hpp"
#include "pointStructure.hpp"
@ -88,8 +89,11 @@ public:
virtual
bool update() = 0;
/*virtual
bool write()const=0;*/
virtual
bool writeToSameTimeFile()const = 0;
virtual
bool write(iOstream& os)const=0;
/*static
uniquePtr<regionPoints> create(

View File

@ -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;
}

View File

@ -90,6 +90,13 @@ public:
}
bool update()override;
bool writeToSameTimeFile()const override
{
return true;
}
bool write(iOstream& os)const override;
};