directionalWallPointDataI.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) 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 // Update this with w2 if w2 nearer to pt.
36 template<class Type>
37 template<class TrackingData>
38 inline bool directionalWallPointData<Type>::update
39 (
40  const point& pt,
41  const directionalWallPointData<Type>& w2,
42  const scalar tol,
43  TrackingData& n
44 )
45 {
46  vector d(pt - w2.origin());
47  // Knock out component in direction of n
48  d -= n*(d&n);
49  scalar dist2 = magSqr(d);
50 
51  if (this->valid(n))
52  {
53  vector d(pt - this->origin());
54  // Knock out component in direction of n
55  d -= n*(d&n);
56  scalar currentDistSqr(magSqr(d));
57 
58  scalar diff = currentDistSqr - dist2;
59 
60  if (diff < 0)
61  {
62  // already nearer to pt
63  return false;
64  }
65 
66  if
67  (
68  (diff < SMALL)
69  || ((currentDistSqr > SMALL) && (diff/currentDistSqr < tol))
70  )
71  {
72  // don't propagate small changes
73  return false;
74  }
75  }
76 
77  // Either *this is not yet valid or w2 is closer
78  {
79  // current not yet set so use any value
80  this->distSqr() = magSqr(pt - w2.origin());
81  this->origin() = w2.origin();
82  this->data() = w2.data();
83 
84  return true;
85  }
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
91 // Null constructor
92 template<class Type>
94 :
95  wallPointData<Type>()
96 {}
97 
98 
99 // Construct from components
100 template<class Type>
102 (
103  const point& origin,
104  const Type& data,
105  const scalar distSqr
106 )
107 :
108  wallPointData<Type>(origin, data, distSqr)
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
114 // Update this with w2 if w2 nearer to pt.
115 template<class Type>
116 template<class TrackingData>
118 (
119  const polyMesh& mesh,
120  const label thisCelli,
121  const label,
122  const directionalWallPointData<Type>& neighbourWallInfo,
123  const scalar tol,
124  TrackingData& td
125 )
126 {
127  const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
128 
129  return update
130  (
131  cellCentres[thisCelli],
132  neighbourWallInfo,
133  tol,
134  td
135  );
136 }
137 
138 
139 // Update this with w2 if w2 nearer to pt.
140 template<class Type>
141 template<class TrackingData>
143 (
144  const polyMesh& mesh,
145  const label thisFacei,
146  const label,
147  const directionalWallPointData<Type>& neighbourWallInfo,
148  const scalar tol,
149  TrackingData& td
150 )
151 {
152  const vectorField& faceCentres = mesh.faceCentres();
153 
154  return update
155  (
156  faceCentres[thisFacei],
157  neighbourWallInfo,
158  tol,
159  td
160  );
161 }
162 
163 
164 // Update this with w2 if w2 nearer to pt.
165 template<class Type>
166 template<class TrackingData>
168 (
169  const polyMesh& mesh,
170  const label thisFacei,
171  const directionalWallPointData<Type>& neighbourWallInfo,
172  const scalar tol,
173  TrackingData& td
174 )
175 {
176  const vectorField& faceCentres = mesh.faceCentres();
177 
178  return update
179  (
180  faceCentres[thisFacei],
181  neighbourWallInfo,
182  tol,
183  td
184  );
185 }
186 
187 
188 // ************************************************************************* //
189 
190 } // End namespace Foam
191 
192 // ************************************************************************* //
update
mesh update()
Foam::directionalWallPointData::updateCell
bool updateCell(const polyMesh &mesh, const label thisCelli, const label neighbourFacei, const directionalWallPointData< Type > &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: directionalWallPointDataI.H:118
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::directionalWallPointData
Holds information (coordinate and normal) regarding the nearest wall point.
Definition: directionalWallPointData.H:51
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Field< vector >
Foam::directionalWallPointData::directionalWallPointData
directionalWallPointData()
Construct null.
Definition: directionalWallPointDataI.H:93
w2
#define w2
Definition: blockCreate.C:35
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H: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
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::directionalWallPointData::updateFace
bool updateFace(const polyMesh &mesh, const label thisFacei, const label neighbourCelli, const directionalWallPointData< Type > &neighbourWallInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: directionalWallPointDataI.H:143
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55