1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
27 #include "meshTools.H"
28 #include "hexMatcher.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 inline Foam::directionInfo::directionInfo()
40 // Construct from components
41 inline Foam::directionInfo::directionInfo
53 inline Foam::directionInfo::directionInfo(const directionInfo& w2)
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 template<class TrackingData>
63 inline bool Foam::directionInfo::valid(TrackingData& td) const
69 // No geometric data so never any problem on cyclics
70 template<class TrackingData>
71 inline bool Foam::directionInfo::sameGeometry
74 const directionInfo& w2,
84 // index_ is already offset in face
85 template<class TrackingData>
86 inline void Foam::directionInfo::leaveDomain
89 const polyPatch& patch,
90 const label patchFaceI,
91 const point& faceCentre,
97 // index_ is offset in face on other side. So reverse it here.
98 // (Note: f[0] on other domain is connected to f[0] in this domain,
99 // f[1] ,, f[size-1] ,,
101 template<class TrackingData>
102 inline void Foam::directionInfo::enterDomain
105 const polyPatch& patch,
106 const label patchFaceI,
107 const point& faceCentre,
113 const face& f = patch[patchFaceI];
115 index_ = (f.size() - index_) % f.size();
120 // No geometric data.
121 template<class TrackingData>
122 inline void Foam::directionInfo::transform
125 const tensor& rotTensor,
131 // Update this cell with neighbouring face information
132 template<class TrackingData>
133 inline bool Foam::directionInfo::updateCell
135 const polyMesh& mesh,
136 const label thisCellI,
137 const label neighbourFaceI,
138 const directionInfo& neighbourInfo,
145 // Already determined.
149 if (hexMatcher().isA(mesh, thisCellI))
151 const face& f = mesh.faces()[neighbourFaceI];
153 if (neighbourInfo.index() == -2)
155 // Geometric information from neighbour
158 else if (neighbourInfo.index() == -1)
160 // Cut tangential to face. Take any edge connected to face
161 // but not used in face.
163 // Get first edge on face.
164 label edgeI = mesh.faceEdges()[neighbourFaceI][0];
166 const edge& e = mesh.edges()[edgeI];
168 // Find face connected to face through edgeI and on same cell.
178 // Find edge on faceI which is connected to e.start() but not edgeI.
183 mesh.faceEdges()[faceI],
190 // Index is a vertex on the face. Convert to mesh edge.
192 // Get mesh edge between f[index_] and f[index_+1]
193 label v0 = f[neighbourInfo.index()];
194 label v1 = f[(neighbourInfo.index() + 1) % f.size()];
196 index_ = findEdge(mesh, mesh.faceEdges()[neighbourFaceI], v0, v1);
201 // Not a hex so mark this as geometric.
206 n_ = neighbourInfo.n();
212 // Update this face with neighbouring cell information
213 template<class TrackingData>
214 inline bool Foam::directionInfo::updateFace
216 const polyMesh& mesh,
217 const label thisFaceI,
218 const label neighbourCellI,
219 const directionInfo& neighbourInfo,
224 // Handle special cases first
228 // Already determined
232 // Handle normal cases where topological or geometrical info comes from
235 if (neighbourInfo.index() >= 0)
237 // Neighbour has topological direction (and hence is hex). Find cut
245 neighbourInfo.index()
250 // Neighbour has geometric information. Use.
255 n_ = neighbourInfo.n();
261 // Merge this with information on same face
262 template<class TrackingData>
263 inline bool Foam::directionInfo::updateFace
265 const polyMesh& mesh,
266 const label, // thisFaceI
267 const directionInfo& neighbourInfo,
279 index_ = neighbourInfo.index();
281 n_ = neighbourInfo.n();
288 template <class TrackingData>
289 inline bool Foam::directionInfo::equal
291 const directionInfo& rhs,
295 return operator==(rhs);
299 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
301 inline bool Foam::directionInfo::operator==(const Foam::directionInfo& rhs)
304 return index() == rhs.index() && n() == rhs.n();
308 inline bool Foam::directionInfo::operator!=(const Foam::directionInfo& rhs)
311 return !(*this == rhs);
315 // ************************************************************************* //