complex.C
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) 2011 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "complex.H"
30#include "IOstreams.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34const char* const Foam::pTraits<Foam::complex>::typeName = "complex";
35const char* const Foam::pTraits<Foam::complex>::componentNames[] = {"re", "im"};
36
39
42
44(
45 -ROOTVGREAT, -ROOTVGREAT
46);
47
49(
50 ROOTVGREAT, ROOTVGREAT
51);
52
53
54// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55
57{
58 is >> p_;
59}
60
61
63{
64 is >> *this;
65}
66
67
68// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
69
71{
72 return '(' + std::to_string(c.Re()) + ',' + std::to_string(c.Im()) + ')';
73}
74
75
76// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
77
79{
80 scalar r, i;
81
82 is.readBegin("complex");
83 is >> r >> i;
84 is.readEnd("complex");
85
86 c.real(r);
87 c.imag(i);
88
90 return is;
91}
92
93
95{
97 << c.real() << token::SPACE << c.imag()
99
100 return os;
101}
102
103
104// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
bool readEnd(const char *funcName)
End read of data chunk, ends with ')'.
Definition: Istream.C:129
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: Istream.C:111
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A complex number, similar to the C++ complex type.
Definition: complex.H:83
constexpr complex() noexcept
Default construct, as zero-initialized.
Definition: complexI.H:31
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
static const complex rootMax
complex (ROOTVGREAT, ROOTVGREAT)
Definition: complex.H:295
static const complex min
complex (-VGREAT,-VGREAT)
Definition: complex.H:292
static const complex max
complex (VGREAT,VGREAT)
Definition: complex.H:293
static const complex rootMin
complex (-ROOTVGREAT, -ROOTVGREAT)
Definition: complex.H:294
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ END_LIST
End list [isseparator].
Definition: token.H:156
@ SPACE
Space [isspace].
Definition: token.H:125
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
A non-counting (dummy) refCount.
Definition: refCount.H:59