mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-07-08 03:07:03 +00:00
The main structure is tested. functons like execute and write are added and tested.
other components are left
This commit is contained in:
@ -0,0 +1,71 @@
|
||||
#include "PostprocessOperationSum.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "fieldFunctions.hpp"
|
||||
|
||||
pFlow::PostprocessOperationSum::PostprocessOperationSum
|
||||
(
|
||||
const dictionary &opDict,
|
||||
const regionPoints ®Points,
|
||||
fieldsDataBase &fieldsDB
|
||||
)
|
||||
:
|
||||
postprocessOperation(opDict, regPoints, fieldsDB)
|
||||
{
|
||||
if( fieldType() == getTypeName<real>() )
|
||||
{
|
||||
processedRegField_ = makeUnique<processedRegFieldType>(
|
||||
regionField(processedFieldName(), regPoints, real(0)));
|
||||
}
|
||||
else if( fieldType() == getTypeName<realx3>() )
|
||||
{
|
||||
processedRegField_ = makeUnique<processedRegFieldType>(
|
||||
regionField(processedFieldName(), regPoints, realx3(0)));
|
||||
}
|
||||
else if( fieldType() == getTypeName<realx4>() )
|
||||
{
|
||||
processedRegField_ = makeUnique<processedRegFieldType>(
|
||||
regionField(processedFieldName(), regPoints, realx4(0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<" in dictionary "<< opDict.globalName()
|
||||
<< " field type is not supported for sum operation"
|
||||
<< " field type is "<< fieldType()
|
||||
<< endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
bool pFlow::PostprocessOperationSum::execute
|
||||
(
|
||||
const std::vector<span<real>>& weights
|
||||
)
|
||||
{
|
||||
auto allField = database().updateFieldAll(fieldName());
|
||||
auto phi = database().updateFieldReal(
|
||||
phiFieldName());
|
||||
|
||||
auto mask = getMask();
|
||||
word procName = processedFieldName();
|
||||
const auto& regP = regPoints();
|
||||
bool dbVol = divideByVolume();
|
||||
|
||||
processedRegField_ = makeUnique<processedRegFieldType>
|
||||
(
|
||||
std::visit([&](auto&& field)->processedRegFieldType
|
||||
{
|
||||
return executeSumOperation(
|
||||
procName,
|
||||
field,
|
||||
regP,
|
||||
dbVol,
|
||||
weights,
|
||||
phi,
|
||||
mask);
|
||||
},
|
||||
allField)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*------------------------------- 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 __PostprocessOperationSum_hpp__
|
||||
#define __PostprocessOperationSum_hpp__
|
||||
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "postprocessOperation.hpp"
|
||||
#include "regionField.hpp"
|
||||
#include "includeMask.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class PostprocessOperationSum
|
||||
:
|
||||
public postprocessOperation
|
||||
{
|
||||
private:
|
||||
|
||||
/// Pointer to the include mask used for masking operations.
|
||||
uniquePtr<processedRegFieldType> processedRegField_ = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("PostprocessOperation<sum>");
|
||||
|
||||
PostprocessOperationSum(
|
||||
const dictionary& opDict,
|
||||
const regionPoints& regPoints,
|
||||
fieldsDataBase& fieldsDB);
|
||||
|
||||
~PostprocessOperationSum() override = default;
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
postprocessOperation,
|
||||
PostprocessOperationSum,
|
||||
dictionary
|
||||
);
|
||||
|
||||
const processedRegFieldType& processedField()const override
|
||||
{
|
||||
return processedRegField_();
|
||||
}
|
||||
|
||||
bool execute(const std::vector<span<real>>& weights) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif //__PostprocessOperation_hpp__
|
@ -0,0 +1,118 @@
|
||||
/*------------------------------- 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 __fieldFunctions_hpp__
|
||||
#define __fieldFunctions_hpp__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "span.hpp"
|
||||
#include "regionPoints.hpp"
|
||||
#include "regionField.hpp"
|
||||
#include "includeMask.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
template<typename T>
|
||||
regionField<T> executeSumOperation
|
||||
(
|
||||
const word& regFieldName,
|
||||
const span<T>& field,
|
||||
const regionPoints& regPoints,
|
||||
const bool devideByVol,
|
||||
const std::vector<span<real>>& weights,
|
||||
const span<real>& phi,
|
||||
const includeMask::Mask& mask
|
||||
)
|
||||
{
|
||||
regionField<T> processedField(regFieldName, regPoints, T{});
|
||||
|
||||
for(uint32 reg =0; reg<regPoints.size(); reg++)
|
||||
{
|
||||
auto partIndices = regPoints.indices(reg);
|
||||
auto vols = regPoints.volumes();
|
||||
auto w = weights[reg];
|
||||
T sum{};
|
||||
uint n = 0;
|
||||
for(auto index:partIndices)
|
||||
{
|
||||
if( index!= -1 && mask( index ))
|
||||
{
|
||||
sum += w[n] * field[index]* phi[index];
|
||||
}
|
||||
n++;
|
||||
}
|
||||
if(devideByVol)
|
||||
{
|
||||
processedField[reg] = sum/vols[reg];
|
||||
}
|
||||
else
|
||||
{
|
||||
processedField[reg] = sum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return processedField;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
regionField<T> executeAverageOperation
|
||||
(
|
||||
const word& regFieldName,
|
||||
const span<T>& field,
|
||||
const regionPoints& regPoints,
|
||||
const std::vector<span<real>>& weights,
|
||||
const span<real>& phi,
|
||||
const includeMask::Mask& mask
|
||||
)
|
||||
{
|
||||
regionField<T> processedField(regFieldName, regPoints, T{});
|
||||
|
||||
for(uint32 reg =0; reg<regPoints.size(); reg++)
|
||||
{
|
||||
auto partIndices = regPoints.indices(reg);
|
||||
auto w = weights[reg];
|
||||
T sumNum{};
|
||||
real sumDen{};
|
||||
uint n = 0;
|
||||
for(auto index:partIndices)
|
||||
{
|
||||
if( index!= -1 && mask( index ))
|
||||
{
|
||||
sumNum += w[n] * field[index]* phi[index];
|
||||
}
|
||||
sumDen += w[n] * phi[index];
|
||||
n++;
|
||||
}
|
||||
|
||||
sumDen = max(sumDen, smallValue);
|
||||
processedField[reg] = sumNum/sumDen;
|
||||
|
||||
}
|
||||
|
||||
return processedField;
|
||||
}
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#endif //__fieldFunctions_hpp__
|
192
src/PostprocessData/operation/includeMask/IncludeMask.hpp
Normal file
192
src/PostprocessData/operation/includeMask/IncludeMask.hpp
Normal file
@ -0,0 +1,192 @@
|
||||
/*------------------------------- 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 __IncludeMask_hpp__
|
||||
#define __IncludeMask_hpp__
|
||||
|
||||
#include "dictionary.hpp"
|
||||
#include "includeMask.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "maskOperations.hpp"
|
||||
#include "Time.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
template<typename T, typename Operator>
|
||||
class IncludeMask
|
||||
:
|
||||
public includeMask
|
||||
{
|
||||
public:
|
||||
|
||||
using Mask = typename includeMask::Mask;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<bool> mask_;
|
||||
|
||||
Operator operator_;
|
||||
|
||||
word fieldName_;
|
||||
|
||||
timeValue lastUpdated_ = -1;
|
||||
|
||||
bool updateMask()
|
||||
{
|
||||
timeValue t = database().currentTime();
|
||||
|
||||
if( equal( t, lastUpdated_)) return true;
|
||||
|
||||
span<T> s;
|
||||
if constexpr (std::is_same_v<T,real>)
|
||||
{
|
||||
s = database().updateFieldReal(fieldName_);
|
||||
}
|
||||
else if constexpr ( std::is_same_v<T,realx3>)
|
||||
{
|
||||
s = database().updateFieldRealx3(fieldName_);
|
||||
}
|
||||
else if constexpr( std::is_same_v<T,realx4>)
|
||||
{
|
||||
s = database().updateFieldRealx4(fieldName_);
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<"Type "<< getTypeName<T>()
|
||||
<<" is not supported for IncludeMask for field "
|
||||
<< fieldName_ << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mask_.resize(s.size());
|
||||
|
||||
for(uint32 i=0; i<s.size(); i++)
|
||||
{
|
||||
mask_[i] = operator_(s[i]);
|
||||
}
|
||||
|
||||
lastUpdated_ = t ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static
|
||||
word operatorName()
|
||||
{
|
||||
return Operator::TYPENAME();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TypeInfoTemplate12("IncludeMask", T, Operator);
|
||||
|
||||
IncludeMask(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& feildsDB)
|
||||
:
|
||||
includeMask(dict, feildsDB),
|
||||
operator_(dict.subDict(operatorName()+"Info")),
|
||||
fieldName_(
|
||||
dict.subDict
|
||||
(
|
||||
operatorName()+"Info"
|
||||
).getVal<word>("field"))
|
||||
{}
|
||||
|
||||
add_vCtor(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
|
||||
Mask getMask() override
|
||||
{
|
||||
updateMask();
|
||||
return Mask(mask_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class IncludeMask<T,allOp<T>>
|
||||
:
|
||||
public includeMask
|
||||
{
|
||||
public:
|
||||
|
||||
using Mask = typename includeMask::Mask;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<bool> mask_;
|
||||
|
||||
timeValue lastUpdated_ = -1;
|
||||
|
||||
bool updateMask()
|
||||
{
|
||||
timeValue t = database().currentTime();
|
||||
|
||||
if( equal( t, lastUpdated_)) return true;
|
||||
|
||||
span<realx3> s = database().updatePoints();
|
||||
mask_.resize(s.size(), true);
|
||||
|
||||
lastUpdated_ = t ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TypeInfoTemplate12("IncludeMask", T, allOp<int8>);
|
||||
|
||||
IncludeMask(
|
||||
const dictionary& opDict,
|
||||
fieldsDataBase& feildsDB)
|
||||
:
|
||||
includeMask(opDict, feildsDB)
|
||||
{
|
||||
span<realx3> s = database().updatePoints();
|
||||
mask_.resize(s.size(), true);
|
||||
}
|
||||
|
||||
add_vCtor(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
|
||||
Mask getMask()override
|
||||
{
|
||||
updateMask();
|
||||
return Mask(mask_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__IncludeMask_hpp__
|
||||
|
||||
|
50
src/PostprocessData/operation/includeMask/IncludeMasks.cpp
Normal file
50
src/PostprocessData/operation/includeMask/IncludeMasks.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "IncludeMask.hpp"
|
||||
|
||||
// real
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareTwo<pFlow::real, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareTwo<pFlow::real, pFlow::betweenEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::allOp<pFlow::real>>;
|
||||
|
||||
// realx3
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareTwo<pFlow::realx3, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareTwo<pFlow::realx3, pFlow::betweenEqOp> >;
|
||||
|
||||
|
||||
// realx4
|
91
src/PostprocessData/operation/includeMask/includeMask.cpp
Normal file
91
src/PostprocessData/operation/includeMask/includeMask.cpp
Normal 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "includeMask.hpp"
|
||||
#include "dictionary.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
|
||||
|
||||
pFlow::includeMask::includeMask
|
||||
(
|
||||
const dictionary& dict,
|
||||
fieldsDataBase& fieldDB
|
||||
)
|
||||
:
|
||||
database_(fieldDB)
|
||||
{}
|
||||
|
||||
|
||||
pFlow::uniquePtr<pFlow::includeMask> pFlow::includeMask::create
|
||||
(
|
||||
const dictionary& opDict,
|
||||
fieldsDataBase& feildsDB
|
||||
)
|
||||
{
|
||||
word mask = opDict.getValOrSet<word>("includeMask", "all");
|
||||
word fieldType;
|
||||
if( mask != "all")
|
||||
{
|
||||
auto& maskDict = opDict.subDict(mask+"Info");
|
||||
word maskField = maskDict.getVal<word>("field");
|
||||
|
||||
if( !feildsDB.getPointFieldType(maskField, fieldType) )
|
||||
{
|
||||
fatalErrorInFunction<<"Error in retriving the type of field"
|
||||
<< maskField <<" from dictionary "
|
||||
<< maskDict.globalName()
|
||||
<< endl;
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldType = getTypeName<real>();
|
||||
}
|
||||
|
||||
word method = angleBracketsNames2("IncludeMask", fieldType, mask);
|
||||
|
||||
if( dictionaryvCtorSelector_.search(method) )
|
||||
{
|
||||
auto objPtr =
|
||||
dictionaryvCtorSelector_[method]
|
||||
(opDict, feildsDB);
|
||||
return objPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<<
|
||||
method << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
115
src/PostprocessData/operation/includeMask/includeMask.hpp
Normal file
115
src/PostprocessData/operation/includeMask/includeMask.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
/*------------------------------- 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 __includeMask_hpp__
|
||||
#define __includeMask_hpp__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "virtualConstructor.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class fieldsDataBase;
|
||||
class dictionary;
|
||||
|
||||
class includeMask
|
||||
{
|
||||
public:
|
||||
|
||||
class Mask
|
||||
{
|
||||
const std::vector<bool>& mask_;
|
||||
|
||||
public:
|
||||
|
||||
Mask(const std::vector<bool>& msk)
|
||||
:
|
||||
mask_(msk)
|
||||
{}
|
||||
|
||||
Mask(const Mask&) = default;
|
||||
|
||||
Mask(Mask&&) = default;
|
||||
|
||||
~Mask()=default;
|
||||
|
||||
auto size()const
|
||||
{
|
||||
return mask_.size();
|
||||
}
|
||||
|
||||
bool operator()(uint32 i)const
|
||||
{
|
||||
return mask_[i];
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
fieldsDataBase& database_;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("includeMask");
|
||||
|
||||
includeMask(const dictionary& opDict, fieldsDataBase& feildsDB);
|
||||
|
||||
virtual ~includeMask() = default;
|
||||
|
||||
create_vCtor
|
||||
(
|
||||
includeMask,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& opDict, fieldsDataBase& feildsDB
|
||||
),
|
||||
(opDict, feildsDB)
|
||||
);
|
||||
|
||||
const fieldsDataBase& database()const
|
||||
{
|
||||
return database_;
|
||||
}
|
||||
|
||||
fieldsDataBase& database()
|
||||
{
|
||||
return database_;
|
||||
}
|
||||
|
||||
virtual
|
||||
Mask getMask()= 0;
|
||||
|
||||
static
|
||||
uniquePtr<includeMask> create(
|
||||
const dictionary& opDict,
|
||||
fieldsDataBase& feildsDB);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__IncludeMask_hpp__
|
||||
|
||||
|
162
src/PostprocessData/operation/includeMask/maskOperations.hpp
Normal file
162
src/PostprocessData/operation/includeMask/maskOperations.hpp
Normal file
@ -0,0 +1,162 @@
|
||||
|
||||
#ifndef __maskOperation_hpp__
|
||||
#define __maskOperation_hpp__
|
||||
|
||||
#include "types.hpp"
|
||||
#include "dictionary.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct greaterThanOp
|
||||
{
|
||||
TypeInfoNV("greaterThan");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val > compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct greaterThanEqOp
|
||||
{
|
||||
TypeInfoNV("greaterThanEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val >= compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct lessThanOp
|
||||
{
|
||||
TypeInfoNV("lessThan");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val < compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct lessThanEqOp
|
||||
{
|
||||
TypeInfoNV("lessThanEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val <= compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct equalOp
|
||||
{
|
||||
TypeInfoNV("equal");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return equal(val , compVal); }
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct betweenOp
|
||||
{
|
||||
TypeInfoNV("between");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
|
||||
return val>compVal1 && val<compVal2; }
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct betweenEqOp
|
||||
{
|
||||
TypeInfoNV("betweenEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
|
||||
return val>=compVal1 && val<=compVal2; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct allOp
|
||||
{
|
||||
TypeInfoNV("all");
|
||||
|
||||
inline
|
||||
bool operator()() const {return true; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename T, template<class> class Operator>
|
||||
class compareOne
|
||||
{
|
||||
public:
|
||||
|
||||
using opertorType = Operator<T>;
|
||||
|
||||
protected:
|
||||
T compValue_{};
|
||||
opertorType operator_{};
|
||||
public:
|
||||
|
||||
TypeInfoNV(Operator<T>::TYPENAME());
|
||||
|
||||
compareOne(const dictionary& dict)
|
||||
:
|
||||
compValue_(dict.getVal<T>("value"))
|
||||
{}
|
||||
|
||||
bool operator()(const T& value)const
|
||||
{
|
||||
return operator_(compValue_, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, template<class> class Operator>
|
||||
class compareTwo
|
||||
{
|
||||
public:
|
||||
using opertorType = Operator<T>;
|
||||
protected:
|
||||
T compValue1_;
|
||||
T compValue2_;
|
||||
opertorType operator_{};
|
||||
public:
|
||||
|
||||
TypeInfoNV(opertorType::TYPENAME());
|
||||
|
||||
compareTwo(const dictionary& dict)
|
||||
:
|
||||
compValue1_(dict.getVal<T>("value1")),
|
||||
compValue2_(dict.getVal<T>("value2"))
|
||||
{}
|
||||
|
||||
bool operator()(const T& value)const
|
||||
{
|
||||
return operator_(compValue1_, compValue2_, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename Operator>
|
||||
class compareZero
|
||||
{
|
||||
protected:
|
||||
Operator operator_{};
|
||||
public:
|
||||
|
||||
TypeInfoNV(Operator::TYPENAME());
|
||||
compareZero(const dictionary& dict);
|
||||
|
||||
bool operator()(const T& value) const
|
||||
{
|
||||
return operator_();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__maskOperation_hpp__
|
@ -0,0 +1,193 @@
|
||||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#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,
|
||||
const regionPoints& regPoints,
|
||||
fieldsDataBase &fieldsDB
|
||||
)
|
||||
:
|
||||
operationDict_(opDict),
|
||||
threshold_
|
||||
(
|
||||
opDict.getValOrSet<int>("threshold", 1)
|
||||
),
|
||||
divideByVolume_
|
||||
(
|
||||
opDict.getValOrSet<Logical>("dividedByVolume", Logical(false))
|
||||
),
|
||||
regionPoints_
|
||||
(
|
||||
regPoints
|
||||
),
|
||||
database_
|
||||
(
|
||||
fieldsDB
|
||||
),
|
||||
fieldName_
|
||||
(
|
||||
opDict.getValOrSet<word>("field", "one")
|
||||
),
|
||||
phiFieldName_
|
||||
(
|
||||
opDict.getValOrSet<word>("phi", "one")
|
||||
),
|
||||
includeMask_
|
||||
(
|
||||
includeMask::create(opDict, fieldsDB)
|
||||
)
|
||||
{
|
||||
|
||||
if(!fieldsDB.getPointFieldType(fieldName_, fieldType_))
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
(
|
||||
[&](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 ®Points,
|
||||
fieldsDataBase &fieldsDB)
|
||||
{
|
||||
word func = opDict.getVal<word>("function");
|
||||
word method = angleBracketsNames("PostprocessOperation", func);
|
||||
if( dictionaryvCtorSelector_.search(method) )
|
||||
{
|
||||
REPORT(3)<<"Operation "<< Green_Text(opDict.name())<<" with function "<< Green_Text(func)<<endl;
|
||||
auto objPtr =
|
||||
dictionaryvCtorSelector_[method]
|
||||
(opDict, regPoints, fieldsDB);
|
||||
return objPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<<
|
||||
method << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
/*------------------------------- 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 __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 Time;
|
||||
|
||||
/*!
|
||||
* @brief Base class for post-processing operations.
|
||||
* This class provides the basic structure and functionality
|
||||
* for performing post-processing operations on simulation data.
|
||||
*/
|
||||
class postprocessOperation
|
||||
{
|
||||
public:
|
||||
|
||||
using Mask = typename includeMask::Mask;
|
||||
|
||||
private:
|
||||
|
||||
/// Dictionary containing operation-specific parameters.
|
||||
dictionary operationDict_;
|
||||
|
||||
/// This Threshold is used to exclude the regions which contain
|
||||
/// fewer than this value.
|
||||
uint32 threshold_;
|
||||
|
||||
/// Logical flag to determine if the result is divided by volume.
|
||||
Logical divideByVolume_;
|
||||
|
||||
/// Reference to the region points used in the operation.
|
||||
const regionPoints& regionPoints_;
|
||||
|
||||
/// Reference to the fields database containing field data.
|
||||
fieldsDataBase& database_;
|
||||
|
||||
/// Name of the field to be processed.
|
||||
word fieldName_;
|
||||
|
||||
/// Type of the field to be processed.
|
||||
word fieldType_;
|
||||
|
||||
/// Name of the phi field to be processed.
|
||||
word phiFieldName_;
|
||||
|
||||
/// Pointer to the include mask used for masking operations.
|
||||
uniquePtr<includeMask> includeMask_ = nullptr;
|
||||
|
||||
mutable uniquePtr<oFstream> osPtr_ = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
TypeInfo("postprocessOperation");
|
||||
|
||||
postprocessOperation(
|
||||
const dictionary& opDict,
|
||||
const regionPoints& regPoints,
|
||||
fieldsDataBase& fieldsDB );
|
||||
|
||||
virtual ~postprocessOperation()=default;
|
||||
|
||||
create_vCtor(
|
||||
postprocessOperation,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& opDict,
|
||||
const regionPoints& regPoints,
|
||||
fieldsDataBase& fieldsDB
|
||||
),
|
||||
(opDict, regPoints, fieldsDB));
|
||||
|
||||
const regionPoints& regPoints()const
|
||||
{
|
||||
return regionPoints_;
|
||||
}
|
||||
|
||||
const fieldsDataBase& database()const
|
||||
{
|
||||
return database_;
|
||||
}
|
||||
|
||||
fieldsDataBase& database()
|
||||
{
|
||||
return database_;
|
||||
}
|
||||
|
||||
const Time& time()const;
|
||||
|
||||
word processedFieldName()const
|
||||
{
|
||||
return operationDict_.name();
|
||||
}
|
||||
|
||||
const word& fieldName()const
|
||||
{
|
||||
return fieldName_;
|
||||
}
|
||||
|
||||
const word& fieldType()const
|
||||
{
|
||||
return fieldType_;
|
||||
}
|
||||
|
||||
const word& phiFieldName()const
|
||||
{
|
||||
return phiFieldName_;
|
||||
}
|
||||
|
||||
const dictionary& operationDict()const
|
||||
{
|
||||
return operationDict_;
|
||||
}
|
||||
const uint32 threshold()const
|
||||
{
|
||||
return threshold_;
|
||||
}
|
||||
|
||||
bool divideByVolume()const
|
||||
{
|
||||
return divideByVolume_();
|
||||
}
|
||||
|
||||
Mask getMask()
|
||||
{
|
||||
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,
|
||||
const regionPoints& regPoints,
|
||||
fieldsDataBase& fieldsDB);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__postprocessOperation_hpp__
|
Reference in New Issue
Block a user