1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "ensightCloudField.H"
35 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
38 void ensightCloudField
40 const Foam::IOobject& fieldObject,
41 const Foam::fileName& postProcPath,
42 const Foam::word& prepend,
43 const Foam::label timeIndex,
44 const Foam::word& cloudName,
45 Foam::Ostream& ensightCaseFile,
51 Info<< "Converting cloud " << cloudName
52 << " field " << fieldObject.name() << endl;
56 Info<< "Creating empty cloud " << cloudName
57 << " field " << fieldObject.name() << endl;
60 word timeFile = prepend + itoa(timeIndex);
62 const Time& runTime = fieldObject.time();
64 if (timeIndex == 0 && Pstream::master())
67 << pTraits<Type>::typeName << " per measured node: 1 ";
68 ensightCaseFile.width(15);
69 ensightCaseFile.setf(ios_base::left);
71 << ("c" + fieldObject.name()).c_str()
72 << (' ' + prepend + "***." + cloudName
73 + "." + fieldObject.name()).c_str()
77 fileName ensightFileName
79 timeFile + "." + cloudName +"." + fieldObject.name()
84 postProcPath/ensightFileName,
85 ios_base::out|ios_base::trunc,
86 runTime.writeFormat(),
87 runTime.writeVersion(),
88 runTime.writeCompression()
91 ensightFile<< pTraits<Type>::typeName << " values" << nl;
95 IOField<Type> vf(fieldObject);
97 ensightFile.setf(ios_base::scientific, ios_base::floatfield);
98 ensightFile.precision(5);
105 if (mag(v) < 1.0e-90)
107 v = pTraits<Type>::zero;
110 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
112 ensightFile << setw(12) << component(v, cmpt);
113 if (++count % 6 == 0)
120 if ((count % 6 != 0) || (count==0))
128 // ************************************************************************* //