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
applications
utilities
postProcessing
dataConversion
foamToEnsight
ensightParticlePositions.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 "
ensightParticlePositions.H
"
27
#include <
finiteVolume/fvMesh.H
>
28
#include <
lagrangian/passiveParticle.H
>
29
#include <
lagrangian/Cloud.H
>
30
#include <
OpenFOAM/OFstream.H
>
31
#include <
OpenFOAM/IOmanip.H
>
32
#include "
itoa.H
"
33
34
using namespace
Foam;
35
36
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
37
38
void
ensightParticlePositions
39
(
40
const
Foam::fvMesh
&
mesh
,
41
const
Foam::fileName
& postProcPath,
42
const
Foam::word
& timeFile,
43
const
Foam::word
&
cloudName
,
44
const
bool
dataExists
45
)
46
{
47
if
(dataExists)
48
{
49
Info
<<
"Converting cloud "
<< cloudName <<
" positions"
<<
endl
;
50
}
51
else
52
{
53
Info
<<
"Creating empty cloud "
<< cloudName <<
" positions"
<<
endl
;
54
}
55
56
const
Time
& runTime = mesh.
time
();
57
58
fileName
ensightFileName(timeFile +
"."
+ cloudName);
59
OFstream
ensightFile
60
(
61
postProcPath/ensightFileName,
62
runTime.
writeFormat
(),
63
runTime.
writeVersion
(),
64
runTime.
writeCompression
()
65
);
66
67
// Output header
68
ensightFile
69
<< cloudName.c_str() <<
nl
70
<<
"particle coordinates"
<<
nl
;
71
72
if
(dataExists)
73
{
74
Cloud<passiveParticle>
parcels(mesh, cloudName,
false
);
75
76
// Set Format
77
ensightFile
.
setf
(
ios_base::scientific
, ios_base::floatfield);
78
ensightFile
.
precision
(5);
79
80
ensightFile
<<
setw
(8) << parcels.size() <<
nl
;
81
82
label nParcels = 0;
83
84
// Output positions
85
forAllConstIter
(
Cloud<passiveParticle>
, parcels,
elmnt
)
86
{
87
const
vector
&
p
=
elmnt
().position();
88
89
ensightFile
90
<<
setw
(8) << ++nParcels
91
<<
setw
(12) << p.
x
() <<
setw
(12) << p.
y
() <<
setw
(12) << p.
z
()
92
<<
nl
;
93
}
94
}
95
else
96
{
97
label nParcels = 0;
98
ensightFile
<<
setw
(8) << nParcels <<
nl
;
99
}
100
}
101
102
103
// ************************ vim: set sw=4 sts=4 et: ************************ //