www.cemf.ir
triSurfaceField.cpp
Go to the documentation of this file.
1 #include "triSurfaceField.hpp"
2 /*------------------------------- phasicFlow ---------------------------------
3  O C enter of
4  O O E ngineering and
5  O O M ultiscale modeling of
6  OOOOOOO F luid flow
7 ------------------------------------------------------------------------------
8  Copyright (C): www.cemf.ir
9  email: hamid.r.norouzi AT gmail.com
10 ------------------------------------------------------------------------------
11 Licence:
12  This file is part of phasicFlow code. It is a free software for simulating
13  granular and multiphase flows. You can redistribute it and/or modify it under
14  the terms of GNU General Public License v3 or any other later versions.
15 
16  phasicFlow is distributed to help others in their research in the field of
17  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
18  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 -----------------------------------------------------------------------------*/
21 
22 template<class T, class MemorySpace>
24 (
25  const objectFile& objf,
27  const T& defVal
28 )
29 :
31  (
32  objf,
33  surface.owner(),
34  surface,
35  defVal
36  )
37 {
38 
39 }
40 
41 template<class T, class MemorySpace>
43 (
44  const objectFile& objf,
45  repository* owner,
47  const T& defVal
48 )
49 :
50  IOobject
51  (
52  objf,
53  IOPattern::AllProcessorsSimilar,
54  owner
55  ),
56  observer
57  (
58  &surface,
59  message::Default()
60  ),
61  field_
62  (
63  objf.name(),
64  "value",
65  surface.capacity(),
66  surface.size(),
67  RESERVE()
68  ),
69  surface_(surface),
70  defaultValue_(defVal)
71 {
72  if(IOobject::implyRead())
73  {
74  REPORT(1)<< "Reading triSurfaceField "<< Green_Text(IOobject::name())<<
75  " from "<<IOobject::path()<<END_REPORT;
76  }
77  else
78  {
79  REPORT(1)<< "Creating triSurfaceField "<< Green_Text(IOobject::name())<<END_REPORT;
80  }
81  if( !IOobject::readObject() )
82  {
84  "Error in reading from file "<<IOobject::path()<<endl;
85  fatalExit;
86  }
87 }
88 
89 template <class T, class MemorySpace>
91 (
92  const objectFile &objf,
94  const T &val,
95  const T &defVal
96 )
97 :
99  (
100  objf,
101  surface.owner(),
102  surface,
103  val,
104  defVal
105  )
106 {}
107 
108 template <class T, class MemorySpace>
110 (
111  const objectFile &objf,
112  repository *owner,
114  const T &val,
115  const T &defVal
116 )
117 :
118  IOobject
119  (
120  objectFile
121  (
122  objf.name(),
123  objf.localPath(),
124  objectFile::READ_NEVER,
125  objf.wFlag()
126  ),
127  IOPattern::AllProcessorsSimilar,
128  owner
129  ),
130  observer
131  (
132  &surface,
133  message::Default()
134  ),
135  field_
136  (
137  objf.name(),
138  "value",
139  surface.capacity(),
140  surface.size(),
141  val
142  ),
143  surface_(surface),
144  defaultValue_(defVal)
145 {
146 }
147 
148 template <class T, class MemorySpace>
150 (
151  iOstream &is,
152  const IOPattern &iop
153 ) const
154 {
155  return field_.write(is, iop);
156 }
157 
158 template <class T, class MemorySpace>
160 (
161  iIstream &is,
162  const IOPattern &iop
163 )
164 {
165  return field_.read(is, iop);
166 }
167 
168 /*template<template<class, class> class VectorField, class T, class MemorySpace>
169 pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField
170 (
171  const triSurface& surface,
172  const T& defVal,
173  bool subscribe
174 )
175 :
176  eventObserver(surface, subscribe),
177  FieldType(surface.capacity(), surface.size(), RESERVE()),
178  surface_(surface),
179  defaultValue_(defVal)
180 {
181  this->fill(defVal);
182 }
183 
184 template<template<class, class> class VectorField, class T, class MemorySpace>
185 pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField
186 (
187  const triSurface& surface,
188  const T& val,
189  const T& defVal,
190  bool subscribe
191 )
192 :
193  eventObserver(surface, subscribe),
194  FieldType(surface.capacity(), surface.size(), RESERVE()),
195  surface_(surface),
196  defaultValue_(defVal)
197 {
198  this->fill(val);
199 }
200 
201 
202 template<template<class, class> class VectorField, class T, class MemorySpace>
203 pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField
204 (
205  const triSurfaceField& src,
206  bool subscribe
207 )
208 :
209  eventObserver(src.surface(), subscribe),
210  FieldType(src),
211  surface_(src.surface()),
212  defaultValue_(src.defaultValue_)
213 {
214 
215 }
216 
217 template<template<class, class> class VectorField, class T, class MemorySpace>
218 pFlow::triSurfaceField<VectorField, T, MemorySpace>::triSurfaceField
219 (
220  const triSurfaceField& src
221 )
222 :
223 triSurfaceField<VectorField, T, MemorySpace>(src, src.subscribed())
224 {}
225 
226 template<template<class, class> class VectorField, class T, class MemorySpace>
227 pFlow::triSurfaceField<VectorField, T, MemorySpace>&
228  pFlow::triSurfaceField<VectorField, T, MemorySpace>::operator=
229 (
230  const triSurfaceField& rhs
231 )
232 {
233  if(this == &rhs) return *this;
234 
235  this->VectorField() = rhs.VectorField();
236  return *this;
237 }
238 
239 template<template<class, class> class VectorField, class T, class MemorySpace>
240 bool pFlow::triSurfaceField<VectorField, T, MemorySpace>::update
241 (
242  const eventMessage& msg
243 )
244 {
245  notImplementedFunction;
246  return true;
247 }
248 
249 
250 template<template<class, class> class VectorField, class T, class MemorySpace>
251 bool pFlow::triSurfaceField<VectorField, T, MemorySpace>::readTriSurfacceField
252 (
253  iIstream& is
254 )
255 {
256  return FieldType::readField(is, surface_.size(), false);
257 }
258 
259 template<template<class, class> class VectorField, class T, class MemorySpace>
260 bool pFlow::triSurfaceField<VectorField, T, MemorySpace>::writeTriSurfaceField
261 (
262  iOstream& os
263 )const
264 {
265  return FieldType::write(os);
266 }*/
pFlow::observer
Definition: observer.hpp:33
Green_Text
#define Green_Text(text)
Definition: iOstream.hpp:42
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::triSurfaceField::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: triSurfaceField.cpp:160
pFlow::triSurfaceField::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: triSurfaceField.cpp:150
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:32
pFlow::IOobject
Definition: IOobject.hpp:35
RESERVE
Definition: Vector.hpp:40
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:35
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::objectFile::name
virtual const word & name() const
Definition: objectFile.hpp:101
pFlow::IOPattern
Definition: IOPattern.hpp:32
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::triSurfaceField::triSurfaceField
triSurfaceField(const objectFile &objf, multiTriSurface &surface, const T &defVal)
Definition: triSurfaceField.cpp:24
pFlow::objectFile::localPath
virtual const fileSystem & localPath() const
Definition: objectFile.hpp:107
pFlow::repository
Definition: repository.hpp:34
triSurfaceField.hpp
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::objectFile::wFlag
writeFlag wFlag() const
Definition: objectFile.hpp:119
pFlow::triangle::surface
INLINE_FUNCTION_HD real surface(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triangleFunctions.hpp:30