# PhasicFlow: utilities/postprocessPhasicFlow/countField.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

countField.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 "countField.hpp"
#include "repository.hpp"
#include "twoPartEntry.hpp"
bool pFlow::countField::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::countField::countField(const dictionary& dict, repository& rep)
:
dict_(dict),
timeFolder_(rep)
{
word includeMaskType = dict_.getVal<word>("includeMask");
auto& incDict = dict_.subDictOrCreate(includeMaskType+"Info");
includeMask_ = includeMask::create(incDict, includeMaskType, timeFolder_);
}
bool pFlow::countField::process(uint32& countedValue)
{
auto& incMask = includeMask_();
countedValue = 0;
uint32 n = incMask.size();
for(uint32 i=0; i<n; i++)
{
if( incMask(i) )
{
countedValue++;
}
}
return true;
}
twoPartEntry.hpp
pFlow::includeMask::create
static uniquePtr< includeMask > create(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: includeMask.cpp:68
pFlow::countField::getFieldType
static bool getFieldType(const dictionary &dict, readFromTimeFolder &timeFolder, word &fieldName, word &fieldType)
Definition: countField.cpp:25
pFlow::readFromTimeFolder
Definition: readFromTimeFolder.hpp:31
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::twoPartEntry
Definition: twoPartEntry.hpp:36
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::dictionary::subDictOrCreate
dictionary & subDictOrCreate(const word &keyword)
search for a sub-dict with keyword create a new sub-dict if not found and return a ref to it fatalExi...
Definition: dictionary.cpp:647
pFlow::countField::process
bool process(uint32 &countedValue)
Definition: countField.cpp:78
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
countField.hpp
pFlow::countField::dict
auto & dict()
Definition: countField.hpp:59
repository.hpp
pFlow::dataEntry
Data entry to be used in dictionries.
Definition: dataEntry.hpp:48
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::countField::countField
countField(const dictionary &dict, repository &rep)
Definition: countField.cpp:63
pFlow::countField::dict_
dictionary dict_
Definition: countField.hpp:40
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::countField::includeMask_
uniquePtr< includeMask > includeMask_
Definition: countField.hpp:44
pFlow::isTwoPartEntry
bool isTwoPartEntry(dataEntry entry)
Definition: twoPartEntry.cpp:56
pFlow::repository
Definition: repository.hpp:34
pFlow::twoPartEntry::firstPart
const word & firstPart() const
Definition: twoPartEntry.hpp:51
pFlow::countField::timeFolder_
readFromTimeFolder timeFolder_
Definition: countField.hpp:42
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::timeFolder
Definition: timeFolder.hpp:32