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-2024 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  // Private Data
56 
57  //- Wanted volume
58  const scalar vol_;
59 
60  //- Normal of plane to sweep
61  const vector n_;
62 
63  //- Optional name of cellSet to calculate volume in
64  const word maskSetName_;
65 
66 
67  // Private Member Functions
68 
69  scalar volumeOfSet(const PackedBoolList&) const;
70 
71  label selectCells
72  (
73  const scalar normalComp,
74  const PackedBoolList&,
75  PackedBoolList& selected
76  ) const;
77 
78  void combine(topoSet& set, const bool add) const;
79 
80 
81 public:
82 
83  //- Runtime type information
84  TypeName("targetVolumeToCell");
85 
86 
87  // Constructors
88 
89  //- Construct from components
91  (
92  const polyMesh& mesh,
93  const scalar vol,
94  const vector&
95  );
96 
97  //- Construct from dictionary
99  (
100  const polyMesh& mesh,
101  const dictionary& dict
102  );
103 
104 
105  //- Destructor
106  virtual ~targetVolumeToCell();
107 
108 
109  // Member Functions
110 
111  virtual sourceType setType() const
112  {
113  return CELLSETSOURCE;
114  }
115 
116  virtual void applyToSet
117  (
118  const topoSetSource::setAction action,
119  topoSet&
120  ) const;
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************************************************************* //
A bit-packed bool list.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
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