union.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) 2025 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::zoneGenerators::Union
26 
27 Description
28  A zoneGenerator which selects all the elements from the zones generated by
29  the given list of zoneGenerators
30 
31  A union of faceZones is oriented only if ALL the faceZones combined are
32  oriented, otherwise the returned faceZone is unoriented.
33 
34 Usage
35  \table
36  Property | Description | Required | Default value
37  type | Type: union | yes |
38  name | Name of the zone | no | zoneGenerator name
39  zoneType | Type of zone | no | all the zone types
40  moveUpdate | Switch to update after mesh motion | no | false
41  \endtable
42  These options are followed by a list of any number of zoneGenerators
43  which can either generate the zones locally or return zones from the lists
44  of zones held by the mesh using the zoneGenerators::lookup zoneGenerator.
45 
46  Each zoneGenerator returns a zoneSet containing a pointZone and/or a
47  cellZone and/or a faceZone, the zoneGenerators::Union operation combines
48  each of the zone types unless the \c zoneType is specified in which case
49  only the zones of that type are combined.
50 
51  A cellZone named \c coneAndAnnulus containing the cells with centres
52  inside the union of the predefined \c cone1 cellZone which is looked-up
53  from the cellZoneList and the locally defined annulus is be generated by
54  \verbatim
55  coneAndAnnulus
56  {
57  type union;
58 
59  cone1;
60 
61  annulus1
62  {
63  type annulus;
64  zoneType cell;
65 
66  point1 (-0.0075 0 -1);
67  point2 (-0.003 0.0025 1);
68  outerRadius 0.002;
69  innerRadius 0.001;
70  }
71  }
72  \endverbatim
73 
74 See also
75  zoneGenerators::difference
76  zoneGenerators::intersection
77  zoneGeneratorList
78 
79 SourceFiles
80  Union.C
81 
82 \*---------------------------------------------------------------------------*/
83 
84 #ifndef union_zoneGenerator_H
85 #define union_zoneGenerator_H
86 
87 #include "zoneGeneratorList.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 namespace zoneGenerators
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class Union Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class Union
101 :
102  public zoneGenerator
103 {
104  // Private Data
105 
106  //- The type of zone to lookup (optional)
107  zoneTypesAll zoneType_;
108 
109  zoneGeneratorList zoneGenerators_;
110 
111 
112  // Private Member Functions
113 
114  //- Add the given list of indices to the selected list
115  void select
116  (
117  boolList& selected,
118  const labelList& indices,
119  const bool select = true
120  ) const;
121 
122  //- Add the given list of face indices and corresponding flipMap
123  // to the selected list and flipMap
124  void select
125  (
126  boolList& selected,
127  boolList& flipMap,
128  const labelList& indices,
129  const boolList& zoneFlipMap,
130  const bool select = true
131  ) const;
132 
133 
134 protected:
135 
136  // Protected Member Functions
137 
138  //- Generate the zoneSet for union or difference
139  // optionally initialising all the points and/or cells and/or faces
140  zoneSet generate(const bool diff, const bool all) const;
141 
142 
143 public:
144 
145  //- Runtime type information
146  TypeName("union");
147 
148 
149  // Constructors
150 
151  //- Construct from dictionary
152  Union
153  (
154  const word& name,
155  const polyMesh& mesh,
156  const dictionary& dict
157  );
158 
159 
160  //- Destructor
161  virtual ~Union();
162 
163 
164  // Member Functions
165 
166  virtual zoneSet generate() const;
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace zoneGenerators
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling words, derived from string.
Definition: word.H:62
static labelList indices(const boolList &selected)
Return the list of selected indices.
friend class zoneGeneratorList
Definition: zoneGenerator.H:80
const word & name() const
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: union.C:242
virtual ~Union()
Destructor.
Definition: union.C:236
Union(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: union.C:219
TypeName("union")
Runtime type information.
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
zoneTypesAll
Enumeration defining the zone types with an option for all the types.
Definition: zoneSet.H:77
List< label > labelList
A List of labels.
Definition: labelList.H:56
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:409
dictionary dict