meshSurfaceOptimizerCalculateTrianglesAndAddressing.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "demandDrivenData.H"
29 #include "meshSurfaceOptimizer.H"
30 #include "meshSurfaceEngine.H"
31 
32 //#define DEBUGTriangulation
33 
34 # ifdef DEBUGTriangulation
35 #include "triSurf.H"
36 #include "triSurfModifier.H"
37 #include "helperFunctions.H"
38 # endif
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
48 {
49  if( triMeshPtr_ )
51  (
52  "void meshSurfaceOptimizer::calculateTrianglesAndAddressing() const"
53  ) << "Addressing is already calculated!" << abort(FatalError);
54 
56 
57  # ifdef DEBUGTriangulation
59 
60  forAll(sPoints, bpI)
61  {
62  triSurf surf;
63 
64  const label spI = sPoints[bpI];
65 
66  partTriMeshSimplex simplex(*triMeshPtr_, spI);
67 
68  triSurfModifier sMod(surf);
69 
70  pointField& pts = sMod.pointsAccess();
71  pts.setSize(simplex.pts().size());
72  forAll(pts, i)
73  pts[i] = simplex.pts()[i];
74 
75  LongList<labelledTri>& trias = sMod.facetsAccess();
76  trias.setSize(simplex.triangles().size());
77  forAll(trias, i)
78  {
79  const triFace& t = simplex.triangles()[i];
80  trias[i] = labelledTri(t[0], t[1], t[2], 0);
81  }
82 
83  sMod.patchesAccess().setSize(1);
84  sMod.patchesAccess()[0].name() = "bnd";
85  sMod.patchesAccess()[0].geometricType() = "patch";
86 
87  fileName sName("bndPointSimplex_");
88  sName += help::scalarToText(bpI);
89  sName += ".stl";
90  surf.writeSurface(sName);
91  }
92  # endif
93 }
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 } // End namespace Foam
98 
99 // ************************************************************************* //
triSurf.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::meshSurfaceOptimizer::triMeshPtr_
partTriMesh * triMeshPtr_
mesh of surface triangles needed for some smoothers
Definition: meshSurfaceOptimizer.H:83
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::partTriMeshSimplex
Definition: partTriMeshSimplex.H:52
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::partTriMesh::meshSurfacePointLabelInTriMesh
const labelList & meshSurfacePointLabelInTriMesh() const
Definition: partTriMesh.H:180
Foam::help::scalarToText
word scalarToText(const scalar s)
convert the scalar value into text
Definition: helperFunctionsStringConversion.C:61
triSurfModifier.H
Foam::triSurfModifier
Definition: triSurfModifier.H:48
Foam::triSurfModifier::patchesAccess
geometricSurfacePatchList & patchesAccess()
access to patches
Definition: triSurfModifierI.H:52
Foam::LongList::setSize
void setSize(const label)
Reset size of List.
Definition: LongListI.H:223
Foam::LongList
Definition: LongList.H:55
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurfModifier::pointsAccess
pointField & pointsAccess()
non-const access to points
Definition: triSurfModifierI.H:37
Foam::partTriMeshSimplex::pts
DynList< point, 32 > & pts()
return points
Definition: partTriMeshSimplex.H:72
Foam::triSurfModifier::facetsAccess
LongList< labelledTri > & facetsAccess()
access to facets
Definition: triSurfModifierI.H:42
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
meshSurfaceEngine.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::partTriMesh
Definition: partTriMesh.H:59
Foam::meshSurfaceOptimizer::calculateTrianglesAndAddressing
void calculateTrianglesAndAddressing() const
calculate surface triangulation
Definition: meshSurfaceOptimizerCalculateTrianglesAndAddressing.C:47
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::triFace
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:68
helperFunctions.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::labelledTri
Triangle with additional region number.
Definition: labelledTri.H:49
Foam::triSurf::writeSurface
void writeSurface(const fileName &) const
Definition: triSurf.C:430
Foam::partTriMeshSimplex::triangles
const DynList< triFace, 32 > & triangles() const
return triangles
Definition: partTriMeshSimplex.H:84
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::triSurf
Definition: triSurf.H:59
meshSurfaceOptimizer.H
Foam::meshSurfaceOptimizer::partitionerPtr_
const meshSurfacePartitioner * partitionerPtr_
surface partitioner
Definition: meshSurfaceOptimizer.H:76