www.cemf.ir
triSurfaceField.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 __trieSurfaceField_hpp__
22 #define __trieSurfaceField_hpp__
23 
24 #include "Field.hpp"
25 #include "multiTriSurface.hpp"
26 #include "observer.hpp"
27 #include "error.hpp"
28 
29 
30 namespace pFlow
31 {
32 
33 
34 template<class T, class MemorySpace=void>
36 :
37  public IOobject,
38  public observer
39 {
40 public:
41 
43 
45 
47 
49 
51 
52 private:
53 
55 
57 
59 
60  // - value when a new item is added to field
62 
63 
64 public:
65 
66  // - type info
67  TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName());
68 
69 
71 
72  // - construct a field from tirSurface and set defaultValue_ and field value to defVal
74  const objectFile& objf,
76  const T& defVal);
77 
79  const objectFile& objf,
82  const T& defVal);
83 
84  // - construct from iIOEntity, tirSurface and a value
86  const objectFile& objf,
88  const T& val,
89  const T& defVal);
90 
92  const objectFile& objf,
95  const T& val,
96  const T& defVal);
97 
98  ~triSurfaceField()override = default;
99 
100 
101 
103 
104  inline
105  const auto& surface()const
106  {
107  return surface_;
108  }
109 
110  inline
111  auto size()const
112  {
113  return field_.size();
114  }
115 
116  inline
117  auto capacity()const
118  {
119  return field_.capacity();
120  }
121 
122  inline
123  void assign(const std::vector<T>& vals)
124  {
125  if(vals.size() != surface_.size())
126  {
128  fatalExit;
129  }
130  field_.assign(vals, surface_.capacity());
131  }
132 
133  inline
134  const auto& deviceViewAll()const
135  {
136  return field_.deviceViewAll();
137  }
138  inline
139  auto deviceView()const
140  {
141  return field_.deviceView();
142  }
143 
144  inline
145  auto hostView()const
146  {
147  return field_.hostView();
148  }
149 
150  inline
151  const FieldType& field()const
152  {
153  return field_;
154  }
155 
156  inline
158  {
159  return field_;
160  }
161 
162  inline
163  void fill(const T& val)
164  {
165  field_.fillField(val);
166  }
167 
169  real t,
170  real dt,
171  uint32 iter,
172  const message& msg,
173  const anyList& varList) override
174  {
176  return false;
177  }
178 
180  bool write(iOstream& is, const IOPattern& iop)const override;
181 
182 
183  bool read(iIstream& is, const IOPattern& iop) override;
184 
185 };
186 
187 /*template<template<class, class> class VectorField, class T, class MemorySpace>
188 iIstream& operator >> (iIstream & is, triSurfaceField<VectorField, T, MemorySpace> & tsF )
189 {
190  if( !tsF.read(is))
191  {
192  ioErrorInFile( is.name(), is.lineNumber() ) <<
193  "error in reading triSurfaceField from file. \n"<<
194  "field name: "<< tsF.name()<<endl;
195  fatalExit;
196  }
197 
198  return is;
199 }
200 
201 template<template<class, class> class VectorField, class T, class MemorySpace>
202 iOstream& operator << (iOstream& os, const triSurfaceField<VectorField, T, MemorySpace>& tsF )
203 {
204  if(! tsF.write(os) )
205  {
206  ioErrorInFile( os.name(), os.lineNumber() )<<
207  "error in writing triSurfaceField into file. \n"<<
208  "field name: "<< tsF.name()<<endl;
209  fatalExit;
210  }
211 
212  return os;
213 }*/
214 
215 }
216 
217 #include "triSurfaceField.cpp"
218 
219 #endif //__trieSurfaceField_hpp__
pFlow::observer
Definition: observer.hpp:33
pFlow::triSurfaceField::field
FieldType & field()
Definition: triSurfaceField.hpp:157
notImplementedFunction
#define notImplementedFunction
Report that a function is yet not implemented.
Definition: error.hpp:84
pFlow::triSurface::capacity
uint32 capacity() const
Definition: triSurface.hpp:167
pFlow::message
Definition: message.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::triSurfaceField::hostView
auto hostView() const
Definition: triSurfaceField.hpp:145
pFlow::triSurfaceField::hearChanges
bool hearChanges(real t, real dt, uint32 iter, const message &msg, const anyList &varList) override
Definition: triSurfaceField.hpp:168
observer.hpp
pFlow::triSurfaceField::field
const FieldType & field() const
Definition: triSurfaceField.hpp:151
pFlow::triSurfaceField::~triSurfaceField
~triSurfaceField() override=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::triSurfaceField::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: triSurfaceField.cpp:160
pFlow::triSurfaceField::size
auto size() const
Definition: triSurfaceField.hpp:111
pFlow::triSurfaceField::deviceView
auto deviceView() const
Definition: triSurfaceField.hpp:139
pFlow::triSurfaceField::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: triSurfaceField.cpp:150
pFlow::Field< uint32, void >
pFlow::triSurfaceField::defaultValue_
T defaultValue_
Definition: triSurfaceField.hpp:61
pFlow
Definition: demGeometry.hpp:27
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:32
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::anyList
Definition: anyList.hpp:35
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:35
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::triSurface::size
uint32 size() const
Definition: triSurface.hpp:162
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::triSurfaceField::surface
const auto & surface() const
Definition: triSurfaceField.hpp:105
multiTriSurface.hpp
pFlow::triSurfaceField::deviceViewAll
const auto & deviceViewAll() const
Definition: triSurfaceField.hpp:134
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
pFlow::triSurfaceField::field_
FieldType field_
Definition: triSurfaceField.hpp:56
pFlow::triSurfaceField< uint32 >::VectorType
typename FieldType::VectorType VectorType
Definition: triSurfaceField.hpp:46
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::IOobject::owner
const repository * owner() const override
Definition: IOobject.hpp:76
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::triSurfaceField< uint32 >::execution_space
typename FieldType::execution_space execution_space
Definition: triSurfaceField.hpp:50
pFlow::triSurfaceField::triSurfaceField
triSurfaceField(const objectFile &objf, multiTriSurface &surface, const T &defVal)
Definition: triSurfaceField.cpp:24
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::triSurfaceField::fill
void fill(const T &val)
Definition: triSurfaceField.hpp:163
pFlow::triSurfaceField::capacity
auto capacity() const
Definition: triSurfaceField.hpp:117
Field.hpp
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(size_t n, const T &val)
Change size of the vector and assign val to vector and.
Definition: VectorSingle.cpp:386
pFlow::triSurfaceField::assign
void assign(const std::vector< T > &vals)
Definition: triSurfaceField.hpp:123
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::triSurfaceField::TypeInfoTemplate111
TypeInfoTemplate111("triSurfaceField", T, VectorType::memoerySpaceName())
pFlow::repository
Definition: repository.hpp:34
triSurfaceField.cpp
pFlow::triSurfaceField::surface_
const multiTriSurface & surface_
Definition: triSurfaceField.hpp:58
pFlow::Field::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
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::triSurfaceField< uint32 >::memory_space
typename FieldType::memory_space memory_space
Definition: triSurfaceField.hpp:48
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
error.hpp