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 "triSurface.hpp"
26 #include "error.hpp"
27 
28 
29 namespace pFlow
30 {
31 
32 
33 template<template<class, class> class VectorField, class T, class MemorySpace=void>
35 :
36  public eventObserver,
37  public Field<VectorField, T, MemorySpace>
38 {
39 public:
40 
42 
44 
46 
47  using iterator = typename FieldType::iterator;
48 
50 
51  using reference = typename FieldType::reference;
52 
54 
55  using valueType = typename FieldType::valueType;
56 
57  using pointer = typename FieldType::pointer;
58 
60 
61 protected:
62 
65 
66  // - value when a new item is added to field
68 
69 
70 public:
71 
72  // - type info
73  TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName());
74 
75 
77 
78  // - construct a field from tirSurface and set defaultValue_ and field value to defVal
79  triSurfaceField( const triSurface& surface, const T& defVal, bool subscribe = true);
80 
81  // - construct from iIOEntity, tirSurface and a value
82  triSurfaceField( const triSurface& surface, const T& val, const T& defVal, bool subscribe = true);
83 
84  // - construct from another triSurfaceField
85  // subscribe to events if true
86  triSurfaceField( const triSurfaceField& src, bool subscribe);
87 
88 
89  // - copy construct
90  triSurfaceField(const triSurfaceField& src);
91 
92  // - no move construct
93  triSurfaceField(triSurfaceField&& src) = delete;
94 
95 
96  // assignment, only assign the VectorField and preserve other parts of this
98 
99  // no move assignment
101 
102 
104  {
105  return makeUnique<triSurfaceFieldType>(*this);
106  }
107 
109  {
110  return new triSurfaceFieldType(*this);
111  }
112 
114 
115  inline const triSurface& surface()const {
116  return surface_;
117  }
118 
120  {
121  return surface_.getTriangleAccessor();
122  }
123 
124  bool update(const eventMessage& msg);
125 
126 
128  bool readTriSurfacceField(iIstream& is);
129 
130  bool writeTriSurfaceField(iOstream& os)const;
131 
132 
133  bool read(iIstream& is)
134  {
135  return readTriSurfacceField(is);
136  }
137 
138  bool write(iOstream& os)const
139  {
140  return writeTriSurfaceField(os);
141  }
142 
143 };
144 
145 template<template<class, class> class VectorField, class T, class MemorySpace>
147 {
148  if( !tsF.read(is))
149  {
150  ioErrorInFile( is.name(), is.lineNumber() ) <<
151  "error in reading triSurfaceField from file. \n"<<
152  "field name: "<< tsF.name()<<endl;
153  fatalExit;
154  }
155 
156  return is;
157 }
158 
159 template<template<class, class> class VectorField, class T, class MemorySpace>
161 {
162  if(! tsF.write(os) )
163  {
164  ioErrorInFile( os.name(), os.lineNumber() )<<
165  "error in writing triSurfaceField into file. \n"<<
166  "field name: "<< tsF.name()<<endl;
167  fatalExit;
168  }
169 
170  return os;
171 }
172 
173 }
174 
175 #include "triSurfaceField.cpp"
176 
177 #endif //__trieSurfaceField_hpp__
pFlow::triSurfaceField::constReference
typename FieldType::constReference constReference
Definition: triSurfaceField.hpp:53
pFlow::triSurface::getTriangleAccessor
auto getTriangleAccessor() const
Definition: triSurface.hpp:174
pFlow::triSurfaceField::surface
const triSurface & surface() const
Definition: triSurfaceField.hpp:115
pFlow::triSurfaceField::read
bool read(iIstream &is)
Definition: triSurfaceField.hpp:133
pFlow::triSurfaceField::readTriSurfacceField
bool readTriSurfacceField(iIstream &is)
Definition: triSurfaceField.cpp:105
pFlow::Field::constReference
typename VectorType::constReference constReference
Definition: Field.hpp:50
pFlow::eventObserver::subscribe
bool subscribe(const eventSubscriber &subscriber)
Definition: eventObserver.cpp:50
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::eventMessage
Definition: eventMessage.hpp:29
pFlow::triSurfaceField::writeTriSurfaceField
bool writeTriSurfaceField(iOstream &os) const
Definition: triSurfaceField.cpp:114
pFlow::triSurfaceField::clonePtr
triSurfaceFieldType * clonePtr() const
Definition: triSurfaceField.hpp:108
pFlow::triSurfaceField::clone
uniquePtr< triSurfaceFieldType > clone() const
Definition: triSurfaceField.hpp:103
pFlow::Field::constPointer
typename VectorType::constPointer constPointer
Definition: Field.hpp:56
pFlow::triSurfaceField::triSurfaceField
triSurfaceField(const triSurface &surface, const T &defVal, bool subscribe=true)
Definition: triSurfaceField.cpp:23
pFlow::eventObserver
Definition: eventObserver.hpp:33
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::triSurfaceField::write
bool write(iOstream &os) const
Definition: triSurfaceField.hpp:138
pFlow::Field
Definition: Field.hpp:33
pFlow::triSurfaceField::defaultValue_
T defaultValue_
Definition: triSurfaceField.hpp:67
pFlow
Definition: demComponent.hpp:28
pFlow::triSurfaceField::surface_
const triSurface & surface_
Definition: triSurfaceField.hpp:64
pFlow::triSurfaceField::operator=
triSurfaceField & operator=(const triSurfaceField &rhs)
Definition: triSurfaceField.cpp:82
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:34
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::triSurfaceField::triSurfaceFieldType
triSurfaceField< VectorField, T, MemorySpace > triSurfaceFieldType
Definition: triSurfaceField.hpp:41
pFlow::triSurfaceField::constPointer
typename FieldType::constPointer constPointer
Definition: triSurfaceField.hpp:59
pFlow::triSurfaceField::VectorType
typename FieldType::VectorType VectorType
Definition: triSurfaceField.hpp:45
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::triSurfaceField::reference
typename FieldType::reference reference
Definition: triSurfaceField.hpp:51
pFlow::triSurfaceField::getTriangleAccessor
auto getTriangleAccessor() const
Definition: triSurfaceField.hpp:119
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::triSurfaceField::constIterator
typename FieldType::constIterator constIterator
Definition: triSurfaceField.hpp:49
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::triSurfaceField::iterator
typename FieldType::iterator iterator
Definition: triSurfaceField.hpp:47
pFlow::triSurfaceField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("triSurfaceField", T, VectorType::memoerySpaceName())
pFlow::Field::pointer
typename VectorType::pointer pointer
Definition: Field.hpp:54
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
Field.hpp
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::Field::valueType
typename VectorType::valueType valueType
Definition: Field.hpp:52
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
triSurfaceField.cpp
pFlow::Field::iterator
typename VectorType::iterator iterator
Definition: Field.hpp:44
pFlow::triSurface
Definition: triSurface.hpp:38
pFlow::triSurfaceField::valueType
typename FieldType::valueType valueType
Definition: triSurfaceField.hpp:55
pFlow::Field::constIterator
typename VectorType::constIterator constIterator
Definition: Field.hpp:46
pFlow::triSurfaceField::pointer
typename FieldType::pointer pointer
Definition: triSurfaceField.hpp:57
pFlow::iOstream
Definition: iOstream.hpp:53
triSurface.hpp
pFlow::triSurfaceField::update
bool update(const eventMessage &msg)
Definition: triSurfaceField.cpp:94
pFlow::Field::VectorType
VectorField< T, PropType > VectorType
Definition: Field.hpp:40
pFlow::Field::reference
typename VectorType::reference reference
Definition: Field.hpp:48
error.hpp