pointField.cpp
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 
22 template<template<class, class> class VectorField, class T, class MemorySpace>
24 (
25  iIstream& is
26 )
27 {
28 
29  return FieldType::readField(is, pStruct_.size(), false);
30 }
31 
32 template<template<class, class> class VectorField, class T, class MemorySpace>
34 (
35  iOstream& os
36 )const
37 {
38  return FieldType::write(os);
39 }
40 
41 
42 
43 template<template<class, class> class VectorField, class T, class MemorySpace>
45 (
46  const pointStructure& pStruct,
47  const T& defVal,
48  bool subscribe
49 )
50 :
51  eventObserver(pStruct, subscribe),
52  FieldType(pStruct.capacity(), pStruct.size(), RESERVE()),
53  pStruct_(pStruct),
54  defaultValue_(defVal)
55 {
56  // set value
57  this->fill(defVal);
58 }
59 
60 template<template<class, class> class VectorField, class T, class MemorySpace>
62 (
63  const pointStructure& pStruct,
64  const T& val,
65  const T& defVal,
66  bool subscribe
67 )
68 :
69  eventObserver(pStruct, subscribe),
70  FieldType(pStruct.capacity(), pStruct.size(), RESERVE()),
71  pStruct_(pStruct),
72  defaultValue_(defVal)
73 {
74  this->fill(val);
75 }
76 
77 template<template<class, class> class VectorField, class T, class MemorySpace>
79 (
80  const pointField& src,
81  bool subscribe
82 )
83 :
84  eventObserver(src.pStruct(), subscribe),
85  FieldType(src),
86  pStruct_(src.pStruct()),
87  defaultValue_(src.defaultValue_)
88 {}
89 
90 template<template<class, class> class VectorField, class T, class MemorySpace>
92 :
93  pointField<VectorField, T, MemorySpace>(src, src.subscribed())
94 {}
95 
96 
97 template<template<class, class> class VectorField, class T, class MemorySpace>
99 (
100  const pointField& rhs
101 )
102 {
103  if(this == &rhs) return *this;
104 
105  this->VectorField() = rhs.VectorField();
106  return *this;
107 }
108 
109 
110 template<template<class, class> class VectorField, class T, class MemorySpace>
112 {
113 
114  if( msg.isDeleted() )
115  {
116  /*const auto& dp = pStruct_.markedDeletePoints();
117  return this->deleteElement(dp);
118  notImplementedFunction;*/
119  }
120  else if( msg.isInsert())
121  {
122  const auto newElems = pStruct().insertedPointIndex();
123  //Vector<T> vals( newElems.size(), defaultValue_);
124  return this->insertSetElement(newElems, defaultValue_);
125  }
126 
127  return true;
128 }
129 
pFlow::pointField::writePointField
bool writePointField(iOstream &os) const
Definition: pointField.cpp:34
pFlow::eventMessage
Definition: eventMessage.hpp:29
pFlow::pointField::pStruct
const pointStructure & pStruct() const
Definition: pointField.hpp:117
pFlow::pointField::defaultValue_
T defaultValue_
Definition: pointField.hpp:68
pFlow::eventObserver
Definition: eventObserver.hpp:33
pFlow::Field< T, T, void >
pFlow::eventMessage::isInsert
bool isInsert() const
Definition: eventMessage.hpp:87
RESERVE
Definition: Vector.hpp:38
pFlow::pointField
Definition: pointField.hpp:35
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::iIstream
Definition: iIstream.hpp:33
fill
void fill(Vector< T, Allocator > &vec, const T &val)
pFlow::pointField::readPointField
bool readPointField(iIstream &is)
Definition: pointField.cpp:24
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::eventMessage::isDeleted
bool isDeleted() const
Definition: eventMessage.hpp:82
pFlow::pointField::update
bool update(const eventMessage &msg)
Definition: pointField.cpp:111
pFlow::pointField::pointField
pointField(const pointStructure &pStruct, const T &defVal, bool subscribe=true)
Definition: pointField.cpp:45
pFlow::iOstream
Definition: iOstream.hpp:53