OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

PatchPostProcessing.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "PatchPostProcessing.H"
00028 #include "IOPtrList.H"
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
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 // * * * * * * * * * * * * * protected Member Functions  * * * * * * * * * * //
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 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
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 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00127 
00128 template<class CloudType>
00129 Foam::PatchPostProcessing<CloudType>::~PatchPostProcessing()
00130 {}
00131 
00132 
00133 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
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