polyMeshGenModifierRemoveUnusedVertices.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 "polyMeshGenModifier.H"
29 #include "demandDrivenData.H"
30 #include "labelList.H"
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
38 {
39  faceListPMG& faces = mesh_.faces_;
41 
42  boolList usePoint(points.size(), false);
43  forAll(faces, faceI)
44  {
45  const face& f = faces[faceI];
46 
47  forAll(f, pI)
48  usePoint[f[pI]] = true;
49  }
50 
51  labelLongList newLabel(points.size(), -1);
52  label nPoints(0);
53  forAll(points, pI)
54  if( usePoint[pI] )
55  newLabel[pI] = nPoints++;
56 
57  //- remove unused points from the list
58  forAll(newLabel, pI)
59  if( (newLabel[pI] != -1) && (newLabel[pI] < pI) )
60  {
61  points[newLabel[pI]] = points[pI];
62  }
63 
64  points.setSize(nPoints);
65 
66  forAll(faces, faceI)
67  {
68  face& f = faces[faceI];
69 
70  forAll(f, pI)
71  f[pI] = newLabel[f[pI]];
72  }
73 
74  mesh_.updatePointSubsets(newLabel);
75 
76  mesh_.clearOut();
77  this->clearOut();
78 }
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 } // End namespace Foam
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
polyMeshGenModifier.H
Foam::polyMeshGenCells::clearOut
void clearOut() const
clear all pointer data
Definition: polyMeshGenCells.C:254
Foam::polyMeshGenModifier::mesh_
polyMeshGen & mesh_
reference to the mesh
Definition: polyMeshGenModifier.H:56
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::LongList< label >
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
labelList.H
Foam::polyMeshGenModifier::clearOut
void clearOut()
clear out unnecessary data (pointFacesPtr_);
Definition: polyMeshGenModifier.H:194
Foam::polyMeshGenPoints::updatePointSubsets
void updatePointSubsets(const ListType &)
Definition: polyMeshGenPointsI.H:138
Foam::polyMeshGenModifier::removeUnusedVertices
void removeUnusedVertices()
remove unused vertices
Definition: polyMeshGenModifierRemoveUnusedVertices.C:37
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
f
labelList f(nPoints)
Foam::polyMeshGenFaces::faces_
faceListPMG faces_
list of faces
Definition: polyMeshGenFaces.H:57
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
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::polyMeshGenPoints::points_
pointFieldPMG points_
list of vertices
Definition: polyMeshGenPoints.H:64
Foam::faceListPMG
Definition: faceListPMG.H:50
Foam::pointFieldPMG
Definition: pointFieldPMG.H:50