# PhasicFlow: utilities/postprocessPhasicFlow/processField.cpp Source File

processField.cpp
Go to the documentation of this file.
/*------------------------------- 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 "processField.hpp"
#include "pointRectCell.hpp"
#include "repository.hpp"
#include "twoPartEntry.hpp"
pFlow::processField::processField(
const dictionary& dict,
pointRectCell& pToCell,
repository& rep)
:
dict_(dict),
pointToCell_(pToCell),
timeFolder_(rep),
processedFieldName_(dict.name()),
operation_(dict.getVal<word>("operation")),
includeMaskType_(dict.getVal<word>("includeMask")),
threshold_(dict.getValOrSet<int32>("threshold", 1))
{
if(!processField::getFieldType(
dict_,
timeFolder_,
fieldName_,
fieldType_) )
{
fatalExit;
}
auto& incDict = dict_.subDictOrCreate(includeMaskType_+"Info");
includeMask_ = includeMask::create(incDict, includeMaskType_, timeFolder_);
}
bool pFlow::processField::getFieldType(
const dictionary& dict,
readFromTimeFolder& timeFolder,
word& fieldName,
word& fieldType)
{
if(dict.containsDataEntry("field"))
{
const dataEntry& entry = dict.dataEntryRef("field");
if( isTwoPartEntry(entry))
{
twoPartEntry tpEntry(entry);
fieldName = "uniformField";
fieldType = tpEntry.firstPart();
}
else
{
fieldName = dict.getVal<word>("field");
if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) )
{
fatalErrorInFunction<<"error in reading field type from file "<< fieldName<<
"in folder "<< timeFolder.path()<<endl;
return false;
}
}
}
else
{
fatalErrorInFunction<< "dictionary "<< dict.globalName()<<
"does not contain field keyword"<<endl;
return false;
}
return true;
}
pFlow::uniquePtr<pFlow::processField>
pFlow::processField::create(
const dictionary& dict,
pointRectCell& pToCell,
repository& rep)
{
word fName, fType;
readFromTimeFolder timeFolder(rep);
if(!getFieldType(dict, timeFolder, fName, fType))
{
fatalExit;
return nullptr;
}
auto method = angleBracketsNames("ProcessField", fType);
if( dictionaryvCtorSelector_.search(method) )
{
auto objPtr =
dictionaryvCtorSelector_[method]
(dict, pToCell, rep);
REPORT(2)<<"Processing/creating " << yellowText(dict.name())<< " with model "<<greenText(method)<<"."<<endREPORT;
return objPtr;
}
else
{
printKeys
(
fatalError << "Ctor Selector "<<
method << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
dictionaryvCtorSelector_
);
fatalExit;
return nullptr;
}
}
pFlow::processField::fieldType_
word fieldType_
Definition: processField.hpp:51
twoPartEntry.hpp
endREPORT
#define endREPORT
Definition: streams.hpp:41
pFlow::includeMask::create
static uniquePtr< includeMask > create(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: includeMask.cpp:68
fatalExit
#define fatalExit
Definition: error.hpp:57
REPORT
#define REPORT(n)
Definition: streams.hpp:40
pFlow::readFromTimeFolder
Definition: readFromTimeFolder.hpp:31
pFlow::processField::create
static uniquePtr< processField > create(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:96
pFlow::twoPartEntry
Definition: twoPartEntry.hpp:36
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::processField::getFieldType
static bool getFieldType(const dictionary &dict, readFromTimeFolder &timeFolder, word &fieldName, word &fieldType)
Definition: processField.cpp:57
pFlow::processField::dict_
dictionary dict_
Definition: processField.hpp:41
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::dictionary::subDictOrCreate
dictionary & subDictOrCreate(const word &keyword)
Definition: dictionary.cpp:634
pFlow::processField::fieldName_
word fieldName_
Definition: processField.hpp:49
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::processField::includeMask_
uniquePtr< includeMask > includeMask_
Definition: processField.hpp:59
pointRectCell.hpp
greenText
#define greenText(text)
Definition: streams.hpp:32
pFlow::dictionary::containsDataEntry
bool containsDataEntry(const word &name) const
Definition: dictionary.cpp:748
repository.hpp
pFlow::dataEntry
Definition: dataEntry.hpp:40
processField.hpp
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Definition: bTypesFunctions.cpp:131
pFlow::pointRectCell
Definition: pointRectCell.hpp:32
pFlow::dictionary::dataEntryRef
dataEntry & dataEntryRef(const word &keyword)
Definition: dictionary.cpp:600
pFlow::processField::processField
processField(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:27
fatalError
#define fatalError
Definition: error.hpp:36
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
pFlow::isTwoPartEntry
bool isTwoPartEntry(dataEntry entry)
Definition: twoPartEntry.cpp:56
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::repository
Definition: repository.hpp:34
pFlow::twoPartEntry::firstPart
const word & firstPart() const
Definition: twoPartEntry.hpp:51
pFlow::processField::timeFolder_
readFromTimeFolder timeFolder_
Definition: processField.hpp:45
yellowText
#define yellowText(text)
Definition: streams.hpp:30
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::processField::includeMaskType_
word includeMaskType_
Definition: processField.hpp:55
pFlow::timeFolder
Definition: timeFolder.hpp:32