www.cemf.ir
pStructSelector.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 
22 #include "pStructSelector.hpp"
23 #include "pointStructure.hpp"
24 #include "dictionary.hpp"
25 
27 (
28  const pointStructure& pStruct,
29  const dictionary& UNUSED(dict)
30 )
31 :
32  pStruct_(pStruct)
33 {}
34 
36  const word& ,
37  const pointStructure& pStruct,
38  const dictionary&
39 )
40 :
41  pStruct_(pStruct)
42 {
43 }
44 
46 {
47  return pStruct_;
48 }
49 
52 {
53 
54  const auto& slctd = selectedPoints();
55 
56  if(slctd.empty()) return realx3Vector("selectedPointPositions");
57 
58  realx3Vector slctdPoints("selectedPointPositions", slctd.size());
59 
60  auto pPos = pStruct().pointPositionHost();
61 
62  for(uint32 i=0; i<slctd.size(); i++)
63  {
64  slctdPoints[i] = pPos[slctd[i]];
65  }
66 
67  return slctdPoints;
68 }
69 
72  const pointStructure& pStruct,
73  const dictionary& dict
74 )
75 {
76  word selectorMethod = angleBracketsNames("selector", dict.getVal<word>("selector"));
77 
78  if( dictionaryvCtorSelector_.search(selectorMethod) )
79  {
80  return dictionaryvCtorSelector_[selectorMethod] (pStruct, dict);
81  }
82  else
83  {
84  printKeys
85  (
86  fatalError << "Ctor Selector "<< selectorMethod << " does not exist. \n"
87  <<"Avaiable ones are: \n\n"
88  ,
89  dictionaryvCtorSelector_
90  );
91  fatalExit;
92  }
93  return nullptr;
94 }
95 
98  const word& type,
99  const pointStructure& pStruct,
100  const dictionary& dict
101 )
102 {
103  word selectorMethod = angleBracketsNames("selector", type);
104 
105  if( wordvCtorSelector_.search(selectorMethod) )
106  {
107  return wordvCtorSelector_[selectorMethod] (type, pStruct, dict);
108  }
109  else
110  {
111  printKeys
112  (
113  fatalError << "Ctor Selector "<< selectorMethod << " does not exist. \n"
114  <<"Avaiable ones are: \n\n"
115  ,
116  wordvCtorSelector_
117  );
118  fatalExit;
119  }
120  return nullptr;
121 
122 }
pFlow::pStructSelector::create
static uniquePtr< pStructSelector > create(const pointStructure &pStruct, const dictionary &dict)
Definition: pStructSelector.cpp:71
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
UNUSED
#define UNUSED(x)
Definition: pFlowMacros.hpp:35
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pStructSelector.hpp
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Output <w1,w2>
Definition: bTypesFunctions.cpp:156
dictionary.hpp
pFlow::pStructSelector::pStruct
const pointStructure & pStruct() const
Definition: pStructSelector.cpp:45
fatalError
#define fatalError
Report a fatal error and exit the applicaiton.
Definition: error.hpp:70
pFlow::realx3Vector
Vector< realx3 > realx3Vector
Definition: Vectors.hpp:48
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::Vector< realx3 >
pointStructure.hpp
pFlow::pStructSelector::pStructSelector
pStructSelector(const pointStructure &pStruct, const dictionary &UNUSED(dict))
the dictionary contains the selector keyword and another dictionary which is used for creating select...
Definition: pStructSelector.cpp:27
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::pStructSelector::selectedPointPositions
realx3Vector selectedPointPositions() const
Definition: pStructSelector.cpp:51