patchFaceOrientationI.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) 2013 OpenFOAM Foundation
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 #include "orientedSurface.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
35 :
36  flipStatus_(orientedSurface::UNVISITED)
37 {}
38 
39 
41 (
42  const label flipStatus
43 )
44 :
45  flipStatus_(flipStatus)
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 
52 {
53  return flipStatus_;
54 }
55 
56 
58 {
59  if (flipStatus_ == orientedSurface::NOFLIP)
60  {
61  flipStatus_ = orientedSurface::FLIP;
62  }
63  else if (flipStatus_ == orientedSurface::FLIP)
64  {
65  flipStatus_ = orientedSurface::NOFLIP;
66  }
67 }
68 
69 
70 template<class TrackingData>
71 inline bool Foam::patchFaceOrientation::valid(TrackingData& td) const
72 {
73  return flipStatus_ != orientedSurface::UNVISITED;
74 }
75 
76 
77 template<class TrackingData>
79 (
80  const polyMesh& mesh,
82  const tensor& rotTensor,
83  const scalar tol,
84  TrackingData& td
85 )
86 {}
87 
88 
89 template<class TrackingData>
91 (
92  const polyMesh& mesh,
94  const label edgeI,
95  const label facei,
96  const patchFaceOrientation& faceInfo,
97  const scalar tol,
98  TrackingData& td
99 )
100 {
101  if (valid(td))
102  {
103  return false;
104  }
105 
106  const face& f = patch.localFaces()[facei];
107  const edge& e = patch.edges()[edgeI];
108 
109  //Pout<< "Updating edge:" << edgeI << " verts:" << e << nl
110  // << " start:" << patch.localPoints()[e[0]] << nl
111  // << " end:" << patch.localPoints()[e[1]] << endl;
112 
113  patchFaceOrientation consistentInfo(faceInfo);
114 
115  // Check how edge relates to face
116  if (f.edgeDirection(e) < 0)
117  {
118  // Create flipped version of faceInfo
119  consistentInfo.flip();
120  }
121 
122  operator=(consistentInfo);
123  return true;
124 }
125 
126 
127 template<class TrackingData>
129 (
130  const polyMesh& mesh,
132  const patchFaceOrientation& edgeInfo,
133  const bool sameOrientation,
134  const scalar tol,
135  TrackingData& td
136 )
137 {
138  if (valid(td))
139  {
140  return false;
141  }
142 
143  // Create (flipped/unflipped) version of edgeInfo
144  patchFaceOrientation consistentInfo(edgeInfo);
145 
146  if (!sameOrientation)
147  {
148  consistentInfo.flip();
149  }
150 
151  operator=(consistentInfo);
152  return true;
153 }
154 
155 
156 template<class TrackingData>
158 (
159  const polyMesh& mesh,
161  const label facei,
162  const label edgeI,
163  const patchFaceOrientation& edgeInfo,
164  const scalar tol,
165  TrackingData& td
166 )
167 {
168  if (valid(td))
169  {
170  return false;
171  }
172 
173  // Transfer flip to face
174  const face& f = patch.localFaces()[facei];
175  const edge& e = patch.edges()[edgeI];
176 
177 
178  //Pout<< "Updating face:" << facei << nl
179  // << " verts:" << f << nl
180  // << " with edge:" << edgeI << nl
181  // << " start:" << patch.localPoints()[e[0]] << nl
182  // << " end:" << patch.localPoints()[e[1]] << endl;
183 
184 
185  // Create (flipped/unflipped) version of edgeInfo
186  patchFaceOrientation consistentInfo(edgeInfo);
187 
188  if (f.edgeDirection(e) > 0)
189  {
190  consistentInfo.flip();
191  }
192 
193  operator=(consistentInfo);
194  return true;
195 }
196 
197 
198 template<class TrackingData>
200 (
201  const patchFaceOrientation& rhs,
202  TrackingData& td
203 ) const
204 {
205  return operator==(rhs);
206 }
207 
208 
209 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
210 
211 inline bool Foam::patchFaceOrientation::operator==
212 (
213  const Foam::patchFaceOrientation& rhs
214 ) const
215 {
216  return flipStatus() == rhs.flipStatus();
217 }
218 
219 
220 inline bool Foam::patchFaceOrientation::operator!=
221 (
222  const Foam::patchFaceOrientation& rhs
223 ) const
224 {
225  return !(*this == rhs);
226 }
227 
228 
229 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::patchFaceOrientation::updateFace
bool updateFace(const polyMesh &mesh, const indirectPrimitivePatch &patch, const label facei, const label edgeI, const patchFaceOrientation &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on face.
Definition: patchFaceOrientationI.H:158
Foam::patchFaceOrientation
Transport of orientation for use in PatchEdgeFaceWave.
Definition: patchFaceOrientation.H:61
Foam::orientedSurface
Given point flip all faces such that normals point in same direction.
Definition: orientedSurface.H:54
Foam::patchFaceOrientation::transform
void transform(const polyMesh &mesh, const indirectPrimitivePatch &patch, const tensor &rotTensor, const scalar tol, TrackingData &td)
Apply rotation matrix.
Definition: patchFaceOrientationI.H:79
Foam::patchFaceOrientation::flip
void flip()
Reverse orientation.
Definition: patchFaceOrientationI.H:57
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::orientedSurface::NOFLIP
Definition: orientedSurface.H:67
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::patchFaceOrientation::updateEdge
bool updateEdge(const polyMesh &mesh, const indirectPrimitivePatch &patch, const label edgeI, const label facei, const patchFaceOrientation &faceInfo, const scalar tol, TrackingData &td)
Influence of face on edge.
Definition: patchFaceOrientationI.H:91
Foam::patchFaceOrientation::patchFaceOrientation
patchFaceOrientation()
Construct null.
Definition: patchFaceOrientationI.H:34
Foam::patchFaceOrientation::valid
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Definition: patchFaceOrientationI.H:71
Foam::orientedSurface::UNVISITED
Definition: orientedSurface.H:65
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::patchFaceOrientation::equal
bool equal(const patchFaceOrientation &, TrackingData &) const
Same (like operator==)
Definition: patchFaceOrientationI.H:200
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::orientedSurface::FLIP
Definition: orientedSurface.H:66
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
transform.H
3D tensor transformation operations.
orientedSurface.H
Foam::patchFaceOrientation::flipStatus
label flipStatus() const
Orientation.
Definition: patchFaceOrientationI.H:51
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90