polyMeshGenModifierAddCells.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 "VRWGraphList.H"
30 #include "demandDrivenData.H"
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
38 {
39  Info << "Adding cells to the mesh" << endl;
40 
41  faceListPMG& faces = mesh_.faces_;
43 
44  VRWGraph& pointFaces = this->pointFaces();
45 
46  //- start adding cells into the mesh
47  label nFaces = faces.size();
48  label nCells = cells.size();
49 
50  forAll(cellFaces, cI)
51  {
52  const faceList& facesInCell = cellFaces[cI];
53 
54  label fI(0);
55  cell c(cellFaces[cI].size());
56 
57  forAll(facesInCell, faceI)
58  {
59  const face& f = facesInCell[faceI];
60 
61  const label pointI = f[0];
62 
63  label fLabel(-1);
64  forAllRow(pointFaces, pointI, pfI)
65  {
66  const label faceI = pointFaces(pointI, pfI);
67 
68  if( faces[faceI] == f )
69  {
70  fLabel = faceI;
71  break;
72  }
73  }
74 
75  if( fLabel == -1 )
76  {
77  faces.append(f);
78  c[fI++] = nFaces;
79 
80  forAll(f, pI)
81  pointFaces.append(f[pI], nFaces);
82 
83  ++nFaces;
84  }
85  else
86  {
87  c[fI++] = fLabel;
88  }
89  }
90 
91  cells.append(c);
92  ++nCells;
93  }
94 
95  this->clearOut();
96  mesh_.clearOut();
97 
98  Info << "Finished adding cells to the mesh" << endl;
99 }
100 
102 {
103  Info << "Adding " << cellFaces.size() << " cells to the mesh" << endl;
104 
105  faceListPMG& faces = mesh_.faces_;
107 
108  VRWGraph& pointFaces = this->pointFaces();
109 
110  //- start adding cells into the mesh
111  label nFaces = faces.size();
112  label nCells = cells.size();
113 
114  forAll(cellFaces, cI)
115  {
116  faceList facesInCell(cellFaces.sizeOfGraph(cI));
117  forAll(facesInCell, fI)
118  {
119  facesInCell[fI].setSize(cellFaces.sizeOfRow(cI, fI));
120 
121  forAll(facesInCell[fI], pI)
122  facesInCell[fI][pI] = cellFaces(cI, fI, pI);
123  }
124 
125  label fI(0);
126  cell c(facesInCell.size());
127 
128  forAll(facesInCell, faceI)
129  {
130  const face& f = facesInCell[faceI];
131 
132  const label pointI = f[0];
133 
134  label fLabel(-1);
135  forAllRow(pointFaces, pointI, pfI)
136  {
137  const label faceI = pointFaces(pointI, pfI);
138 
139  if( faces[faceI] == f )
140  {
141  fLabel = faceI;
142  break;
143  }
144  }
145 
146  if( fLabel == -1 )
147  {
148  faces.append(f);
149  c[fI++] = nFaces;
150 
151  forAll(f, pI)
152  pointFaces.append(f[pI], nFaces);
153 
154  ++nFaces;
155  }
156  else
157  {
158  c[fI++] = fLabel;
159  }
160  }
161 
162  cells.append(c);
163  ++nCells;
164  }
165 
166  this->clearOut();
167  mesh_.clearOut();
168 
169  Info << "Finished adding cells to the mesh" << endl;
170 }
171 
173 {
174  faceListPMG& faces = this->facesAccess();
175  cellListPMG& cells = this->cellsAccess();
176 
177  label nFaces = faces.size();
178 
179  VRWGraph& pointFaces = this->pointFaces();
180 
181  cell c(cellFaces.size());
182  label fI(0);
183 
184  forAll(cellFaces, faceI)
185  {
186  const face& f = cellFaces[faceI];
187 
188  const label pointI = f[0];
189 
190  label fLabel(-1);
191  forAllRow(pointFaces, pointI, pfI)
192  {
193  const label faceI = pointFaces(pointI, pfI);
194 
195  if( faces[faceI] == f )
196  {
197  fLabel = faceI;
198  break;
199  }
200  }
201 
202  if( fLabel == -1 )
203  {
204  faces.append(f);
205  c[fI++] = nFaces;
206 
207  forAll(f, pI)
208  pointFaces.append(f[pI], nFaces);
209 
210  ++nFaces;
211  }
212  else
213  {
214  c[fI++] = fLabel;
215  }
216  }
217 
218  cells.append(c);
219  mesh_.clearOut();
220 }
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::VRWGraphList::sizeOfRow
label sizeOfRow(const label posI, const label rowI) const
Return the number of element in the row at the given position.
Definition: VRWGraphListI.H:107
Foam::VRWGraphList::size
label size() const
Returns the number of graphs.
Definition: VRWGraphListI.H:96
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::polyMeshGenModifier::pointFaces
VRWGraph & pointFaces()
Definition: polyMeshGenModifier.H:79
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
polyMeshGenModifier.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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
Foam::VRWGraphList
Definition: VRWGraphList.H:51
Foam::cellListPMG
Definition: cellListPMG.H:49
Foam::LongList
Definition: LongList.H:55
Foam::polyMeshGenModifier::cellsAccess
cellListPMG & cellsAccess()
access to cells
Definition: polyMeshGenModifier.H:119
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::polyMeshGenModifier::clearOut
void clearOut()
clear out unnecessary data (pointFacesPtr_);
Definition: polyMeshGenModifier.H:194
Foam::Info
messageStream Info
forAllRow
#define forAllRow(graph, rowI, index)
Definition: VRWGraph.H:277
Foam::faceListPMG::append
void append(const face &)
add a face at the end of the list
Definition: faceListPMGI.H:105
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::VRWGraphList::sizeOfGraph
label sizeOfGraph(const label posI) const
Returns the number of rows in the graph at that position.
Definition: VRWGraphListI.H:101
f
labelList f(nPoints)
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
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
Foam::VRWGraph::append
void append(const label rowI, const label)
Append an element to the given row.
Definition: VRWGraphI.H:303
Foam::polyMeshGenCells::cells_
cellListPMG cells_
list of cells
Definition: polyMeshGenCells.H:56
Foam::polyMeshGenModifier::addCell
void addCell(const faceList &cellFaces)
Definition: polyMeshGenModifierAddCells.C:172
Foam::polyMeshGenModifier::addCells
void addCells(const LongList< faceList > &cellFaces)
add cells (vertices must be added)
Definition: polyMeshGenModifierAddCells.C:37
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::polyMeshGenModifier::facesAccess
faceListPMG & facesAccess()
access to mesh faces
Definition: polyMeshGenModifier.H:113
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::faceListPMG
Definition: faceListPMG.H:50
Foam::VRWGraph
Definition: VRWGraph.H:101
VRWGraphList.H
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56