patchDistanceToCell.H
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) 2026 Keysight Technologies
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 Class
27  Foam::patchDistanceToCell
28 
29 Description
30  A \c topoSetCellSource to select cells whose geometric distance from
31  one or more patches is within a user-specified range.
32 
33  The distance is computed using \c MeshWave propagation (same algorithm
34  as turbulence wall distance), which gives the true Euclidean distance
35  from each cell centre to the nearest point on the selected patch faces.
36 
37  Operands:
38  \table
39  Operand | Type | Location
40  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
41  \endtable
42 
43 Usage
44  Minimal example by using \c system/topoSetDict.actions:
45  \verbatim
46  {
47  // Mandatory (inherited) entries
48  name <name>;
49  type cellSet;
50  action <action>;
51 
52  // Mandatory entries
53  source patchDistanceToCell;
54 
55  // Conditional mandatory entries
56  // Select one of the below
57 
58  // Option-1
59  patches
60  (
61  <patchName1>
62  <patchName2>
63  ...
64  );
65 
66  // Option-2
67  patch <patchName>;
68 
69  // Maximum distance from the patch [m]
70  distance <scalar>;
71 
72  // Optional minimum distance from the patch [m] (default: 0)
73  minDistance <scalar>;
74  }
75  \endverbatim
76 
77  where the entries mean:
78  \table
79  Property | Description | Type | Reqd | Deflt
80  name | Name of cellSet | word | yes | -
81  type | Type name: cellSet | word | yes | -
82  action | Action applied on cells - see below | word | yes | -
83  source | Source name: patchDistanceToCell | word | yes | -
84  distance | Maximum distance from patch [m] | scalar | yes | -
85  minDistance | Minimum distance from patch [m] | scalar | no | 0
86  \endtable
87 
88  Options for the \c action entry:
89  \verbatim
90  new | Create a new cellSet from selected cells
91  add | Add selected cells into this cellSet
92  subtract | Remove selected cells from this cellSet
93  \endverbatim
94 
95  Options for the conditional mandatory entries:
96  \verbatim
97  Entry | Description | Type | Reqd | Deflt
98  patches | Names of patches or wildcards | wordList | cond'l | -
99  patch | Name of patch or wildcard | word | cond'l | -
100  \endverbatim
101 
102 Note
103  The order of precedence among the conditional mandatory entries from the
104  highest to the lowest is \c patches, and \c patch.
105 
106 SourceFiles
107  patchDistanceToCell.C
108 
109 \*---------------------------------------------------------------------------*/
110 
111 #ifndef Foam_patchDistanceToCell_H
112 #define Foam_patchDistanceToCell_H
113 
114 #include "topoSetCellSource.H"
115 #include "wordRes.H"
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 namespace Foam
120 {
121 
122 /*---------------------------------------------------------------------------*\
123  Class patchDistanceToCell Declaration
124 \*---------------------------------------------------------------------------*/
125 
126 class patchDistanceToCell
127 :
128  public topoSetCellSource
129 {
130  // Private Data
131 
132  //- Add usage string
133  static addToUsageTable usage_;
134 
135  //- Matcher for patches
136  wordRes selectedPatches_;
137 
138  //- Maximum distance from the patch [m]
139  scalar distance_;
140 
141  //- Minimum distance from the patch [m]
142  scalar minDistance_;
143 
144 
145  // Private Member Functions
146 
147  void combine(topoSet& set, const bool add) const;
148 
149 
150 public:
151 
152  //- Runtime type information
153  TypeName("patchDistanceToCell");
154 
155  // Constructors
156 
157  //- Construct from components (single patch, distance range)
159  (
160  const polyMesh& mesh,
161  const wordRe& patchName,
162  const scalar distance,
163  const scalar minDistance = 0
164  );
165 
166  //- Construct from dictionary
167  patchDistanceToCell(const polyMesh& mesh, const dictionary& dict);
168 
169  //- Construct from Istream
170  patchDistanceToCell(const polyMesh& mesh, Istream& is);
172 
173  //- Destructor
174  virtual ~patchDistanceToCell() = default;
175 
176 
177  // Member Functions
178 
179  virtual void applyToSet
180  (
181  const topoSetSource::setAction action,
182  topoSet& set
183  ) const;
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
dictionary dict
TypeName("patchDistanceToCell")
Runtime type information.
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
const polyMesh & mesh() const noexcept
Reference to the mesh.
setAction
Enumeration defining various actions.
patchDistanceToCell(const polyMesh &mesh, const wordRe &patchName, const scalar distance, const scalar minDistance=0)
Construct from components (single patch, distance range)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
virtual ~patchDistanceToCell()=default
Destructor.
Namespace for OpenFOAM.