1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
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
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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "tetCreatorOctree.H"
29 #include "demandDrivenData.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void tetCreatorOctree::createTetsFromFacesWithCentreNode()
42 Info << "Creating tets from faces with centre node" << endl;
44 const labelList& cubeLabel = *cubeLabelPtr_;
45 const VRWGraph& nodeLabels = octreeCheck_.nodeLabels();
46 const VRWGraph& subNodeLabels = *subNodeLabelsPtr_;
47 const FRWGraph<label, 8>& pointLeaves = octreeCheck_.nodeLeaves();
49 if( !faceCentreLabelPtr_ )
50 faceCentreLabelPtr_ = new VRWGraph(cubeLabel.size());
51 VRWGraph& faceCentreLabel = *faceCentreLabelPtr_;
53 //- start creating tets
54 forAll(pointLeaves, pointI)
59 for(label plI=0;plI<8;++plI)
61 pl[plI] = pointLeaves(pointI, plI);
72 //- create 6 tets for each possible combination
73 //- there are 12 possible combinations
74 for(label fI=0;fI<6;++fI)
76 const label* fEdges = meshOctreeCubeCoordinates::faceEdges_[fI];
78 for(label feI=0;feI<2;++feI)
80 const label feJ = feI + 2;
82 //- the are two possible combinations of edges for each face
84 meshOctreeCubeCoordinates::edgeNodes_[fEdges[feI]];
86 meshOctreeCubeCoordinates::edgeNodes_[fEdges[feJ]];
88 const label sp = sEdge[0];
89 const label ep = eEdge[0];
91 if( pl[sp] == pl[ep] )
93 if( pl[sp] != pl[sEdge[1]] )
95 if( pl[ep] != pl[eEdge[1]] )
99 Info << "Octree node " << pointI << " has leaves";
100 for(label plI=0;plI<8;++plI)
101 Info << ' ' << pointLeaves(pointI, plI);
103 Info << "Searching face " << fI << endl;
104 Info << "Searching face edge " << feI << endl;
107 //- allocate face centre labels
108 if( faceCentreLabel.sizeOfRow(pl[sp]) == 0 )
110 faceCentreLabel.setRowSize(pl[sp], 6);
111 forAllRow(faceCentreLabel, pl[sp], k)
112 faceCentreLabel(pl[sp], k) = -1;
114 if( faceCentreLabel.sizeOfRow(pl[ep]) == 0 )
116 faceCentreLabel.setRowSize(pl[ep], 6);
117 forAllRow(faceCentreLabel, pl[ep], k)
118 faceCentreLabel(pl[ep], k) = -1;
120 //- create centre labels
123 fs = meshOctreeCubeCoordinates::edgeFaces_[fEdges[feJ]][0];
125 fs = meshOctreeCubeCoordinates::edgeFaces_[fEdges[feJ]][1];
127 fe = meshOctreeCubeCoordinates::edgeFaces_[fEdges[feI]][0];
129 fe = meshOctreeCubeCoordinates::edgeFaces_[fEdges[feI]][1];
132 Info << "Face for the cube at edge " << feI << " is "
134 Info << "Face for the cube at edge " << feJ << " is "
138 //- create face centre point
139 if( faceCentreLabel(pl[sp], fs) == -1 )
141 faceCentreLabel(pl[sp], fs) = tetPoints_.size();
142 faceCentreLabel(pl[ep], fe) = tetPoints_.size();
143 point p(vector::zero);
144 const label* fn = meshOctreeCubeCoordinates::faceNodes_[fe];
145 for(label i=0;i<4;++i)
146 p += tetPoints_[nodeLabels(pl[ep], fn[i])];
148 tetPoints_.append(p);
151 //- create tets connecting centroids
156 faceCentreLabel(pl[sp], fs),
157 subNodeLabels(pl[ep], 7-eEdge[0]),
158 subNodeLabels(pl[ep], 7-eEdge[1]),
166 faceCentreLabel(pl[sp], fs),
167 subNodeLabels(pl[sp], 7-sEdge[1]),
168 subNodeLabels(pl[sp], 7-sEdge[0]),
173 FixedList<label, 4> subNodes;
174 subNodes[0] = subNodeLabels(pl[sp], 7-sEdge[1]);
175 subNodes[1] = subNodeLabels(pl[sp], 7-sEdge[0]);
176 subNodes[2] = subNodeLabels(pl[ep], 7-eEdge[0]);
177 subNodes[3] = subNodeLabels(pl[ep], 7-eEdge[1]);
180 Info << "Sub nodes are " << subNodes << endl;
183 forAll(subNodes, nodeI)
191 subNodes[(nodeI+1)%4],
192 faceCentreLabel(pl[sEdge[0]], fs)
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace Foam
205 // ************************************************************************* //