ensightParticlePositions.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "ensightParticlePositions.H"
00028 #include "fvMesh.H"
00029 #include "passiveParticle.H"
00030 #include "Cloud.H"
00031 #include "OFstream.H"
00032 #include "IOmanip.H"
00033 #include "itoa.H"
00034
00035 using namespace Foam;
00036
00037
00038
00039 void ensightParticlePositions
00040 (
00041 const Foam::fvMesh& mesh,
00042 const Foam::fileName& postProcPath,
00043 const Foam::word& timeFile,
00044 const Foam::word& cloudName,
00045 const bool dataExists
00046 )
00047 {
00048 if (dataExists)
00049 {
00050 Info<< "Converting cloud " << cloudName << " positions" << endl;
00051 }
00052 else
00053 {
00054 Info<< "Creating empty cloud " << cloudName << " positions" << endl;
00055 }
00056
00057 const Time& runTime = mesh.time();
00058
00059 fileName ensightFileName(timeFile + "." + cloudName);
00060 OFstream ensightFile
00061 (
00062 postProcPath/ensightFileName,
00063 runTime.writeFormat(),
00064 runTime.writeVersion(),
00065 runTime.writeCompression()
00066 );
00067
00068
00069 ensightFile
00070 << cloudName.c_str() << nl
00071 << "particle coordinates" << nl;
00072
00073 if (dataExists)
00074 {
00075 Cloud<passiveParticle> parcels(mesh, cloudName, false);
00076
00077
00078 ensightFile.setf(ios_base::scientific, ios_base::floatfield);
00079 ensightFile.precision(5);
00080
00081 ensightFile<< setw(8) << parcels.size() << nl;
00082
00083 label nParcels = 0;
00084
00085
00086 forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
00087 {
00088 const vector& p = elmnt().position();
00089
00090 ensightFile
00091 << setw(8) << ++nParcels
00092 << setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
00093 << nl;
00094 }
00095 }
00096 else
00097 {
00098 label nParcels = 0;
00099 ensightFile<< setw(8) << nParcels << nl;
00100 }
00101 }
00102
00103
00104
Copyright © 2000-2009 OpenCFD Ltd