transportDataI.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMesh.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 // Update this with w2 if w2 nearer to pt.
34 template<class TrackingData>
35 inline bool Foam::transportData::update
36 (
37  const point& pt,
38  const transportData& w2,
39  const scalar tol,
40  TrackingData& td
41 )
42 {
43  const scalar dist2 = magSqr(pt - w2.origin());
44 
45  if (valid(td))
46  {
47  const scalar diff = distSqr() - dist2;
48 
49  if (diff < 0)
50  {
51  // Already nearer to pt
52  return false;
53  }
54 
55  if ((diff < SMALL) || ((distSqr() > SMALL) && (diff/distSqr() < tol)))
56  {
57  // Don't propagate small changes
58  return false;
59  }
60  }
61 
62  // Either *this is not yet valid or w2 is closer
63  {
64  // current not yet set so use any value
65  distSqr() = dist2;
66  origin() = w2.origin();
67  data() = w2.data();
68 
69  if (distSqr() > sqr(0.25*data()))
70  {
71  // No need to transport gap data since too far away
72  return false;
73  }
74 
75  return true;
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
83 :
84  wallPointData<scalar>()
85 {}
86 
87 
89 (
90  const point& origin,
91  const scalar gapSize,
92  const scalar distSqr
93 )
94 :
95  wallPointData<scalar>(origin, gapSize, distSqr)
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
101 template<class TrackingData>
103 (
104  const polyMesh& mesh,
105  const label cellI,
106  const label faceI,
107  const transportData& neighbourWallInfo,
108  const scalar tol,
109  TrackingData& td
110 )
111 {
112  if (td.surfaceIndex_[faceI] != -1)
113  {
114  return false;
115  }
116 
117  const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
118 
119  bool updated = update
120  (
121  cellCentres[cellI],
122  neighbourWallInfo,
123  tol,
124  td
125  );
126 
127  return updated;
128 }
129 
130 
131 template<class TrackingData>
133 (
134  const polyMesh& mesh,
135  const label thisFaceI,
136  const label neighbourCellI,
137  const transportData& neighbourWallInfo,
138  const scalar tol,
139  TrackingData& td
140 )
141 {
142  if (td.surfaceIndex_[thisFaceI] != -1)
143  {
144  return false;
145  }
146 
147  return update
148  (
149  mesh.faceCentres()[thisFaceI],
150  neighbourWallInfo,
151  tol,
152  td
153  );
154 }
155 
156 
157 template<class TrackingData>
159 (
160  const polyMesh& mesh,
161  const label thisFaceI,
162  const transportData& neighbourWallInfo,
163  const scalar tol,
164  TrackingData& td
165 )
166 {
167  if (td.surfaceIndex_[thisFaceI] != -1)
168  {
169  return false;
170  }
171 
172  return update
173  (
174  mesh.faceCentres()[thisFaceI],
175  neighbourWallInfo,
176  tol,
177  td
178  );
179 }
180 
181 
182 // ************************************************************************* //
Foam::transportData
Holds information (coordinate and distance). Walks out 0.5*distance.
Definition: transportData.H:54
Foam::transportData::updateCell
bool updateCell(const polyMesh &mesh, const label thisCellI, const label neighbourFaceI, const transportData &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: transportDataI.H:103
Foam::transportData::updateFace
bool updateFace(const polyMesh &mesh, const label thisFaceI, const label neighbourCellI, const transportData &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: transportDataI.H:133
update
mesh update()
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
Foam::transportData::transportData
transportData()
Construct null.
Definition: transportDataI.H:82
Foam::Field< vector >
Foam::wallPointData< scalar >::data
const scalar & data() const
Definition: wallPointData.H:114
w2
#define w2
Definition: blockCreate.C:35
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::Vector< scalar >
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:77
Foam::wallPointData
Holds information (coordinate and normal) regarding nearest wall point.
Definition: wallPointData.H:52
transform.H
3D tensor transformation operations.
Foam::point
vector point
Point is a vector.
Definition: point.H:43