rotatedBoxToCell.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) 2011-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::rotatedBoxToCell
26 
27 Description
28  A topoSetSource to select cells based on cell centres inside a rotated
29  and/or skewed box.
30 
31  The box can be defined with an origin and three vectors; i, j, and k. The
32  origin is one corner of the box, and the vectors are the edges connected to
33  that corner.
34 
35  For example, the following defines a box rotated 45 degrees around the
36  z-axis, with width and depth of 0.2, height of 200, and with a bottom left
37  corner at (0.4 0.4 -100):
38 
39  \verbatim
40  origin (0.4 0.4 -100);
41  i (0.141421 0.141421 0);
42  j (-0.141421 0.141421 0);
43  k (0 0 200);
44  \endverbatim
45 
46  Alternatively, the box can be defined using a non-rotated box and details
47  of how it should be rotated. This syntax is triggered by the presence of
48  the keyword "box". A standard bounding box is supplied, along with a centre
49  of rotation and two vectors, n1 and n2. The rotation is taken to be that
50  which transforms n1 onto n2.
51 
52  The above example can be equivalently specified in this alternative form as
53  follows:
54 
55  \verbatim
56  box (0.4 0.4 -100) (0.6 0.6 100);
57  centre (0.4 0.4 0);
58  n1 (1 0 0);
59  n2 (1 1 0);
60  \endverbatim
61 
62 SourceFiles
63  rotatedBoxToCell.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef rotatedBoxToCell_H
68 #define rotatedBoxToCell_H
69 
70 #include "topoSetSource.H"
71 #include "treeBoundBox.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class rotatedBoxToCell Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class rotatedBoxToCell
83 :
84  public topoSetSource
85 {
86  // Private Data
87 
88  //- Skewed box origin
89  vector origin_;
90 
91  //- Skewed box edge vector
92  vector i_;
93 
94  //- Skewed box edge vector
95  vector j_;
96 
97  //- Skewed box edge vector
98  vector k_;
99 
100 
101  // Private Member Functions
102 
103  void combine(topoSet& set, const bool add) const;
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("rotatedBoxToCell");
110 
111  // Constructors
112 
113  //- Construct from components
115  (
116  const polyMesh& mesh,
117  const vector& origin,
118  const vector& i,
119  const vector& j,
120  const vector& k
121  );
122 
123  //- Construct from dictionary
124  rotatedBoxToCell(const polyMesh& mesh, const dictionary& dict);
125 
126 
127  //- Destructor
128  virtual ~rotatedBoxToCell();
129 
130 
131  // Member Functions
132 
133  virtual sourceType setType() const
134  {
135  return CELLSETSOURCE;
136  }
137 
138  virtual void applyToSet
139  (
140  const topoSetSource::setAction action,
141  topoSet&
142  ) const;
143 
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #endif
154 
155 // ************************************************************************* //
label k
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 cell centres inside a rotated and/or skewed box.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
virtual sourceType setType() const
rotatedBoxToCell(const polyMesh &mesh, const vector &origin, const vector &i, const vector &j, const vector &k)
Construct from components.
virtual ~rotatedBoxToCell()
Destructor.
TypeName("rotatedBoxToCell")
Runtime type information.
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
Namespace for OpenFOAM.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dictionary dict