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-------------------------------------------------------------------------------
10License
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
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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void transfer(List< T > &list)
Definition: List.C:447
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:409
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:590
Base for creating a MeshedSurface by performing some type of cell cutting/intersection.
virtual void performCut(const primitiveMesh &mesh, const bool triangulate, const labelUList &cellIdLabels)
Cut mesh, restricted to a list of cells.
void operator=(const cuttingSurfaceBase &rhs)
Copy assignment.
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
static int debug
Debug information.
const labelList & meshCells() const
The mesh cells cut.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
label nCells() const noexcept
Number of mesh cells.
dynamicFvMesh & mesh
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:225
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:207
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333