polyMeshGenModifierAddCellByCell.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 
29 #include "demandDrivenData.H"
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
37 (
39 )
40 :
42  nFaces_(mesh.faces().size()),
43  newFaces_(nFaces_),
44  nCells_(mesh.cells().size()),
45  newCells_(nCells_)
46 {
47  this->pointFaces();
48  faceListPMG& faces = this->facesAccess();
49  forAll(faces, faceI)
50  newFaces_[faceI].transfer(faces[faceI]);
51 
52  cellListPMG& cells = this->cellsAccess();
53  forAll(cells, cellI)
54  newCells_[cellI].transfer(cells[cellI]);
55 };
56 
57 // Destructor
59 {
60  faceListPMG& faces = this->facesAccess();
61  faces.setSize(nFaces_);
62  forAll(faces, faceI)
63  faces[faceI].transfer(newFaces_[faceI]);
64 
65  cellListPMG& cells = this->cellsAccess();
66  cells.setSize(newCells_.size());
67  forAll(cells, cellI)
68  cells[cellI].transfer(newCells_[cellI]);
69 }
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
74 {
75  cell c(cellFaces.size());
76 
77  VRWGraph& pointFaces = this->pointFaces();
78 
79  forAll(cellFaces, faceI)
80  {
81  const face& f = cellFaces[faceI];
82 
83  const label pointI = f[0];
84 
85  label fLabel(-1);
86  forAllRow(pointFaces, pointI, pfI)
87  {
88  const label faceI = pointFaces(pointI, pfI);
89 
90  if( newFaces_[faceI] == f )
91  {
92  fLabel = faceI;
93  break;
94  }
95  }
96 
97  if( fLabel == -1 )
98  {
99  newFaces_.append(f);
100  c[faceI] = nFaces_;
101  forAll(f, pI)
102  pointFaces.append(f[pI], nFaces_);
103 
104  ++nFaces_;
105  }
106  else
107  {
108  c[faceI] = fLabel;
109  }
110  }
111 
112  newCells_.append(c);
113  ++nCells_;
114 }
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 } // End namespace Foam
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
polyMeshGenModifierAddCellByCell.H
Foam::cellListPMG::setSize
void setSize(const label nElmts)
set the number of used elements
Definition: cellListPMGI.H:61
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.
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:136
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::cellListPMG
Definition: cellListPMG.H:49
Foam::polyMeshGenModifierAddCellByCell::nCells_
label nCells_
number of cells
Definition: polyMeshGenModifierAddCellByCell.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::polyMeshGenModifierAddCellByCell::nFaces_
label nFaces_
number of faces
Definition: polyMeshGenModifierAddCellByCell.H:51
Foam::faceListPMG::setSize
void setSize(const label nElmts)
set the number of used elements
Definition: faceListPMGI.H:78
Foam::polyMeshGenModifierAddCellByCell::polyMeshGenModifierAddCellByCell
polyMeshGenModifierAddCellByCell(polyMeshGen &mesh)
Construct from the reference to the mesh.
Definition: polyMeshGenModifierAddCellByCell.C:37
forAllRow
#define forAllRow(graph, rowI, index)
Definition: VRWGraph.H:277
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyMeshGenModifier
Definition: polyMeshGenModifier.H:52
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1004
f
labelList f(nPoints)
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::polyMeshGenModifierAddCellByCell::~polyMeshGenModifierAddCellByCell
~polyMeshGenModifierAddCellByCell()
Definition: polyMeshGenModifierAddCellByCell.C:58
Foam::polyMeshGenModifierAddCellByCell::newCells_
LongList< cell > newCells_
Definition: polyMeshGenModifierAddCellByCell.H:56
Foam::polyMeshGenModifierAddCellByCell::newFaces_
LongList< face > newFaces_
Definition: polyMeshGenModifierAddCellByCell.H:52
Foam::VRWGraph::append
void append(const label rowI, const label)
Append an element to the given row.
Definition: VRWGraphI.H:303
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
Foam::polyMeshGenModifierAddCellByCell::addCell
void addCell(const faceList &cell)
add a single cell (vertices must be added);
Definition: polyMeshGenModifierAddCellByCell.C:73
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Foam::faceListPMG::transfer
void transfer(faceList &)