www.cemf.ir
processField.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 "processField.hpp"
22 #include "pointRectCell.hpp"
23 #include "repository.hpp"
24 #include "twoPartEntry.hpp"
25 
26 
28  const dictionary& dict,
29  pointRectCell& pToCell,
30  repository& rep)
31 :
32  dict_(dict),
33  pointToCell_(pToCell),
34  timeFolder_(rep),
35  processedFieldName_(dict.name()),
36  operation_(dict.getVal<word>("operation")),
37  includeMaskType_(dict.getVal<word>("includeMask")),
38  threshold_(dict.getValOrSetMax<int32>("threshold", 1))
39 {
40 
42  dict_,
44  fieldName_,
45  fieldType_) )
46  {
47  fatalExit;
48  }
49 
50  auto& incDict = dict_.subDictOrCreate(includeMaskType_+"Info");
51 
53 
54 }
55 
57  const dictionary& dict,
59  word& fieldName,
60  word& fieldType)
61 {
62  if(dict.containsDataEntry("field"))
63  {
64  const dataEntry& entry = dict.dataEntryRef("field");
65 
66  if( isTwoPartEntry(entry))
67  {
68  twoPartEntry tpEntry(entry);
69  fieldName = "uniformField";
70  fieldType = tpEntry.firstPart();
71  }
72  else
73  {
74  fieldName = dict.getVal<word>("field");
75  if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) )
76  {
77  fatalErrorInFunction<<"error in reading field type from file "<< fieldName<<
78  "in folder "<< timeFolder.path()<<endl;
79  return false;
80  }
81  }
82  }
83  else
84  {
85  fatalErrorInFunction<< "dictionary "<< dict.globalName()<<
86  "does not contain field keyword"<<endl;
87  return false;
88  }
89 
90  return true;
91 }
92 
93 
96  const dictionary& dict,
97  pointRectCell& pToCell,
98  repository& rep)
99 {
100 
101  word fName, fType;
103  if(!getFieldType(dict, timeFolder, fName, fType))
104  {
105  fatalExit;
106  return nullptr;
107  }
108 
109  auto method = angleBracketsNames("ProcessField", fType);
110 
111  if( dictionaryvCtorSelector_.search(method) )
112  {
113  auto objPtr =
114  dictionaryvCtorSelector_[method]
115  (dict, pToCell, rep);
116  REPORT(2)<<"Processing/creating " << Yellow_Text(dict.name())<< " with model "<<Green_Text(method)<<"."<<END_REPORT;
117  return objPtr;
118  }
119  else
120  {
121  printKeys
122  (
123  fatalError << "Ctor Selector "<<
124  method << " dose not exist. \n"
125  <<"Avaiable ones are: \n\n"
126  ,
127  dictionaryvCtorSelector_
128  );
129  fatalExit;
130  return nullptr;
131  }
132 }
pFlow::processField::fieldType_
word fieldType_
Definition: processField.hpp:51
Green_Text
#define Green_Text(text)
Definition: iOstream.hpp:42
twoPartEntry.hpp
pFlow::includeMask::create
static uniquePtr< includeMask > create(const dictionary &dict, const word &opType, readFromTimeFolder &timeFolder)
Definition: includeMask.cpp:68
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::readFromTimeFolder
Definition: readFromTimeFolder.hpp:31
pFlow::processField::create
static uniquePtr< processField > create(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:95
pFlow::twoPartEntry
Definition: twoPartEntry.hpp:36
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::processField::getFieldType
static bool getFieldType(const dictionary &dict, readFromTimeFolder &timeFolder, word &fieldName, word &fieldType)
Definition: processField.cpp:56
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
global name of entry, separated with dots
Definition: dictionary.cpp:356
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::processField::fieldName_
word fieldName_
Definition: processField.hpp:49
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::processField::includeMask_
uniquePtr< includeMask > includeMask_
Definition: processField.hpp:59
pointRectCell.hpp
Yellow_Text
#define Yellow_Text(text)
Definition: iOstream.hpp:40
pFlow::dictionary::containsDataEntry
bool containsDataEntry(const word &name) const
check if a data entry exist
Definition: dictionary.cpp:761
repository.hpp
pFlow::dataEntry
Data entry to be used in dictionries.
Definition: dataEntry.hpp:48
processField.hpp
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Output <w1,w2>
Definition: bTypesFunctions.cpp:156
pFlow::pointRectCell
Definition: pointRectCell.hpp:32
pFlow::dictionary::dataEntryRef
dataEntry & dataEntryRef(const word &keyword)
ref to a subdictioanry fatalExit if not found/not a dataEntry
Definition: dictionary.cpp:613
pFlow::processField::processField
processField(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:27
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
fatalError
#define fatalError
Report a fatal error and exit the applicaiton.
Definition: error.hpp:70
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::isTwoPartEntry
bool isTwoPartEntry(dataEntry entry)
Definition: twoPartEntry.cpp:56
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
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
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::processField::includeMaskType_
word includeMaskType_
Definition: processField.hpp:55
pFlow::timeFolder
Definition: timeFolder.hpp:32