mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
prime2 is added and readme update
This commit is contained in:
@ -77,6 +77,7 @@ pFlow::PostprocessOperationAverage::PostprocessOperationAverage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Performs weighted average of field values within each region
|
||||
bool pFlow::PostprocessOperationAverage::execute
|
||||
(
|
||||
@ -109,7 +110,7 @@ bool pFlow::PostprocessOperationAverage::execute
|
||||
allField)
|
||||
);
|
||||
|
||||
if(calculateFluctuation2_)
|
||||
if(calculateFluctuation2_())
|
||||
{
|
||||
auto& processedRegField = processedRegFieldPtr_();
|
||||
fluctuation2FieldPtr_ = makeUnique<processedRegFieldType>
|
||||
@ -136,5 +137,40 @@ bool pFlow::PostprocessOperationAverage::execute
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::PostprocessOperationAverage::write(const fileSystem &parDir) const
|
||||
{
|
||||
if(! postprocessOperation::write(parDir))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!calculateFluctuation2_())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
auto ti = time().TimeInfo();
|
||||
|
||||
if(!os2Ptr_)
|
||||
{
|
||||
fileSystem path = parDir+(
|
||||
processedFieldName()+"_prime2" + ".Start_" + ti.timeName());
|
||||
os2Ptr_ = makeUnique<oFstream>(path);
|
||||
|
||||
regPoints().write(os2Ptr_());
|
||||
}
|
||||
|
||||
|
||||
std::visit
|
||||
(
|
||||
[&](auto&& arg)->bool
|
||||
{
|
||||
return writeField(os2Ptr_(), ti.t(), arg, threshold());
|
||||
},
|
||||
fluctuation2FieldPtr_()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
@ -150,6 +150,9 @@ private:
|
||||
|
||||
uniquePtr<processedRegFieldType> fluctuation2FieldPtr_ = nullptr;
|
||||
|
||||
/// Pointer to the output stream for writing fluctuation2 results
|
||||
mutable uniquePtr<oFstream> os2Ptr_ = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("PostprocessOperation<average>");
|
||||
@ -190,6 +193,10 @@ public:
|
||||
return processedRegFieldPtr_();
|
||||
}
|
||||
|
||||
/// write to os stream
|
||||
bool write(const fileSystem &parDir)const override;
|
||||
|
||||
|
||||
/// @brief Execute average operation on field values
|
||||
/// @param weights Weight factors for particles
|
||||
/// @return True if successful
|
||||
|
@ -23,64 +23,6 @@ Licence:
|
||||
#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
|
||||
(
|
||||
|
@ -76,19 +76,12 @@ Licence:
|
||||
#include "oFstream.hpp"
|
||||
#include "regionField.hpp"
|
||||
#include "includeMask.hpp"
|
||||
#include "postprocessOperationFunctions.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/// Type alias for processed region field types.
|
||||
/// Only regionField<real>, regionField<realx3>, and regionField<realx4> are supported
|
||||
/// in the postprocessOperation class.
|
||||
using processedRegFieldType = std::variant
|
||||
<
|
||||
regionField<real>,
|
||||
regionField<realx3>,
|
||||
regionField<realx4>
|
||||
>;
|
||||
|
||||
|
||||
/// - forward declaration
|
||||
class fieldsDataBase;
|
||||
|
@ -0,0 +1,100 @@
|
||||
/*------------------------------- 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 __postprocessOperationFunctions_hpp__
|
||||
#define __postprocessOperationFunctions_hpp__
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include "types.hpp"
|
||||
#include "iOstream.hpp"
|
||||
#include "regionField.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
/// Type alias for processed region field types.
|
||||
/// Only regionField<real>, regionField<realx3>, and regionField<realx4> are supported
|
||||
/// in the postprocessOperation class.
|
||||
using processedRegFieldType = std::variant
|
||||
<
|
||||
regionField<real>,
|
||||
regionField<realx3>,
|
||||
regionField<realx4>
|
||||
>;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#endif //__postprocessOperationFunctions_hpp__
|
Reference in New Issue
Block a user