particleI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMesh.H"
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 {
33  label id = particleCount_++;
34 
35  if (id == labelMax)
36  {
38  << "Particle counter has overflowed. This might cause problems"
39  << " when reconstructing particle tracks." << endl;
40  }
41  return id;
42 }
43 
44 
45 inline const Foam::polyMesh& Foam::particle::mesh() const
46 {
47  return mesh_;
48 }
49 
50 
52 {
53  return coordinates_;
54 }
55 
56 
58 {
59  return celli_;
60 }
61 
62 
64 {
65  return tetFacei_;
66 }
67 
68 
70 {
71  return tetPti_;
72 }
73 
74 
76 {
77  return facei_;
78 }
79 
80 
81 inline Foam::scalar Foam::particle::stepFraction() const
82 {
83  return stepFraction_;
84 }
85 
86 
87 inline Foam::scalar& Foam::particle::stepFraction()
88 {
89  return stepFraction_;
90 }
91 
92 
94 {
95  return origProc_;
96 }
97 
98 
100 {
101  return origProc_;
102 }
103 
104 
106 {
107  return origId_;
108 }
109 
110 
112 {
113  return origId_;
114 }
115 
116 
118 {
119  if (mesh_.time().subCycling())
120  {
121  const TimeState& tsNew = mesh_.time();
122  const TimeState& tsOld = mesh_.time().prevTimeState();
123 
124  const scalar tFrac =
125  (
126  (tsNew.value() - tsNew.deltaTValue())
127  - (tsOld.value() - tsOld.deltaTValue())
128  )/tsOld.deltaTValue();
129 
130  const scalar dtFrac = tsNew.deltaTValue()/tsOld.deltaTValue();
131 
132  return Pair<scalar>(tFrac, dtFrac);
133  }
134  else
135  {
136  return Pair<scalar>(0, 1);
137  }
138 }
139 
140 
141 inline Foam::scalar Foam::particle::currentTimeFraction() const
142 {
143  const Pair<scalar> s = stepFractionSpan();
144 
145  return s[0] + stepFraction_*s[1];
146 }
147 
148 
150 {
151  return tetIndices(celli_, tetFacei_, tetPti_);
152 }
153 
154 
156 {
157  if (mesh_.moving())
158  {
159  return movingTetTransform(0)[0];
160  }
161  else
162  {
163  return stationaryTetTransform();
164  }
165 }
166 
167 
169 {
170  return currentTetIndices().faceTri(mesh_).normal();
171 }
172 
173 
175 {
176  return currentTetIndices().oldFaceTri(mesh_).normal();
177 }
178 
179 
180 inline bool Foam::particle::onFace() const
181 {
182  return facei_ >= 0;
183 }
184 
185 
187 {
188  return onFace() && mesh_.isInternalFace(facei_);
189 }
190 
191 
193 {
194  return onFace() && !mesh_.isInternalFace(facei_);
195 }
196 
197 
199 {
200  return mesh_.boundaryMesh().whichPatch(facei_);
201 }
202 
203 
205 {
206  return currentTetTransform() & coordinates_;
207 }
208 
209 
210 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:424
label origProc() const
Return the originating processor ID.
Definition: particleI.H:93
const polyMesh & mesh() const
Return the mesh database.
Definition: particleI.H:45
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool moving() const
Is mesh moving.
Definition: polyMesh.H:496
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:48
bool onBoundaryFace() const
Is the particle on a boundary face?
Definition: particleI.H:192
triPointRef faceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
Definition: tetIndicesI.H:115
bool subCycling() const
Return true if time currently being sub-cycled, otherwise false.
Definition: Time.H:431
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Pair< scalar > stepFractionSpan() const
Return the step fraction change within the overall time-step.
Definition: particleI.H:117
vector oldNormal() const
Return the normal of the tri on tetFacei_ for the.
Definition: particleI.H:174
const TimeState & prevTimeState() const
Return previous TimeState if time is being sub-cycled.
Definition: Time.H:437
label tetPt() const
Return current tet face particle is in.
Definition: particleI.H:69
vector normal() const
Return the normal of the tri on tetFacei_ for the.
Definition: particleI.H:168
label cell() const
Return current cell particle is in.
Definition: particleI.H:57
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
label face() const
Return current face particle is on otherwise -1.
Definition: particleI.H:75
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:41
const Type & value() const
Return const reference to value.
static const label labelMax
Definition: label.H:62
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
barycentricTensor currentTetTransform() const
Return the current tet transformation tensor.
Definition: particleI.H:155
vector normal() const
Return vector normal.
Definition: triangleI.H:103
label origId() const
Return the particle ID on the originating processor.
Definition: particleI.H:105
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
bool onFace() const
Is the particle on a face?
Definition: particleI.H:180
label tetFace() const
Return current tet face particle is in.
Definition: particleI.H:63
label getNewParticleID() const
Get unique particle creation id.
Definition: particleI.H:31
const Time & time() const
Return time.
scalar stepFraction() const
Return the fraction of time-step completed.
Definition: particleI.H:81
tetIndices currentTetIndices() const
Return the indices of the current tet that the.
Definition: particleI.H:149
#define WarningInFunction
Report a warning using Foam::Warning.
Templated 4x3 tensor derived from VectorSpace. Has 12 components. Can represent a barycentric transfo...
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:51
static label particleCount_
Cumulative particle counter - used to provode unique ID.
Definition: particle.H:377
bool onInternalFace() const
Is the particle on an internal face?
Definition: particleI.H:186
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
triPointRef oldFaceTri(const polyMesh &mesh) const
Return the geometry corresponding to the tri on the face for.
Definition: tetIndicesI.H:130
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
vector position() const
Return current particle position.
Definition: particleI.H:204
label patch() const
Return the index of patch that the particle is on.
Definition: particleI.H:198
scalar currentTimeFraction() const
Return the current fraction within the timestep. This differs.
Definition: particleI.H:141