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 "foamFileSurfaceWriter.H"
00027
00028 #include <OpenFOAM/OFstream.H>
00029 #include <OpenFOAM/OSspecific.H>
00030
00031
00032
00033 template<class Type>
00034 Foam::foamFileSurfaceWriter<Type>::foamFileSurfaceWriter()
00035 :
00036 surfaceWriter<Type>()
00037 {}
00038
00039
00040
00041
00042 template<class Type>
00043 Foam::foamFileSurfaceWriter<Type>::~foamFileSurfaceWriter()
00044 {}
00045
00046
00047
00048
00049 template<class Type>
00050 void Foam::foamFileSurfaceWriter<Type>::write
00051 (
00052 const fileName& outputDir,
00053 const fileName& surfaceName,
00054 const pointField& points,
00055 const faceList& faces,
00056 const bool verbose
00057 ) const
00058 {
00059 fileName surfaceDir(outputDir/surfaceName);
00060
00061 if (!isDir(surfaceDir))
00062 {
00063 mkDir(surfaceDir);
00064 }
00065
00066 if (verbose)
00067 {
00068 Info<< "Writing geometry to " << surfaceDir << endl;
00069 }
00070
00071
00072 OFstream(surfaceDir/"points")() << points;
00073
00074
00075 OFstream(surfaceDir/"faces")() << faces;
00076
00077
00078
00079 pointField faceCentres(faces.size(),point::zero);
00080
00081 forAll (faces, faceI)
00082 {
00083 faceCentres[faceI] = faces[faceI].centre(points);
00084 }
00085
00086 OFstream(surfaceDir/"faceCentres")() << faceCentres;
00087 }
00088
00089
00090 template<class Type>
00091 void Foam::foamFileSurfaceWriter<Type>::write
00092 (
00093 const fileName& outputDir,
00094 const fileName& surfaceName,
00095 const pointField& points,
00096 const faceList& faces,
00097 const fileName& fieldName,
00098 const Field<Type>& values,
00099 const bool verbose
00100 ) const
00101 {
00102 fileName surfaceDir(outputDir/surfaceName);
00103
00104 if (!isDir(surfaceDir))
00105 {
00106 mkDir(surfaceDir);
00107 }
00108
00109 if (verbose)
00110 {
00111 Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
00112 }
00113
00114
00115
00116
00117
00118 fileName foamName(pTraits<Type>::typeName);
00119 fileName valuesDir(surfaceDir / (foamName + Field<Type>::typeName));
00120
00121 if (!isDir(valuesDir))
00122 {
00123 mkDir(valuesDir);
00124 }
00125
00126
00127 OFstream(valuesDir/fieldName)() << values;
00128 }
00129
00130
00131