PhasicFlow
v0.1
www.cemf.ir
dynamicPointStructure.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
#include "
dynamicPointStructure.hpp
"
22
23
24
pFlow::dynamicPointStructure::dynamicPointStructure
25
(
26
Time
& time,
27
const
word
& integrationMethod
28
)
29
:
30
time_(time),
31
integrationMethod_(integrationMethod),
32
pStruct_(
33
time_.emplaceObject<
pointStructure
>(
34
objectFile
(
35
pointStructureFile__
,
36
""
,
37
objectFile::READ_ALWAYS,
38
objectFile::WRITE_ALWAYS
39
)
40
)
41
),
42
velocity_(
43
time_.emplaceObject<
realx3PointField_D
>(
44
objectFile
(
45
"velocity"
,
46
""
,
47
objectFile::READ_ALWAYS,
48
objectFile::WRITE_ALWAYS
49
),
50
pStruct
(),
51
zero3
52
)
53
)
54
55
{
56
57
this->subscribe(
pStruct
());
58
59
REPORT
(1)<<
"Creating integration method "
<<
60
greenText
(integrationMethod_)<<
" for dynamicPointStructure."
<<
endREPORT
;
61
62
integrationPos_ = integration::create(
63
"pStructPosition"
,
64
time_.integration(),
65
pStruct
(),
66
integrationMethod_);
67
68
integrationVel_ = integration::create(
69
"pStructVelocity"
,
70
time_.integration(),
71
pStruct
(),
72
integrationMethod_);
73
74
if
( !integrationPos_ )
75
{
76
fatalErrorInFunction
<<
77
" error in creating integration object for dynamicPointStructure (position). \n"
;
78
fatalExit
;
79
}
80
81
if
( !integrationVel_ )
82
{
83
fatalErrorInFunction
<<
84
" error in creating integration object for dynamicPointStructure (velocity). \n"
;
85
fatalExit
;
86
}
87
88
89
if
(!integrationPos_->needSetInitialVals())
return
;
90
91
92
93
auto
[minInd, maxInd] =
pStruct
().activeRange();
94
int32IndexContainer
indexHD(minInd, maxInd);
95
96
auto
n
= indexHD.
size
();
97
auto
index = indexHD.
indicesHost
();
98
99
realx3Vector
pos(
n
,
RESERVE
());
100
realx3Vector
vel(
n
,
RESERVE
());
101
const
auto
hVel = velocity().hostVector();
102
const
auto
hPos =
pStruct
().pointPosition().hostVector();
103
104
for
(
auto
i=0; i<
n
; i++)
105
{
106
pos.push_back( hPos[index(i)]);
107
vel.push_back( hVel[index(i)]);
108
}
109
110
//output<< "pos "<< pos<<endl;
111
//output<< "vel "<< vel<<endl;
112
113
REPORT
(2)<<
"Initializing the required vectors for position integratoin "
<<
endREPORT
;
114
integrationPos_->setInitialVals(indexHD, pos);
115
116
REPORT
(2)<<
"Initializing the required vectors for velocity integratoin\n "
<<
endREPORT
;
117
integrationVel_->setInitialVals(indexHD, vel);
118
}
119
120
bool
pFlow::dynamicPointStructure::predict
121
(
122
real
dt,
123
realx3PointField_D
&
acceleration
124
)
125
{
126
auto
& pos =
pStruct
().pointPosition();
127
128
if
(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))
return
false
;
129
if
(!integrationVel_().predict(dt, velocity_.VectorField(),
acceleration
.VectorField()))
return
false
;
130
131
return
true
;
132
}
133
134
bool
pFlow::dynamicPointStructure::correct
135
(
136
real
dt,
137
realx3PointField_D
&
acceleration
138
)
139
{
140
auto
& pos =
pStruct
().pointPosition();
141
142
if
(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))
return
false
;
143
144
if
(!integrationVel_().correct(dt, velocity_.VectorField(),
acceleration
.VectorField()))
return
false
;
145
146
return
true
;
147
}
148
149
/*FUNCTION_H
150
pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::dynamicPointStructure::insertPoints
151
(
152
const realx3Vector& pos,
153
const List<eventObserver*>& exclusionList
154
)
155
{
156
auto newIndicesPtr = pointStructure::insertPoints(pos, exclusionList);
157
158
// no new point is inserted
159
if( !newIndicesPtr ) return newIndicesPtr;
160
161
if(!integrationPos_().needSetInitialVals()) return newIndicesPtr;
162
163
auto hVel = velocity_.hostVector();
164
auto n = newIndicesPtr().size();
165
auto index = newIndicesPtr().indicesHost();
166
167
realx3Vector velVec(n, RESERVE());
168
for(auto i=0; i<n; i++)
169
{
170
velVec.push_back( hVel[ index(i) ]);
171
}
172
173
integrationPos_->setInitialVals(newIndicesPtr(), pos );
174
integrationVel_->setInitialVals(newIndicesPtr(), velVec );
175
176
return newIndicesPtr;
177
178
}*/
179
180
181
bool
pFlow::dynamicPointStructure::update
(
182
const
eventMessage
& msg)
183
{
184
if
( msg.
isInsert
())
185
{
186
187
if
(!
integrationPos_
->needSetInitialVals())
return
true
;
188
189
const
auto
indexHD =
pStruct
().
insertedPointIndex
();
190
191
192
auto
n
= indexHD.size();
193
194
if
(
n
==0)
return
true
;
195
196
auto
index = indexHD.indicesHost();
197
198
realx3Vector
pos(
n
,
RESERVE
());
199
realx3Vector
vel(
n
,
RESERVE
());
200
const
auto
hVel =
velocity
().hostVector();
201
const
auto
hPos =
pStruct
().
pointPosition
().
hostVector
();
202
203
for
(
auto
i=0; i<
n
; i++)
204
{
205
pos.push_back( hPos[index(i)]);
206
vel.push_back( hVel[index(i)]);
207
}
208
209
210
211
integrationPos_
->setInitialVals(indexHD, pos);
212
213
integrationVel_
->setInitialVals(indexHD, vel);
214
215
}
216
217
return
true
;
218
}
pFlow::VectorSingle::hostVector
const INLINE_FUNCTION_H auto hostVector() const
Definition:
VectorSingle.hpp:336
pFlow::pointStructureFile__
const char * pointStructureFile__
Definition:
vocabs.hpp:42
endREPORT
#define endREPORT
Definition:
streams.hpp:41
pFlow::dynamicPointStructure::velocity
const realx3PointField_D & velocity() const
Definition:
dynamicPointStructure.hpp:98
pFlow::real
float real
Definition:
builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition:
error.hpp:57
pFlow::eventMessage
Definition:
eventMessage.hpp:29
REPORT
#define REPORT(n)
Definition:
streams.hpp:40
pFlow::dynamicPointStructure::dynamicPointStructure
dynamicPointStructure(Time &time, const word &integrationMethod)
Definition:
dynamicPointStructure.cpp:25
pFlow::word
std::string word
Definition:
builtinTypes.hpp:63
pFlow::indexContainer::size
INLINE_FUNCTION_HD size_t size() const
Definition:
indexContainer.hpp:107
pFlow::zero3
const realx3 zero3(0.0)
Definition:
types.hpp:97
pFlow::sphereParticlesKernels::acceleration
void acceleration(realx3 g, deviceViewType1D< real > mass, deviceViewType1D< realx3 > force, deviceViewType1D< real > I, deviceViewType1D< realx3 > torque, IncludeFunctionType incld, deviceViewType1D< realx3 > lAcc, deviceViewType1D< realx3 > rAcc)
Definition:
sphereParticlesKernels.hpp:34
pFlow::dynamicPointStructure::predict
bool predict(real dt, realx3PointField_D &acceleration)
Definition:
dynamicPointStructure.cpp:121
pFlow::pointStructure::insertedPointIndex
FUNCTION_H auto insertedPointIndex() const
Definition:
pointStructure.hpp:305
greenText
#define greenText(text)
Definition:
streams.hpp:32
pFlow::pointStructure::pointPosition
FUNCTION_H realx3Field_D & pointPosition()
Definition:
pointStructure.cpp:64
pFlow::eventMessage::isInsert
bool isInsert() const
Definition:
eventMessage.hpp:87
pFlow::dynamicPointStructure::update
bool update(const eventMessage &msg) override
Definition:
dynamicPointStructure.cpp:181
RESERVE
Definition:
Vector.hpp:38
pFlow::pointField
Definition:
pointField.hpp:35
pFlow::pointStructure
Definition:
pointStructure.hpp:44
n
int32 n
Definition:
NBSCrossLoop.hpp:24
fatalErrorInFunction
#define fatalErrorInFunction
Definition:
error.hpp:42
pFlow::dynamicPointStructure::correct
bool correct(real dt, realx3PointField_D &acceleration)
Definition:
dynamicPointStructure.cpp:135
pFlow::dynamicPointStructure::pStruct
pointStructure & pStruct()
Definition:
dynamicPointStructure.hpp:88
pFlow::indexContainer::indicesHost
auto indicesHost() const
Definition:
indexContainer.hpp:153
pFlow::dynamicPointStructure::integrationVel_
uniquePtr< integration > integrationVel_
Definition:
dynamicPointStructure.hpp:50
pFlow::objectFile
Definition:
objectFile.hpp:33
pStruct
auto & pStruct
Definition:
setPointStructure.hpp:24
dynamicPointStructure.hpp
pFlow::dynamicPointStructure::integrationPos_
uniquePtr< integration > integrationPos_
Definition:
dynamicPointStructure.hpp:48
pFlow::Vector< realx3 >
pFlow::indexContainer< int32 >
pFlow::Time
Definition:
Time.hpp:39
src
Particles
dynamicPointStructure
dynamicPointStructure.cpp
Generated by
1.8.17