Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::orientedType
28
29Description
30 Class to determine the 'oriented' status of surface fields
31
32SourceFiles
33 orientedType.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_orientedType_H
38#define Foam_orientedType_H
39
40#include "Enum.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47// Forward Declarations
48class orientedType;
49
53/*---------------------------------------------------------------------------*\
54 Class orientedType Declaration
55\*---------------------------------------------------------------------------*/
56
57class orientedType
58{
59public:
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
78private:
79
80 // Private Data
81
82 //- Oriented type
83 orientedOption oriented_;
84
85
86public:
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
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
175orientedType min(const orientedType& a, const orientedType& b);
176orientedType max(const orientedType& a, const orientedType& b);
177orientedType lerp(const orientedType& a, const orientedType& b);
178
179orientedType cmptMultiply(const orientedType& ot1, const orientedType& ot2);
180orientedType cmptDivide(const orientedType& ot1, const orientedType& ot);
181orientedType cmptAv(const orientedType& ot);
182
183orientedType pow(const orientedType& ot, const scalar p);
184orientedType sqr(const orientedType& ot);
185orientedType pow2(const orientedType& ot);
186orientedType pow3(const orientedType& ot);
187orientedType pow4(const orientedType& ot);
188orientedType pow5(const orientedType& ot);
189orientedType pow6(const orientedType& ot);
190orientedType pow025(const orientedType& ot);
191
192
196orientedType mag(const orientedType& ot);
200orientedType neg(const orientedType& ot);
204orientedType inv(const orientedType& ot);
205
206
208orientedType atan2(const orientedType& ot1, const orientedType& ot2);
209orientedType hypot(const orientedType& ot1, const orientedType& ot2);
211
212
213// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
214
216orientedType operator*(const scalar s, const orientedType& ot);
217orientedType operator/(const orientedType& ot, const scalar s);
218
219orientedType operator+(const orientedType& ot1, const orientedType& ot2);
220orientedType operator-(const orientedType& ot1, const orientedType& ot2);
221orientedType operator/(const orientedType& ot1, const orientedType& ot2);
222orientedType operator*(const orientedType& ot1, const orientedType& ot2);
223orientedType operator^(const orientedType& ot1, const orientedType& ot2);
224orientedType operator&(const orientedType& ot1, const orientedType& ot2);
225orientedType operator&&(const orientedType& ot1, const orientedType& ot2);
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229} // End namespace Foam
230
231// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232
233#endif
234
235// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Class to determine the 'oriented' status of surface fields.
void operator/=(const orientedType &ot)
bool is_oriented() const noexcept
True if ORIENTED.
void setOriented(bool on=true) noexcept
Set the oriented flag: on/off.
void operator*=(const orientedType &ot)
orientedOption & oriented() noexcept
Return non-const reference to the oriented flag.
void read(const dictionary &dict)
Read the "oriented" state from dictionary.
orientedOption
Enumeration defining oriented flags.
@ UNKNOWN
Unknown/undefined orientation.
@ ORIENTED
Is oriented.
@ UNORIENTED
Is unoriented.
static bool checkType(const orientedType &a, const orientedType &b) noexcept
True if can operate on this combination of oriented types.
void operator-=(const orientedType &ot)
friend Istream & operator>>(Istream &is, orientedType &ot)
orientedType & operator=(const orientedType &) noexcept=default
Copy assignment.
bool operator()() const noexcept
Convert to bool. Same as is_oriented().
bool writeEntry(Ostream &os) const
Write the "oriented" flag entry (if ORIENTED).
friend Ostream & operator<<(Ostream &os, const orientedType &ot)
constexpr orientedType(const bool isOriented) noexcept
Construct from bool.
static const Enum< orientedOption > orientedOptionNames
Named enumerations for oriented flags.
orientedOption oriented() const noexcept
Return the oriented flag.
void operator+=(const orientedType &ot)
constexpr orientedType() noexcept
Default construct as UNKNOWN.
orientedType(const orientedType &) noexcept=default
Copy construct.
orientedType(orientedOption opt) noexcept
Implicit construct from enumeration.
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
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))
Namespace for OpenFOAM.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
dimensionedScalar pow6(const dimensionedScalar &ds)
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
dimensionedScalar pos0(const dimensionedScalar &ds)
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition bitSetI.H:702
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
dimensionedScalar negPart(const dimensionedScalar &ds)
dimensionedScalar sqrt(const dimensionedScalar &ds)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &f1)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator&(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensionSet trans(const dimensionSet &ds)
Check the argument is dimensionless (for transcendental functions).
dimensionedScalar neg(const dimensionedScalar &ds)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
const direction noexcept
Definition scalarImpl.H:265
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensionedScalar neg0(const dimensionedScalar &ds)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensioned< typename scalarProduct< Type1, Type2 >::type > operator&&(const dimensioned< Type1 > &, const dimensioned< Type2 > &)
dimensionSet pow2(const dimensionSet &ds)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedScalar posPart(const dimensionedScalar &ds)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
dimensionedScalar pow025(const dimensionedScalar &ds)
dictionary dict
volScalarField & b