1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ParticleTracks.H"
28 #include "ListListOps.H"
29 #include "IOPtrList.H"
31 // * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * //
33 template<class CloudType>
34 void Foam::ParticleTracks<CloudType>::write()
36 if (cloudPtr_.valid())
49 Info<< "void Foam::ParticleTracks<CloudType>::write()" << nl
50 << "cloupPtr invalid" << endl;
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 template<class CloudType>
59 Foam::ParticleTracks<CloudType>::ParticleTracks
61 const dictionary& dict,
65 CloudFunctionObject<CloudType>(dict, owner, typeName),
66 trackInterval_(readLabel(this->coeffDict().lookup("trackInterval"))),
67 maxSamples_(readLabel(this->coeffDict().lookup("maxSamples"))),
68 resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
74 template<class CloudType>
75 Foam::ParticleTracks<CloudType>::ParticleTracks
77 const ParticleTracks<CloudType>& ppm
80 CloudFunctionObject<CloudType>(ppm),
81 trackInterval_(ppm.trackInterval_),
82 maxSamples_(ppm.maxSamples_),
83 resetOnWrite_(ppm.resetOnWrite_),
84 faceHitCounter_(ppm.faceHitCounter_),
85 cloudPtr_(ppm.cloudPtr_)
89 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 template<class CloudType>
92 Foam::ParticleTracks<CloudType>::~ParticleTracks()
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 template<class CloudType>
99 void Foam::ParticleTracks<CloudType>::preEvolve()
101 if (!cloudPtr_.valid())
105 this->owner().cloneBare(this->owner().name() + "Tracks").ptr()
111 template<class CloudType>
112 void Foam::ParticleTracks<CloudType>::postFace
120 this->owner().solution().output()
121 || this->owner().solution().transient()
124 if (!cloudPtr_.valid())
128 "Foam::ParticleTracks<CloudType>::postFace"
130 "const parcelType,& "
133 )<< "Cloud storage not allocated" << abort(FatalError);
136 hitTableType::iterator iter =
137 faceHitCounter_.find(labelPair(p.origProc(), p.origId()));
140 if (iter != faceHitCounter_.end())
148 faceHitCounter_.insert(labelPair(p.origProc(), p.origId()), localI);
151 label nSamples = floor(localI/trackInterval_);
152 if ((localI % trackInterval_ == 0) && (nSamples < maxSamples_))
156 static_cast<parcelType*>(p.clone(this->owner().mesh()).ptr())
163 // ************************************************************************* //