This commit is contained in:
omid.khs 2023-02-20 00:44:41 +03:30
parent 4a591edb87
commit 73bfd41546
13 changed files with 1202 additions and 1077 deletions

View File

@ -19,116 +19,229 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __contactSearch_hpp__
#define __contactSearch_hpp__
#ifndef __ContactSearch_hpp__
#define __ContactSearch_hpp__
#include "interactionBase.hpp"
#include "unsortedPairs.hpp"
#include "contactSearch.hpp"
#include "box.hpp"
#include "dictionary.hpp"
namespace pFlow
{
class contactSearch
template<
template<class> class BaseMethod,
template<class> class WallMapping
>
class ContactSearch
:
public interactionBase
public contactSearch
{
public:
using IdType = typename interactionBase::IdType;
using IdType = typename contactSearch::IdType;
using IndexType = typename interactionBase::IndexType;
using IndexType = typename contactSearch::IndexType;
using ExecutionSpace = typename interactionBase::ExecutionSpace;
using ExecutionSpace = typename contactSearch::ExecutionSpace;
using PairContainerType = unsortedPairs<ExecutionSpace, IdType>;
using PairContainerType = typename contactSearch::PairContainerType;
using ParticleContactSearchType =
BaseMethod<
ExecutionSpace>;
using WallMappingType =
WallMapping<
ExecutionSpace>;
protected:
const box& domain_;
dictionary dict_;
Timer sphereSphereTimer_;
Timer sphereWallTimer_;
auto& dict()
{
return dict_;
}
uniquePtr<ParticleContactSearchType> particleContactSearch_ = nullptr;
uniquePtr<WallMappingType> wallMapping_ = nullptr;
public:
TypeInfo("contactSearch");
TypeInfoTemplate2("ContactSearch", ParticleContactSearchType, WallMappingType);
contactSearch(
const dictionary& dict,
ContactSearch(
const dictionary& csDict,
const box& domain,
const particles& prtcl,
const geometry& geom,
Timers& timers);
Timers& timers)
:
contactSearch(csDict, domain, prtcl, geom, timers)
{
virtual ~contactSearch()=default;
auto method = dict().getVal<word>("method");
auto wmMethod = dict().getVal<word>("wallMapping");
auto nbDict = dict().subDict(method+"Info");
real minD, maxD;
this->Particles().boundingSphereMinMax(minD, maxD);
const auto& position = this->Particles().pointPosition().deviceVectorAll();
const auto& diam = this->Particles().boundingSphere().deviceVectorAll();
particleContactSearch_ =
makeUnique<ParticleContactSearchType>
(
nbDict,
this->domain(),
minD,
maxD,
position,
diam
);
REPORT(2)<<"Contact search algorithm for particle-particle is "<<
greenText(particleContactSearch_().typeName())<<endREPORT;
create_vCtor
(
auto wmDict = dict().subDict(wmMethod+"Info");
int32 wnPoints = this->Geometry().numPoints();
int32 wnTri = this->Geometry().size();
const auto& wPoints = this->Geometry().points().deviceVectorAll();
const auto& wVertices = this->Geometry().vertices().deviceVectorAll();
wallMapping_ =
makeUnique<WallMappingType>(
wmDict,
particleContactSearch_().numLevels(),
particleContactSearch_().getCellsLevels(),
wnPoints,
wnTri,
wPoints,
wVertices
);
REPORT(2)<<"Wall mapping algorithm for particle-wall is "<<
greenText(wallMapping_().typeName())<< endREPORT;
}
add_vCtor(
contactSearch,
dictionary,
(
const dictionary& dict,
const box& domain,
const particles& prtcl,
const geometry& geom,
Timers& timers
),
(dict, domain, prtcl, geom, timers)
);
const auto& domain()const
{
return domain_;
}
const auto& dict()const
{
return dict_;
}
virtual
ContactSearch,
dictionary);
bool broadSearch(
PairContainerType& ppPairs,
PairContainerType& pwPairs,
bool force = false) = 0;
bool force = false) override
{
virtual
bool ppEnterBroadSearch()const = 0;
if(particleContactSearch_)
{
auto activeRange = this->Particles().activeRange();
virtual
bool pwEnterBroadSearch()const = 0;
sphereSphereTimer_.start();
virtual
bool ppPerformedBroadSearch()const = 0;
if(this->Particles().allActive())
{
particleContactSearch_().broadSearch(ppPairs, activeRange, force);
}
else
{
particleContactSearch_().broadSearch(ppPairs, activeRange, this->Particles().activePointsMaskD(), force);
}
virtual
bool pwPerformedBroadSearch()const = 0;
sphereSphereTimer_.end();
}
else
return false;
if(wallMapping_)
{
sphereWallTimer_.start();
wallMapping_().broadSearch(pwPairs, particleContactSearch_(), force);
sphereWallTimer_.end();
}
else
return false;
return true;
}
bool ppEnterBroadSearch()const override
{
if(particleContactSearch_)
{
return particleContactSearch_().enterBoadSearch();
}
return false;
}
bool pwEnterBroadSearch()const override
{
if(wallMapping_)
{
return wallMapping_().enterBoadSearch();
}
return false;
}
static
uniquePtr<contactSearch> create(
const dictionary& dict,
const box& domain,
const particles& prtcl,
const geometry& geom,
Timers& timers);
bool ppPerformedBroadSearch()const override
{
if(particleContactSearch_)
{
return particleContactSearch_().performedSearch();
}
return false;
}
bool pwPerformedBroadSearch()const override
{
if(wallMapping_)
{
return wallMapping_().performedSearch();
}
return false;
}
/*bool update(const eventMessage& msg)
{
if(msg.isSizeChanged() )
{
auto newSize = this->prtcl().size();
if(!particleContactSearch_().objectSizeChanged(newSize))
{
fatalErrorInFunction<<
"erro in changing the size for particleContactSearch_ \n";
return false;
}
}
if(msg.isCapacityChanged() )
{
auto newSize = this->prtcl().capacity();
if(!particleContactSearch_().objectSizeChanged(newSize))
{
fatalErrorInFunction<<
"erro in changing the capacity for particleContactSearch_ \n";
return false;
}
}
return true;
}*/
};
}

