cutPoly.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Namespace
25  Foam::cutPoly
26 
27 Description
28  Low level functions for cutting poly faces and cells
29 
30  Cutting a face using an iso-surface defined at the points is done by
31  walking around the face. A start point is chosen and then the walk proceeds
32  until a "cut" edge is found with points on either side of the iso-surface.
33  This edge is noted and the walk continues until another cut edge is found.
34  These two edge cuts, along with all points in-between, form a sub-face on
35  one side of the iso-surface. This algorithm continues around the entire
36  face, potentially cutting off multiple sub-faces. The remainder is a single
37  contiguous face on the other side of the iso-surface.
38 
39  Cutting a cell is then done by walking from cut-edge to cut-edge around the
40  cell's faces.
41 
42 SourceFiles
43  cutPoly.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef cutPoly_H
48 #define cutPoly_H
49 
50 #include "cellEdgeAddressing.H"
51 #include "PrimitivePatch.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 class OBJstream;
59 
60 namespace cutPoly
61 {
62 
63 //- This flag determines which side of the iso-surface is separated into
64 // multiple sub-faces, and which side is kept as the central contiguous face
65 static const bool separatedBelow = true;
66 
67 //- Return the cuts for a given face. This returns a list of pairs of
68 // face-edge indices. Both edges in the pair are cut, and connecting these
69 // cuts creates an edge of the iso-surface.
71 (
72  const face& f,
73  const scalarField& pAlphas,
74  const scalar isoAlpha
75 );
76 
77 //- Return the cuts for a given cell. This returns a list of lists of cell-edge
78 // indices. Each sub-list represents a single closed loop of cell-edges. The
79 // edges listed are all cut, and connecting these cuts up creates a face of
80 // the iso-surface.
82 (
83  const cell& c,
84  const cellEdgeAddressing& cAddr,
85  const faceUList& fs,
86  const List<List<labelPair>>& fCuts,
87  const scalarField& pAlphas,
88  const scalar isoAlpha
89 );
90 
91 //- Write the cuts for a given face to an OBJ file
92 void writeFaceCuts
93 (
94  const face& f,
95  const List<labelPair>& fCuts,
96  const pointField& ps,
97  const scalarField& pAlphas,
98  const scalar isoAlpha,
99  OBJstream& obj
100 );
101 
102 //- Write the cuts for a given cell to an OBJ file
103 void writeCellCuts
104 (
105  const cell& c,
106  const cellEdgeAddressing& cAddr,
107  const List<List<label>>& cCuts,
108  const faceList& fs,
109  const pointField& ps,
110  const scalarField& pAlphas,
111  const scalar isoAlpha,
112  OBJstream& obj
113 );
114 
115 } // End namespace cutPoly
116 } // End namespace Foam
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 #endif
121 
122 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
OFstream which keeps track of vertices.
Definition: OBJstream.H:56
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
const dimensionedScalar c
Speed of light in a vacuum.
static const bool separatedBelow
This flag determines which side of the iso-surface is separated into.
Definition: cutPoly.H:65
void writeCellCuts(const cell &c, const cellEdgeAddressing &cAddr, const List< List< label >> &cCuts, const faceList &fs, const pointField &ps, const scalarField &pAlphas, const scalar isoAlpha, OBJstream &obj)
Write the cuts for a given cell to an OBJ file.
Definition: cutPoly.C:271
void writeFaceCuts(const face &f, const List< labelPair > &fCuts, const pointField &ps, const scalarField &pAlphas, const scalar isoAlpha, OBJstream &obj)
Write the cuts for a given face to an OBJ file.
Definition: cutPoly.C:245
List< labelPair > faceCuts(const face &f, const scalarField &pAlphas, const scalar isoAlpha)
Return the cuts for a given face. This returns a list of pairs of.
Definition: cutPoly.C:61
labelListList cellCuts(const cell &c, const cellEdgeAddressing &cAddr, const faceUList &fs, const List< List< labelPair >> &fCuts, const scalarField &pAlphas, const scalar isoAlpha)
Return the cuts for a given cell. This returns a list of lists of cell-edge.
Definition: cutPoly.C:121
Namespace for OpenFOAM.
labelList f(nPoints)