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.getValOrSet<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 }
56 
58  const dictionary& dict,
60  word& fieldName,
61  word& fieldType)
62 {
63  if(dict.containsDataEntry("field"))
64  {
65  const dataEntry& entry = dict.dataEntryRef("field");
66 
67  if( isTwoPartEntry(entry))
68  {
69  twoPartEntry tpEntry(entry);
70  fieldName = "uniformField";
71  fieldType = tpEntry.firstPart();
72  }
73  else
74  {
75  fieldName = dict.getVal<word>("field");
76  if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) )
77  {
78  fatalErrorInFunction<<"error in reading field type from file "<< fieldName<<
79  "in folder "<< timeFolder.path()<<endl;
80  return false;
81  }
82  }
83  }
84  else
85  {
86  fatalErrorInFunction<< "dictionary "<< dict.globalName()<<
87  "does not contain field keyword"<<endl;
88  return false;
89  }
90 
91  return true;
92 }
93 
94 
97  const dictionary& dict,
98  pointRectCell& pToCell,
99  repository& rep)
100 {
101 
102  word fName, fType;
104  if(!getFieldType(dict, timeFolder, fName, fType))
105  {
106  fatalExit;
107  return nullptr;
108  }
109 
110 
111  auto method = angleBracketsNames("ProcessField", fType);
112 
113  if( dictionaryvCtorSelector_.search(method) )
114  {
115  auto objPtr =
116  dictionaryvCtorSelector_[method]
117  (dict, pToCell, rep);
118  REPORT(2)<<"Processing/creating " << yellowText(dict.name())<< " with model "<<greenText(method)<<"."<<endREPORT;
119  return objPtr;
120  }
121  else
122  {
123  printKeys
124  (
125  fatalError << "Ctor Selector "<<
126  method << " dose not exist. \n"
127  <<"Avaiable ones are: \n\n"
128  ,
129  dictionaryvCtorSelector_
130  );
131  fatalExit;
132  return nullptr;
133  }
134 }
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