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 "baseAlgorithms.hpp"
26 
27 namespace pFlow
28 {
29 
30 template<typename T, typename MemorySpace=void>
32 {
33 public:
34 
36 
37  using memory_space = typename viewType::memory_space;
38 
39 protected:
40 
42 
43  word name_="noName";
44 
46 
48 
49  constexpr static inline const char* memoerySpaceName()
50  {
51  return memory_space::name();
52  }
53 
54 public:
55 
56 
57  TypeInfoTemplateNV2("rectMeshField", T, memoerySpaceName());
58 
59  rectMeshField(const rectangleMesh& mesh, const word& name ,const T& defVal)
60  :
61  mesh_(&mesh),
62  name_(name),
63  field_("pFlow::reactMeshField", mesh_->nx(), mesh_->ny(), mesh_->nz()),
64  defaultValue_(defVal)
65  {
66  this->fill(defaultValue_);
67  }
68 
69  rectMeshField(const rectangleMesh& mesh, const T& defVal)
70  :
71  rectMeshField(mesh, "noName", defVal)
72  {}
73 
74  rectMeshField(const rectMeshField&) = default;
75 
76  rectMeshField& operator = (const rectMeshField&) = default;
77 
78  rectMeshField(rectMeshField&&) = default;
79 
81 
82 
84  {
85  return makeUnique<rectMeshField>(*this);
86  }
87 
88  inline rectMeshField* clonePtr()const
89  {
90  return new rectMeshField(*this);
91  }
92 
94  const word& name()const
95  {
96  return name_;
97  }
98 
100  int64 size()const
101  {
102  return mesh_->size();
103  }
104 
105  auto nx()const
106  {
107  return mesh_->nx();
108  }
109 
110  auto ny()const
111  {
112  return mesh_->ny();
113  }
114 
115  auto nz()const
116  {
117  return mesh_->nz();
118  }
119 
120  const auto& mesh()
121  {
122  return *mesh_;
123  }
124 
126  real cellVol()const
127  {
128  return mesh_->cellVol();
129  }
130 
133  {
134  return field_(i,j,k);
135  }
136 
138  const T& operator()(int32 i, int32 j, int32 k)const
139  {
140  return field_(i,j,k);
141  }
142 
143  void fill(T val)
144  {
145  pFlow::fill(
146  field_,
147  range(0,mesh_->nx()),
148  range(0,mesh_->ny()),
149  range(0,mesh_->nz()),
150  val
151  );
152  }
153 
154  bool read(iIstream& is)
155  {
157  return true;
158  }
159 
160  bool write(iOstream& os)const
161  {
163  return true;
164  }
165 
166 };
167 
168 
169 
170 }
171 
172 
173 #endif // __rectMeshField_hpp__
pFlow::cells::nz
INLINE_FUNCTION_HD indexType nz() const
Definition: cells.hpp:139
notImplementedFunction
#define notImplementedFunction
Definition: error.hpp:47
pFlow::rectMeshField::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectMeshField.hpp:100
pFlow::rectMeshField::operator()
const INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k) const
Definition: rectMeshField.hpp:138
pFlow::rectMeshField::mesh
const auto & mesh()
Definition: rectMeshField.hpp:120
pFlow::rectMeshField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("rectMeshField", T, memoerySpaceName())
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::rectMeshField::operator()
INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k)
Definition: rectMeshField.hpp:132
pFlow::rectMeshField
Definition: rectMeshField.hpp:31
pFlow::rectMeshField< int32, HostSpace >::memory_space
typename viewType::memory_space memory_space
Definition: rectMeshField.hpp:37
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::cells::nx
INLINE_FUNCTION_HD indexType nx() const
Definition: cells.hpp:127
rectangleMesh.hpp
pFlow::rectMeshField::fill
void fill(T val)
Definition: rectMeshField.hpp:143
pFlow::rectMeshField::defaultValue_
T defaultValue_
Definition: rectMeshField.hpp:47
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:31
pFlow::rectMeshField::write
bool write(iOstream &os) const
Definition: rectMeshField.hpp:160
pFlow::rectMeshField::rectMeshField
rectMeshField(const rectangleMesh &mesh, const word &name, const T &defVal)
Definition: rectMeshField.hpp:59
pFlow
Definition: demComponent.hpp:28
pFlow::rectMeshField::rectMeshField
rectMeshField(const rectangleMesh &mesh, const T &defVal)
Definition: rectMeshField.hpp:69
pFlow::rectMeshField::clone
uniquePtr< rectMeshField > clone() const
Definition: rectMeshField.hpp:83
pFlow::rectMeshField::nx
auto nx() const
Definition: rectMeshField.hpp:105
pFlow::rectMeshField::ny
auto ny() const
Definition: rectMeshField.hpp:110
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::rectMeshField::name
const INLINE_FUNCTION_H word & name() const
Definition: rectMeshField.hpp:94
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::rectMeshField::read
bool read(iIstream &is)
Definition: rectMeshField.hpp:154
pFlow::rectMeshField::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectMeshField.hpp:126
pFlow::rectangleMesh::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectangleMesh.hpp:93
pFlow::rectMeshField::clonePtr
rectMeshField * clonePtr() const
Definition: rectMeshField.hpp:88
pFlow::rectMeshField::nz
auto nz() const
Definition: rectMeshField.hpp:115
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::rectMeshField::operator=
rectMeshField & operator=(const rectMeshField &)=default
pFlow::rectMeshField::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: rectMeshField.hpp:49
pFlow::rectMeshField::mesh_
const rectangleMesh * mesh_
Definition: rectMeshField.hpp:41
pFlow::rectMeshField::name_
word name_
Definition: rectMeshField.hpp:43
pFlow::cells::ny
INLINE_FUNCTION_HD indexType ny() const
Definition: cells.hpp:133
pFlow::rectMeshField< int32, HostSpace >::viewType
ViewType3D< int32, HostSpace > viewType
Definition: rectMeshField.hpp:35
pFlow::rectMeshField::field_
viewType field_
Definition: rectMeshField.hpp:45
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
baseAlgorithms.hpp
pFlow::rectangleMesh::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectangleMesh.hpp:87
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
Definition: KokkosTypes.hpp:68