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 "PatchPostProcessing.H"
00027 #include <OpenFOAM/Pstream.H>
00028 #include <OpenFOAM/ListListOps.H>
00029
00030
00031
00032 template <class CloudType>
00033 Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
00034 (
00035 const label globalPatchI
00036 ) const
00037 {
00038 forAll(patchIds_, patchI)
00039 {
00040 if (patchIds_[patchI] == globalPatchI)
00041 {
00042 return patchI;
00043 }
00044 }
00045
00046 return -1;
00047 }
00048
00049
00050
00051
00052 template<class CloudType>
00053 void Foam::PatchPostProcessing<CloudType>::write()
00054 {
00055 forAll(patchData_, patchI)
00056 {
00057 List<List<string> > procData(Pstream::nProcs());
00058 procData[Pstream::myProcNo()] = patchData_[patchI];
00059
00060 Pstream::gatherList(procData);
00061
00062 if (Pstream::master())
00063 {
00064 fileName outputDir;
00065
00066 if (Pstream::parRun())
00067 {
00068
00069
00070 outputDir =
00071 mesh_.time().path()/".."/"postProcessing"/cloud::prefix/
00072 this->owner().name()/this->owner().time().timeName();
00073 }
00074 else
00075 {
00076 outputDir =
00077 mesh_.time().path()/"postProcessing"/cloud::prefix/
00078 this->owner().name()/this->owner().time().timeName();
00079 }
00080
00081
00082 mkDir(outputDir);
00083
00084 OFstream patchOutFile
00085 (
00086 outputDir/patchNames_[patchI] + ".post",
00087 IOstream::ASCII,
00088 IOstream::currentVersion,
00089 mesh_.time().writeCompression()
00090 );
00091
00092 List<string> globalData;
00093 globalData = ListListOps::combine<List<string> >
00094 (
00095 procData,
00096 accessOp<List<string> >()
00097 );
00098 sort(globalData);
00099
00100 patchOutFile<< "# Time " + parcelType::propHeader << nl;
00101
00102 forAll(globalData, i)
00103 {
00104 patchOutFile<< globalData[i].c_str() << nl;
00105 }
00106 }
00107
00108 patchData_[patchI].clearStorage();
00109 }
00110 }
00111
00112
00113
00114
00115 template<class CloudType>
00116 Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
00117 (
00118 const dictionary& dict,
00119 CloudType& owner
00120 )
00121 :
00122 PostProcessingModel<CloudType>(dict, owner, typeName),
00123 mesh_(owner.mesh()),
00124 maxStoredParcels_(readLabel(this->coeffDict().lookup("maxStoredParcels"))),
00125 patchNames_(this->coeffDict().lookup("patches")),
00126 patchData_(patchNames_.size()),
00127 patchIds_(patchNames_.size())
00128 {
00129 forAll(patchNames_, patchI)
00130 {
00131 label id = mesh_.boundaryMesh().findPatchID(patchNames_[patchI]);
00132 if (id < 0)
00133 {
00134 FatalErrorIn
00135 (
00136 "PatchPostProcessing<CloudType>::PatchPostProcessing"
00137 "("
00138 "const dictionary&, "
00139 "CloudType& owner"
00140 ")"
00141 )<< "Requested patch " << patchNames_[patchI] << " not found" << nl
00142 << "Available patches are: " << mesh_.boundaryMesh().names() << nl
00143 << exit(FatalError);
00144 }
00145 patchIds_[patchI] = id;
00146 }
00147 }
00148
00149
00150
00151
00152 template<class CloudType>
00153 Foam::PatchPostProcessing<CloudType>::~PatchPostProcessing()
00154 {}
00155
00156
00157
00158
00159 template<class CloudType>
00160 bool Foam::PatchPostProcessing<CloudType>::active() const
00161 {
00162 return true;
00163 }
00164
00165
00166 template<class CloudType>
00167 void Foam::PatchPostProcessing<CloudType>::postPatch
00168 (
00169 const parcelType& p,
00170 const label patchI
00171 )
00172 {
00173 label localPatchI = applyToPatch(patchI);
00174 if (localPatchI >= 0 && patchData_[localPatchI].size() < maxStoredParcels_)
00175 {
00176 OStringStream data;
00177 data<< this->owner().time().timeName() << ' ' << p;
00178 patchData_[localPatchI].append(data.str());
00179 }
00180 }
00181
00182
00183