PatchPostProcessing.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 "PatchPostProcessing.H"
00028 #include "IOPtrList.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 IOPtrList<parcelType> postObject
00058 (
00059 IOobject
00060 (
00061 patchNames_[patchI] + ".post",
00062 this->owner().time().timeName(),
00063 "postProcessing",
00064 this->owner(),
00065 IOobject::NO_READ,
00066 IOobject::NO_WRITE
00067 ),
00068 patchData_[patchI].size()
00069 );
00070
00071 forAll(postObject, ptrI)
00072 {
00073 postObject.set(ptrI, patchData_[patchI][ptrI].ptr());
00074 }
00075
00076 postObject.note() = parcelType::propHeader;
00077
00078 postObject.writeObject
00079 (
00080 IOstream::ASCII,
00081 IOstream::currentVersion,
00082 mesh_.time().writeCompression()
00083 );
00084
00085 patchData_[patchI].clearStorage();
00086 }
00087 }
00088
00089
00090
00091
00092 template<class CloudType>
00093 Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
00094 (
00095 const dictionary& dict,
00096 CloudType& owner
00097 )
00098 :
00099 PostProcessingModel<CloudType>(dict, owner, typeName),
00100 mesh_(owner.mesh()),
00101 patchNames_(this->coeffDict().lookup("patches")),
00102 patchData_(patchNames_.size()),
00103 patchIds_(patchNames_.size())
00104 {
00105 forAll(patchNames_, patchI)
00106 {
00107 label id = mesh_.boundaryMesh().findPatchID(patchNames_[patchI]);
00108 if (id < 0)
00109 {
00110 FatalErrorIn
00111 (
00112 "PatchPostProcessing<CloudType>::PatchPostProcessing"
00113 "("
00114 "const dictionary&, "
00115 "CloudType& owner"
00116 ")"
00117 )<< "Requested patch " << patchNames_[patchI] << " not found" << nl
00118 << "Available patches are: " << mesh_.boundaryMesh().names() << nl
00119 << exit(FatalError);
00120 }
00121 patchIds_[patchI] = id;
00122 }
00123 }
00124
00125
00126
00127
00128 template<class CloudType>
00129 Foam::PatchPostProcessing<CloudType>::~PatchPostProcessing()
00130 {}
00131
00132
00133
00134
00135 template<class CloudType>
00136 bool Foam::PatchPostProcessing<CloudType>::active() const
00137 {
00138 return true;
00139 }
00140
00141
00142 template<class CloudType>
00143 void Foam::PatchPostProcessing<CloudType>::postPatch
00144 (
00145 const parcelType& p,
00146 const label patchI
00147 )
00148 {
00149 label localPatchI = applyToPatch(patchI);
00150 if (localPatchI >= 0 && patchData_[localPatchI].size() < maxStoredParcels_)
00151 {
00152 patchData_[localPatchI].append(p.clone());
00153 }
00154 }
00155
00156
00157
Copyright © 2000-2009 OpenCFD Ltd