-
Notifications
You must be signed in to change notification settings - Fork 1
/
particleI.H
210 lines (150 loc) · 4.35 KB
/
particleI.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::particle::getNewParticleID() const
{
label id = particleCount_++;
if (id == labelMax)
{
WarningInFunction
<< "Particle counter has overflowed. This might cause problems"
<< " when reconstructing particle tracks." << endl;
}
return id;
}
inline const Foam::polyMesh& Foam::particle::mesh() const
{
return mesh_;
}
inline const Foam::barycentric& Foam::particle::coordinates() const
{
return coordinates_;
}
inline Foam::label Foam::particle::cell() const
{
return celli_;
}
inline Foam::label Foam::particle::tetFace() const
{
return tetFacei_;
}
inline Foam::label Foam::particle::tetPt() const
{
return tetPti_;
}
inline Foam::label Foam::particle::face() const
{
return facei_;
}
inline Foam::scalar Foam::particle::stepFraction() const
{
return stepFraction_;
}
inline Foam::scalar& Foam::particle::stepFraction()
{
return stepFraction_;
}
inline Foam::label Foam::particle::origProc() const
{
return origProc_;
}
inline Foam::label& Foam::particle::origProc()
{
return origProc_;
}
inline Foam::label Foam::particle::origId() const
{
return origId_;
}
inline Foam::label& Foam::particle::origId()
{
return origId_;
}
inline Foam::Pair<Foam::scalar> Foam::particle::stepFractionSpan() const
{
if (mesh_.time().subCycling())
{
const TimeState& tsNew = mesh_.time();
const TimeState& tsOld = mesh_.time().prevTimeState();
const scalar tFrac =
(
(tsNew.value() - tsNew.deltaTValue())
- (tsOld.value() - tsOld.deltaTValue())
)/tsOld.deltaTValue();
const scalar dtFrac = tsNew.deltaTValue()/tsOld.deltaTValue();
return Pair<scalar>(tFrac, dtFrac);
}
else
{
return Pair<scalar>(0, 1);
}
}
inline Foam::scalar Foam::particle::currentTimeFraction() const
{
const Pair<scalar> s = stepFractionSpan();
return s[0] + stepFraction_*s[1];
}
inline Foam::tetIndices Foam::particle::currentTetIndices() const
{
return tetIndices(celli_, tetFacei_, tetPti_);
}
inline Foam::barycentricTensor Foam::particle::currentTetTransform() const
{
if (mesh_.moving())
{
return movingTetTransform(0)[0];
}
else
{
return stationaryTetTransform();
}
}
inline Foam::vector Foam::particle::normal() const
{
return currentTetIndices().faceTri(mesh_).normal();
}
inline Foam::vector Foam::particle::oldNormal() const
{
return currentTetIndices().oldFaceTri(mesh_).normal();
}
inline bool Foam::particle::onFace() const
{
return facei_ >= 0;
}
inline bool Foam::particle::onInternalFace() const
{
return onFace() && mesh_.isInternalFace(facei_);
}
inline bool Foam::particle::onBoundaryFace() const
{
return onFace() && !mesh_.isInternalFace(facei_);
}
inline Foam::label Foam::particle::patch() const
{
return mesh_.boundaryMesh().whichPatch(facei_);
}
inline Foam::vector Foam::particle::position() const
{
return currentTetTransform() & coordinates_;
}
// ************************************************************************* //