1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ensightOutputFunctions.H"
28 #include "passiveParticle.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
39 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
44 const string& ensightType,
45 const word& fieldName,
46 const fileName& dataMask,
47 const fileName& local,
52 caseFile.setf(ios_base::left);
54 fileName dirName(dataMask);
57 dirName = dirName/local;
68 // prefix variables with 'c' (cloud)
70 << ensightType.c_str()
71 << " per measured node: " << ts << " "
73 << ("c" + Foam::name(cloudNo) + fieldName).c_str()
75 << (dirName/fieldName).c_str()
81 << ensightType.c_str()
83 << setw(15) << fieldName
85 << (dirName/fieldName).c_str()
91 void ensightParticlePositions
94 const fileName& dataDir,
95 const fileName& subDir,
96 const word& cloudName,
97 IOstream::streamFormat format
100 Cloud<passiveParticle> parcels(mesh, cloudName, false);
102 fileName cloudDir = subDir/cloud::prefix/cloudName;
103 fileName postFileName = cloudDir/"positions";
105 // the ITER/lagrangian subdirectory must exist
106 mkDir(dataDir/cloudDir);
107 ensightFile os(dataDir/postFileName, format);
109 // tag binary format (just like geometry files)
110 os.writeBinaryHeader();
111 os.write(postFileName);
113 os.write("particle coordinates");
115 os.write(parcels.size(), 8); // unusual width
118 // binary write is Ensight6 - first ids, then positions
119 if (format == IOstream::BINARY)
126 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
128 const vector& p = elmnt().position();
139 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
141 const vector& p = elmnt().position();
143 os.write(++nParcels, 8); // unusual width
155 void ensightLagrangianField
157 const IOobject& fieldObject,
158 const fileName& dataDir,
159 const fileName& subDir,
160 const word& cloudName,
161 IOstream::streamFormat format
164 Info<< " " << fieldObject.name() << flush;
166 fileName cloudDir = subDir/cloud::prefix/cloudName;
167 fileName postFileName = cloudDir/fieldObject.name();
170 postFileName + " with " + pTraits<Type>::typeName + " values";
172 ensightFile os(dataDir/postFileName, format);
176 IOField<Type> field(fieldObject);
185 if (mag(val) < 1.0e-90)
187 val = pTraits<Type>::zero;
190 for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++)
192 os.write( component(val, cmpt) );
195 count += pTraits<Type>::nComponents;
203 // add final newline if required
211 //- write generalized field components
212 template <class Type>
215 const ensightParts& partsList,
216 const IOobject& fieldObject,
218 const fileName& dataDir,
219 const fileName& subDir,
220 IOstream::streamFormat format
223 Info<< " " << fieldObject.name() << flush;
225 fileName postFileName = subDir/fieldObject.name();
227 ensightFile os(dataDir/postFileName, format);
228 os.write(postFileName);
231 // ie, volField<Type>
235 GeometricField<Type, fvPatchField, volMesh>
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 // ************************************************************************* //