fieldToCell.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) 2011-2015 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::fieldToCell
29 
30 Description
31  A \c topoSetCellSource to select cells based on \c volScalarField values,
32  i.e. select cells with given field value of >= min and <= max.
33 
34  Operands:
35  \table
36  Operand | Type | Location
37  input | volScalarField | $FOAM_CASE/<time>/<inpField>
38  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
39  \endtable
40 
41 Usage
42  Minimal example by using \c system/topoSetDict.actions:
43  \verbatim
44  {
45  // Mandatory (inherited) entries
46  name <name>;
47  type cellSet;
48  action <action>;
49 
50  // Mandatory entries
51  source fieldToCell;
52  field <fieldName>;
53  min <minFieldValue>;
54  max <maxFieldValue>;
55  }
56  \endverbatim
57 
58  where the entries mean:
59  \table
60  Property | Description | Type | Req'd | Dflt
61  name | Name of cellSet | word | yes | -
62  type | Type name: cellSet | word | yes | -
63  action | Action applied on cells - see below | word | yes | -
64  source | Source name: fieldToCell | word | yes | -
65  field | Name of volScalarField to use | word | yes | -
66  min | The min value for the subset | scalar | yes | -
67  max | The max value for the subset | scalar | yes | -
68  \endtable
69 
70  Options for the \c action entry:
71  \verbatim
72  new | Create a new cellSet from selected cells
73  add | Add selected cells into this cellSet
74  subtract | Remove selected cells from this cellSet
75  \endverbatim
76 
77 See also
78  - Foam::topoSetSource
79  - Foam::topoSetCellSource
80 
81 SourceFiles
82  fieldToCell.C
83 
84 \*---------------------------------------------------------------------------*/
85 
86 #ifndef fieldToCell_H
87 #define fieldToCell_H
88 
89 #include "topoSetCellSource.H"
90 #include "scalarField.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class fieldToCell Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class fieldToCell
102 :
103  public topoSetCellSource
104 {
105  // Private Data
106 
107  //- Add usage string
108  static addToUsageTable usage_;
109 
110  //- Name of volScalarField, volVectorField
111  word fieldName_;
112 
113  //- Min to subset field values with
114  scalar min_;
115 
116  //- Max to subset field values with
117  scalar max_;
118 
119 
120  // Private Member Functions
121 
122  //- Depending on field values add to or delete from cellSet.
123  void applyToSet
124  (
125  const topoSetSource::setAction action,
126  const scalarField& field,
127  topoSet& set
128  ) const;
129 
130 
131 public:
132 
133  //- Runtime type information
134  TypeName("fieldToCell");
135 
136 
137  // Constructors
138 
139  //- Construct from components
141  (
142  const polyMesh& mesh,
143  const word& fieldName,
144  const scalar min,
145  const scalar max
146  );
147 
148  //- Construct from dictionary
149  fieldToCell(const polyMesh& mesh, const dictionary& dict);
150 
151  //- Construct from Istream
152  fieldToCell(const polyMesh& mesh, Istream& is);
153 
154 
155  //- Destructor
156  virtual ~fieldToCell() = default;
157 
158 
159  // Member Functions
160 
161  virtual void applyToSet
162  (
163  const topoSetSource::setAction action,
164  topoSet& set
165  ) const;
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
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:65
Foam::fieldToCell::~fieldToCell
virtual ~fieldToCell()=default
Destructor.
scalarField.H
Foam::fieldToCell::fieldToCell
fieldToCell(const polyMesh &mesh, const word &fieldName, const scalar min, const scalar max)
Construct from components.
Definition: fieldToCell.C:123
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:100
Foam::fieldToCell
A topoSetCellSource to select cells based on volScalarField values, i.e. select cells with given fiel...
Definition: fieldToCell.H:160
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
field
rDeltaTY field()
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
topoSetCellSource.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
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:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::topoSetCellSource
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Definition: topoSetCellSource.H:54
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
Foam::fieldToCell::TypeName
TypeName("fieldToCell")
Runtime type information.