ensightCloudField.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 "ensightCloudField.H"
00028 #include "Time.H"
00029 #include "IOField.H"
00030 #include "OFstream.H"
00031 #include "IOmanip.H"
00032
00033 using namespace Foam;
00034
00035
00036
00037 template<class Type>
00038 void ensightCloudField
00039 (
00040 const Foam::IOobject& fieldObject,
00041 const Foam::fileName& postProcPath,
00042 const Foam::word& prepend,
00043 const Foam::label timeIndex,
00044 const Foam::word& cloudName,
00045 Foam::Ostream& ensightCaseFile,
00046 const bool dataExists
00047 )
00048 {
00049 if (dataExists)
00050 {
00051 Info<< "Converting cloud " << cloudName
00052 << " field " << fieldObject.name() << endl;
00053 }
00054 else
00055 {
00056 Info<< "Creating empty cloud " << cloudName
00057 << " field " << fieldObject.name() << endl;
00058 }
00059
00060 word timeFile = prepend + itoa(timeIndex);
00061
00062 const Time& runTime = fieldObject.time();
00063
00064 if (timeIndex == 0 && Pstream::master())
00065 {
00066 ensightCaseFile
00067 << pTraits<Type>::typeName << " per measured node: 1 ";
00068 ensightCaseFile.width(15);
00069 ensightCaseFile.setf(ios_base::left);
00070 ensightCaseFile
00071 << ("c" + fieldObject.name()).c_str()
00072 << (' ' + prepend + "***." + cloudName
00073 + "." + fieldObject.name()).c_str()
00074 << nl;
00075 }
00076
00077 fileName ensightFileName
00078 (
00079 timeFile + "." + cloudName +"." + fieldObject.name()
00080 );
00081
00082 OFstream ensightFile
00083 (
00084 postProcPath/ensightFileName,
00085 runTime.writeFormat(),
00086 runTime.writeVersion(),
00087 runTime.writeCompression()
00088 );
00089
00090 ensightFile<< pTraits<Type>::typeName << " values" << nl;
00091
00092 if (dataExists)
00093 {
00094 IOField<Type> vf(fieldObject);
00095
00096 ensightFile.setf(ios_base::scientific, ios_base::floatfield);
00097 ensightFile.precision(5);
00098
00099 label count = 0;
00100 forAll(vf, i)
00101 {
00102 Type v = vf[i];
00103
00104 if (mag(v) < 1.0e-90)
00105 {
00106 v = pTraits<Type>::zero;
00107 }
00108
00109 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00110 {
00111 ensightFile << setw(12) << component(v, cmpt);
00112 if (++count % 6 == 0)
00113 {
00114 ensightFile << nl;
00115 }
00116 }
00117 }
00118
00119 if ((count % 6 != 0) || (count==0))
00120 {
00121 ensightFile << nl;
00122 }
00123 }
00124 }
00125
00126
00127
Copyright © 2000-2009 OpenCFD Ltd