Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / tetrahedra / tetCreatorOctree / tetCreatorOctree.C
blob72504360f384da5a400d5fb4f0cc28f816ab22b2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9     This file is part of cfMesh.
11     cfMesh 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     cfMesh 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 cfMesh.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "tetCreatorOctree.H"
29 #include "meshOctree.H"
30 #include "demandDrivenData.H"
32 //#define DEBUGTets
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 const meshOctreeCubeCoordinates tetCreatorOctree::edgeCoordinates_[12][4]=
42     {
43         {    //- edge 0
44             meshOctreeCubeCoordinates(0, 0, 1, 0),
45             meshOctreeCubeCoordinates(0, -1, 1, 0),
46             meshOctreeCubeCoordinates(0, -1, 0, 0),
47             meshOctreeCubeCoordinates(0, 0, 0, 0)
48         },
49         {    //- edge 1
50             meshOctreeCubeCoordinates(0, 0, 0, 0),
51             meshOctreeCubeCoordinates(0, -1, 0, 0),
52             meshOctreeCubeCoordinates(0, -1, -1, 0),
53             meshOctreeCubeCoordinates(0, 0, -1, 0)
54         },
55         {   //- edge 2
56             meshOctreeCubeCoordinates(0, 1, 0, 0),
57             meshOctreeCubeCoordinates(0, 0, 0, 0),
58             meshOctreeCubeCoordinates(0, 0, -1, 0),
59             meshOctreeCubeCoordinates(0, 1, -1, 0)
60         },
61         {    //- edge 3
62             meshOctreeCubeCoordinates(0, 1, 1, 0),
63             meshOctreeCubeCoordinates(0, 0, 1, 0),
64             meshOctreeCubeCoordinates(0, 0, 0, 0),
65             meshOctreeCubeCoordinates(0, 1, 0, 0)
66         },
67         {    //- edge 4
68             meshOctreeCubeCoordinates(0, 0, 0, 0),
69             meshOctreeCubeCoordinates(0, 0, 1, 0),
70             meshOctreeCubeCoordinates(1, 0, 1, 0),
71             meshOctreeCubeCoordinates(1, 0, 0, 0)
72         },
73         {    //- edge 5
74             meshOctreeCubeCoordinates(0, 0, -1, 0),
75             meshOctreeCubeCoordinates(0, 0, 0, 0),
76             meshOctreeCubeCoordinates(1, 0, 0, 0),
77             meshOctreeCubeCoordinates(1, 0, -1, 0)
78         },
79         {   //- edge 6
80             meshOctreeCubeCoordinates(-1, 0, -1, 0),
81             meshOctreeCubeCoordinates(-1, 0, 0, 0),
82             meshOctreeCubeCoordinates(0, 0, 0, 0),
83             meshOctreeCubeCoordinates(0, 0, -1, 0)
84         },
85         {    //- edge 7
86             meshOctreeCubeCoordinates(-1, 0, 0, 0),
87             meshOctreeCubeCoordinates(-1, 0, 1, 0),
88             meshOctreeCubeCoordinates(0, 0, 1, 0),
89             meshOctreeCubeCoordinates(0, 0, 0, 0)
90         },
91         {    //- edge 8
92             meshOctreeCubeCoordinates(-1, 0, 0, 0),
93             meshOctreeCubeCoordinates(-1, -1, 0, 0),
94             meshOctreeCubeCoordinates(0, -1, 0, 0),
95             meshOctreeCubeCoordinates(0, 0, 0, 0)
96         },
97         {    //- edge 9
98             meshOctreeCubeCoordinates(0, 0, 0, 0),
99             meshOctreeCubeCoordinates(0, -1, 0, 0),
100             meshOctreeCubeCoordinates(1, -1, 0, 0),
101             meshOctreeCubeCoordinates(1, 0, 0, 0)
102         },
103         {   //- edge 10
104             meshOctreeCubeCoordinates(0, 1, 0, 0),
105             meshOctreeCubeCoordinates(0, 0, 0, 0),
106             meshOctreeCubeCoordinates(1, 0, 0, 0),
107             meshOctreeCubeCoordinates(1, 1, 0, 0)
108         },
109         {    //- edge 11
110             meshOctreeCubeCoordinates(-1, 1, 0, 0),
111             meshOctreeCubeCoordinates(-1, 0, 0, 0),
112             meshOctreeCubeCoordinates(0, 0, 0, 0),
113             meshOctreeCubeCoordinates(0, 1, 0, 0)
114         }
115     };
117 const label tetCreatorOctree::faceCentreHelper_[3][4] =
118     {
119         {3, 5, 2, 4},
120         {5, 1, 4, 0},
121         {1, 3, 0, 2}
122     };
124 void tetCreatorOctree::createTets()
126     createPointsAndAddressing();
128     createTetsFromFacesWithCentreNode();
130     createTetsAroundSplitEdges();
132     createTetsAroundEdges();
134     createTetsFromSplitFaces();
136     clearOut();
137     sortedLeaves_.setSize(0);
139     created_ = true;
142 void tetCreatorOctree::clearOut()
144     sortedLeaves_.clear();
145     deleteDemandDrivenData(subNodeLabelsPtr_);
146     deleteDemandDrivenData(cubeLabelPtr_);
147     deleteDemandDrivenData(faceCentreLabelPtr_);
150 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
152 // Construct from octree and mesh data
153 tetCreatorOctree::tetCreatorOctree
155     const meshOctree& octree,
156     const IOdictionary& meshDict
159     octreeCheck_(octree, meshDict, true),
160     tetPoints_(),
161     tets_(),
162     sortedLeaves_(),
163     subNodeLabelsPtr_(NULL),
164     cubeLabelPtr_(NULL),
165     faceCentreLabelPtr_(NULL),
166     created_(false)
168     createTets();
170     clearOut();
173 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
175 tetCreatorOctree::~tetCreatorOctree()
177     clearOut();
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //