www.cemf.ir
positionParticles.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 "positionParticles.hpp"
22 #include "vocabs.hpp"
23 #include "dictionary.hpp"
24 #include "systemControl.hpp"
25 
27  const realx3Vector& position)const
28 {
29  struct indexMorton
30  {
31  uint64 morton;
32  uint64 index;
33  };
34 
35  /*realx3 minP = min(position);
36  realx3 maxP = max(position);
37  real cellsize = maxDiameter();
38  cells<uint64> allCells( box(minP, maxP), cellsize);
39 
40  Vector<indexMorton> indMor(position.size(),RESERVE());
41 
42  indMor.clear();
43 
44  uint64 ind=0;
45  for(const auto& p:position)
46  {
47  auto cellInd = allCells.pointIndex(p);
48  indMor.push_back(
49  { xyzToMortonCode64(cellInd.x(), cellInd.y(), cellInd.z()),
50  ind++});
51  }
52 
53  INFORMATION<<"Performing morton sorting."<<END_INFO;
54  std::sort(
55  indMor.begin(),
56  indMor.end(),
57  []( const indexMorton &lhs, const indexMorton &rhs){
58  return lhs.morton < rhs.morton; } );
59 
60  realx3Vector sortedPos(position.capacity(), RESERVE());
61  sortedPos.clear();
62 
63 
64  for(auto& ind:indMor)
65  {
66  sortedPos.push_back( position[ind.index] );
67  }*/
68 
69  WARNING<<"Morton sorting is inactive!"<<END_WARNING;
70  return position;
71 }
72 
73 
75 (
76  systemControl& control,
77  const dictionary& dict
78 )
79 :
80  regionType_(dict.getValOrSet<word>("regionType", "domain")),
81  maxNumberOfParticles_(dict.getValOrSet(
82  "maxNumberOfParticles",
83  static_cast<uint32>(10000))),
84  mortonSorting_(dict.getValOrSet("mortonSorting", Logical("Yes")))
85 {
86 
87  if( regionType_ != "domain" )
88  {
89  pRegion_ = peakableRegion::create(
90  regionType_,
91  dict.subDict(regionType_+"Info"));
92  }
93  else
94  {
95  fileDictionary domainDict
96  (
98  {
100  "",
103  },
104  &control.settings()
105  );
106  pRegion_ = peakableRegion::create(regionType_,domainDict.subDict("globalBox"));
107  }
108 
109 }
110 
111 
113 {
114  if(mortonSorting_)
115  {
116  return sortByMortonCode(position());
117  }
118  else
119  {
120  realx3Vector vec("final position",position().capacity(), 0 , RESERVE());
121  vec.assign( position().begin(), position().end());
122  return vec;
123  }
124 }
125 
128 (
129  systemControl& control,
130  const dictionary & dict
131 )
132 {
133 
134  word method = dict.getVal<word>("method");
135 
136 
137  if( dictionaryvCtorSelector_.search(method) )
138  {
139  return dictionaryvCtorSelector_[method] (control, dict);
140  }
141  else
142  {
143  printKeys
144  (
145  fatalError << "Ctor Selector "<< method << " dose not exist. \n"
146  <<"Avaiable ones are: \n\n"
147  ,
148  dictionaryvCtorSelector_
149  );
150  fatalExit;
151  }
152 
153  return nullptr;
154 }
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::positionParticles::positionParticles
positionParticles(systemControl &control, const dictionary &dict)
Definition: positionParticles.cpp:75
systemControl.hpp
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
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::indexMorton
Definition: mortonIndexing.hpp:77
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:44
RESERVE
Definition: Vector.hpp:40
END_WARNING
#define END_WARNING
Definition: streams.hpp:44
dictionary.hpp
pFlow::objectFile::READ_ALWAYS
@ READ_ALWAYS
Definition: objectFile.hpp:36
pFlow::positionParticles::position
virtual const realx3Vector & position() const =0
pFlow::positionParticles::sortByMortonCode
realx3Vector sortByMortonCode(const realx3Vector &position) const
Definition: positionParticles.cpp:26
pFlow::peakableRegion::create
static uniquePtr< peakableRegion > create(const word &type, const dictionary &dict)
Definition: peakableRegion.cpp:36
pFlow::systemControl::settings
const repository & settings() const
Definition: systemControl.hpp:105
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::positionParticles::create
static uniquePtr< positionParticles > create(systemControl &control, const dictionary &dict)
Definition: positionParticles.cpp:128
pFlow::Logical
Holds a bool value and converts strings to bool.
Definition: Logical.hpp:39
pFlow::fileDictionary
Definition: fileDictionary.hpp:29
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::positionParticles::getFinalPosition
virtual realx3Vector getFinalPosition()
Definition: positionParticles.cpp:112
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
vocabs.hpp
pFlow::Vector< realx3 >
positionParticles.hpp
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
WARNING
#define WARNING
Definition: streams.hpp:43