mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: changed definition of complex::one (#1247)
- was historically defined as (1 1), but it is more consistent with the concept of one to have a real component only. Now defined as (1 0): 1+0i STYLE: remove obscure '!' operator for complex conjugate - either use the member function or the '~' operator
This commit is contained in:
committed by
Andrew Heather
parent
f513f8bec6
commit
1788bce0a2
@ -56,11 +56,10 @@ int main(int argc, char *argv[])
|
|||||||
<< "complexVector::one : " << complexVector::one << nl
|
<< "complexVector::one : " << complexVector::one << nl
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
// Comparison
|
for (complex c : { complex{1, 0}, complex{1, 2}} )
|
||||||
|
|
||||||
for (complex c : { complex{1, 0}, complex{1, 2}} )
|
|
||||||
{
|
{
|
||||||
print1(c);
|
print1(c);
|
||||||
|
|
||||||
// TDB: allow implicit construct from scalar?
|
// TDB: allow implicit construct from scalar?
|
||||||
//
|
//
|
||||||
// if (c == 1.0)
|
// if (c == 1.0)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011 OpenFOAM Foundation
|
| Copyright (C) 2011 OpenFOAM Foundation
|
||||||
@ -27,7 +27,7 @@ Typedef
|
|||||||
Foam::complexVector
|
Foam::complexVector
|
||||||
|
|
||||||
Description
|
Description
|
||||||
complexVector obtained from generic Vector.
|
A Vector of complex values with 'scalar' precision.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
complexVectorI.H
|
complexVectorI.H
|
||||||
@ -48,6 +48,7 @@ namespace Foam
|
|||||||
typedef Vector<complex> complexVector;
|
typedef Vector<complex> complexVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
#include "complexVectorI.H"
|
#include "complexVectorI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -23,10 +23,6 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
|
||||||
complexVector specific part of 3D complexVector obtained from
|
|
||||||
generic Vector.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -34,7 +30,7 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline complexVector operator*(const complex& v1, const complexVector& v2)
|
inline complexVector operator*(const complex& v1, const complexVector& v2)
|
||||||
{
|
{
|
||||||
@ -80,8 +76,7 @@ inline complexVector operator/(const complex& v1, const complexVector& v2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// complexVector dot product
|
//- Dot product for complexVector
|
||||||
|
|
||||||
inline complex operator&(const complexVector& v1, const complexVector& v2)
|
inline complex operator&(const complexVector& v1, const complexVector& v2)
|
||||||
{
|
{
|
||||||
return complex
|
return complex
|
||||||
@ -93,8 +88,7 @@ inline complex operator&(const complexVector& v1, const complexVector& v2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// complexVector cross product
|
//- Cross product for complexVector
|
||||||
|
|
||||||
inline complexVector operator^(const complexVector& v1, const complexVector& v2)
|
inline complexVector operator^(const complexVector& v1, const complexVector& v2)
|
||||||
{
|
{
|
||||||
return complexVector
|
return complexVector
|
||||||
@ -106,8 +100,7 @@ inline complexVector operator^(const complexVector& v1, const complexVector& v2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// complexVector cross product
|
//- Cross product for complexVector
|
||||||
|
|
||||||
inline complexVector operator^(const vector& v1, const complexVector& v2)
|
inline complexVector operator^(const vector& v1, const complexVector& v2)
|
||||||
{
|
{
|
||||||
return complexVector
|
return complexVector
|
||||||
|
|||||||
@ -32,7 +32,7 @@ License
|
|||||||
|
|
||||||
const char* const Foam::complex::typeName = "complex";
|
const char* const Foam::complex::typeName = "complex";
|
||||||
const Foam::complex Foam::complex::zero(0, 0);
|
const Foam::complex Foam::complex::zero(0, 0);
|
||||||
const Foam::complex Foam::complex::one(1, 1);
|
const Foam::complex Foam::complex::one(1, 0);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public:
|
|||||||
//- A complex zero (0,0)
|
//- A complex zero (0,0)
|
||||||
static const complex zero;
|
static const complex zero;
|
||||||
|
|
||||||
//- A complex one (1,1)
|
//- A complex one (1,0)
|
||||||
static const complex one;
|
static const complex one;
|
||||||
|
|
||||||
|
|
||||||
@ -189,12 +189,6 @@ public:
|
|||||||
inline void operator*=(const scalar s);
|
inline void operator*=(const scalar s);
|
||||||
inline void operator/=(const scalar s);
|
inline void operator/=(const scalar s);
|
||||||
|
|
||||||
//- Conjugate
|
|
||||||
inline complex operator~() const;
|
|
||||||
|
|
||||||
//- Conjugate
|
|
||||||
inline complex operator!() const;
|
|
||||||
|
|
||||||
inline bool operator==(const complex& c) const;
|
inline bool operator==(const complex& c) const;
|
||||||
inline bool operator!=(const complex& c) const;
|
inline bool operator!=(const complex& c) const;
|
||||||
|
|
||||||
@ -244,6 +238,12 @@ template<>
|
|||||||
inline bool contiguous<complex>() {return true;}
|
inline bool contiguous<complex>() {return true;}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Complex conjugate
|
||||||
|
inline complex operator~(const complex& c);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -174,18 +174,6 @@ inline void Foam::complex::operator/=(const scalar s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::complex Foam::complex::operator~() const
|
|
||||||
{
|
|
||||||
return conjugate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::complex Foam::complex::operator!() const
|
|
||||||
{
|
|
||||||
return conjugate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::complex::operator==(const complex& c) const
|
inline bool Foam::complex::operator==(const complex& c) const
|
||||||
{
|
{
|
||||||
return (equal(re, c.re) && equal(im, c.im));
|
return (equal(re, c.re) && equal(im, c.im));
|
||||||
@ -198,6 +186,14 @@ inline bool Foam::complex::operator!=(const complex& c) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::complex Foam::operator~(const complex& c)
|
||||||
|
{
|
||||||
|
return c.conjugate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user