Relaxation.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "Relaxation.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  const dictionary& dict,
37  CloudType& owner
38 )
39 :
40  DampingModel<CloudType>(dict, owner, typeName),
41  uAverage_(nullptr),
42  oneByTimeScaleAverage_(nullptr)
43 {}
44 
45 
46 template<class CloudType>
48 (
49  const Relaxation<CloudType>& cm
50 )
51 :
53  uAverage_(nullptr),
54  oneByTimeScaleAverage_(cm.oneByTimeScaleAverage_->clone())
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 
60 template<class CloudType>
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class CloudType>
70 {
71  if (store)
72  {
73  const fvMesh& mesh = this->owner().mesh();
74  const word& cloudName = this->owner().name();
75 
76  const auto& volumeAverage =
77  mesh.lookupObject<AveragingMethod<scalar>>
78  (
79  IOobject::scopedName(cloudName, "volumeAverage")
80  );
81  const auto& radiusAverage =
82  mesh.lookupObject<AveragingMethod<scalar>>
83  (
84  IOobject::scopedName(cloudName, "radiusAverage")
85  );
86  const auto& uAverage =
87  mesh.lookupObject<AveragingMethod<vector>>
88  (
89  IOobject::scopedName(cloudName, "uAverage")
90  );
91  const auto& uSqrAverage =
92  mesh.lookupObject<AveragingMethod<scalar>>
93  (
94  IOobject::scopedName(cloudName, "uSqrAverage")
95  );
96  const auto& frequencyAverage =
97  mesh.lookupObject<AveragingMethod<scalar>>
98  (
99  IOobject::scopedName(cloudName, "frequencyAverage")
100  );
101 
102  uAverage_ = &uAverage;
103 
104  oneByTimeScaleAverage_.reset
105  (
107  (
108  IOobject
109  (
110  IOobject::scopedName(cloudName, "oneByTimeScaleAverage"),
111  this->owner().db().time().timeName(),
112  mesh
113  ),
114  this->owner().solution().dict(),
115  mesh
116  ).ptr()
117  );
118 
119  oneByTimeScaleAverage_() =
120  (
121  this->timeScaleModel_->oneByTau
122  (
123  volumeAverage,
124  radiusAverage,
125  uSqrAverage,
126  frequencyAverage
127  )
128  )();
129  }
130  else
131  {
132  uAverage_ = nullptr;
133  oneByTimeScaleAverage_.clear();
134  }
135 }
136 
137 
138 template<class CloudType>
140 (
141  typename CloudType::parcelType& p,
142  const scalar deltaT
143 ) const
144 {
145  const tetIndices tetIs(p.currentTetIndices());
146 
147  const scalar x =
148  deltaT*oneByTimeScaleAverage_->interpolate(p.coordinates(), tetIs);
149 
150  const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
151 
152  return (u - p.U())*x/(x + 2.0);
153 }
154 
155 
156 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Relaxation(const dictionary &dict, CloudType &owner)
Construct from components.
Definition: Relaxation.C:28
word timeName
Definition: getTimeIndex.H:3
dynamicFvMesh & mesh
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void cacheFields(const bool store)
Member Functions.
Definition: Relaxation.C:62
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:78
virtual vector velocityCorrection(typename CloudType::parcelType &p, const scalar deltaT) const
Calculate the velocity correction.
Definition: Relaxation.C:133
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const =0
Interpolate.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Relaxation collisional damping model.
Definition: Relaxation.H:64
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition: PtrListI.H:81
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:92
volScalarField & p
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
virtual ~Relaxation()
Destructor.
Definition: Relaxation.C:55
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
Base class for collisional damping models.