Merge branch 'upstream/OpenFOAM' into master
[freefoam.git] / src / autoMesh / autoHexMesh / autoHexMeshDriver / autoHexMeshDriver.H
blob4e05284d511eee986736fc7c6f44282d4afc69db
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::autoHexMeshDriver
28 Description
29     main meshing driver.
31 SourceFiles
32     autoHexMeshDriver.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef autoHexMeshDriver_H
37 #define autoHexMeshDriver_H
39 #include <OpenFOAM/autoPtr.H>
40 #include <OpenFOAM/dictionary.H>
41 #include <meshTools/wallPoint.H>
42 #include <meshTools/searchableSurfaces.H>
43 #include <autoMesh/refinementSurfaces.H>
44 #include <autoMesh/shellSurfaces.H>
45 #include <autoMesh/meshRefinement.H>
46 #include <decompositionMethods/decompositionMethod.H>
47 #include <dynamicMesh/fvMeshDistribute.H>
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 // Class forward declarations
55 class fvMesh;
57 /*---------------------------------------------------------------------------*\
58                            Class autoHexMeshDriver Declaration
59 \*---------------------------------------------------------------------------*/
61 class autoHexMeshDriver
63     // Static data members
65         //- Extrusion controls
66         enum extrudeMode
67         {
68             NOEXTRUDE,      /*!< Do not extrude. No layers added. */
69             EXTRUDE,        /*!< Extrude */
70             EXTRUDEREMOVE   /*!< Extrude but afterwards remove added */
71                             /*!< faces locally */
72         };
75     // Private classes
77         //- Combine operator class for equalizing displacements.
78         class minMagEqOp
79         {
80         public:
82             void operator()(vector& x, const vector& y) const
83             {
84                 if (magSqr(y) < magSqr(x))
85                 {
86                     x = y;
87                 }
88             }
89         };
91         //- Combine operator class to combine normal with other normal.
92         class nomalsCombine
93         {
94         public:
96             void operator()(vector& x, const vector& y) const
97             {
98                 if (y != wallPoint::greatPoint)
99                 {
100                     if (x == wallPoint::greatPoint)
101                     {
102                         x = y;
103                     }
104                     else
105                     {
106                         x *= (x&y);
107                     }
108                 }
109             }
110         };
114     // Private data
116         //- Reference to mesh
117         fvMesh& mesh_;
119         //- Input dictionary
120         const dictionary dict_;
122         //- Debug level
123         const label debug_;
125         //- Merge distance
126         const scalar mergeDist_;
129         //- All surface based geometry
130         autoPtr<searchableSurfaces> allGeometryPtr_;
132         //- Shells (geometry for inside/outside refinement)
133         autoPtr<shellSurfaces> shellsPtr_;
135         //- Surfaces (geometry for intersection based refinement)
136         autoPtr<refinementSurfaces> surfacesPtr_;
138         //- Per refinement surface region the patch
139         labelList globalToPatch_;
141         //- Mesh refinement engine
142         autoPtr<meshRefinement> meshRefinerPtr_;
144         //- Decomposition engine
145         autoPtr<decompositionMethod> decomposerPtr_;
147         //- Mesh distribution engine
148         autoPtr<fvMeshDistribute> distributorPtr_;
152     // Private Member Functions
154         //- Calculate merge distance. Check against writing tolerance.
155         scalar getMergeDistance(const scalar mergeTol) const;
157         //static void orientOutside(PtrList<searchableSurface>&);
159         //- Disallow default bitwise copy construct
160         autoHexMeshDriver(const autoHexMeshDriver&);
162         //- Disallow default bitwise assignment
163         void operator=(const autoHexMeshDriver&);
165 public:
167     //- Runtime type information
168     ClassName("autoHexMeshDriver");
171     // Constructors
173         //- Construct from dictionary and mesh to modify
174         autoHexMeshDriver
175         (
176             fvMesh& mesh,
177             const bool overwrite,
178             const dictionary& meshDict,
179             const dictionary& decomposeDict
180         );
183     // Member Functions
185         // Access
187             //- reference to mesh
188             const fvMesh& mesh() const
189             {
190                 return mesh_;
191             }
192             fvMesh& mesh()
193             {
194                 return mesh_;
195             }
197             //- Surfaces to base refinement on
198             const refinementSurfaces& surfaces() const
199             {
200                 return surfacesPtr_();
201             }
203             //- Surfaces to volume refinement on
204             const shellSurfaces& shells() const
205             {
206                 return shellsPtr_();
207             }
209             //- Per refinementsurface, per region the patch
210             const labelList& globalToPatch() const
211             {
212                 return globalToPatch_;
213             }
216         // Meshing
218             //- Write mesh
219             void writeMesh(const string&) const;
221             //- Do all : refine, snap, layers
222             void doMesh();
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 } // End namespace Foam
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 #endif
234 // ************************ vim: set sw=4 sts=4 et: ************************ //