1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ensightOutputFunctions.H"
28 #include "passiveParticle.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
37 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
39 void Foam::ensightCaseEntry
42 const string& ensightType,
43 const word& fieldName,
44 const fileName& dataMask,
45 const fileName& local,
50 caseFile.setf(ios_base::left);
52 fileName dirName(dataMask);
55 dirName = dirName/local;
66 // prefix variables with 'c' (cloud)
68 << ensightType.c_str()
69 << " per measured node: " << ts << " "
71 << ("c" + Foam::name(cloudNo) + fieldName).c_str()
73 << (dirName/fieldName).c_str()
79 << ensightType.c_str()
81 << setw(15) << fieldName
83 << (dirName/fieldName).c_str()
89 void Foam::ensightParticlePositions
92 const fileName& dataDir,
93 const fileName& subDir,
94 const word& cloudName,
95 IOstream::streamFormat format
98 Cloud<passiveParticle> parcels(mesh, cloudName, false);
100 fileName cloudDir = subDir/cloud::prefix/cloudName;
101 fileName postFileName = cloudDir/"positions";
103 // the ITER/lagrangian subdirectory must exist
104 mkDir(dataDir/cloudDir);
105 ensightFile os(dataDir/postFileName, format);
107 // tag binary format (just like geometry files)
108 os.writeBinaryHeader();
109 os.write(postFileName);
111 os.write("particle coordinates");
113 os.write(parcels.size(), 8); // unusual width
116 // binary write is Ensight6 - first ids, then positions
117 if (format == IOstream::BINARY)
124 forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
126 const vector& p = elmnt().position();
137 forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
139 const vector& p = elmnt().position();
141 os.write(++nParcels, 8); // unusual width
153 void Foam::ensightLagrangianField
155 const IOobject& fieldObject,
156 const fileName& dataDir,
157 const fileName& subDir,
158 const word& cloudName,
159 IOstream::streamFormat format
162 Info<< " " << fieldObject.name() << flush;
164 fileName cloudDir = subDir/cloud::prefix/cloudName;
165 fileName postFileName = cloudDir/fieldObject.name();
168 postFileName + " with " + pTraits<Type>::typeName + " values";
170 ensightFile os(dataDir/postFileName, format);
174 IOField<Type> field(fieldObject);
183 if (mag(val) < 1.0e-90)
185 val = pTraits<Type>::zero;
188 for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++)
190 os.write( component(val, cmpt) );
193 count += pTraits<Type>::nComponents;
201 // add final newline if required
209 //- write generalized field components
210 template <class Type>
211 void Foam::ensightVolField
213 const ensightParts& partsList,
214 const IOobject& fieldObject,
216 const fileName& dataDir,
217 const fileName& subDir,
218 IOstream::streamFormat format
221 Info<< " " << fieldObject.name() << flush;
223 fileName postFileName = subDir/fieldObject.name();
225 ensightFile os(dataDir/postFileName, format);
226 os.write(postFileName);
229 // ie, volField<Type>
233 GeometricField<Type, fvPatchField, volMesh>
242 // ************************************************************************* //