mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-08-07 03:37:02 +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__
|
Reference in New Issue
Block a user