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