Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
primitives
VectorSpace
VectorSpace.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
\*---------------------------------------------------------------------------*/
25
26
#include "
VectorSpace.H
"
27
#include <
OpenFOAM/IOstreams.H
>
28
29
#include <sstream>
30
31
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33
// Construct from Istream
34
template
<
class
Form,
class
Cmpt,
int
nCmpt>
35
Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
36
(
37
Istream
& is
38
)
39
{
40
// Read beginning of VectorSpace<Cmpt>
41
is.
readBegin
(
"VectorSpace<Form, Cmpt, nCmpt>"
);
42
43
for
(
int
i=0; i<nCmpt; i++)
44
{
45
is >> v_[i];
46
}
47
48
// Read end of VectorSpace<Cmpt>
49
is.
readEnd
(
"VectorSpace<Form, Cmpt, nCmpt>"
);
50
51
// Check state of Istream
52
is.
check
(
"VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(Istream&)"
);
53
}
54
55
56
// Return a string representation
57
template
<
class
Form,
class
Cmpt,
int
nCmpt>
58
Foam::word
59
Foam::name
60
(
61
const
VectorSpace<Form, Cmpt, nCmpt>
& vs
62
)
63
{
64
std::ostringstream buf;
65
66
buf <<
'('
;
67
68
for
(
int
i=0; i<nCmpt-1; i++)
69
{
70
buf << vs.
v_
[i] <<
','
;
71
}
72
73
buf << vs.
v_
[nCmpt-1] <<
')'
;
74
75
return
buf.str();
76
}
77
78
79
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
80
81
template
<
class
Form,
class
Cmpt,
int
nCmpt>
82
Foam::Istream
& Foam::operator>>
83
(
84
Istream
& is,
85
VectorSpace<Form, Cmpt, nCmpt>
& vs
86
)
87
{
88
// Read beginning of VectorSpace<Cmpt, nCmpt>
89
is.
readBegin
(
"VectorSpace<Form, Cmpt, nCmpt>"
);
90
91
for
(
int
i=0; i<nCmpt; i++)
92
{
93
is >> vs.
v_
[i];
94
}
95
96
// Read end of VectorSpace<Cmpt, nCmpt>
97
is.
readEnd
(
"VectorSpace<Form, Cmpt, nCmpt>"
);
98
99
// Check state of Istream
100
is.
check
(
"operator>>(Istream&, VectorSpace<Form, Cmpt, nCmpt>&)"
);
101
102
return
is;
103
}
104
105
106
template
<
class
Form,
class
Cmpt,
int
nCmpt>
107
Foam::Ostream
& Foam::operator<<
108
(
109
Ostream
& os,
110
const
VectorSpace<Form, Cmpt, nCmpt>
& vs
111
)
112
{
113
os << token::BEGIN_LIST;
114
115
for
(
int
i=0; i<nCmpt-1; i++)
116
{
117
os << vs.
v_
[i] << token::SPACE;
118
}
119
120
os << vs.
v_
[nCmpt-1] << token::END_LIST;
121
122
// Check state of Ostream
123
os.
check
(
"operator<<(Ostream&, const VectorSpace<Form, Cmpt, nCmpt>&)"
);
124
125
return
os;
126
}
127
128
129
// ************************ vim: set sw=4 sts=4 et: ************************ //