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

@ -0,0 +1,152 @@
#include "PostprocessComponent.hpp"
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
template<typename RegionType, typename ProcessMethodType>
pFlow::PostprocessComponent<RegionType,ProcessMethodType>::PostprocessComponent
(
const dictionary& dict,
fieldsDataBase& fieldsDB,
const baseTimeControl& defaultTimeControl
)
:
postprocessComponent(dict, fieldsDB, defaultTimeControl),
regionPointsPtr_
(
makeUnique<RegionType>(dict, fieldsDB)
),
regionsProcessMethod_
(
regionPointsPtr_().size()
),
operationDicts_(readDictList("operations", dict))
{
for(auto& opDict:operationDicts_)
{
operatios_.push_back
(
postprocessOperation::create
(
opDict,
regionPointsPtr_(),
this->database()
)
);
}
}
template <typename RegionType, typename ProcessMethodType>
bool pFlow::PostprocessComponent<RegionType, ProcessMethodType>::execute
(
const timeInfo &ti,
bool forceUpdate
)
{
if( !forceUpdate && !timeControl().eventTime(ti))
{
executed_ = false;
return true;
}
// update processing methods
auto& regPoints = this->regPoints();
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 = regPoints.indices(i);
regionsProcessMethod_[i].updateWeights(
centers[i],
indices,
points);
}
std::vector<span<real>> weights(n);
for(uint32 i=0; i<n; i++)
{
// get the span of weight of each region
weights[i] = regionsProcessMethod_[i].getWeights();
}
for(auto& op:operatios_)
{
if( !op->execute(weights) )
{
fatalErrorInFunction
<<"error occured in executing operatoin defined in dict "
<< op->operationDict()
<<endl;
return false;
}
}
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

@ -0,0 +1,119 @@
/*------------------------------- 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 __PostProcessComponent_hpp__
#define __PostProcessComponent_hpp__
#include <vector>
#include "ListPtr.hpp"
#include "List.hpp"
#include "postprocessComponent.hpp"
#include "postprocessOperation.hpp"
#include "dictionaryList.hpp"
#include "fieldsDataBase.hpp"
#include "regionPoints.hpp"
#include "regionField.hpp"
namespace pFlow
{
template<typename RegionType, typename ProcessMethodType>
class PostprocessComponent
:
public postprocessComponent
{
private:
ListPtr<postprocessOperation> operatios_;
/// Region type for selecting a subset of particles for processing
uniquePtr<RegionType> regionPointsPtr_;
/// Method for processing the selected particles data
std::vector<ProcessMethodType> regionsProcessMethod_;
bool executed_{false};
dictionaryList operationDicts_;
protected:
std::vector<ProcessMethodType>& regionProecessMethod()
{
return regionsProcessMethod_;
}
public:
// type info
TypeInfoTemplate12(
"PostprocessComponent",
RegionType,
ProcessMethodType);
PostprocessComponent(
const dictionary& dict,
fieldsDataBase& fieldsDB,
const baseTimeControl& defaultTimeControl);
~PostprocessComponent() override = default;
// add the virtual constructor
add_vCtor(
postprocessComponent,
PostprocessComponent,
dictionary
);
word name()const override
{
return operationDicts_.parrent().name();
}
regionPoints& regPoints() override
{
return static_cast<regionPoints&>(regionPointsPtr_());
}
const regionPoints& regPoints()const override
{
return static_cast<const regionPoints&>(regionPointsPtr_());
}
bool execute(const timeInfo& ti, bool forceUpdate = false) override;
bool executed()const override
{
return executed_;
}
bool write(const fileSystem& parDir)const override;
};
}
#include "PostprocessComponent.cpp"
#endif

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 __PostprocessComponentGaussian_hpp__
#define __PostprocessComponentGaussian_hpp__
#include "PostprocessComponent.hpp"
#include "GaussianDistribution.hpp"
namespace pFlow
{
template<typename RegionType>
class PostprocessComponentGaussian
:
public PostprocessComponent<RegionType, GaussianDistribution>
{
public:
/// type info
TypeInfoTemplate12("PostprocessComponent", RegionType, GaussianDistribution);
PostprocessComponentGaussian
(
const dictionary& dict,
fieldsDataBase& fieldsDB,
const baseTimeControl& defaultTimeControl
)
:
PostprocessComponent<RegionType,GaussianDistribution>(dict, fieldsDB, defaultTimeControl)
{
/// initializes the Gaussian 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] = GaussianDistribution(c[i], pow(d[i],2));
}
}
// add the virtual constructor
add_vCtor(
postprocessComponent,
PostprocessComponentGaussian,
dictionary
);
};
}
#endif //__PostprocessComponentGaussian_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

@ -0,0 +1,33 @@
/*------------------------------- 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 "PostprocessComponentGaussian.hpp"
#include "PostprocessComponentUniform.hpp"
#include "PostprocessComponentArithmetic.hpp"
// region types
#include "sphereRegionPoints.hpp"
template class pFlow::PostprocessComponentGaussian<pFlow::sphereRegionPoints>;
template class pFlow::PostprocessComponentUniform<pFlow::sphereRegionPoints>;
template class pFlow::PostprocessComponentArithmetic<pFlow::sphereRegionPoints>;