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