View File

@ -18,57 +18,187 @@ Licence:
-----------------------------------------------------------------------------*/
#include "particles.hpp"
#include "dictionary.hpp"
#include "insertion.hpp"
#include "streams.hpp"
bool pFlow::insertion::readInsertionDict
template<typename ShapeType>
bool pFlow::Insertion<ShapeType>::readInsertionDict
(
const dictionary& dict
)
{
active_ = dict.getVal<Logical>("active");
if(active_)
REPORT(1)<< "Particle insertion mechanism is "<<
yellowText("active")<<" in the simulation."<<endREPORT;
else
REPORT(1)<< "Particle insertion mechanism is "<<
yellowText("not active")<<" in the simulation."<<endREPORT;
if(!insertion::readInsertionDict(dict)) return false;
regions_.clear();
if( !this->isActive() )
{
return true;
}
wordList regionDicNames = dict.dictionaryKeywords();
for(auto& name:regionDicNames)
{
REPORT(2)<<"reading insertion region "<< greenText(name)<<endREPORT;
regions_.push_backSafe(dict.subDict(name), shapes_);
}
return true;
}
bool pFlow::insertion::writeInsertionDict
template<typename ShapeType>
bool pFlow::Insertion<ShapeType>::writeInsertionDict
(
dictionary& dict
)const
{
if(!dict.add("active", active_) )
{
fatalErrorInFunction<<
" error in writing active to dictionary "<<dict.globalName()<<endl;
return false;
}
if( !insertion::writeInsertionDict(dict) ) return false;
if(!dict.add("checkForCollision", checkForCollision_) )
if( !this->isActive() ) return true;
ForAll(i,regions_)
{
fatalErrorInFunction<<
" error in writing checkForCollision to dictionary "<<dict.globalName()<<endl;
return false;
auto& rgnDict = dict.subDictOrCreate(regions_[i].name());
if( !regions_[i].write(rgnDict) )
{
return false;
}
}
return true;
}
pFlow::insertion::insertion
template<typename ShapeType>
pFlow::Insertion<ShapeType>::Insertion
(
particles& prtcl
particles& prtcl,
const ShapeType& shapes
)
:
particles_(prtcl)
{}
insertion(prtcl),
shapes_(shapes)
{
}
template<typename ShapeType>
bool pFlow::Insertion<ShapeType>::insertParticles
(
real currentTime,
real dt
)
{
if(!isActive()) return true;
ForAll(i,regions_)
{
bool insertionOccured = false;
auto& rgn = regions_[i];
if( rgn.insertionTime(currentTime, dt) )
{
realx3Vector pos;
wordVector shapes;
if( rgn.insertParticles(currentTime, dt, shapes, pos, insertionOccured) )
{
if(insertionOccured)
{
REPORT(0)<<"\nParticle insertion from "<< greenText(rgn.name())<<endREPORT;
REPORT(1)<< cyanText(pos.size()) << " new particles is being inserted at Time: "<<
cyanText(currentTime) <<" s."<<endREPORT;
if(!particles_.insertParticles(pos, shapes, rgn.setFields()))
{
fatalErrorInFunction<<
" Cannot add "<< pos.size() << " particles from region "<< rgn.name() <<
" to particles. \n";
return false;
}
REPORT(1)<<"Total number of particles inserted from this region is "<<
cyanText(rgn.totalInserted())<<'\n'<<endREPORT;
}
else
{
continue;
}
}
else
{
if(insertionOccured)
{
yWARNING<< "\n fewer number of particles are inserted from region "<< rgn.name() <<
" than expected. You may stop the simulation to change settings."<<endyWARNING;
continue;
}
else
{
fatalErrorInFunction<<
" error in inserting particles from region "<< rgn.name()<<endl;
return false;
}
}
}
}
return true;
}
template<typename ShapeType>
bool pFlow::Insertion<ShapeType>::read
(
iIstream& is
)
{
// create an empty dictionary
dictionary dict(is.name(), true);
if(!dict.read(is))
{
ioErrorInFile( is.name(), is.lineNumber() )<<
" error in reading "<< insertionFile__ << "dictionary from file."<<endl;
return false;
}
if(!readInsertionDict(dict))
{
fatalErrorInFunction<<
" error in reading from dictionary "<<dict.globalName()<<endl;
return false;
}
return true;
}
template<typename ShapeType>
bool pFlow::Insertion<ShapeType>::write
(
iOstream& os
)const
{
dictionary dict(insertionFile__,true);
if(! writeInsertionDict(dict) )
{
fatalErrorInFunction<<
" error in writing to " << dict.globalName()<<endl;
return false;
}
if( !dict.write(os) )
{
ioErrorInFile(os.name(), os.lineNumber())<<
" erro in writing to "<< os.name()<<endl;
return false;
}
return true;
}

View File

@ -18,55 +18,53 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __insertion_hpp__
#define __insertion_hpp__
#ifndef __Insertion_hpp__
#define __Insertion_hpp__
#include "streams.hpp"
#include "insertion.hpp"
#include "ListPtr.hpp"
#include "InsertionRegion.hpp"
#include "particles.hpp"
namespace pFlow
{
class particles;
class dictionary;
class insertion
template<typename ShapeType>
class Insertion
:
public insertion
{
protected:
// - insertion active
Logical active_ = "No";
// - check for collision / desabled for now
Logical checkForCollision_ = "No";
const ShapeType& shapes_;
// - insertion regions
ListPtr<InsertionRegion<ShapeType>> regions_;
// - particles
particles& particles_;
bool readInsertionDict(const dictionary& dict);
bool writeInsertionDict(dictionary& dict)const;
public:
// type info
TypeInfo("insertion");
TypeInfoTemplateNV("Insertion",ShapeType);
insertion(particles& prtcl);
virtual ~insertion() = default;
bool isActive()const {
return active_();
}
Insertion(particles& prtcl, const ShapeType& shapes);
virtual bool read(iIstream& is) = 0;
bool insertParticles(real currentTime, real dt);
virtual bool write(iOstream& os)const = 0;
virtual bool read(iIstream& is) override;
virtual bool write(iOstream& os)const override;
};
}
#include "Insertion.cpp"
#endif

