Loading...
Searching...
No Matches
ParticleTracks.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "ParticleTracks.H"
30#include "Pstream.H"
31#include "ListListOps.H"
32#include "IOPtrList.H"
33
34// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * //
35
36template<class CloudType>
38{
39 if (cloudPtr_)
40 {
41 cloudPtr_->write();
42
43 if (resetOnWrite_)
44 {
45 cloudPtr_->clear();
46 }
47 }
48 else
49 {
50 DebugInFunction << "invalid cloud pointer" << endl;
51 }
52}
53
54
55// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56
57template<class CloudType>
59(
60 const dictionary& dict,
61 CloudType& owner,
62 const word& modelName
63)
64:
65 CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
66 trackInterval_(this->coeffDict().getLabel("trackInterval")),
67 maxSamples_(this->coeffDict().getLabel("maxSamples")),
68 resetOnWrite_(this->coeffDict().getBool("resetOnWrite")),
69 faceHitCounter_(),
70 cloudPtr_(nullptr)
71{}
72
73
74template<class CloudType>
76(
78)
79:
81 trackInterval_(ppm.trackInterval_),
82 maxSamples_(ppm.maxSamples_),
83 resetOnWrite_(ppm.resetOnWrite_),
84 faceHitCounter_(ppm.faceHitCounter_),
85 cloudPtr_(ppm.cloudPtr_)
86{}
87
88
89// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90
91template<class CloudType>
93(
94 const typename parcelType::trackingData& td
95)
96{
97 if (!cloudPtr_)
98 {
99 cloudPtr_.reset
100 (
101 this->owner().cloneBare(this->owner().name() + "Tracks").ptr()
102 );
103 }
104}
105
106
107template<class CloudType>
109(
110 const parcelType& p,
111 const typename parcelType::trackingData& td
112)
113{
114 if
115 (
116 this->owner().solution().output()
117 || this->owner().solution().transient()
118 )
119 {
120 if (!cloudPtr_)
121 {
123 << "Cloud storage not allocated" << abort(FatalError);
124 }
125
126 const label count =
127 ++(faceHitCounter_(labelPair(p.origProc(), p.origId()), 0));
128
129 const label nSamples = floor(count/trackInterval_);
130
131 if ((count % trackInterval_) == 0 && nSamples < maxSamples_)
132 {
133 cloudPtr_->append
134 (
135 static_cast<parcelType*>(p.clone(this->owner().mesh()).ptr())
136 );
137 }
138 }
139
140 return true;
141}
142
143
144// ************************************************************************* //
Templated cloud function object base class.
CloudFunctionObject(CloudType &owner)
Construct null from owner.
const CloudType & owner() const
Return const access to the owner cloud.
particle::trackingData trackingData
Definition DSMCParcel.H:155
Records particle state (all variables) on each call to postFace.
ParticleTracks(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
void write()
Write post-processing info.
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Selector class for relaxation factors, solver type and solution.
Definition solution.H:95
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
const dictionary & dict() const
Return const access to the cloud dictionary.
const word & modelName() const
Return const access to the name of the sub-model.
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
auto & name
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
#define DebugInFunction
Report an information message using Foam::Info.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition BitOps.H:73
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
DSMCCloud< dsmcParcel > CloudType
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dictionary dict
const label nSamples(pdfDictionary.get< label >("nSamples"))