targetVolumeToCell.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) 2012-2021 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 Class
25  Foam::targetVolumeToCell
26 
27 Description
28  A topoSetSource to select cells based on the wanted volume of selected
29  cells. Adapts a plane until it has enough.
30 
31 SourceFiles
32  targetVolumeToCell.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef targetVolumeToCell_H
37 #define targetVolumeToCell_H
38 
39 #include "topoSetSource.H"
40 #include "PackedBoolList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class targetVolumeToCell Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 :
53  public topoSetSource
54 {
55 
56  // Private Data
57 
58 
59  //- Wanted volume
60  const scalar vol_;
61 
62  //- Normal of plane to sweep
63  const vector n_;
64 
65  //- Optional name of cellSet to calculate volume in
66  const word maskSetName_;
67 
68 
69  // Private Member Functions
70 
71  scalar volumeOfSet(const PackedBoolList&) const;
72 
73  label selectCells
74  (
75  const scalar normalComp,
76  const PackedBoolList&,
77  PackedBoolList& selected
78  ) const;
79 
80  void combine(topoSet& set, const bool add) const;
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("targetVolumeToCell");
87 
88  // Constructors
89 
90  //- Construct from components
92  (
93  const polyMesh& mesh,
94  const scalar vol,
95  const vector&
96  );
97 
98  //- Construct from dictionary
100  (
101  const polyMesh& mesh,
102  const dictionary& dict
103  );
104 
105 
106  //- Destructor
107  virtual ~targetVolumeToCell();
108 
109 
110  // Member Functions
111 
112  virtual sourceType setType() const
113  {
114  return CELLSETSOURCE;
115  }
116 
117  virtual void applyToSet
118  (
119  const topoSetSource::setAction action,
120  topoSet&
121  ) const;
122 
123 };
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
A bit-packed bool list.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A topoSetSource to select cells based on the wanted volume of selected cells. Adapts a plane until it...
TypeName("targetVolumeToCell")
Runtime type information.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
virtual sourceType setType() const
targetVolumeToCell(const polyMesh &mesh, const scalar vol, const vector &)
Construct from components.
virtual ~targetVolumeToCell()
Destructor.
Base class of a source for a topoSet.
Definition: topoSetSource.H:64
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:71
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:83
const polyMesh & mesh() const
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:65
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dictionary dict