View File

@ -18,122 +18,98 @@ Licence:
-----------------------------------------------------------------------------*/
#include "insertionRegion.hpp"
#include "dictionary.hpp"
bool pFlow::insertionRegion::readInsertionRegion
template<typename ShapeType>
bool pFlow::InsertionRegion<ShapeType>::checkForContact
(
const dictionary& dict
const realx3Vector& pos,
const realVector& diams,
const realx3& p,
const real& d
)
{
name_ = dict.name();
type_ = dict.getVal<word>("type");
pRegion_ = peakableRegion::create(type_, dict.subDict(type_+"Info"));
mixture_ = makeUnique<shapeMixture>(dict.subDict("mixture"));
addToNumInserted(mixture_().totalInserted());
if( !dict.containsDictionay("setFields"))
ForAll(i, pos)
{
output<<"\n insertion region "<< name_ << " does not contain setFields dictionary."
" An empty dictoiinary is created for it. \n";
setFields_ = makeUnique<setFieldList>( dictionary("setFields") );
}
else
{
setFields_ = makeUnique<setFieldList>( dict.subDict("setFields") );
if( length(pos[i]-p) < 0.5*(diams[i]+d) ) return true;
}
for(auto& sfEntry:setFields_())
return false;
}
template<typename ShapeType>
pFlow::InsertionRegion<ShapeType>::InsertionRegion
(
const dictionary& dict,
const ShapeType& shapes
)
:
insertionRegion(dict),
shapes_(shapes)
{
}
template<typename ShapeType>
bool pFlow::InsertionRegion<ShapeType>::insertParticles
(
real currentTime,
real dt,
wordVector& names,
realx3Vector& pos,
bool& insertionOccured
)
{
insertionOccured = false;
if(!insertionTime( currentTime, dt)) return true;
size_t newNum = numberToBeInserted(currentTime);
if(newNum == 0) return true;
names.reserve(max(newNum,names.capacity()));
pos.reserve(max(newNum,pos.capacity()));
names.clear();
pos.clear();
realVector diams(newNum, RESERVE());
mixture_->getNextShapeNameN(newNum, names);
if(!shapes_.shapeToDiameter(names,diams))
{
if(!sfEntry.checkForTypeAndValueAll())
fatalErrorInFunction<<
" error occured in insertion region "<< name() <<
" while converting shapes to diameter. \n";
return false;
}
size_t n = 0;
for(label iter=0; iter< 10*newNum ; ++iter)
{
if( !(n < newNum) )
{
fatalErrorInFunction<<
" error in setFields dictionary "<< dict.globalName()<<endl;
return false;
addToNumInserted(newNum);
insertionOccured = true;
return true;
}
realx3 p = pRegion_().peek();
real d = diams[pos.size()];
if( !checkForContact(pos, diams, p, d) )
{
pos.push_back(p);
n++;
}
}
return true;
}
bool pFlow::insertionRegion::writeInsertionRegion
(
dictionary& dict
) const
{
if(!dict.add("type", type_)) return false;
if(pRegion_)
{
auto& prDict = dict.subDictOrCreate(type_+"Info");
if(!pRegion_().write(prDict)) return false;
}
if(mixture_)
{
auto& mixDict = dict.subDictOrCreate("mixture");
if(!mixture_().write(mixDict)) return false;
}
if(setFields_)
{
auto& sfDict = dict.subDictOrCreate("setFields");
setFields_().write(sfDict);
}
return true;
}
pFlow::insertionRegion::insertionRegion
(
const dictionary& dict
)
:
timeFlowControl(dict)
{
if(!readInsertionRegion(dict))
{
fatalExit;
}
}
pFlow::insertionRegion::insertionRegion
(
const insertionRegion& src
)
:
timeFlowControl(src),
name_(src.name_),
type_(src.type_),
pRegion_( src.pRegion_? src.pRegion_->clone(): nullptr),
mixture_( src.mixture_? src.mixture_->clone(): nullptr),
setFields_( src.setFields_? src.setFields_->clone(): nullptr)
{}
pFlow::insertionRegion& pFlow::insertionRegion::operator=
(
const insertionRegion& src
)
{
if(&src == this)return *this;
timeFlowControl::operator=(src);
name_ = src.name_;
type_ = src.type_;
pRegion_ = (src.pRegion_? src.pRegion_->clone(): nullptr);
mixture_ = (src.mixture_? src.mixture_->clone(): nullptr);
setFields_ = (src.setFields_? src.setFields_->clone(): nullptr);
return *this;
}
fatalErrorInFunction<<
" Cannot insert "<< newNum << " new particles from region "<< name()<<". \n"
" pFlow could position only "<< n<< " particles in this region. \n";
addToNumInserted(n);
insertionOccured = false;
return false;
}

View File

