www.cemf.ir
pointField_old.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 __pointField_hpp__
22 #define __pointField_hpp__
23 
24 
25 #include "Field.hpp"
26 #include "pointStructure.hpp"
27 #include "error.hpp"
28 
29 namespace pFlow
30 {
31 
32 
33 
34 template<template<class, class> class VectorField, class T, class MemorySpace=void>
35 class pointField
36 :
37  public eventObserver,
38  public Field<VectorField, T, MemorySpace>
39 {
40 public:
41 
43 
45 
47 
48  using iterator = typename FieldType::iterator;
49 
50  using constIterator = typename FieldType::constIterator;
51 
52  using reference = typename FieldType::reference;
53 
54  using constReference = typename FieldType::constReference;
55 
56  using valueType = typename FieldType::valueType;
57 
58  using pointer = typename FieldType::pointer;
59 
60  using constPointer = typename FieldType::constPointer;
61 
62 protected:
63 
65  const pointStructure& pStruct_;
66 
67  // - value when a new item is added to field
69 
70 
71 public:
72 
73  // - type info
74  TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName());
75 
76 
78 
79  // - construct a field from pointStructure and set defaultValue_ and field value to defVal
80  pointField( const pointStructure& pStruct, const T& defVal, bool subscribe = true);
81 
82  // - construct from iIOEntity, pointStructure and a value
83  pointField( const pointStructure& pStruct, const T& val, const T& defVal, bool subscribe = true);
84 
85  // - construct from another pointField
86  // subscribe to events if true
87  pointField( const pointField& src, bool subscribe);
88 
89 
90  // - copy construct
91  pointField(const pointField& src);
92 
93  // - no move construct
94  pointField(pointField&& src) = delete;
95 
96 
97  // assignment, only assign the VectorField and preserve other parts of this
98  pointField& operator = (const pointField& rhs);
99 
100  // no move assignment
101  pointField& operator = (pointField&&) = delete;
102 
103 
105  {
106  return makeUnique<pointFieldType>(*this);
107  }
108 
109  inline pointFieldType* clonePtr()const
110  {
111  return new pointFieldType(*this);
112  }
113 
115 
116  // - reference to pointStructure
117  inline const pointStructure& pStruct()const {
118  return pStruct_;
119  }
120 
121  // if all points are active
123  bool allActive()const {
124  return pStruct_.allActive();
125  }
126 
127 
129  bool isActive(label i)const {
130  return pStruct_.isActive(i);
131  }
132 
133  const auto& pointFlag()const
134  {
135  return pStruct_.pointFlag();
136  }
137 
138  range activeRange()const
139  {
140  return pStruct_.activeRange();
141  }
142 
143  // - update the field if any changes occure in pStruct
144  // for now it checks for deleted points
145  bool update(const eventMessage& msg);
146 
147 
149  bool readPointField(iIstream& is);
150 
151  bool writePointField(iOstream& os)const;
152 
153 
154  bool read(iIstream& is)
155  {
156  return readPointField(is);
157  }
158 
159  bool write(iOstream& os)const
160  {
161  return writePointField(os);
162  }
163 };
164 
165 template<template<class, class> class VectorField, class T, class MemorySpace>
167 {
168  if( !pF.read(is))
169  {
170  ioErrorInFile( is.name(), is.lineNumber() ) <<
171  "error in reading pointField from file. \n";
172  fatalExit;
173  }
174 
175  return is;
176 }
177 
178 template<template<class, class> class VectorField, class T, class MemorySpace>
180 {
181  if(! pF.write(os) )
182  {
183  ioErrorInFile( os.name(), os.lineNumber() )<<
184  "error in writing pointField into file. \n";
185  fatalExit;
186  }
187 
188  return os;
189 }
190 
191 }
192 
193 #include "pointField.cpp"
194 #include "pointFieldAlgorithms.hpp"
195 
196 #endif // __pointField_hpp__
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::pointField::operator=
pointField & operator=(const pointField &rhs)
pFlow::pointField::isActive
INLINE_FUNCTION_H bool isActive(label i) const
Definition: pointField_old.hpp:129
pFlow::pointField::pStruct
const pointStructure & pStruct() const
Definition: pointField.hpp:134
pFlow::pointField::pStruct_
const pointStructure & pStruct_
refrence to point structure
Definition: pointField.hpp:62
pFlow::pointField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName())
pFlow::pointField::pointField
pointField(const objectFile &objf, pointStructure &pStruct, const T &defVal)
Definition: pointField.cpp:22
pFlow::pointField::defaultValue_
T defaultValue_
Definition: pointField_old.hpp:68
pFlow::pointField::read
bool read(iIstream &is)
Definition: pointField_old.hpp:154
pFlow::Field< pFlow::VectorSingle, pFlow::AB3History >
pFlow::pointField< pFlow::VectorSingle, pFlow::AB3History >::constIterator
typename FieldType::constIterator constIterator
Definition: pointField_old.hpp:50
pFlow
Definition: demGeometry.hpp:27
pFlow::pointField::pointFieldType
pointField< VectorField, T, MemorySpace > pointFieldType
Definition: pointField_old.hpp:42
pFlow::pointField< pFlow::VectorSingle, pFlow::AB3History >::constPointer
typename FieldType::constPointer constPointer
Definition: pointField_old.hpp:60
pFlow::pointField
Definition: pointField.hpp:33
pFlow::internalPoints::activeRange
auto activeRange() const
Definition: internalPoints.hpp:201
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::pointField::writePointField
bool writePointField(iOstream &os, const IOPattern &iop) const
Definition: pointField.cpp:283
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::internalField< pFlow::VectorSingle, pFlow::AB3History >::VectorType
typename FieldType::VectorType VectorType
Definition: internalField.hpp:47
pFlow::pointField::clonePtr
pointFieldType * clonePtr() const
Definition: pointField_old.hpp:109
pFlow::pointField< pFlow::VectorSingle, pFlow::AB3History >::valueType
typename FieldType::valueType valueType
Definition: pointField_old.hpp:56
pFlow::internalField< pFlow::VectorSingle, pFlow::AB3History >::reference
typename FieldType::reference reference
Definition: pointField copy.hpp:52
pFlow::internalField< pFlow::VectorSingle, pFlow::AB3History >::iterator
typename FieldType::iterator iterator
Definition: pointField copy.hpp:48
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::pointField::write
bool write(iOstream &os) const
Definition: pointField_old.hpp:159
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::pointField::activeRange
range activeRange() const
Definition: pointField_old.hpp:138
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::VectorSingle< pFlow::VectorSingle, pFlow::AB3History >
pFlow::pointField::allActive
INLINE_FUNCTION_H bool allActive() const
Definition: pointField_old.hpp:123
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::pointField< pFlow::VectorSingle, pFlow::AB3History >::constReference
typename FieldType::constReference constReference
Definition: pointField_old.hpp:54
pFlow::pointField::readPointField
bool readPointField(iIstream &is, const IOPattern &iop)
Definition: pointField.cpp:236
pFlow::Field< pFlow::VectorSingle, pFlow::AB3History >::pointer
typename VectorType::pointer pointer
Definition: Field.hpp:62
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
Field.hpp
pFlow::pointField::clone
uniquePtr< pointFieldType > clone() const
Definition: pointField_old.hpp:104
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::Field< pFlow::VectorSingle, pFlow::AB3History >::iterator
typename VectorType::iterator iterator
Definition: Field.hpp:52
pointField.cpp
pFlow::pointField::update
bool update(const eventMessage &msg)
pointFieldAlgorithms.hpp
pFlow::internalField< pFlow::VectorSingle, pFlow::AB3History >::pointer
typename FieldType::pointer pointer
Definition: pointField copy.hpp:58
pointStructure.hpp
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::observer::subscribe
void subscribe(const subscriber *subscrbr, message msg)
pFlow::pointField::pointFlag
const auto & pointFlag() const
Definition: pointField_old.hpp:133
pFlow::Field< pFlow::VectorSingle, pFlow::AB3History >::reference
typename VectorType::reference reference
Definition: Field.hpp:56
error.hpp