1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "ensightOutputFunctions.H"
29 #include "passiveParticle.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
40 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
45 const string& ensightType,
46 const word& fieldName,
47 const fileName& dataMask,
48 const fileName& local,
53 caseFile.setf(ios_base::left);
55 fileName dirName(dataMask);
58 dirName = dirName/local;
69 // prefix variables with 'c' (cloud)
71 << ensightType.c_str()
72 << " per measured node: " << ts << " "
74 << ("c" + Foam::name(cloudNo) + fieldName).c_str()
76 << (dirName/fieldName).c_str()
82 << ensightType.c_str()
84 << setw(15) << fieldName
86 << (dirName/fieldName).c_str()
92 void ensightParticlePositions
95 const fileName& dataDir,
96 const fileName& subDir,
97 const word& cloudName,
98 IOstream::streamFormat format
101 Cloud<passiveParticle> parcels(mesh, cloudName, false);
103 fileName cloudDir = subDir/cloud::prefix/cloudName;
104 fileName postFileName = cloudDir/"positions";
106 // the ITER/lagrangian subdirectory must exist
107 mkDir(dataDir/cloudDir);
108 ensightFile os(dataDir/postFileName, format);
110 // tag binary format (just like geometry files)
111 os.writeBinaryHeader();
112 os.write(postFileName);
114 os.write("particle coordinates");
116 os.write(parcels.size(), 8); // unusual width
119 // binary write is Ensight6 - first ids, then positions
120 if (format == IOstream::BINARY)
127 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
129 const vector& p = elmnt().position();
140 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
142 const vector& p = elmnt().position();
144 os.write(++nParcels, 8); // unusual width
156 void ensightLagrangianField
158 const IOobject& fieldObject,
159 const fileName& dataDir,
160 const fileName& subDir,
161 const word& cloudName,
162 IOstream::streamFormat format
165 Info<< " " << fieldObject.name() << flush;
167 fileName cloudDir = subDir/cloud::prefix/cloudName;
168 fileName postFileName = cloudDir/fieldObject.name();
171 postFileName + " with " + pTraits<Type>::typeName + " values";
173 ensightFile os(dataDir/postFileName, format);
177 IOField<Type> field(fieldObject);
186 if (mag(val) < 1.0e-90)
188 val = pTraits<Type>::zero;
191 for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++)
193 os.write( component(val, cmpt) );
196 count += pTraits<Type>::nComponents;
204 // add final newline if required
212 //- write generalized field components
213 template <class Type>
216 const ensightParts& partsList,
217 const IOobject& fieldObject,
219 const fileName& dataDir,
220 const fileName& subDir,
221 IOstream::streamFormat format
224 Info<< " " << fieldObject.name() << flush;
226 fileName postFileName = subDir/fieldObject.name();
228 ensightFile os(dataDir/postFileName, format);
229 os.write(postFileName);
232 // ie, volField<Type>
236 GeometricField<Type, fvPatchField, volMesh>
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 // ************************************************************************* //