www.cemf.ir
countField.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "countField.hpp"
22 #include "repository.hpp"
23 #include "twoPartEntry.hpp"
24 
26  const dictionary& dict,
28  word& fieldName,
29  word& fieldType)
30 {
31  if(dict.containsDataEntry("field"))
32  {
33  const dataEntry& entry = dict.dataEntryRef("field");
34 
35  if( isTwoPartEntry(entry))
36  {
37  twoPartEntry tpEntry(entry);
38  fieldName = "uniformField";
39  fieldType = tpEntry.firstPart();
40  }
41  else
42  {
43  fieldName = dict.getVal<word>("field");
44  if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) )
45  {
46  fatalErrorInFunction<<"error in reading field type from file "<< fieldName<<
47  "in folder "<< timeFolder.path()<<endl;
48  return false;
49  }
50  }
51  }
52  else
53  {
54  fatalErrorInFunction<< "dictionary "<< dict.globalName()<<
55  "does not contain field keyword"<<endl;
56  return false;
57  }
58 
59  return true;
60 }
61 
62 
64 :
65  dict_(dict),
66  timeFolder_(rep)
67 {
68 
69  word includeMaskType = dict_.getVal<word>("includeMask");
70 
71  auto& incDict = dict_.subDictOrCreate(includeMaskType+"Info");
72 
73  includeMask_ = includeMask::create(incDict, includeMaskType, timeFolder_);
74 
75 }
76 
77 
79 {
80  auto& incMask = includeMask_();
81 
82  countedValue = 0;
83  uint32 n = incMask.size();
84 
85  for(uint32 i=0; i<n; i++)
86  {
87  if( incMask(i) )
88  {
89  countedValue++;
90  }
91  }
92 
93  return true;
94 }
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