@ -18,97 +18,78 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __insertionRegion_hpp__
#define __insertionRegion_hpp__
#ifndef __InsertionRegion_hpp__
#define __InsertionRegion_hpp__
#include "timeFlowControl.hpp"
#include "shapeMixture.hpp"
#include "peakableRegions.hpp"
#include "setFieldList.hpp"
#include "insertionRegion.hpp"
#include "dictionary.hpp"
namespace pFlow
{
class dictionary;
class insertionRegion
template<typename ShapeType>
class InsertionRegion
:
public timeFlowControl
public insertionRegion
{
protected:
// - type of particle shapes
const ShapeType& shapes_;
// - name of the region
word name_;
// - type of insertion region
word type_;
// peakable region of points
uniquePtr<peakableRegion> pRegion_ = nullptr;
// mixture of shapes
uniquePtr<shapeMixture> mixture_ = nullptr;
// setFields for insertion region
uniquePtr<setFieldList> setFields_ = nullptr;
bool readInsertionRegion(const dictionary& dict);
bool writeInsertionRegion(dictionary& dict) const;
static bool checkForContact(
const realx3Vector& pos,
const realVector& diams,
const realx3& p,
const real& d);
public:
TypeInfoNV("insertionRegion");
// - type info
TypeInfoTemplateNV("insertionRegion", ShapeType);
//// - Constructors
InsertionRegion(const dictionary& dict, const ShapeType& shapes);
insertionRegion(const dictionary& dict);
InsertionRegion(const InsertionRegion<ShapeType>& ) = default;
insertionRegion(const insertionRegion& src);
InsertionRegion(InsertionRegion<ShapeType>&&) = default;
insertionRegion(insertionRegion&&) = default;
InsertionRegion<ShapeType>& operator=(const InsertionRegion<ShapeType>& ) = default;
insertionRegion& operator=(const insertionRegion&);
insertionRegion& operator=(insertionRegion&&) = default;
InsertionRegion<ShapeType>& operator=(InsertionRegion<ShapeType>&&) = default;
~insertionRegion() = default;
auto clone()const
{
return makeUnique<InsertionRegion<ShapeType>>(*this);
}
auto clonePtr()const
{
return new InsertionRegion<ShapeType>(*this);
}
//// - Methods
const auto& setFields()const
{
return setFields_();
}
bool insertParticles
(
real currentTime,
real dt,
wordVector& names,
realx3Vector& pos,
bool& insertionOccured
);
const auto& name()const
{
return name_;
}
//// - IO operation
bool read(const dictionary& dict)
{
if(!timeFlowControl::read(dict))return false;
return readInsertionRegion(dict);
}
bool write(dictionary& dict)const
{
if(!timeFlowControl::write(dict)) return false;
return writeInsertionRegion(dict);
}
//bool read(const dictionary& dict);
//bool write(dictionary& dict)const;
};
} //pFlow
#endif //__insertionRegion_hpp__
} // pFlow
#include "InsertionRegion.cpp"
#endif

View File

@ -18,34 +18,36 @@ Licence:
-----------------------------------------------------------------------------*/
#include "randomReal.hpp"
#include "RandomReal.hpp"
pFlow::uniquePtr<pFlow::randomReal> pFlow::randomReal::create
template<typename DistributionType>
pFlow::RandomReal<DistributionType>::RandomReal
(
word distribution
)
:
randomReal(distribution),
distribution_()
{
word dist = angleBracketsNames("randomReal", distribution);
if( wordvCtorSelector_.search(dist) )
{
return wordvCtorSelector_[dist] (distribution);
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< dist << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
wordvCtorSelector_
);
fatalExit();
}
return nullptr;
}
template<typename DistributionType>
pFlow::real pFlow::RandomReal<DistributionType>::randomNumber
(
real a, real b
)
{
return distribution_.randomNumber(a,b);
}
template<typename DistributionType>
pFlow::realx3 pFlow::RandomReal<DistributionType>::randomNumber
(
realx3 a,
realx3 b
)
{
return distribution_.randomNumber(a,b);
}

View File

@ -18,50 +18,56 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __randomReal_hpp__
#define __randomReal_hpp__
#ifndef __RandomReal_hpp__
#define __RandomReal_hpp__
//#include <random>
#include "randomReal.hpp"
#include "uniformRandomReal.hpp"
#include "types.hpp"
#include "virtualConstructor.hpp"
namespace pFlow
{
class randomReal
template<typename DistributionType>
class RandomReal
:
public randomReal
{
protected:
DistributionType distribution_;
public:
TypeInfo("randomReal");
// type info
TypeInfoTemplate("randomReal", DistributionType);
randomReal(word UNUSED(distribution)){}
create_vCtor
RandomReal(word distribution);
add_vCtor
(
randomReal,
word,
(word distribution),
(distribution)
RandomReal,
word
);
virtual ~randomReal()= default;
virtual ~RandomReal()= default;
virtual real randomNumber(real a, real b) = 0;
virtual real randomNumber(real a, real b)override;
virtual realx3 randomNumber(realx3 a, realx3 b) = 0;
virtual realx3 randomNumber(realx3 a, realx3 b)override;
static
uniquePtr<randomReal> create(word distribution);
};
}
#include "RandomReal.cpp"
#endif

View File

