1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "PatchPostProcessing.H"
29 #include "ListListOps.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 template <class CloudType>
34 Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
36 const label globalPatchI
39 forAll(patchIds_, patchI)
41 if (patchIds_[patchI] == globalPatchI)
51 // * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * //
53 template<class CloudType>
54 void Foam::PatchPostProcessing<CloudType>::write()
56 forAll(patchData_, patchI)
58 List<List<string> > procData(Pstream::nProcs());
59 procData[Pstream::myProcNo()] = patchData_[patchI];
61 Pstream::gatherList(procData);
63 if (Pstream::master())
67 if (Pstream::parRun())
69 // Put in undecomposed case (Note: gives problems for
70 // distributed data running)
72 mesh_.time().path()/".."/"postProcessing"/cloud::prefix/
73 this->owner().name()/this->owner().time().timeName();
78 mesh_.time().path()/"postProcessing"/cloud::prefix/
79 this->owner().name()/this->owner().time().timeName();
82 // Create directory if it doesn't exist
87 outputDir/patchNames_[patchI] + ".post",
88 ios_base::out|ios_base::trunc,
90 IOstream::currentVersion,
91 mesh_.time().writeCompression()
94 List<string> globalData;
95 globalData = ListListOps::combine<List<string> >
98 accessOp<List<string> >()
102 patchOutFile<< "# Time " + parcelType::propHeader << nl;
104 forAll(globalData, i)
106 patchOutFile<< globalData[i].c_str() << nl;
110 patchData_[patchI].clearStorage();
115 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 template<class CloudType>
118 Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
120 const dictionary& dict,
124 PostProcessingModel<CloudType>(dict, owner, typeName),
126 maxStoredParcels_(readLabel(this->coeffDict().lookup("maxStoredParcels"))),
127 patchNames_(this->coeffDict().lookup("patches")),
128 patchData_(patchNames_.size()),
129 patchIds_(patchNames_.size())
131 forAll(patchNames_, patchI)
133 label id = mesh_.boundaryMesh().findPatchID(patchNames_[patchI]);
138 "PatchPostProcessing<CloudType>::PatchPostProcessing"
140 "const dictionary&, "
143 )<< "Requested patch " << patchNames_[patchI] << " not found" << nl
144 << "Available patches are: " << mesh_.boundaryMesh().names() << nl
147 patchIds_[patchI] = id;
152 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 template<class CloudType>
155 Foam::PatchPostProcessing<CloudType>::~PatchPostProcessing()
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161 template<class CloudType>
162 bool Foam::PatchPostProcessing<CloudType>::active() const
168 template<class CloudType>
169 void Foam::PatchPostProcessing<CloudType>::postPatch
175 label localPatchI = applyToPatch(patchI);
176 if (localPatchI >= 0 && patchData_[localPatchI].size() < maxStoredParcels_)
179 data<< this->owner().time().timeName() << ' ' << p;
180 patchData_[localPatchI].append(data.str());
185 // ************************************************************************* //