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
lagrangian
solidParticle
solidParticleIO.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 "
solidParticle.H
"
27
#include <
OpenFOAM/IOstreams.H
>
28
29
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31
Foam::solidParticle::solidParticle
32
(
33
const
Cloud<solidParticle>
&
cloud
,
34
Istream
& is,
35
bool
readFields
36
)
37
:
38
Particle<solidParticle>
(cloud, is,
readFields
)
39
{
40
if
(readFields)
41
{
42
if
(is.format() == IOstream::ASCII)
43
{
44
d_ =
readScalar
(is);
45
is >> U_;
46
}
47
else
48
{
49
is.read
50
(
51
reinterpret_cast<char*>(&d_),
52
sizeof
(d_) +
sizeof
(U_)
53
);
54
}
55
}
56
57
// Check state of Istream
58
is.check(
"solidParticle::solidParticle(Istream&)"
);
59
}
60
61
62
void
Foam::solidParticle::readFields
(
Cloud<solidParticle>
& c)
63
{
64
if
(!c.
size
())
65
{
66
return
;
67
}
68
IOField<scalar>
d
(c.
fieldIOobject
(
"d"
,
IOobject::MUST_READ
));
69
c.
checkFieldIOobject
(c,
d
);
70
71
IOField<vector>
U
(c.
fieldIOobject
(
"U"
,
IOobject::MUST_READ
));
72
c.
checkFieldIOobject
(c,
U
);
73
74
label i = 0;
75
forAllIter
(
Cloud<solidParticle>
, c, iter)
76
{
77
solidParticle
&
p
= iter();
78
79
p.d_ =
d
[i];
80
p.U_ =
U
[i];
81
i++;
82
}
83
}
84
85
86
void
Foam::solidParticle::writeFields
(
const
Cloud<solidParticle>
& c)
87
{
88
Particle<solidParticle>::writeFields
(c);
89
90
label np = c.
size
();
91
92
IOField<scalar>
d
(c.
fieldIOobject
(
"d"
,
IOobject::NO_READ
), np);
93
IOField<vector>
U
(c.
fieldIOobject
(
"U"
,
IOobject::NO_READ
), np);
94
95
label i = 0;
96
forAllConstIter
(
Cloud<solidParticle>
, c, iter)
97
{
98
const
solidParticle
&
p
= iter();
99
100
d
[i] = p.d_;
101
U
[i] = p.U_;
102
i++;
103
}
104
105
d
.write();
106
U
.write();
107
}
108
109
110
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
111
112
Foam::Ostream
&
Foam::operator<<
(
Ostream
& os,
const
solidParticle
&
p
)
113
{
114
if
(os.
format
() ==
IOstream::ASCII
)
115
{
116
os << static_cast<const Particle<solidParticle>&>(
p
)
117
<<
token::SPACE
<< p.d_
118
<<
token::SPACE
<< p.U_;
119
}
120
else
121
{
122
os << static_cast<const Particle<solidParticle>&>(
p
);
123
os.
write
124
(
125
reinterpret_cast<const char*>(&p.d_),
126
sizeof
(p.d_) +
sizeof
(p.U_)
127
);
128
}
129
130
// Check state of Ostream
131
os.
check
(
"Ostream& operator<<(Ostream&, const solidParticle&)"
);
132
133
return
os;
134
}
135
136
137
// ************************ vim: set sw=4 sts=4 et: ************************ //