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-2020 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 
41 (
42  const primitiveMesh& mesh,
43  const bool triangulate,
44  const bitSet& cellIdLabels
45 )
46 {
47  bitSet subsetCells(cellIdLabels);
48 
49  performCut(mesh, triangulate, std::move(subsetCells));
50 }
51 
52 
54 (
55  const primitiveMesh& mesh,
56  const bool triangulate,
57  const labelUList& cellIdLabels
58 )
59 {
60  bitSet subsetCells;
61 
62  if (notNull(cellIdLabels))
63  {
64  // Pre-populate with restriction
65  subsetCells.resize(mesh.nCells());
66  subsetCells.set(cellIdLabels);
67  }
68 
69  performCut(mesh, triangulate, std::move(subsetCells));
70 }
71 
72 
74 {
75  if (!faceMap.empty())
76  {
77  Mesh::remapFaces(faceMap);
78 
79  List<label> remappedCells(faceMap.size());
80  forAll(faceMap, facei)
81  {
82  remappedCells[facei] = meshCells_[faceMap[facei]];
83  }
84  meshCells_.transfer(remappedCells);
85  }
86 }
87 
88 
89 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
90 
91 void Foam::cuttingSurfaceBase::operator=(const cuttingSurfaceBase& rhs)
92 {
93  if (this == &rhs)
94  {
95  return; // Self-assignment is a no-op
96  }
97 
98  static_cast<Mesh&>(*this) = rhs;
99  meshCells_ = rhs.meshCells();
100 }
101 
102 
103 // ************************************************************************* //
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:504
void operator=(const cuttingSurfaceBase &rhs)
Copy assignment.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:222
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:455
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
virtual void performCut(const primitiveMesh &mesh, const bool triangulate, const labelUList &cellIdLabels)
Cut mesh, restricted to a list of cells.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
static int debug
Debug information.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
label nCells() const noexcept
Number of mesh cells.
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:246