Relaxation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "Relaxation.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class CloudType>
32 (
33  const dictionary& dict,
34  CloudType& owner
35 )
36 :
37  DampingModel<CloudType>(dict, owner, typeName),
38  uAverage_(nullptr),
39  oneByTimeScaleAverage_(nullptr)
40 {}
41 
42 
43 template<class CloudType>
45 (
46  const Relaxation<CloudType>& cm
47 )
48 :
50  uAverage_(nullptr),
51  oneByTimeScaleAverage_(cm.oneByTimeScaleAverage_, false)
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 
57 template<class CloudType>
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class CloudType>
67 {
68  if (store)
69  {
70  const fvMesh& mesh = this->owner().mesh();
71  const word& cloudName = this->owner().name();
72 
73  const AveragingMethod<scalar>& volumeAverage =
75  (
76  cloudName + ":volumeAverage"
77  );
78  const AveragingMethod<scalar>& radiusAverage =
80  (
81  cloudName + ":radiusAverage"
82  );
83  const AveragingMethod<vector>& uAverage =
85  (
86  cloudName + ":uAverage"
87  );
88  const AveragingMethod<scalar>& uSqrAverage =
90  (
91  cloudName + ":uSqrAverage"
92  );
93  const AveragingMethod<scalar>& frequencyAverage =
95  (
96  cloudName + ":frequencyAverage"
97  );
98 
99  uAverage_ = &uAverage;
100 
101  oneByTimeScaleAverage_.reset
102  (
104  (
105  IOobject
106  (
107  cloudName + ":oneByTimeScaleAverage",
108  this->owner().db().time().name(),
109  mesh
110  ),
111  this->owner().solution().dict(),
112  mesh
113  ).ptr()
114  );
115 
116  oneByTimeScaleAverage_() =
117  (
118  this->timeScaleModel_->oneByTau
119  (
120  volumeAverage,
121  radiusAverage,
122  uSqrAverage,
123  frequencyAverage
124  )
125  )();
126  }
127  else
128  {
129  uAverage_ = nullptr;
130  oneByTimeScaleAverage_.clear();
131  }
132 }
133 
134 
135 template<class CloudType>
137 (
138  typename CloudType::parcelType& p,
139  const scalar deltaT
140 ) const
141 {
142  const tetIndices tetIs(p.currentTetIndices(this->owner().mesh()));
143 
144  const scalar x =
145  deltaT*oneByTimeScaleAverage_->interpolate(p.coordinates(), tetIs);
146 
147  const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
148 
149  return (u - p.U())*x/(x + 2.0);
150 }
151 
152 
153 // ************************************************************************* //
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:79
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
Base class for collisional damping models.
Definition: DampingModel.H:60
Relaxation collisional damping model.
Definition: Relaxation.H:66
Relaxation(const dictionary &dict, CloudType &owner)
Construct from components.
Definition: Relaxation.C:32
virtual void cacheFields(const bool store)
Member Functions.
Definition: Relaxation.C:66
virtual vector velocityCorrection(typename CloudType::parcelType &p, const scalar deltaT) const
Calculate the velocity correction.
Definition: Relaxation.C:137
virtual ~Relaxation()
Destructor.
Definition: Relaxation.C:59
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:174
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:82
A class for handling words, derived from string.
Definition: word.H:62
dictionary dict
volScalarField & p
const word cloudName(propsDict.lookup("cloudName"))