twoPhaseEulerFoam:frictionalStressModel/Schaeffer: Correct mut on processor boundaries
[OpenFOAM-1.7.x.git] / src / dynamicMesh / boundaryMesh / octreeDataFaceList.H
blob8c5c2ad8e0a2113e21c8658ddea13abeeef993ce
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Class
25     Foam::octreeDataFaceList
27 Description
28     Holds data for octree to work on list of faces on a bMesh
29     (= PrimitivePatch which holds faces, not references them)
30     Same as octreeDataFace except for that.
32 SourceFiles
33     octreeDataFaceList.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef octreeDataFaceList_H
38 #define octreeDataFaceList_H
40 #include "treeBoundBoxList.H"
41 #include "faceList.H"
42 #include "point.H"
43 #include "className.H"
44 #include "bMesh.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
52 template<class Type> class octree;
54 /*---------------------------------------------------------------------------*\
55                            Class octreeDataFaceList Declaration
56 \*---------------------------------------------------------------------------*/
58 class octreeDataFaceList
60     // Static data
62         //- tolerance on linear dimensions
63         static scalar tol;
66     // Static function
68         static inline label nexti(label max, label i)
69         {
70             return (i + 1) % max;
71         }            
74     // Private data
76         //- the mesh
77         const bMesh& mesh_;
79         //- labels (in mesh indexing) of faces
80         labelList faceLabels_;
82         //- bbs for all above faces
83         treeBoundBoxList allBb_;
86     // Private Member Functions
88         //- Set allBb to tight fitting bounding box
89         void calcBb();
91 public:
93     // Declare name of the class and its debug switch
94     ClassName("octreeDataFaceList");
96     // Constructors
98         //- Construct from all faces in bMesh.
99         octreeDataFaceList(const bMesh& mesh);
101         //- Construct from selected faces in bMesh.
102         octreeDataFaceList(const bMesh& mesh, const labelList& faceLabels);
104         //- Construct as copy
105         octreeDataFaceList(const octreeDataFaceList&);
108     // Destructor
110         ~octreeDataFaceList();
113     // Member Functions
115         // Access
117             const bMesh& mesh() const
118             {
119                 return mesh_;
120             }
122             const labelList& faceLabels() const
123             {
124                 return faceLabels_;
125             }
127             const treeBoundBoxList& allBb() const
128             {
129                 return allBb_;
130             }
132             label size() const
133             {
134                 return allBb_.size();
135             }
137         // Search
139             //- Get type of sample
140             label getSampleType
141             (
142                 const octree<octreeDataFaceList>&,
143                 const point&
144             ) const;
146             //- Does (bb of) shape at index overlap bb
147             bool overlaps
148             (
149                 const label index,
150                 const treeBoundBox& sampleBb
151             ) const;
153             //- Does shape at index contain sample
154             bool contains
155             (
156                 const label index,
157                 const point& sample
158             ) const;
160             //- Segment (from start to end) intersection with shape
161             //  at index. If intersects returns true and sets intersectionPoint
162             bool intersects
163             (
164                 const label index,
165                 const point& start,
166                 const point& end,
167                 point& intersectionPoint
168             ) const;
170             //- Sets newTightest to bounding box (and returns true) if
171             //  nearer to sample than tightest bounding box. Otherwise
172             //  returns false.
173             bool findTightest
174             (
175                 const label index,
176                 const point& sample,
177                 treeBoundBox& tightest
178             ) const;
180             //- Given index get unit normal and calculate (numerical) sign 
181             //  of sample.
182             //  Used to determine accuracy of calcNearest or inside/outside.
183             scalar calcSign
184             (
185                 const label index,
186                 const point& sample,
187                 vector& n
188             ) const;
190             //- Calculates nearest (to sample) point in shape.
191             //  Returns point and mag(nearest - sample). Returns GREAT if
192             //  sample does not project onto (triangle decomposition) of face.
193             scalar calcNearest
194             (
195                 const label index,
196                 const point& sample,
197                 point& nearest
198             ) const;
201         // Edit
203         // Write
205             //- Write shape at index
206             void write(Ostream& os, const label index) const;
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace Foam
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 #endif
219 // ************************************************************************* //