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
ensightCloudField.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 "
ensightCloudField.H
"
27
#include <
OpenFOAM/Time.H
>
28
#include <
OpenFOAM/IOField.H
>
29
#include <
OpenFOAM/OFstream.H
>
30
#include <
OpenFOAM/IOmanip.H
>
31
32
using namespace
Foam;
33
34
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
35
36
template
<
class
Type>
37
void
ensightCloudField
38
(
39
const
Foam::IOobject
&
fieldObject
,
40
const
Foam::fileName
& postProcPath,
41
const
Foam::word
& prepend,
42
const
Foam::label
timeIndex
,
43
const
Foam::word
&
cloudName
,
44
Foam::Ostream
& ensightCaseFile,
45
const
bool
dataExists
46
)
47
{
48
if
(dataExists)
49
{
50
Info
<<
"Converting cloud "
<< cloudName
51
<<
" field "
<< fieldObject.
name
() <<
endl
;
52
}
53
else
54
{
55
Info
<<
"Creating empty cloud "
<< cloudName
56
<<
" field "
<< fieldObject.
name
() <<
endl
;
57
}
58
59
word
timeFile = prepend +
itoa
(timeIndex);
60
61
const
Time
& runTime = fieldObject.
time
();
62
63
if
(timeIndex == 0 &&
Pstream::master
())
64
{
65
ensightCaseFile
66
<<
pTraits<Type>::typeName
<<
" per measured node: 1 "
;
67
ensightCaseFile.
width
(15);
68
ensightCaseFile.
setf
(ios_base::left);
69
ensightCaseFile
70
<< (
"c"
+ fieldObject.
name
()).c_str()
71
<< (
' '
+ prepend +
"***."
+ cloudName
72
+
"."
+ fieldObject.
name
()).c_str()
73
<<
nl
;
74
}
75
76
fileName
ensightFileName
77
(
78
timeFile +
"."
+ cloudName +
"."
+ fieldObject.
name
()
79
);
80
81
OFstream
ensightFile
82
(
83
postProcPath/ensightFileName,
84
runTime.
writeFormat
(),
85
runTime.
writeVersion
(),
86
runTime.
writeCompression
()
87
);
88
89
ensightFile<< pTraits<Type>::typeName
<<
" values"
<<
nl
;
90
91
if
(dataExists)
92
{
93
IOField<Type>
vf(fieldObject);
94
95
ensightFile
.
setf
(
ios_base::scientific
, ios_base::floatfield);
96
ensightFile
.
precision
(5);
97
98
label count = 0;
99
forAll
(vf, i)
100
{
101
Type v = vf[i];
102
103
if
(
mag
(v) < 1.0
e
-90)
104
{
105
v =
pTraits<Type>::zero
;
106
}
107
108
for
(
direction
cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
109
{
110
ensightFile
<<
setw
(12) <<
component
(v, cmpt);
111
if
(++count % 6 == 0)
112
{
113
ensightFile
<<
nl
;
114
}
115
}
116
}
117
118
if
((count % 6 != 0) || (count==0))
119
{
120
ensightFile
<<
nl
;
121
}
122
}
123
}
124
125
126
// ************************ vim: set sw=4 sts=4 et: ************************ //