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 \*---------------------------------------------------------------------------*/
29 #include "partTriMeshSimplex.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 partTriMeshSimplex::partTriMeshSimplex
42 const partTriMesh& tm,
49 const pointField& points = tm.points();
50 const LongList<labelledTri>& trias = tm.triangles();
51 const VRWGraph& pt = tm.pointTriangles();
52 const LongList<direction>& pType = tm.pointType();
54 //trias_.setSize(pt.sizeOfRow(pI));
57 Map<label> addr(2*pt.sizeOfRow(pI));
60 const labelledTri& tri = trias[pt(pI, tI)];
61 for(label i=0;i<3;++i)
63 const label tpI = tri[i];
65 if( !addr.found(tpI) )
67 addr.insert(tpI, counter);
68 pts_.append(points[tpI]);
74 Info << "Tet " << tetI << " is " << tet << endl;
78 for(label i=0;i<3;++i)
85 //- avoid using triangle serving as barriers for other points
86 if( !(pType[tri[2]] & partTriMesh::FACECENTRE) && (pos != 0) )
95 triFace(addr[tri[0]], addr[tri[1]], addr[tri[2]])
102 triFace(addr[tri[1]], addr[tri[2]], addr[tri[0]])
109 triFace(addr[tri[2]], addr[tri[0]], addr[tri[1]])
116 "partTriMeshSimplex::partTriMeshSimplex("
117 "(const partTriMesh& tm, const label pI)"
118 ) << "Point " << pI << " is not present in triangle" << tri
119 << abort(FatalError);
125 Info << "Simplex at point " << pI << " points " << pts_ << endl;
126 Info << "Simplex at point " << pI << " triangles " << trias_ << endl;
129 if( pts_.size() == 0 || trias_.size() == 0 )
130 FatalError << "Simplex at point " << pI << " is not valid "
131 << pts_ << " triangles " << trias_ << abort(FatalError);
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 partTriMeshSimplex::~partTriMeshSimplex()
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 vector partTriMeshSimplex::normal() const
143 vector normal(vector::zero);
148 const triFace& t = trias_[tI];
152 0.5 * ((pts_[t[1]] - pts_[t[0]]) ^ (pts_[t[2]] - pts_[t[0]]))
154 const scalar magn = mag(n);
160 return (normal / (magN + VSMALL));
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace Foam
167 // ************************************************************************* //