orientedType.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) 2017-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::orientedType
28 
29 Description
30  Class to determine the 'oriented' status of surface fields
31 
32 SourceFiles
33  orientedType.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_orientedType_H
38 #define Foam_orientedType_H
39 
40 #include "Enum.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward Declarations
48 class orientedType;
49 
50 Istream& operator>>(Istream& is, orientedType& ot);
51 Ostream& operator<<(Ostream& os, const orientedType& ot);
52 
53 /*---------------------------------------------------------------------------*\
54  Class orientedType Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class orientedType
58 {
59 public:
60 
61  // Public Data Types
62 
63  //- Enumeration defining oriented flags
64  enum orientedOption : unsigned char
65  {
66  UNKNOWN = 0,
67  ORIENTED = 1,
68  UNORIENTED = 2
69  };
70 
71 
72  // Static Data
73 
74  //- Named enumerations for oriented flags
76 
77 
78 private:
79 
80  // Private Data
81 
82  //- Oriented type
83  orientedOption oriented_;
84 
85 
86 public:
87 
88  // Generated Methods
89 
90  //- Copy construct
91  orientedType(const orientedType&) noexcept = default;
92 
93  //- Copy assignment
94  orientedType& operator=(const orientedType&) noexcept = default;
95 
96 
97  // Constructors
98 
99  //- Default construct as \c UNKNOWN
100  constexpr orientedType() noexcept
101  :
102  oriented_(UNKNOWN)
103  {}
104 
105  //- Implicit construct from enumeration
107  :
108  oriented_(opt)
109  {}
110 
111  //- Construct from bool
112  explicit constexpr orientedType(const bool isOriented) noexcept
113  :
114  oriented_(isOriented ? ORIENTED : UNORIENTED)
115  {}
116 
117  //- Construct from Istream
118  explicit orientedType(Istream& is);
119 
120 
121  // Member Functions
122 
123  //- True if can operate on this combination of oriented types
124  static bool checkType
125  (
126  const orientedType& a,
127  const orientedType& b
128  ) noexcept;
129 
130  //- Return the oriented flag
131  orientedOption oriented() const noexcept { return oriented_; }
132 
133  //- Return non-const reference to the oriented flag
134  orientedOption& oriented() noexcept { return oriented_; }
135 
136  //- True if \c ORIENTED
137  bool is_oriented() const noexcept { return (oriented_ == ORIENTED); }
138 
139  //- Set the oriented flag: on/off
140  void setOriented(bool on = true) noexcept
141  {
142  oriented_ = on ? ORIENTED : UNORIENTED;
143  }
144 
145  //- Read the "oriented" state from dictionary
146  void read(const dictionary& dict);
147 
148  //- Write the "oriented" flag entry (if \c ORIENTED)
149  // \return True if entry was written
150  bool writeEntry(Ostream& os) const;
151 
152 
153  // Member Operators
154 
155  void operator+=(const orientedType& ot);
156  void operator-=(const orientedType& ot);
157  void operator*=(const orientedType& ot);
158  void operator/=(const orientedType& ot);
159  void operator*=(const scalar s);
160  void operator/=(const scalar s);
161 
162  //- Convert to bool. Same as is_oriented()
163  bool operator()() const noexcept { return is_oriented(); }
164 
165 
166  // IOstream Operators
167 
168  friend Istream& operator>>(Istream& is, orientedType& ot);
169  friend Ostream& operator<<(Ostream& os, const orientedType& ot);
170 };
171 
172 
173 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
174 
175 orientedType min(const orientedType& a, const orientedType& b);
176 orientedType max(const orientedType& a, const orientedType& b);
177 orientedType lerp(const orientedType& a, const orientedType& b);
178 
179 orientedType cmptMultiply(const orientedType& ot1, const orientedType& ot2);
180 orientedType cmptDivide(const orientedType& ot1, const orientedType& ot);
181 orientedType cmptAv(const orientedType& ot);
182 
183 orientedType pow(const orientedType& ot, const scalar p);
184 orientedType sqr(const orientedType& ot);
185 orientedType pow2(const orientedType& ot);
186 orientedType pow3(const orientedType& ot);
187 orientedType pow4(const orientedType& ot);
188 orientedType pow5(const orientedType& ot);
189 orientedType pow6(const orientedType& ot);
190 orientedType pow025(const orientedType& ot);
191 
192 
194 orientedType cbrt(const orientedType& ot);
195 orientedType magSqr(const orientedType& ot);
196 orientedType mag(const orientedType& ot);
197 orientedType sign(const orientedType& ot);
198 orientedType pos(const orientedType& ot);
199 orientedType pos0(const orientedType& ot);
200 orientedType neg(const orientedType& ot);
201 orientedType neg0(const orientedType& ot);
204 orientedType inv(const orientedType& ot);
205 
206 
207 orientedType trans(const orientedType& ot);
208 orientedType atan2(const orientedType& ot1, const orientedType& ot2);
209 orientedType hypot(const orientedType& ot1, const orientedType& ot2);
211 
212 
213 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
214 
216 orientedType operator*(const scalar s, const orientedType& ot);
217 orientedType operator/(const orientedType& ot, const scalar s);
218 
219 orientedType operator+(const orientedType& ot1, const orientedType& ot2);
220 orientedType operator-(const orientedType& ot1, const orientedType& ot2);
221 orientedType operator/(const orientedType& ot1, const orientedType& ot2);
222 orientedType operator*(const orientedType& ot1, const orientedType& ot2);
223 orientedType operator^(const orientedType& ot1, const orientedType& ot2);
224 orientedType operator&(const orientedType& ot1, const orientedType& ot2);
225 orientedType operator&&(const orientedType& ot1, const orientedType& ot2);
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
constexpr orientedType() noexcept
Default construct as UNKNOWN.
Definition: orientedType.H:107
dimensionedScalar sign(const dimensionedScalar &ds)
dictionary dict
friend Ostream & operator<<(Ostream &os, const orientedType &ot)
void setOriented(bool on=true) noexcept
Set the oriented flag: on/off.
Definition: orientedType.H:163
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
orientedOption
Enumeration defining oriented flags.
Definition: orientedType.H:61
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar pow025(const dimensionedScalar &ds)
dimensionSet operator &&(const dimensionSet &ds1, const dimensionSet &ds2)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
static const Enum< orientedOption > orientedOptionNames
Named enumerations for oriented flags.
Definition: orientedType.H:74
Class to determine the &#39;oriented&#39; status of surface fields.
Definition: orientedType.H:52
bool writeEntry(Ostream &os) const
Write the "oriented" flag entry (if ORIENTED)
Definition: orientedType.C:116
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
dimensionedScalar posPart(const dimensionedScalar &ds)
dimensionedScalar neg(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
bool is_oriented() const noexcept
True if ORIENTED.
Definition: orientedType.H:158
dimensionedScalar pos(const dimensionedScalar &ds)
void operator+=(const orientedType &ot)
Definition: orientedType.C:131
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Istream & operator>>(Istream &, directionInfo &)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensionedScalar neg0(const dimensionedScalar &ds)
static bool checkType(const orientedType &a, const orientedType &b) noexcept
True if can operate on this combination of oriented types.
Definition: orientedType.C:43
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
dimensionSet pow2(const dimensionSet &ds)
Definition: dimensionSet.C:352
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
dimensionedScalar pos0(const dimensionedScalar &ds)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
orientedOption oriented() const noexcept
Return the oriented flag.
Definition: orientedType.H:148
OBJstream os(runTime.globalPath()/outputName)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
dimensionSet trans(const dimensionSet &ds)
Check the argument is dimensionless (for transcendental functions)
Definition: dimensionSet.C:471
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition: bitSetI.H:704
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
void read(const dictionary &dict)
Read the "oriented" state from dictionary.
Definition: orientedType.C:104
dimensionedScalar pow3(const dimensionedScalar &ds)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
friend Istream & operator>>(Istream &is, orientedType &ot)
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensionedScalar pow6(const dimensionedScalar &ds)
void operator/=(const orientedType &ot)
Definition: orientedType.C:161
volScalarField & p
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
void operator*=(const orientedType &ot)
Definition: orientedType.C:155
void operator-=(const orientedType &ot)
Definition: orientedType.C:143
bool operator()() const noexcept
Convert to bool. Same as is_oriented()
Definition: orientedType.H:193
orientedType & operator=(const orientedType &) noexcept=default
Copy assignment.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Namespace for OpenFOAM.
dimensionedScalar negPart(const dimensionedScalar &ds)
Unknown/undefined orientation.
Definition: orientedType.H:63