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 \*---------------------------------------------------------------------------*/
28 #include "polyMeshGenModifier.H"
29 #include "demandDrivenData.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void polyMeshGenModifier::removeCells
42 const boolList& removeCell,
43 const bool removeProcFaces
46 Info << "Removing selected cells from the mesh" << endl;
50 faceListPMG& faces = mesh_.faces_;
51 cellListPMG& cells = mesh_.cells_;
53 if( removeCell.size() != cells.size() )
55 Info << "Size of cells " << cells.size() << endl;
56 Info << "Size of list for removal " << removeCell.size() << endl;
59 "void polyMeshGenModifier::removeCells(const boolList& removeCell)"
60 ) << "Incorrect number of entries in removeCell list!"
64 //- flip internal faces which will become boundary ones
65 const labelList& owner = mesh_.owner();
66 const labelList& neighbour = mesh_.neighbour();
69 # pragma omp parallel for schedule(dynamic, 40)
73 if( neighbour[faceI] == -1 )
79 if( removeCell[owner[faceI]] && !removeCell[neighbour[faceI]] )
80 faces[faceI] = faces[faceI].reverseFace();
85 //- remove unwanted cells
87 labelLongList newCellLabel(cells.size(), -1);
88 forAll(newCellLabel, cellI)
89 if( !removeCell[cellI] )
90 newCellLabel[cellI] = nCells++;
93 if( (newCellLabel[cellI] != -1) && (newCellLabel[cellI] < cellI) )
95 cells[newCellLabel[cellI]].transfer(cells[cellI]);
98 cells.setSize(nCells);
100 //- update cell subsets in the mesh
101 mesh_.updateCellSubsets(newCellLabel);
103 reduce(nCells, sumOp<label>());
104 Info << "New cells size " << nCells << endl;
106 //- reorder positions of boundary faces
107 //- this outs the newly-created bnd faces at the end of the list
108 this->reorderBoundaryFaces();
111 //- remove unused faces
112 boolList removeFace(faces.size(), true);
115 # pragma omp parallel if( cells.size() > 1000 )
119 # pragma omp for schedule(dynamic, 40)
123 const cell& c = cells[cellI];
126 removeFace[c[fI]] = false;
129 if( Pstream::parRun() && !removeProcFaces )
131 const PtrList<processorBoundaryPatch>& procBoundaries =
132 mesh_.procBoundaries_;
137 for(label fI=procBoundaries[0].patchStart();fI<faces.size();++fI)
138 removeFace[fI] = false;
144 this->removeFaces(removeFace);
146 Info << "Finished removing selected cells from the mesh" << endl;
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //