meshToMeshDataI.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) 2017-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 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 :
34  tgtCelli_(-2)
35 {}
36 
37 
38 inline Foam::meshToMeshData::meshToMeshData(const label tgtCelli)
39 :
40  tgtCelli_(tgtCelli)
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 
46 template<class TrackingData>
47 inline bool Foam::meshToMeshData::valid(TrackingData& td) const
48 {
49  return tgtCelli_ != -2;
50 }
51 
52 
53 // No geometric data so never any problem on cyclics
54 template<class TrackingData>
56 (
57  const polyMesh&,
58  const meshToMeshData&,
59  const scalar,
60  TrackingData& td
61 ) const
62 {
63  return true;
64 }
65 
66 
67 template<class TrackingData>
69 (
70  const polyMesh&,
71  const polyPatch& patch,
72  const label patchFacei,
73  const point& faceCentre,
74  TrackingData& td
75 )
76 {}
77 
78 
79 template<class TrackingData>
81 (
82  const polyMesh&,
83  const tensor& rotTensor,
84  TrackingData& td
85 )
86 {}
87 
88 
89 // Update absolute geometric quantities.
90 template<class TrackingData>
92 (
93  const polyMesh&,
94  const polyPatch& patch,
95  const label patchFacei,
96  const point& faceCentre,
97  TrackingData& td
98 )
99 {}
100 
101 
102 // Update cell with neighbouring face information
103 template<class TrackingData>
105 (
106  const polyMesh& mesh,
107  const label thisCelli,
108  const label neighbourFacei,
109  const meshToMeshData& neighbourInfo,
110  const scalar tol,
111  TrackingData& td
112 )
113 {
114  if (!valid(td))
115  {
116  const point& cc = mesh.cellCentres()[thisCelli];
117 
118  // See if we are in the neighbour
119  const label tgti = neighbourInfo.tgtCelli_;
120 
121  // Try match of neighbour
122  if (td.tgtMesh_.pointInCell(cc, tgti, polyMesh::CELL_TETS))
123  {
124  tgtCelli_ = tgti;
125  return true;
126  }
127 
128  // Try match of neighbour's neighbours
129  const labelList& tgtNbrs = td.tgtMesh_.cellCells(tgti);
130  for (const label tgti : tgtNbrs)
131  {
132  // Try match of neighbour
133  if (td.tgtMesh_.pointInCell(cc, tgti, polyMesh::CELL_TETS))
134  {
135  tgtCelli_ = tgti;
136  return true;
137  }
138  }
139 
140  // Leave unmatched cell for visit from different face
141  }
142 
143  return false;
144 }
145 
146 
147 // Update face with neighbouring cell information
148 template<class TrackingData>
150 (
151  const polyMesh& mesh,
152  const label thisFacei,
153  const label neighbourCelli,
154  const meshToMeshData& neighbourInfo,
155  const scalar tol,
156  TrackingData& td
157 )
158 {
159  if (!valid(td))
160  {
161  tgtCelli_ = neighbourInfo.tgtCelli_;
162  return true;
163  }
164 
165  return false;
166 }
167 
168 
169 // Update face with coupled face information
170 template<class TrackingData>
172 (
173  const polyMesh& mesh,
174  const label thisFacei,
175  const meshToMeshData& neighbourInfo,
176  const scalar tol,
177  TrackingData& td
178 )
179 {
180  if (!valid(td))
181  {
182  tgtCelli_ = neighbourInfo.tgtCelli_;
183  return true;
184  }
185 
186  return false;
187 }
188 
189 
190 template<class TrackingData>
191 inline bool Foam::meshToMeshData::equal
192 (
193  const meshToMeshData& rhs,
194  TrackingData& td
195 ) const
196 {
197  if (!valid(td))
198  {
199  return (!rhs.valid(td));
200  }
201  else
202  {
203  return operator==(rhs);
204  }
205 }
206 
207 
208 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
209 
210 inline bool Foam::meshToMeshData::operator==
211 (
212  const meshToMeshData& rhs
213 ) const
214 {
215  return tgtCelli_ == rhs.tgtCelli_;
216 }
217 
218 
219 inline bool Foam::meshToMeshData::operator!=
220 (
221  const meshToMeshData& rhs
222 ) const
223 {
224  return !(*this == rhs);
225 }
226 
227 
228 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::meshToMeshData::transform
void transform(const polyMesh &, const tensor &, TrackingData &)
Apply rotation matrix to any coordinates.
Definition: meshToMeshDataI.H:81
polyMesh.H
Foam::meshToMeshData
Transfers refinement levels such that slow transition between levels is maintained....
Definition: meshToMeshData.H:62
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::meshToMeshData::updateFace
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const meshToMeshData &neighbourInfo, const scalar tol, TrackingData &)
Influence of neighbouring cell.
Definition: meshToMeshDataI.H:150
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:84
Foam::polyMesh::CELL_TETS
Definition: polyMesh.H:109
Foam::meshToMeshData::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &)
Definition: meshToMeshDataI.H:69
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::List< label >
Foam::meshToMeshData::valid
bool valid(TrackingData &) const
Changed or contains original (invalid) value.
Definition: meshToMeshDataI.H:47
Foam::meshToMeshData::sameGeometry
bool sameGeometry(const polyMesh &, const meshToMeshData &, const scalar, TrackingData &) const
Check for identical geometrical data (eg, cyclics checking)
Definition: meshToMeshDataI.H:56
Foam::meshToMeshData::enterDomain
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &)
Reverse of leaveDomain.
Definition: meshToMeshDataI.H:92
Foam::meshToMeshData::meshToMeshData
meshToMeshData()
Default construct.
Definition: meshToMeshDataI.H:32
Foam::meshToMeshData::equal
bool equal(const meshToMeshData &, TrackingData &) const
Test for equality, with TrackingData.
Definition: meshToMeshDataI.H:192
Foam::meshToMeshData::updateCell
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const meshToMeshData &neighbourInfo, const scalar tol, TrackingData &)
Influence of neighbouring face.
Definition: meshToMeshDataI.H:105