www.cemf.ir
regularSimulationDomain.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 
22 #include "processors.hpp"
23 #include "streams.hpp"
24 
26 {
27 
28  dictionary& thisBoundaries = this->subDict(thisBoundariesDictName());
29 
30  for(uint32 i=0; i<sizeOfBoundaries(); i++)
31  {
32  word bName = bundaryName(i);
33  dictionary& bDict = thisBoundaries.subDict(bName);
34 
35  if(!bDict.add("neighborProcessorNo",(uint32) processors::globalRank()))
36  {
37  fatalErrorInFunction<<"error in adding neighborProcessorNo to "<< bName <<
38  " in dictionary "<< thisBoundaries.globalName()<<endl;
39  return false;
40  }
41 
42  auto bType = bDict.getVal<word>("type");
43  uint32 mirrorIndex = 0;
44 
45  if(bType == "periodic")
46  {
47  if(bName == bundaryName(0)) mirrorIndex = 1;
48  if(bName == bundaryName(1)) mirrorIndex = 0;
49  if(bName == bundaryName(2)) mirrorIndex = 3;
50  if(bName == bundaryName(3)) mirrorIndex = 2;
51  if(bName == bundaryName(4)) mirrorIndex = 5;
52  if(bName == bundaryName(5)) mirrorIndex = 4;
53 
54  if(! bDict.addOrReplace("mirrorBoundaryIndex", mirrorIndex))
55  {
57  "canno add entry mirroBoundaryIndex to dictionary "<<
58  bDict.globalName()<<endl;
59  return false;
60  }
61  }
62  }
63 
64  return true;
65 }
66 
68 {
69  thisDomain_ = domain(globalBox());
70  return true;
71 }
72 
74 (
75  systemControl& control
76 )
77 :
78  simulationDomain(control)
79 {}
80 
82 {
83  initialNumPoints_ = pointPos.size();
84  if(!setThisDomain()) return false;
85  if(!createBoundaryDicts()) return false;
86  return true;
87 }
88 
90 {
91  return initialNumPoints_;
92 }
93 
94 /*bool pFlow::regularSimulationDomain::updateDomains(
95  span<realx3> pointPos,
96  pFlagTypeHost flags)
97 {
98  return true;
99 }*/
100 
102 {
103  return 0;
104 }
105 
107 {
108  return 0;
109 }
110 
111 bool
113 {
114  return true;
115 }
116 
117 const pFlow::domain&
119 {
120  return thisDomain_;
121 }
122 
123 bool
125  span<char> src,
126  span<char> dst,
127  size_t sizeOfElement
128 ) const
129 {
130  size_t requiredSize = sizeOfElement*initialNumberInThis();
131  if(dst.size() < requiredSize)
132  {
134  "size of destination data block [in byte]"<< dst.size()<<
135  "is smaller than the required size [in byte]"<< requiredSize<<endl;
136  return false;
137  }
138 
139  if(src.size() < requiredSize )
140  {
142  "size of source data block [in byte]"<< src.size()<<
143  "is smaller than the required size [in byte]"<< requiredSize<<endl;
144  return false;
145 
146  }
147 
148  std::memcpy(dst.data(), src.data(), requiredSize);
149 
150  return true;
151 }
152 
154 (
155  span<realx3> src,
156  span<realx3> dst
157 ) const
158 {
159  return initialTransferBlockData(
160  charSpan(src),
161  charSpan(dst),
162  sizeof(realx3));
163 }
164 
166 (
167  span<real> src,
168  span<real> dst
169 ) const
170 {
171  return initialTransferBlockData(
172  charSpan(src),
173  charSpan(dst),
174  sizeof(real));
175 }
176 
178 (
179  span<uint32> src,
180  span<uint32> dst
181 ) const
182 {
183  return initialTransferBlockData(
184  charSpan(src),
185  charSpan(dst),
186  sizeof(uint32));
187 }
188 
190 (
191  span<int32> src,
192  span<int32> dst
193 ) const
194 {
195  return initialTransferBlockData(
196  charSpan(src),
197  charSpan(dst),
198  sizeof(int32));
199 }
pFlow::regularSimulationDomain::regularSimulationDomain
regularSimulationDomain(systemControl &control)
Definition: regularSimulationDomain.cpp:74
pFlow::span
Definition: span.hpp:31
pFlow::regularSimulationDomain::domainActive
bool domainActive() const final
Is this domain active? Active mean, there is particle in it and boundaries and other entities of simu...
Definition: regularSimulationDomain.cpp:112
pFlow::regularSimulationDomain::initialUpdateDomains
bool initialUpdateDomains(span< realx3 > pointPos) final
Definition: regularSimulationDomain.cpp:81
pFlow::real
float real
Definition: builtinTypes.hpp:45
processors.hpp
pFlow::simulationDomain::thisBoundariesDictName
word thisBoundariesDictName() const
Definition: simulationDomain.hpp:105
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::processors::globalRank
static int globalRank()
Rank of the processor in the global MPI.
Definition: processors.hpp:139
pFlow::span::size
INLINE_FUNCTION_HD uint32 size() const
Returns the number of elements in the span.
Definition: span.hpp:101
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::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::regularSimulationDomain::thisDomain
const domain & thisDomain() const final
return the simulation domain of this processor
Definition: regularSimulationDomain.cpp:118
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
pFlow::regularSimulationDomain::numberToBeExported
uint32 numberToBeExported() const final
Definition: regularSimulationDomain.cpp:106
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::regularSimulationDomain::setThisDomain
bool setThisDomain() final
Definition: regularSimulationDomain.cpp:67
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::regularSimulationDomain::initialTransferBlockData
bool initialTransferBlockData(span< char > src, span< char > dst, size_t sizeOfElement) const final
Definition: regularSimulationDomain.cpp:124
pFlow::regularSimulationDomain::createBoundaryDicts
bool createBoundaryDicts() final
Definition: regularSimulationDomain.cpp:25
pFlow::regularSimulationDomain::numberToBeImported
uint32 numberToBeImported() const final
Number of points to be imported after updating domains.
Definition: regularSimulationDomain.cpp:101
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
Definition: dictionary.cpp:560
streams.hpp
pFlow::span::data
INLINE_FUNCTION_HD T * data() const
Definition: span.hpp:94
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::charSpan
span< char > charSpan(span< T > s)
Definition: span.hpp:177
pFlow::dictionary::addOrReplace
bool addOrReplace(const word &keyword, const T &v)
Definition: dictionary.hpp:445
pFlow::simulationDomain
Definition: simulationDomain.hpp:38
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
regularSimulationDomain.hpp
pFlow::regularSimulationDomain::initialNumberInThis
uint32 initialNumberInThis() const final
Definition: regularSimulationDomain.cpp:89
pFlow::triple< real >
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