targetVolumeToCell.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) 2012 OpenFOAM Foundation
9  Copyright (C) 2018-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::targetVolumeToCell
29 
30 Description
31  A \c topoSetCellSource to select cells based on a target
32  volume of cells. Adapts a plane until it has enough.
33 
34  Operands:
35  \table
36  Operand | Type | Location
37  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
38  \endtable
39 
40 Usage
41  Minimal example by using \c system/topoSetDict.actions:
42  \verbatim
43  {
44  // Mandatory (inherited) entries
45  name <name>;
46  type cellSet;
47  action <action>;
48 
49  // Mandatory entries
50  source targetVolumeToCell;
51  volume 10;
52  normal (1 0 0);
53 
54  // Optional entries
55  set <cellSetName>;
56  }
57  \endverbatim
58 
59  where the entries mean:
60  \table
61  Property | Description | Type | Req'd | Dflt
62  name | Name of cellSet | word | yes | -
63  type | Type name: cellSet | word | yes | -
64  action | Action applied on cells - see below | word | yes | -
65  source | Source name: targetVolumeToCell | word | yes | -
66  volume | The target volume [m3] | scalar | yes | -
67  normal | The plane normal | vector | yes | -
68  set | Restrict to named cellSet | word | no | ""
69  \endtable
70 
71  Options for the \c action entry:
72  \verbatim
73  new | Create a new cellSet from selected cells
74  add | Add selected cells into this cellSet
75  subtract | Remove selected cells from this cellSet
76  \endverbatim
77 
78 See also
79  - Foam::topoSetSource
80  - Foam::topoSetCellSource
81 
82 SourceFiles
83  targetVolumeToCell.C
84 
85 \*---------------------------------------------------------------------------*/
86 
87 #ifndef targetVolumeToCell_H
88 #define targetVolumeToCell_H
89 
90 #include "topoSetCellSource.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 
97 // Forward declarations
98 class bitSet;
99 
100 /*---------------------------------------------------------------------------*\
101  Class targetVolumeToCell Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 class targetVolumeToCell
105 :
106  public topoSetCellSource
107 {
108  // Private Data
109 
110  //- Add usage string
111  static addToUsageTable usage_;
112 
113  //- Target volume
114  const scalar vol_;
115 
116  //- Normal of plane to sweep
117  const vector normal_;
118 
119  //- Optional name of cellSet to calculate volume in
120  const word maskSetName_;
121 
122 
123  // Private Member Functions
124 
125  //- The volume of the selected cells
126  scalar volumeOfSet(const bitSet& selected) const;
127 
128  label selectCells
129  (
130  const scalar normalComp,
131  const bitSet&,
132  bitSet& selected
133  ) const;
134 
135  void combine(topoSet& set, const bool add) const;
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("targetVolumeToCell");
142 
143 
144  // Constructors
145 
146  //- Construct from components
148  (
149  const polyMesh& mesh,
150  const scalar vol,
151  const vector& normal,
152  const word& maskSetName = ""
153  );
154 
155  //- Construct from dictionary
156  targetVolumeToCell(const polyMesh& mesh, const dictionary& dict);
157 
158  //- Construct from Istream
160 
161 
162  //- Destructor
163  virtual ~targetVolumeToCell() = default;
164 
165 
166  // Member Functions
167 
168  virtual void applyToSet
169  (
170  const topoSetSource::setAction action,
171  topoSet& set
172  ) const;
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::combine
Definition: FaceCellWave.C:57
Foam::targetVolumeToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: targetVolumeToCell.C:329
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:99
Foam::topoSetSource::mesh
const polyMesh & mesh() const
Reference to the mesh.
Definition: topoSetSource.H:333
Foam::targetVolumeToCell::~targetVolumeToCell
virtual ~targetVolumeToCell()=default
Destructor.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::targetVolumeToCell
A topoSetCellSource to select cells based on a target volume of cells. Adapts a plane until it has en...
Definition: targetVolumeToCell.H:159
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
topoSetCellSource.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::targetVolumeToCell::TypeName
TypeName("targetVolumeToCell")
Runtime type information.
Foam::Vector< scalar >
Foam::topoSetCellSource
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Definition: topoSetCellSource.H:54
Foam::targetVolumeToCell::targetVolumeToCell
targetVolumeToCell(const polyMesh &mesh, const scalar vol, const vector &normal, const word &maskSetName="")
Construct from components.
Definition: targetVolumeToCell.C:284