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-2022 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  //- Named enumerations for oriented flags
73 
74 
75 private:
76 
77  // Private Data
78 
79  //- Oriented type
80  orientedOption oriented_;
81 
82 
83 public:
84 
85  // Generated Methods
86 
87  //- Copy construct
88  orientedType(const orientedType&) noexcept = default;
89 
90  //- Copy assignment
91  orientedType& operator=(const orientedType&) noexcept = default;
92 
93 
94  // Constructors
95 
96  //- Default construct as \c UNKNOWN
97  constexpr orientedType() noexcept
98  :
99  oriented_(UNKNOWN)
100  {}
101 
102  //- Implicit construct from enumeration
104  :
105  oriented_(opt)
106  {}
107 
108  //- Construct from bool
109  explicit constexpr orientedType(const bool isOriented) noexcept
110  :
111  oriented_(isOriented ? ORIENTED : UNORIENTED)
112  {}
113 
114  //- Construct from Istream
115  explicit orientedType(Istream& is);
116 
117 
118  // Member Functions
119 
120  //- Return true if can operate on this pair of oriented types
121  static bool checkType
122  (
123  const orientedType& ot1,
124  const orientedType& ot2
125  ) noexcept;
126 
127  //- Return the oriented flag
128  orientedOption oriented() const noexcept { return oriented_; }
129 
130  //- Return non-const reference to the oriented flag
131  orientedOption& oriented() noexcept { return oriented_; }
132 
133  //- True if \c ORIENTED
134  bool is_oriented() const noexcept { return (oriented_ == ORIENTED); }
135 
136  //- Set the oriented flag: on/off
137  void setOriented(bool on = true) noexcept
138  {
139  oriented_ = on ? ORIENTED : UNORIENTED;
140  }
141 
142  //- Read the "oriented" state from dictionary
143  void read(const dictionary& dict);
144 
145  //- Write the "oriented" flag entry (if \c ORIENTED)
146  // \return True if entry was written
147  bool writeEntry(Ostream& os) const;
148 
149 
150  // Member Operators
151 
152  void operator+=(const orientedType& ot);
153  void operator-=(const orientedType& ot);
154  void operator*=(const orientedType& ot);
155  void operator/=(const orientedType& ot);
156  void operator*=(const scalar s);
157  void operator/=(const scalar s);
158 
159  //- Convert to bool. Same as is_oriented()
160  bool operator()() const noexcept { return is_oriented(); }
161 
162 
163  // IOstream Operators
164 
165  friend Istream& operator>>(Istream& is, orientedType& ot);
166  friend Ostream& operator<<(Ostream& os, const orientedType& ot);
167 };
168 
169 
170 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
171 
172 orientedType max(const orientedType& ot1, const orientedType& ot2);
173 orientedType min(const orientedType& ot1, const orientedType& ot2);
174 orientedType cmptMultiply(const orientedType& ot1, const orientedType& ot2);
175 orientedType cmptDivide(const orientedType& ot1, const orientedType& ot);
176 orientedType cmptAv(const orientedType& ot);
177 
178 
179 orientedType pow(const orientedType& ot, const scalar r);
180 orientedType sqr(const orientedType& ot);
181 orientedType pow3(const orientedType& ot);
182 orientedType pow4(const orientedType& ot);
183 orientedType pow5(const orientedType& ot);
184 orientedType pow6(const orientedType& ot);
185 orientedType pow025(const orientedType& ot);
186 
187 
188 orientedType sqrt(const orientedType& ot);
189 orientedType cbrt(const orientedType& ot);
191 orientedType mag(const orientedType& ot);
192 orientedType sign(const orientedType& ot);
193 orientedType pos(const orientedType& ot);
194 orientedType pos0(const orientedType& ot);
195 orientedType neg(const orientedType& ot);
196 orientedType neg0(const orientedType& ot);
199 orientedType inv(const orientedType& ot);
200 
201 
202 orientedType trans(const orientedType& ot);
203 orientedType atan2(const orientedType& ot1, const orientedType& ot2);
204 orientedType hypot(const orientedType& ot1, const orientedType& ot2);
206 
208 orientedType operator*(const scalar s, const orientedType& ot);
209 orientedType operator/(const orientedType& ot, const scalar s);
210 
211 orientedType operator+(const orientedType& ot1, const orientedType& ot2);
212 orientedType operator-(const orientedType& ot1, const orientedType& ot2);
213 orientedType operator/(const orientedType& ot1, const orientedType& ot2);
214 orientedType operator*(const orientedType& ot1, const orientedType& ot2);
215 orientedType operator^(const orientedType& ot1, const orientedType& ot2);
216 orientedType operator&(const orientedType& ot1, const orientedType& ot2);
217 orientedType operator&&(const orientedType& ot1, const orientedType& ot2);
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
constexpr orientedType() noexcept
Default construct as UNKNOWN.
Definition: orientedType.H:104
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:160
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:71
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:81
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:155
dimensionedScalar pos(const dimensionedScalar &ds)
void operator+=(const orientedType &ot)
Definition: orientedType.C:96
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensionedScalar neg0(const dimensionedScalar &ds)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
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:55
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:145
OBJstream os(runTime.globalPath()/outputName)
dimensionSet trans(const dimensionSet &ds)
Check the argument is dimensionless (for transcendental functions)
Definition: dimensionSet.C:479
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition: bitSetI.H:783
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:76
void read(const dictionary &dict)
Read the "oriented" state from dictionary.
Definition: orientedType.C:69
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:140
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:529
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
void operator*=(const orientedType &ot)
Definition: orientedType.C:134
void operator-=(const orientedType &ot)
Definition: orientedType.C:115
bool operator()() const noexcept
Convert to bool. Same as is_oriented()
Definition: orientedType.H:190
orientedType & operator=(const orientedType &) noexcept=default
Copy assignment.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static bool checkType(const orientedType &ot1, const orientedType &ot2) noexcept
Return true if can operate on this pair of oriented types.
Definition: orientedType.C:43
Namespace for OpenFOAM.
dimensionedScalar negPart(const dimensionedScalar &ds)