www.cemf.ir
simulationDomain.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 "simulationDomain.hpp"
22 #include "pFlowProcessors.hpp"
23 #include "systemControl.hpp"
24 #include "vocabs.hpp"
25 
27 {
28 
29  dictionary& boundaries = this->subDict("boundaries");
30 
31  real neighborLength = boundaries.getVal<real>("neighborLength");
32 
33  real boundaryExtntionLengthRatio =
34  boundaries.getValOrSetMax("boundaryExtntionLengthRatio", 0.1);
35 
36  uint32 updateInterval =
37  boundaries.getValOrSetMax<uint32>("updateInterval", 1u);
38 
39  uint32 neighborListUpdateInterval =
40  boundaries.getValMax("neighborListUpdateInterval", updateInterval);
41 
42  boundaries.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval);
43 
44  // create this boundaries dictionary
45  this->addDict(thisBoundariesDictName(), boundaries);
46  dictionary& thisBDict = this->subDict(thisBoundariesDictName());
47  thisBDict.addOrReplace("neighborLength", neighborLength);
48  thisBDict.addOrReplace("boundaryExtntionLengthRatio", boundaryExtntionLengthRatio);
49  thisBDict.addOrReplace("updateInterval", updateInterval);
50  thisBDict.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval);
51 
52 
53  for(uint32 i=0; i<sizeOfBoundaries(); i++)
54  {
55  word bName = bundaryName(i);
56  if( !boundaries.containsDictionay(bName) )
57  {
58  fatalErrorInFunction<<"dictionary "<< bName<<
59  "does not exist in "<< boundaries.globalName()<<endl;
60  return false;
61  }
62  auto& bDict = thisBDict.subDict(bName);
63 
64  if(!bDict.addOrKeep("neighborLength", neighborLength))
65  {
66  fatalErrorInFunction<<"error in adding neighborLength to "<< bName <<
67  "in dictionary "<< boundaries.globalName()<<endl;
68  return false;
69  }
70 
71  if(!bDict.addOrReplace("updateInterval", updateInterval))
72  {
73  fatalErrorInFunction<<"error in adding updateInterval to "<< bName <<
74  "in dictionary "<< boundaries.globalName()<<endl;
75  return false;
76  }
77 
78  bDict.addOrReplace("boundaryExtntionLengthRatio", boundaryExtntionLengthRatio);
79 
80  }
81 
82  return true;
83 }
84 
87  objectFile(
89  "",
90  objectFile::READ_ALWAYS,
91  objectFile::WRITE_NEVER),
92  &control.settings()),
93  globalBox_(subDict("globalBox"))
94 {
95  if( !prepareBoundaryDicts() )
96  {
98  "Error in preparing dictionaries for boundaries"<<endl;
99  fatalExit;
100  }
101 }
102 
104 (
105  const realx3 &lowerPointExtension,
106  const realx3 &upperPointExtension
107 ) const
108 {
109  realx3 minP = thisDomain().minPoint() + lowerPointExtension;
110  realx3 maxP = thisDomain().maxPoint() + upperPointExtension;
111  return domain({minP, maxP});
112 }
113 
114 const pFlow::plane&
116 {
117  return thisDomain().boundaryPlane(i);
118 }
119 
122 {
123  word sType = angleBracketsNames(
124  "simulationDomain",
125  pFlowProcessors().localRunTypeName());
126 
127 
128  if( systemControlvCtorSelector_.search(sType) )
129  {
130  return systemControlvCtorSelector_[sType] (control);
131  }
132  else
133  {
134  printKeys
135  (
136  fatalError << "Ctor Selector "<< sType << " dose not exist. \n"
137  <<"Avaiable ones are: \n\n"
138  ,
139  systemControlvCtorSelector_
140  );
141  fatalExit;
142  }
143  return nullptr;
144 }
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::plane
Definition: plane.hpp:30
pFlow::simulationDomain::thisBoundariesDictName
word thisBoundariesDictName() const
Definition: simulationDomain.hpp:105
systemControl.hpp
pFlow::simulationDomain::extendThisDomain
domain extendThisDomain(const realx3 &lowerPointExtension, const realx3 &upperPointExtension) const
Definition: simulationDomain.cpp:104
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::simulationDomain::sizeOfBoundaries
static uint32 sizeOfBoundaries()
Definition: simulationDomain.hpp:204
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::systemControl
Definition: systemControl.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::simulationDomain::boundaryPlane
const plane & boundaryPlane(uint32 i) const
return a const ref to the plane of boundary i of this processor
Definition: simulationDomain.cpp:115
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
simulationDomain.hpp
pFlow::dictionary::containsDictionay
bool containsDictionay(const word &name) const
check if a sub-dictionary exists
Definition: dictionary.cpp:749
pFlow::dictionary::getValMax
T getValMax(const word &keyword, const T &maxVal) const
get the value of data entry and return max(value, maxVal)
Definition: dictionary.hpp:395
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Output <w1,w2>
Definition: bTypesFunctions.cpp:156
pFlow::objectFile
Definition: objectFile.hpp:30
fatalError
#define fatalError
Report a fatal error and exit the applicaiton.
Definition: error.hpp:70
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
Definition: dictionary.cpp:560
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::simulationDomain::create
static uniquePtr< simulationDomain > create(systemControl &control)
Definition: simulationDomain.cpp:121
pFlow::dictionary::addOrReplace
bool addOrReplace(const word &keyword, const T &v)
Definition: dictionary.hpp:445
pFlow::pFlowProcessors
localProcessors & pFlowProcessors()
Definition: pFlowProcessors.cpp:5
pFlow::fileDictionary
Definition: fileDictionary.hpp:29
pFlow::uniquePtr< pFlow::simulationDomain >
pFlowProcessors.hpp
pFlow::simulationDomain::simulationDomain
simulationDomain(systemControl &control)
Constrcut from components.
Definition: simulationDomain.cpp:85
pFlow::domain
Definition: domain.hpp:31
pFlow::simulationDomain::bundaryName
static const word & bundaryName(uint32 i)
Boundary name based on boundary index.
Definition: simulationDomain.hpp:198
pFlow::dictionary::addDict
bool addDict(const word &keyword, const dictionary &dict)
add a dictionary with the specifiedd keyword, if it exists, replace it.
Definition: dictionary.cpp:526
vocabs.hpp
pFlow::triple< real >
pFlow::dictionary::getValOrSetMax
T getValOrSetMax(const word &keyword, const T &setMaxVal) const
get the value of data entry anf return max(setMaxVal, value) if not found, set the value to setMaxVal
Definition: dictionary.hpp:432
pFlow::domainFile__
const char *const domainFile__
Definition: vocabs.hpp:39
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::simulationDomain::prepareBoundaryDicts
bool prepareBoundaryDicts()
Definition: simulationDomain.cpp:26