cuttingSurfaceBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "cuttingSurfaceBase.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
33 (
34  Foam::debug::debugSwitch("cuttingSurfaceBase", 0)
35 );
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 
47 (
48  const primitiveMesh& mesh,
49  const bool triangulate,
50  const bitSet& cellIdLabels
51 )
52 {
53  bitSet subsetCells(cellIdLabels);
54 
55  performCut(mesh, triangulate, std::move(subsetCells));
56 }
57 
58 
60 (
61  const primitiveMesh& mesh,
62  const bool triangulate,
63  const labelUList& cellIdLabels
64 )
65 {
66  bitSet subsetCells;
67 
68  if (notNull(cellIdLabels))
69  {
70  // Pre-populate with restriction
71  subsetCells.resize(mesh.nCells());
72  subsetCells.set(cellIdLabels);
73  }
74 
75  performCut(mesh, triangulate, std::move(subsetCells));
76 }
77 
78 
80 {
81  if (!faceMap.empty())
82  {
83  MeshStorage::remapFaces(faceMap);
84 
85  List<label> remappedCells(faceMap.size());
86  forAll(faceMap, facei)
87  {
88  remappedCells[facei] = meshCells_[faceMap[facei]];
89  }
90  meshCells_.transfer(remappedCells);
91  }
92 }
93 
94 
95 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
96 
98 {
99  if (this == &rhs)
100  {
101  return; // Self-assignment is a no-op
102  }
103 
104  static_cast<MeshStorage&>(*this) = rhs;
105  meshCells_ = rhs.meshCells();
106 }
107 
108 
109 // ************************************************************************* //
Foam::cuttingSurfaceBase::meshCells
const labelList & meshCells() const
The mesh cells cut.
Definition: cuttingSurfaceBase.H:196
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:94
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::debug::debugSwitch
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:225
Foam::cuttingSurfaceBase::cuttingSurfaceBase
cuttingSurfaceBase()
Construct null.
Definition: cuttingSurfaceBase.C:40
Foam::bitSet::set
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:563
Foam::PackedList::resize
void resize(const label nElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:388
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
cuttingSurfaceBase.H
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::cuttingSurfaceBase::remapFaces
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
Definition: cuttingSurfaceBase.C:79
Foam::notNull
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:195
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::List< label >
Foam::cuttingSurfaceBase::debug
static int debug
Debug information.
Definition: cuttingSurfaceBase.H:180
Foam::UList< label >
Foam::cuttingSurfaceBase
Base for creating a MeshedSurface by performing some type of cell cutting/intersection.
Definition: cuttingSurfaceBase.H:59
Foam::cuttingSurfaceBase::operator=
void operator=(const cuttingSurfaceBase &rhs)
Copy assignment.
Definition: cuttingSurfaceBase.C:97
Foam::MeshedSurface< face >
Foam::cuttingSurfaceBase::performCut
virtual void performCut(const primitiveMesh &mesh, const bool triangulate, const labelUList &cellIdLabels)
Cut mesh, restricted to a list of cells.
Definition: cuttingSurfaceBase.C:60
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78