@ -18,163 +18,43 @@ Licence:
-----------------------------------------------------------------------------*/
#include "IOstream.hpp"
#include "iOstream.hpp"
#include "token.hpp"
#include "error.hpp"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void pFlow::iOstream::decrIndent()
unsigned int pFlow::IOstream::precision_ = 6;
pFlow::word pFlow::IOstream::staticName_("IOstream");
const pFlow::word& pFlow::IOstream::name() const
{
if (!indentLevel_)
{
std::cerr
<< "iOstream::decrIndent() : attempt to decrement 0 indent level\n";
}
else
{
--indentLevel_;
}
return staticName_;
}
pFlow::iOstream& pFlow::iOstream::writeWordKeyword(const word& kw)
pFlow::word& pFlow::IOstream::name()
{
indent();
writeQuoted(kw, false);
if (indentSize_ <= 1)
return staticName_;
}
bool pFlow::IOstream::check(const char* operation) const
{
return fatalCheck(operation);
}
bool pFlow::IOstream::fatalCheck(const char* operation) const
{
const bool ok = !bad();
if (!ok)
{
write(char(token::SPACE));
return *this;
fatalErrorInFunction
<< "error in IOstream " << name() << " for operation " << operation;
fatalExit;
}
int32 nSpaces = entryIndentation_ - int32(kw.size());
// Could also increment by indentSize_ ...
if (nSpaces < 1)
{
nSpaces = 1;
}
while (nSpaces--)
{
write(char(token::SPACE));
}
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginBlock(const word& kw)
{
indent(); write(kw); newLine();
beginBlock();
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginBlock()
{
indent(); write(char(token::BEGIN_BLOCK)); newLine();
incrIndent();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endBlock()
{
decrIndent();
indent(); write(char(token::END_BLOCK)); newLine();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endEntry()
{
write(char(token::END_STATEMENT)); newLine();
return *this;
}
//- Write a newLine to stream
pFlow::iOstream& pFlow::iOstream::newLine()
{
write(char(token::NL));
return *this;
}
pFlow::iOstream& pFlow::iOstream::space
(
int32 n
)
{
for(int32 i=0; i<n; i++)
{
write(char(token::SPACE));
}
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginList
(
)
{
write(char(token::BEGIN_LIST));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginList
(
const word& kw
)
{
writeWordKeyword(kw); beginList();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endList
(
)
{
write(char(token::END_LIST));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginSquare
(
)
{
write(char(token::BEGIN_SQR));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginSquare
(
const word& kw
)
{
writeWordKeyword(kw); beginSquare();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endSquare
(
)
{
write(char(token::END_SQR));
return *this;
}
// ************************************************************************* //
return ok;
}

View File

@ -19,401 +19,291 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __iOstream_hpp__
#define __iOstream_hpp__
#ifndef __IOstream_hpp__
#define __IOstream_hpp__
// based on OpenFOAM stream, with some modifications/simplifications
// to be tailored to our needs
#include <iostream>
#include "IOstream.hpp"
#include "bTypesFunctions.hpp"
const inline char* defaultColor = "\033[0m";
const inline char* blackColor = "\033[30m";
const inline char* redColor = "\033[31m";
const inline char* greenColor = "\033[32m";
const inline char* yellowColor = "\033[33m";
const inline char* blueColor = "\033[34m";
const inline char* magentaColor = "\033[35m";
const inline char* cyanColor = "\033[36m";
const inline char* whiteColor = "\033[37m";
using std::ios_base;
using std::istream;
using std::ostream;
const inline char* boldChar = "\033[1m";
using std::cin;
using std::cout;
using std::cerr;
namespace pFlow
{
// Forward Declarations
class token;
class iOstream
:
public IOstream
class IOstream
{
public:
enum streamAccess : char
{
CLOSED = 0, //!< stream is not open
OPENED //!< stream is open
};
//- Default precision
static unsigned int precision_;
protected:
// Protected Data
//- Name for any generic stream - normally treat as readonly
static word staticName_;
//- Indentation of the entry from the start of the keyword
static constexpr const unsigned short entryIndentation_ = 16;
streamAccess openClosed_;
//- Number of spaces per indent level
unsigned short indentSize_ = 4;
ios_base::iostate ioState_;
//- Current indent level
unsigned short indentLevel_ = 0;
//- The file line
int32 lineNumber_;
// Protected Member Functions
//- Set stream opened
void setOpened()
{
openClosed_ = OPENED;
}
//- Set stream closed
void setClosed()
{
openClosed_ = CLOSED;
}
//- Set stream state
void setState(ios_base::iostate state)
{
ioState_ = state;
}
//- Set stream to be good
void setGood()
{
ioState_ = ios_base::iostate(0);
}
public:
// Constructor
explicit iOstream()
{}
// Constructors
explicit IOstream():
openClosed_(CLOSED),
ioState_(ios_base::iostate(0)),
lineNumber_(0)
{
setBad();
}
//- Copy construct
iOstream(const iOstream&) = default;
IOstream(const IOstream&) = default;
//- Destructor
virtual ~iOstream() = default;
virtual ~IOstream() = default;
//// Member Functions
//- Return the name of the stream
virtual const word& name() const;
// Write Functions
//- Return non-const access to the name of the stream
virtual word& name();
//- Write token to stream or otherwise handle it.
// \return false if the token type was not handled by this method
virtual bool write(const token& tok) = 0;
//- Check IOstream status for given operation.
// Print IOstream state or generate a FatalIOError
// when an error has occurred.
// The base implementation is a fatalCheck
virtual bool check(const char* operation) const;
//- Write character
virtual iOstream& write(const char c) = 0;
//- Check IOstream status for given operation.
// Generate a FatalIOError when an error has occurred.
bool fatalCheck(const char* operation) const;
//- Write character string
virtual iOstream& write(const char* str) = 0;
//- Return true if stream has been opened
bool opened() const
{
return openClosed_ == OPENED;
}
//- Write word
virtual iOstream& write(const word& str) = 0;
//- Return true if stream is closed
bool closed() const
{
return openClosed_ == CLOSED;
}
//- Return true if next operation might succeed
bool good() const
{
return ioState_ == 0;
}
//- Write std::string surrounded by quotes.
// Optional write without quotes.
virtual iOstream& writeQuoted
//- Return true if end of input seen
bool eof() const
{
return ioState_ & ios_base::eofbit;
}
//- Return true if next operation will fail
bool fail() const
{
return ioState_ & (ios_base::badbit | ios_base::failbit);
}
//- Return true if stream is corrupted
bool bad() const
{
return ioState_ & ios_base::badbit;
}
//- Return true if the stream has not failed
explicit operator bool() const
{
return !fail();
}
//- Return true if the stream has failed
bool operator!() const
{
return fail();
}
//- Const access to the current stream line number
int32 lineNumber() const
{
return lineNumber_;
}
//- Non-const access to the current stream line number
int32& lineNumber()
{
return lineNumber_;
}
//- Set the stream line number
// \return the previous value
int32 lineNumber(const int32 num)
{
const int32 old(lineNumber_);
lineNumber_ = num;
return old;
}
//- Return flags of stream
virtual ios_base::fmtflags flags() const = 0;
//- Return the default precision
static unsigned int defaultPrecision()
{
return precision_;
}
//- Reset the default precision
// \return the previous value
static unsigned int defaultPrecision(unsigned int prec)
{
unsigned int old(precision_);
precision_ = prec;
return old;
}
//- Set stream to have reached eof
void setEof()
{
ioState_ |= ios_base::eofbit;
}
//- Set stream to have failed
void setFail()
{
ioState_ |= ios_base::failbit;
}
//- Set stream to be bad
void setBad()
{
ioState_ |= ios_base::badbit;
}
//- Set flags of stream
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0;
//- Set flags of stream
ios_base::fmtflags setf(const ios_base::fmtflags f)
{
return flags(flags() | f);
}
//- Set flags of given field of stream
ios_base::fmtflags setf
(
const word& str,
const bool quoted=true
) = 0;
//- Write int64
virtual iOstream& write(const int64 val) = 0;
//- Write int32
virtual iOstream& write(const int32 val) = 0;
//- Write label
virtual iOstream& write(const label val) = 0;
//- Write uint32
virtual iOstream& write(const uint32 val) = 0;
//- Write uint16
virtual iOstream& write(const uint16 val) = 0;
//- Write float
virtual iOstream& write(const float val) = 0;
//- Write double
virtual iOstream& write(const double val) = 0;
//- Add indentation characters
virtual void indent() = 0;
//- Return indent level
unsigned short indentSize() const
const ios_base::fmtflags f,
const ios_base::fmtflags mask
)
{
return indentSize_;
return flags((flags() & ~mask) | (f & mask));
}
//- Access to indent size
unsigned short& indentSize()
//- Unset flags of stream
void unsetf(const ios_base::fmtflags f)
{
return indentSize_;
flags(flags() & ~f);
}
//- Return indent level
unsigned short indentLevel() const
{
return indentLevel_;
}
//- Access to indent level
unsigned short& indentLevel()
{
return indentLevel_;
}
//- Increment the indent level
void incrIndent()
{
++indentLevel_;
}
//- Decrement the indent level
void decrIndent();
//- Write begin block group with a name
// Increments indentation, adds newline.
virtual iOstream& beginBlock(const word& kw);
//- Write begin block group without a name
// Increments indentation, adds newline.
virtual iOstream& beginBlock();
//- Write end block group
// Decrements indentation, adds newline.
virtual iOstream& endBlock();
//- Write begin list "("
virtual iOstream& beginList();
//- Write begin list with keyword "kw ("
virtual iOstream& beginList(const word& kw);
//- Write end list ")"
virtual iOstream& endList();
//- Write begin list "["
virtual iOstream& beginSquare();
//- Write begin list with keyword "kw ["
virtual iOstream& beginSquare(const word& kw);
//- Write end list "]"
virtual iOstream& endSquare();
//- Write end entry (';') followed by newline.
virtual iOstream& endEntry();
//- Write a newLine to stream
virtual iOstream& newLine();
//- Write space to stream
virtual iOstream& space(int32 n=1);
//- Write the keyword followed by an appropriate indentation
virtual iOstream& writeWordKeyword(const word& kw);
//- Write a keyword/value entry.
template<class T>
iOstream& writeWordEntry(const word& key, const T& value)
{
writeWordKeyword(key) << value;
return endEntry();
}
//// Stream state functions
//- Flush stream
virtual void flush() = 0;
//- Add newline and flush stream
virtual void endl() = 0;
//- Get padding character
virtual char fill() const = 0;
//- Set padding character for formatted field up to field width
virtual char fill(const char fillch) = 0;
//- Get width of output field
virtual int width() const = 0;
//- Set width of output field (and return old width)
virtual int width(const int w) = 0;
//- Get precision of output field
virtual int precision() const = 0;
//- Set precision of output field (and return old precision)
virtual int precision(const int p) = 0;
}; // end of IOstream
// Member Operators
//- An IOstream manipulator
typedef IOstream& (*IOstreamManip)(IOstream&);
//- Return a non-const reference to const iOstream
// Needed for write functions where the stream argument is temporary:
// e.g. thing thisThing(OFstream("thingFileName")());
iOstream& operator()() const
{
return const_cast<iOstream&>(*this);
}
};
//- An iOstream manipulator
typedef iOstream& (*iOstreamManip)(iOstream&);
//- operator<< handling for manipulators without arguments
inline iOstream& operator<<(iOstream& os, iOstreamManip f)
inline IOstream& dec(IOstream& io)
{
return f(os);
io.setf(ios_base::dec, ios_base::dec|ios_base::hex|ios_base::oct);
return io;
}
//- operator<< handling for manipulators without arguments
inline iOstream& operator<<(iOstream& os, IOstreamManip f)
inline IOstream& hex(IOstream& io)
{
f(os);
return os;
io.setf(ios_base::hex, ios_base::dec|ios_base::hex|ios_base::oct);
return io;
}
inline IOstream& oct(IOstream& io)
{
io.setf(ios_base::oct, ios_base::dec|ios_base::hex|ios_base::oct);
return io;
}
inline IOstream& fixed(IOstream& io)
{
io.setf(ios_base::fixed, ios_base::floatfield);
return io;
}
inline IOstream& scientific(IOstream& io)
{
io.setf(ios_base::scientific, ios_base::floatfield);
return io;
}
//- Indent stream
inline iOstream& indent(iOstream& os)
{
os.indent();
return os;
}
//- Increment the indent level
inline iOstream& incrIndent(iOstream& os)
{
os.incrIndent();
return os;
}
} // pFlow
//- Decrement the indent level
inline iOstream& decrIndent(iOstream& os)
{
os.decrIndent();
return os;
}
//- Flush stream
inline iOstream& flush(iOstream& os)
{
os.flush();
return os;
}
//- Add newline and flush stream
inline iOstream& endl(iOstream& os)
{
os.endl();
return os;
}
//- Write begin block group without a name
// Increments indentation, adds newline.
inline iOstream& beginBlock(iOstream& os)
{
os.beginBlock();
return os;
}
//- Write end block group
// Decrements indentation, adds newline.
inline iOstream& endBlock(iOstream& os)
{
os.endBlock();
return os;
}
//- Write end entry (';') followed by newline.
inline iOstream& endEntry(iOstream& os)
{
os.endEntry();
return os;
}
// overloading for basic types
inline iOstream& operator<<( iOstream& os, const char c)
{
return os.write(c);
}
inline iOstream& operator<<( iOstream& os, const char * buf)
{
return os.write(buf);
}
inline iOstream& operator<<( iOstream& os, const word& w)
{
return os.write(w);
}
inline iOstream& operator<<( iOstream& os, const int64& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const int32& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const int16& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const int8& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const label& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const uint32& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const uint16& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const float& val)
{
return os.write(val);
}
inline iOstream& operator<<( iOstream& os, const double& val)
{
return os.write(val);
}
// Useful aliases for tab and newline characters
constexpr char tab = '\t';
constexpr char nl = '\n';
} // pFlow
#endif
// ************************************************************************* //
#endif // __IOstream__hpp__

View File

@ -19,42 +19,45 @@ Licence:
-----------------------------------------------------------------------------*/
#include "peakableRegion.hpp"
#include "dictionary.hpp"
pFlow::peakableRegion::peakableRegion
template<typename RegionType>
pFlow::PeakableRegion<RegionType>::PeakableRegion
(
const word& type, const dictionary& dict
const word& type,
const dictionary& dict
)
:
peakableRegion(type, dict),
region_(dict)
{
CONSUME_PARAM(type);
CONSUME_PARAM(dict);
}
template<typename RegionType>
bool pFlow::PeakableRegion<RegionType>::isInside
(
const realx3& point
)const
{
return region_.isInside(point);
}
pFlow::uniquePtr<pFlow::peakableRegion> pFlow::peakableRegion::create
(
const word& type,
const dictionary& dict
)
template<typename RegionType>
pFlow::realx3 pFlow::PeakableRegion<RegionType>::peek()const
{
word regionType = angleBracketsNames("peakableRegion", type);
return region_.peek();
}
template<typename RegionType>
bool pFlow::PeakableRegion<RegionType>::read(const dictionary& dict)
{
return region_.read(dict);
}
template<typename RegionType>
bool pFlow::PeakableRegion<RegionType>::write(dictionary& dict)const
{
return region_.write(dict);
}
if( wordvCtorSelector_.search(regionType) )
{
return wordvCtorSelector_[regionType] (type, dict);
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< regionType << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
wordvCtorSelector_
);
fatalExit;
}
return nullptr;
}

View File

@ -19,64 +19,72 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __peakableRegion_hpp__
#define __peakableRegion_hpp__
#ifndef __PeakableRegion_hpp__
#define __PeakableRegion_hpp__
#include "types.hpp"
#include "virtualConstructor.hpp"
#include "peakableRegion.hpp"
#include "dictionary.hpp"
namespace pFlow
{
class dictionary;
class peakableRegion
template<typename RegionType>
class PeakableRegion
:
public peakableRegion
{
protected:
RegionType region_;
public:
// type info
TypeInfo("peakableRegion");
TypeInfoTemplate("peakableRegion", RegionType);
peakableRegion(const word& type, const dictionary& dict);
//// - Constructors
PeakableRegion(const word& type, const dictionary& dict);
create_vCtor(
add_vCtor(
peakableRegion,
word,
(const word& type, const dictionary& dict),
(type, dict)
PeakableRegion,
word
);
virtual uniquePtr<peakableRegion> clone()const = 0;
virtual uniquePtr<peakableRegion> clone()const override
{
return makeUnique<PeakableRegion<RegionType>>(*this);
}
virtual peakableRegion* clonePtr()const = 0;
virtual peakableRegion* clonePtr()const override
{
return new PeakableRegion<RegionType>(*this);
}
virtual ~peakableRegion() = default;
virtual ~PeakableRegion() = default;
//// - Methods
virtual bool isInside(const realx3& point)const = 0;
virtual bool isInside(const realx3& point)const override;
virtual realx3 peek()const = 0;
virtual realx3 peek()const override;
//// - IO operatoins
virtual bool read(const dictionary& dict) = 0;
virtual bool read(const dictionary& dict) override;
virtual bool write(dictionary& dict)const = 0;
// - static create
static uniquePtr<peakableRegion>
create(const word& type, const dictionary& dict);
virtual bool write(dictionary& dict)const override;
};
} // pFlow
#include "PeakableRegion.cpp"
#endif

View File

@ -18,87 +18,230 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __includeMask_hpp__
#define __includeMask_hpp__
#ifndef __IncludeMask_hpp__
#define __IncludeMask_hpp__
#include "virtualConstructor.hpp"
#include "readFromTimeFolder.hpp"
#include "dictionary.hpp"
#include "includeMask.hpp"
namespace pFlow
{
class includeMask
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:
word fieldName_;
Operator operator_{};
public:
word fieldType_;
TypeInfoNV(Operator::TYPENAME());
compareZero(const dictionary& dict);
word operatorType_;
bool operator()(const T& value) const
{
return operator_();
}
};
readFromTimeFolder& timeFolder_;
static
bool getFieldType(const dictionary& dict, readFromTimeFolder& timeFolder, word& fName, word& fType);
template<typename T, typename Operator>
class IncludeMask
:
public includeMask
{
protected:
Operator operator_;
pointField_H<T> field_;
public:
TypeInfo("includeMask");
TypeInfoTemplate2("IncludeMask", T, Operator);
includeMask(const dictionary& dict, const word& opType, readFromTimeFolder& timeFolder);
virtual ~includeMask() = default;
create_vCtor(
includeMask,
dictionary,
(
const dictionary& dict,
const word& opType,
readFromTimeFolder& timeFolder
),
(dict, opType, timeFolder)
);
word fieldName()const
{
return fieldName_;
}
word fieldType()const
{
return fieldType_;
}
word operatorType()const
{
return operatorType_;
}
auto& timeFolder()
{
return timeFolder_;
}
virtual bool isIncluded(int32 n) const = 0;
bool operator()(int32 n) const
{
return isIncluded(n);
}
static
uniquePtr<includeMask> create(
IncludeMask(
const dictionary& dict,
const word& opType,
readFromTimeFolder& timeFolder);
const word& opType,
readFromTimeFolder& timeFolder)
:
includeMask(dict, opType, timeFolder),
operator_(dict),
field_(timeFolder.readPointField_H<T>(this->fieldName()))
{}
add_vCtor(
includeMask,
IncludeMask,
dictionary);
bool isIncluded(int32 n)const override
{
return operator_(field_[n]);
}
};
template<typename T>
class IncludeMask<T,allOp<T>>
:
public includeMask
{
public:
TypeInfoTemplate2("IncludeMask", T, allOp<int8>);
IncludeMask(
const dictionary& dict,
const word& opType,
readFromTimeFolder& timeFolder)
:
includeMask(dict, opType, timeFolder)
{}
add_vCtor(
includeMask,
IncludeMask,
dictionary);
bool isIncluded(int32 n)const override
{
return true;
}
};
} // pFlow

View File

@ -18,152 +18,147 @@ Licence:
-----------------------------------------------------------------------------*/
#ifndef __processField_hpp__
#define __processField_hpp__
#ifndef __ProcessField_hpp__
#define __ProcessField_hpp__
#include "virtualConstructor.hpp"
#include "dictionary.hpp"
#include "readFromTimeFolder.hpp"
#include "includeMask.hpp"
#include "pointRectCell.hpp"
#include "processField.hpp"
#include "rectMeshFields.hpp"
#include "twoPartEntry.hpp"
#include "fieldOperations.hpp"
#include "rectMeshFieldToVTK.hpp"
namespace pFlow
{
class repository;
class processField
template<typename T>
class ProcessField
:
public processField
{
protected:
dictionary dict_;
pointField_H<T>& field_;
pointRectCell& pointToCell_;
mutable readFromTimeFolder timeFolder_;
word processedFieldName_;
word fieldName_;
word fieldType_;
word operation_;
word includeMaskType_;
int32 threshold_ = 1;
uniquePtr<includeMask> includeMask_ = nullptr;
bool static getFieldType(
const dictionary& dict,
readFromTimeFolder& timeFolder,
word& fieldName,
word& fieldType);
rectMeshField_H<T>& processedField_;
public:
TypeInfo("processField");
processField(const dictionary& dict, pointRectCell& pToCell, repository& rep);
TypeInfoTemplate("ProcessField", T);
create_vCtor(
processField,
dictionary,
(const dictionary& dict,
pointRectCell& pToCell,
repository& rep),
(dict, pToCell, rep) );
const auto& mesh()const
{
return pointToCell_.mesh();
}
const auto& pointToCell()const
{
return pointToCell_;
}
auto& dict()
{
return dict_;
}
const auto& dict()const
{
return dict_;
}
auto& timeFolderRepository()
{
return timeFolder_.db();
}
auto& processedRepository()
{
return pointToCell_.processedRepository();
}
const word& fieldType()const
{
return fieldType_;
}
const word& fieldName()const
{
return fieldName_;
}
bool isUniform()const
{
return fieldName_ == "uniformField";
}
const word& operation()const
{
return operation_;
}
auto& timeFolder()
{
return timeFolder_;
}
const word& includeMaskType()const
{
return includeMaskType_;
}
auto threshold()const
{
return threshold_;
}
const word& processedFieldName()const
{
return processedFieldName_;
}
// requires a class to read pointField from timefolder
virtual bool process() = 0;
virtual bool writeToVTK(iOstream& is) const = 0;
static
uniquePtr<processField> create(
ProcessField(
const dictionary& dict,
pointRectCell& pToCell,
repository& rep);
repository& rep)
:
processField(dict, pToCell, rep),
field_(
this->isUniform()?
timeFolder().createUniformPointField_H(this->fieldName(), getUniformValue() ):
timeFolder().readPointField_H<T>(this->fieldName())
),
processedField_
(
processedRepository().emplaceObject<rectMeshField_H<T>>
(
objectFile
(
processedFieldName(),
"",
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
mesh(),
processedFieldName(),
T{}
)
)
{
}
add_vCtor(
processField,
ProcessField,
dictionary);
T getUniformValue()const
{
const dataEntry& entry = dict().dataEntryRef("field");
twoPartEntry tpEntry(entry);
return tpEntry.secondPartVal<T>();
}
virtual bool process() override
{
const includeMask& incMask = includeMask_();
auto numerator = sumMaksOp( field_ , this->pointToCell(), incMask);
rectMeshField_H<real> denomerator( this->mesh(), real{} );
if(operation() == "sum")
{
denomerator = rectMeshField_H<real>(this->mesh(), static_cast<real>(1.0));
}else if(operation() == "average")
{
pointField_H<real> oneFld(field_.pStruct(), static_cast<real>(1.0), static_cast<real>(1.0));
denomerator = sumOp(oneFld, this->pointToCell());
}else if(operation() == "averageMask")
{
pointField_H<real> oneFld(field_.pStruct(), static_cast<real>(1.0), static_cast<real>(1.0));
denomerator = sumMaksOp(oneFld, this->pointToCell(), incMask);
}else
{
fatalErrorInFunction<<"operation is not known: "<< operation()<<endl;
fatalExit;
}
for(int32 i=0; i<this->mesh().nx(); i++ )
{
for(int32 j=0; j<this->mesh().ny(); j++ )
{
for(int32 k=0; k<this->mesh().nz(); k++ )
{
if( pointToCell().nPointInCell(i,j,k)>= threshold() )
{
processedField_(i,j,k) = numerator(i,j,k)/denomerator(i,j,k);
}
else
{
processedField_(i,j,k) = T{};
}
}
}
}
return true;
}
bool writeToVTK(iOstream& os)const override
{
return convertRectMeshField(os, processedField_);
}
};
}
} // pFlow
#endif //__processField_hpp__
#endif //__ProcessField_hpp__