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-2019 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 
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  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  forAll(tgtNbrs, i)
131  {
132  label tgti = tgtNbrs[i];
133 
134  // Try match of neighbour
135  if (td.tgtMesh_.pointInCell(cc, tgti, polyMesh::CELL_TETS))
136  {
137  tgtCelli_ = tgti;
138  return true;
139  }
140  }
141 
142  // Leave unmatched cell for visit from different face
143  }
144 
145  return false;
146 }
147 
148 
149 // Update face with neighbouring cell information
150 template<class TrackingData>
152 (
153  const polyMesh& mesh,
154  const label thisFacei,
155  const label neighbourCelli,
156  const meshToMeshData& neighbourInfo,
157  const scalar tol,
158  TrackingData& td
159 )
160 {
161  if (!valid(td))
162  {
163  tgtCelli_ = neighbourInfo.tgtCelli_;
164  return true;
165  }
166 
167  return false;
168 }
169 
170 
171 // Update face with coupled face information
172 template<class TrackingData>
174 (
175  const polyMesh& mesh,
176  const label thisFacei,
177  const meshToMeshData& neighbourInfo,
178  const scalar tol,
179  TrackingData& td
180 )
181 {
182  if (!valid(td))
183  {
184  tgtCelli_ = neighbourInfo.tgtCelli_;
185  return true;
186  }
187 
188  return false;
189 }
190 
191 
192 template<class TrackingData>
193 inline bool Foam::meshToMeshData::equal
194 (
195  const meshToMeshData& rhs,
196  TrackingData& td
197 ) const
198 {
199  if (!valid(td))
200  {
201  return (!rhs.valid(td));
202  }
203  else
204  {
205  return operator==(rhs);
206  }
207 }
208 
209 
210 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
211 
212 inline bool Foam::meshToMeshData::operator==
213 (
214  const Foam::meshToMeshData& rhs
215 ) const
216 {
217  return tgtCelli_ == rhs.tgtCelli_;
218 }
219 
220 
221 inline bool Foam::meshToMeshData::operator!=
222 (
223  const Foam::meshToMeshData& rhs
224 ) const
225 {
226  return !(*this == rhs);
227 }
228 
229 
230 // ************************************************************************* //
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
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::label
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:62
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:66
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:152
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:176
Foam::polyMesh::CELL_TETS
Definition: polyMesh.H:110
Foam::meshToMeshData::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &)
Convert any absolute coordinates into relative to (patch)face.
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
Check whether origin has been changed at all or.
Definition: meshToMeshDataI.H:47
Foam::meshToMeshData::sameGeometry
bool sameGeometry(const polyMesh &, const meshToMeshData &, const scalar, TrackingData &) const
Check for identical geometrical data. Used for 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()
Construct null.
Definition: meshToMeshDataI.H:32
Foam::meshToMeshData::equal
bool equal(const meshToMeshData &, TrackingData &) const
Same (like operator==)
Definition: meshToMeshDataI.H:194
Foam::meshToMeshData::tgtCelli_
label tgtCelli_
Definition: meshToMeshData.H:87
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