1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Various utility functions that perform mesh-related operations.
32 University of Massachusetts Amherst
39 \*---------------------------------------------------------------------------*/
52 #include "triPointRef.H"
53 #include "tetPointRef.H"
54 #include "vectorField.H"
55 #include "linePointRef.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 /*---------------------------------------------------------------------------*\
65 Namespace meshOps Declaration
66 \*---------------------------------------------------------------------------*/
70 // Method to find the common-edge between two faces.
71 inline bool findCommonEdge
75 const UList<labelList>& faceEdges,
79 // Method to find the interior/boundary faces
80 // for an input quad-face and adjacent triangle-prism cell.
81 inline void findPrismFaces
85 const UList<face>& faces,
86 const UList<cell>& cells,
87 const UList<label>& neighbour,
88 FixedList<face,2>& bdyf,
89 FixedList<label,2>& bidx,
90 FixedList<face,2>& intf,
91 FixedList<label,2>& iidx
94 // Utility method to build a hull of cells
95 // connected to the edge (for 2D simplical meshes)
96 inline void constructPrismHull
99 const UList<face>& faces,
100 const UList<cell>& cells,
101 const UList<label>& owner,
102 const UList<label>& neighbour,
103 const UList<labelList>& edgeFaces,
104 labelList& hullTriFaces,
108 // Utility method to build a hull of cells (and faces)
109 // around an edge (for 3D simplical meshes)
110 inline void constructHull
113 const UList<face>& faces,
114 const UList<edge>& edges,
115 const UList<cell>& cells,
116 const UList<label>& owner,
117 const UList<label>& neighbour,
118 const UList<labelList>& faceEdges,
119 const UList<labelList>& edgeFaces,
120 const labelList& hullVertices,
121 labelList& hullEdges,
122 labelList& hullFaces,
123 labelList& hullCells,
124 labelListList& ringEntities
127 // Utility method to find the isolated point
128 // given two triangular faces.
129 inline label findIsolatedPoint
131 const face& baseFace,
132 const face& checkFace
135 // Method to find the isolated point on a triangular face
136 // that doesn't lie on the specified edge
137 inline void findIsolatedPoint
145 // Given a face and cell index, find the apex point for a tet cell.
146 inline label tetApexPoint
150 const UList<face>& faces,
151 const UList<cell>& cells
154 // Given a cell index, find the centroid / volume of a cell.
155 inline void cellCentreAndVolume
158 const vectorField& points,
159 const UList<face>& faces,
160 const UList<cell>& cells,
161 const UList<label>& owner,
166 // Determine whether a segment intersects a triangular face
167 inline bool segmentTriFaceIntersection
169 const triPointRef& faceToCheck,
170 const linePointRef& edgeToCheck,
174 // Determine whether the particular point lies
175 // inside the given triangular face
176 inline bool pointInTriFace
178 const triPointRef& faceToCheck,
179 const vector& checkPoint,
183 // Dijkstra's algorithm for the shortest path problem
186 const Map<point>& points,
187 const Map<edge>& edges,
188 const label startPoint,
189 const label endPoint,
193 // Method to insert a label between two labels in a list
194 inline void insertLabel
196 const label newLabel,
202 // Utility method to replace a label in a given list
203 inline void replaceLabel
205 const label original,
206 const label replacement,
210 // Utility method to size-up the list to include an item
211 template <class Type>
212 inline void sizeUpList
218 // Utility method to size-down the list to remove an item
219 template <class Type>
220 inline void sizeDownList
226 // Remove an item at a particular index in the list
227 template <class Type>
228 inline void removeIndex
242 // Parallel send (for fixed lists)
243 template <class Type, unsigned Size>
247 const FixedList<Type,Size>& data
250 // Parallel send (for lists)
251 template <class Type>
255 const UList<Type>& data
266 // Parallel receive (for fixed lists)
267 template <class Type, unsigned Size>
271 FixedList<Type,Size>& data
274 // Parallel receive (for lists)
275 template <class Type>
282 // Wait for buffer transfer completion.
283 inline void waitForBuffers();
285 // Select a list of elements from connectivity,
286 // and output to a VTK format
289 const polyMesh& mesh,
291 const labelList& cList,
292 const label primitiveType,
293 const UList<point>& meshPoints,
294 const UList<edge>& edges = List<edge>(0),
295 const UList<face>& faces = List<face>(0),
296 const UList<cell>& cells = List<cell>(0),
297 const UList<label>& owner = List<label>(0),
298 const UList<scalar>& scalField = UList<scalar>(),
299 const UList<label>& lablField = UList<label>(),
300 const UList<vector>& vectField = UList<vector>()
303 // Actual routine to write out the VTK file
306 const polyMesh& mesh,
310 const label nTotalCells,
311 const vectorField& points,
312 const labelListList& cpList = labelListList(0),
313 const label primitiveType = 3,
314 const Map<label>& reversePointMap = Map<label>(),
315 const Map<label>& reverseCellMap = Map<label>(),
316 const UList<scalar>& scalField = UList<scalar>(),
317 const UList<label>& lablField = UList<label>(),
318 const UList<vector>& vectField = UList<vector>()
321 } // End namespace meshOps
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 // Add additional operations missing in ops.H
328 { public: T operator()(const T& x, const T& y) const { return x < y; } };
332 { public: T operator()(const T& x, const T& y) const { return x <= y; } };
336 { public: T operator()(const T& x, const T& y) const { return x > y; } };
340 { public: T operator()(const T& x, const T& y) const { return x >= y; } };
342 } // End namespace Foam
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 #include "meshOpsI.H"
349 # include "meshOps.C"
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 // ************************************************************************* //