PatchInteractionFields.H
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) 2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::PatchInteractionFields
28 
29 Group
30  grpLagrangianIntermediateFunctionObjects
31 
32 Description
33  Creates volume fields whose boundaries are used to store patch interaction
34  statistics.
35 
36  Current field output per patch face:
37  - <cloud><model>:count - cumulative particle hits
38  - <cloud><model>:mass - cumulative mass of hitting particles
39 
40  Fields can be reset according to:
41  - none: fields are not reset
42  - timeStep: reset at each time step
43  - writeTime: reset at each write time
44 
45 Usage
46 
47  \verbatim
48  patchInteractionFields1
49  {
50  type patchInteractionFields;
51  resetMode writeTime;
52  }
53  \endverbatim
54 
55 SourceFiles
56  PatchInteractionFields.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef PatchInteractionFields_H
61 #define PatchInteractionFields_H
62 
63 #include "CloudFunctionObject.H"
64 #include "volFields.H"
65 #include "Enum.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class PatchInteractionFields Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class CloudType>
78 :
79  public CloudFunctionObject<CloudType>
80 {
81 public:
82 
83  // Public enumerations
84 
85  //- Reset mode
86  enum class resetMode
87  {
88  none,
89  timeStep,
90  writeTime
91  };
92 
93  static const Enum<resetMode> resetModeNames_;
94 
95 
96 private:
97 
98  // Private Data
99 
100  //- Convenience typedef for parcel type
101  typedef typename CloudType::parcelType parcelType;
102 
103  //- Parcel mass field
104  autoPtr<volScalarField> massPtr_;
105 
106  //- Parcel count field
107  autoPtr<volScalarField> countPtr_;
108 
109  //- Reset mode
110  resetMode resetMode_;
111 
112 
113 protected:
114 
115  // Protected Member Functions
116 
117  //- Create|read|reset the fields
118  void reset();
119 
120  //- Write post-processing info
121  virtual void write();
122 
123  //- Helper function to clear or reset fields
124  void clearOrReset
125  (
126  autoPtr<volScalarField>& fieldPtr,
127  const word& fieldName,
128  const dimensionSet& dims
129  ) const;
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("patchInteractionFields");
136 
137 
138  // Constructors
139 
140  //- Construct from dictionary
142  (
143  const dictionary& dict,
144  CloudType& owner,
145  const word& modelName
146  );
147 
148  //- Construct copy
150 
151  //- Construct and return a clone
153  {
155  (
157  );
158  }
159 
160 
161  //- Destructor
162  virtual ~PatchInteractionFields() = default;
163 
164 
165  // Member Functions
166 
167  // Evaluation
168 
169  //- Pre-evolve hook
170  virtual void preEvolve
171  (
172  const typename parcelType::trackingData& td
173  );
174 
175  //- Post-patch hook
176  virtual void postPatch
177  (
178  const parcelType& p,
179  const polyPatch& pp,
180  bool& keepParticle
181  );
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #ifdef NoRepository
192  #include "PatchInteractionFields.C"
193 #endif
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
volFields.H
Foam::PatchInteractionFields::PatchInteractionFields
PatchInteractionFields(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: PatchInteractionFields.C:121
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Enum< resetMode >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::PatchInteractionFields::resetMode::none
PatchInteractionFields.C
Foam::PatchInteractionFields::clone
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
Definition: PatchInteractionFields.H:151
Foam::PatchInteractionFields::TypeName
TypeName("patchInteractionFields")
Runtime type information.
Foam::dimensionSet
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:108
Foam::subModelBase::modelName
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:107
Foam::PatchInteractionFields
Creates volume fields whose boundaries are used to store patch interaction statistics.
Definition: PatchInteractionFields.H:76
Foam::PatchInteractionFields::resetMode::timeStep
CloudFunctionObject.H
Foam::PatchInteractionFields::preEvolve
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: PatchInteractionFields.C:161
Foam::PatchInteractionFields::resetModeNames_
static const Enum< resetMode > resetModeNames_
Definition: PatchInteractionFields.H:92
Foam::PatchInteractionFields::postPatch
virtual void postPatch(const parcelType &p, const polyPatch &pp, bool &keepParticle)
Post-patch hook.
Definition: PatchInteractionFields.C:174
Foam::subModelBase::dict
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:113
Foam::PatchInteractionFields::reset
void reset()
Create|read|reset the fields.
Definition: PatchInteractionFields.C:80
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::CloudSubModelBase::owner
const CloudType & owner() const
Return const access to the owner cloud.
Definition: CloudSubModelBase.C:106
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::PatchInteractionFields::clearOrReset
void clearOrReset(autoPtr< volScalarField > &fieldPtr, const word &fieldName, const dimensionSet &dims) const
Helper function to clear or reset fields.
Definition: PatchInteractionFields.C:45
Foam::PatchInteractionFields::~PatchInteractionFields
virtual ~PatchInteractionFields()=default
Destructor.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::PatchInteractionFields::resetMode
resetMode
Reset mode.
Definition: PatchInteractionFields.H:85
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
Foam::PatchInteractionFields::resetMode::writeTime
Foam::PatchInteractionFields::write
virtual void write()
Write post-processing info.
Definition: PatchInteractionFields.C:88
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
Enum.H