www.cemf.ir
rectMeshField.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 
21 #ifndef __rectMeshField_hpp__
22 #define __rectMeshField_hpp__
23 
24 #include "rectangleMesh.hpp"
25 #include "ViewAlgorithms.hpp"
26 
27 namespace pFlow
28 {
29 
30 template<typename T>
32 :
33  public IOobject
34 {
35 public:
36 
38 
39  using memory_space = typename viewType::memory_space;
40 
41 protected:
42 
44 
45  word name_="noName";
46 
48 
50 
51  constexpr static inline const char* memoerySpaceName()
52  {
53  return memory_space::name();
54  }
55 
56 public:
57 
58 
59  TypeInfoTemplateNV111("rectMeshField", T, memoerySpaceName());
60 
61  rectMeshField(rectangleMesh& mesh, const word& name ,const T& defVal)
62  :
63  IOobject(
65  (
66  name,
67  "",
70  ),
71  IOPattern::MasterProcessorOnly,
72  nullptr
73  ),
74  mesh_(&mesh),
75  name_(name),
76  field_("reactMeshField."+name, mesh_->nx(), mesh_->ny(), mesh_->nz()),
77  defaultValue_(defVal)
78  {
79  this->fill(defaultValue_);
80  }
81 
82  rectMeshField(rectangleMesh& mesh, const T& defVal)
83  :
84  IOobject(
86  (
87  "noName",
88  "",
91  ),
92  IOPattern::MasterProcessorOnly,
93  nullptr
94  ),
95  mesh_(&mesh),
96  name_("noName"),
97  field_("reactMeshField.noName", mesh_->nx(), mesh_->ny(), mesh_->nz()),
98  defaultValue_(defVal)
99  {
100  this->fill(defaultValue_);
101  }
102 
103  rectMeshField(const rectMeshField&) = default;
104 
105  rectMeshField& operator = (const rectMeshField&) = default;
106 
107  rectMeshField(rectMeshField&&) = default;
108 
109  rectMeshField& operator =(rectMeshField&&) = default;
110 
111 
113  {
114  return makeUnique<rectMeshField>(*this);
115  }
116 
117  inline rectMeshField* clonePtr()const
118  {
119  return new rectMeshField(*this);
120  }
121 
123  const word& name()const
124  {
125  return name_;
126  }
127 
129  int64 size()const
130  {
131  return mesh_->size();
132  }
133 
134  auto nx()const
135  {
136  return mesh_->nx();
137  }
138 
139  auto ny()const
140  {
141  return mesh_->ny();
142  }
143 
144  auto nz()const
145  {
146  return mesh_->nz();
147  }
148 
149  const auto& mesh()
150  {
151  return *mesh_;
152  }
153 
155  real cellVol()const
156  {
157  return mesh_->cellVol();
158  }
159 
162  {
163  return field_(i,j,k);
164  }
165 
167  const T& operator()(int32 i, int32 j, int32 k)const
168  {
169  return field_(i,j,k);
170  }
171 
172  void fill(T val)
173  {
174  pFlow::fill(
175  field_,
176  val
177  );
178  }
179 
180 
181  bool write(iOstream& is, const IOPattern& iop)const override
182  {
184  return true;
185  }
186 
187  bool read(iIstream& is, const IOPattern& iop) override
188  {
190  return true;
191  }
192 
193  bool read(iIstream& is)
194  {
196  return true;
197  }
198 
199  bool write(iOstream& os)const
200  {
202  return true;
203  }
204 
205 };
206 
207 
208 
209 }
210 
211 
212 #endif // __rectMeshField_hpp__
pFlow::rectMeshField::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: rectMeshField.hpp:181
notImplementedFunction
#define notImplementedFunction
Report that a function is yet not implemented.
Definition: error.hpp:84
pFlow::rectangleMesh::size
int64 size() const
Definition: rectangleMesh.hpp:72
pFlow::rectMeshField::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectMeshField.hpp:129
pFlow::rectangleMesh::cellVol
real cellVol() const
Definition: rectangleMesh.hpp:92
pFlow::rectMeshField::operator()
const INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k) const
Definition: rectMeshField.hpp:167
pFlow::rectMeshField::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: rectMeshField.hpp:187
pFlow::rectMeshField::mesh
const auto & mesh()
Definition: rectMeshField.hpp:149
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::rectangleMesh::ny
int32 ny() const
Definition: rectangleMesh.hpp:82
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::rectMeshField< int32 >::viewType
ViewType3D< int32, HostSpace > viewType
Definition: rectMeshField.hpp:37
pFlow::rectMeshField::operator()
INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k)
Definition: rectMeshField.hpp:161
pFlow::rectMeshField::TypeInfoTemplateNV111
TypeInfoTemplateNV111("rectMeshField", T, memoerySpaceName())
pFlow::rectMeshField
Definition: rectMeshField.hpp:31
ViewAlgorithms.hpp
pFlow::rectMeshField< int32 >::memory_space
typename viewType::memory_space memory_space
Definition: rectMeshField.hpp:39
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::rectMeshField::rectMeshField
rectMeshField(rectangleMesh &mesh, const word &name, const T &defVal)
Definition: rectMeshField.hpp:61
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
rectangleMesh.hpp
pFlow::rectMeshField::fill
void fill(T val)
Definition: rectMeshField.hpp:172
pFlow::rectMeshField::defaultValue_
T defaultValue_
Definition: rectMeshField.hpp:49
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::rectMeshField::write
bool write(iOstream &os) const
Definition: rectMeshField.hpp:199
pFlow
Definition: demGeometry.hpp:27
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:44
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::rectMeshField::clone
uniquePtr< rectMeshField > clone() const
Definition: rectMeshField.hpp:112
pFlow::rectMeshField::nx
auto nx() const
Definition: rectMeshField.hpp:134
pFlow::rectMeshField::ny
auto ny() const
Definition: rectMeshField.hpp:139
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::rectMeshField::name
const INLINE_FUNCTION_H word & name() const
Definition: rectMeshField.hpp:123
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::rectangleMesh::nz
int32 nz() const
Definition: rectangleMesh.hpp:87
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::rectMeshField::rectMeshField
rectMeshField(rectangleMesh &mesh, const T &defVal)
Definition: rectMeshField.hpp:82
pFlow::rectMeshField::read
bool read(iIstream &is)
Definition: rectMeshField.hpp:193
pFlow::rectMeshField::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectMeshField.hpp:155
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::rectMeshField::clonePtr
rectMeshField * clonePtr() const
Definition: rectMeshField.hpp:117
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
3D view as an array
Definition: KokkosTypes.hpp:101
pFlow::objectFile::READ_NEVER
@ READ_NEVER
Definition: objectFile.hpp:37
pFlow::rectMeshField::nz
auto nz() const
Definition: rectMeshField.hpp:144
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::rectMeshField::operator=
rectMeshField & operator=(const rectMeshField &)=default
pFlow::rectMeshField::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: rectMeshField.hpp:51
pFlow::rectMeshField::mesh_
const rectangleMesh * mesh_
Definition: rectMeshField.hpp:43
pFlow::rectMeshField::name_
word name_
Definition: rectMeshField.hpp:45
pFlow::rectMeshField::field_
viewType field_
Definition: rectMeshField.hpp:47
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::rectangleMesh::nx
int32 nx() const
Definition: rectangleMesh.hpp:77