www.cemf.ir
internalField.hpp
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 #ifndef __internalField_hpp__
21 #define __internalField_hpp__
22 
23 #include "internalPoints.hpp"
24 #include "Field.hpp"
25 #include "observer.hpp"
26 #include "dataIO.hpp"
27 #include "anyList.hpp"
28 
29 
30 namespace pFlow
31 {
32 
33 template<class T, class MemorySpace=void>
35 :
36  public observer
37 {
38 
39 public:
40 
42 
44 
46 
48 
50 
52 
53 protected:
54 
57 
60 
63 
64  static inline
66  (
72  );
73 
74  bool insert(const anyList& varList);
75 
76  bool rearrange(const anyList& varList);
77 
78 public:
79 
81  const word& name,
82  const internalPoints& internal,
83  const T& defVal);
84 
86  const word& name,
87  const internalPoints& internal,
88  const T& defVal,
89  const T& val);
90 
91  inline
92  const auto& deviceViewAll()const
93  {
94  return field_.deviceViewAll();
95  }
96  inline
97  auto deviceView()const
98  {
99  return field_.deviceView();
100  }
101 
102  inline
103  auto hostView()const
104  {
105  return field_.hostView();
106  }
107 
108  inline
109  const FieldType& field()const
110  {
111  return field_;
112  }
113 
114  inline
116  {
117  return field_;
118  }
119 
121  {
123  }
124 
126  {
128  }
129 
131 
132  inline
133  auto size()const
134  {
135  return field_.size();
136  }
137 
138  inline
139  auto capacity()const
140  {
141  return field_.capacity();
142  }
143 
144  inline
145  word name()const
146  {
147  return field_.name();
148  }
149 
150  inline
151  word fieldKey()const
152  {
153  return field_.fieldKey();
154  }
155 
156  inline
157  const T& defaultValue()const
158  {
159  return defaultValue_;
160  }
161 
162  inline
164  {
165  return internalPoints_.activeRange();
166  }
167 
168  inline
169  auto isAllActive()const
170  {
171  return internalPoints_.isAllActive();
172  }
173 
174  inline
175  void fillInternal(const T& val)
176  {
177  field_.fillField(activeRange(), val);
178  }
179 
180  inline
181  bool insertSetElement(uint32IndexContainer indices, const T& val)
182  {
183  return field_.insertSetElement(indices, val);
184  }
185 
186  inline const Time& time()const
187  {
188  return internalPoints_.time();
189  }
190 
191  bool hearChanges
192  (
193  real t,
194  real dt,
195  uint32 iter,
196  const message& msg,
197  const anyList& varList
198  ) override;
199 
200 
202 
203  bool write(iOstream& os, const IOPattern& iop)const;
204 
205 };
206 
207 template<class T, class MemorySpace>
208 inline
209 iOstream& operator<<
210 (
211  iOstream& os,
212  const internalField<T, MemorySpace>& ifeild
213 )
214 {
215  if( !ifeild.write(os, IOPattern::AllProcessorsDifferent) )
216  {
217  ioErrorInFile(os.name(), os.lineNumber());
218  fatalExit;
219  }
220 
221  return os;
222 }
223 
224 } // pFlow
225 
226 #include "internalField.cpp"
228 
229 #endif // __internalField_hpp__
pFlow::internalPoints::isAllActive
bool isAllActive() const
Definition: internalPoints.hpp:195
pFlow::internalField::defaultMessage_
static const message defaultMessage_
Definition: internalField.hpp:65
pFlow::observer
Definition: observer.hpp:33
pFlow::internalField::internalField
internalField(const word &name, const internalPoints &internal, const T &defVal)
Definition: internalField.cpp:80
anyList.hpp
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::message
Definition: message.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::internalField::deviceViewAll
const auto & deviceViewAll() const
Definition: internalField.hpp:92
observer.hpp
pFlow::internalField::size
auto size() const
Definition: internalField.hpp:133
pFlow::internalField::fieldKey
word fieldKey() const
Definition: internalField.hpp:151
pFlow::Field::fieldKey
word fieldKey() const
return field key
Definition: Field.hpp:177
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::internalField::hostView
auto hostView() const
Definition: internalField.hpp:103
pFlow::internalField::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalField.hpp:120
pFlow::internalField< realx3, void >::memory_space
typename FieldType::memory_space memory_space
Definition: internalField.hpp:49
pFlow::internalField::defaultValue_
T defaultValue_
value when a new item is added to field
Definition: internalField.hpp:59
pFlow::internalField::internalPoints_
const internalPoints & internalPoints_
const ref to internal points
Definition: internalField.hpp:62
pFlow::message::SIZE_CHANGED
@ SIZE_CHANGED
Definition: message.hpp:40
pFlow::Field< realx3, void >
pFlow::Field::name
word name() const
Definition: Field.hpp:182
pFlow::internalField::activeRange
rangeU32 activeRange() const
Definition: internalField.hpp:163
pFlow::message::ITEM_REARRANGE
@ ITEM_REARRANGE
Definition: message.hpp:44
pFlow::internalField::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: internalField.cpp:164
pFlow
Definition: demGeometry.hpp:27
pFlow::internalField::isAllActive
auto isAllActive() const
Definition: internalField.hpp:169
pFlow::internalField::fillInternal
void fillInternal(const T &val)
Definition: internalField.hpp:175
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::internalField::field
FieldType & field()
Definition: internalField.hpp:115
pFlow::internalField::insertSetElement
bool insertSetElement(uint32IndexContainer indices, const T &val)
Definition: internalField.hpp:181
pFlow::internalField::field_
FieldType field_
Field.
Definition: internalField.hpp:56
pFlow::internalField::FieldTypeHost
Field< T, HostSpace > FieldTypeHost
Definition: internalField.hpp:45
pFlow::internalPoints::activeRange
auto activeRange() const
Definition: internalPoints.hpp:201
pFlow::anyList
Definition: anyList.hpp:35
pFlow::internalField::rearrange
bool rearrange(const anyList &varList)
Definition: internalField.cpp:58
internalFieldAlgorithms.hpp
pFlow::IOPattern::AllProcessorsDifferent
@ AllProcessorsDifferent
Definition: IOPattern.hpp:57
pFlow::internalPoints::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalPoints.cpp:194
pFlow::internalField< realx3, void >::VectorType
typename FieldType::VectorType VectorType
Definition: internalField.hpp:47
pFlow::internalField::field
const FieldType & field() const
Definition: internalField.hpp:109
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
pFlow::internalField< realx3, void >::execution_space
typename FieldType::execution_space execution_space
Definition: internalField.hpp:51
pFlow::internalField::time
const Time & time() const
Definition: internalField.hpp:186
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::internalPoints::time
virtual Time & time()=0
pFlow::message::ITEM_INSERT
@ ITEM_INSERT
Definition: message.hpp:42
pFlow::Range< uint32 >
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::internalField
Definition: internalField.hpp:34
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
dataIO.hpp
pFlow::internalField::defaultValue
const T & defaultValue() const
Definition: internalField.hpp:157
internalField.cpp
pFlow::message::ITEM_DELETE
@ ITEM_DELETE
Definition: message.hpp:41
Field.hpp
pFlow::message::CAP_CHANGED
@ CAP_CHANGED
Definition: message.hpp:39
pFlow::internalField::capacity
auto capacity() const
Definition: internalField.hpp:139
pFlow::internalField::insert
bool insert(const anyList &varList)
Definition: internalField.cpp:22
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::internalField::write
bool write(iOstream &os, const IOPattern &iop) const
Definition: internalField.cpp:203
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::internalField::activeValuesHost
FieldTypeHost activeValuesHost() const
Definition: internalField.cpp:134
pFlow::internalPoints::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalPoints.cpp:201
pFlow::Field::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::internalField::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalField.hpp:125
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
internalPoints.hpp
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const uint32IndexContainer &indices, const T &val)
Definition: VectorSingle.cpp:583
pFlow::Field::VectorType
VectorSingle< T, MemorySpace > VectorType
Definition: Field.hpp:42
pFlow::Field::execution_space
typename VectorType::execution_space execution_space
Definition: Field.hpp:50
pFlow::pointFlag< DefaultExecutionSpace >
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::internalField::deviceView
auto deviceView() const
Definition: internalField.hpp:97
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297
pFlow::Field::fillField
void fillField(rangeU32 span, const T &val)
Definition: Field.hpp:188
pFlow::internalField::name
word name() const
Definition: internalField.hpp:145
pFlow::Time
Definition: Time.hpp:37