Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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 "Relaxation.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class CloudType>
35(
36 const dictionary& dict,
38)
39:
41 uAverage_(nullptr),
42 oneByTimeScaleAverage_(nullptr)
43{}
44
45
46template<class CloudType>
48(
49 const Relaxation<CloudType>& cm
50)
51:
53 uAverage_(nullptr),
54 oneByTimeScaleAverage_(cm.oneByTimeScaleAverage_->clone())
55{}
56
57
58// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59
60template<class CloudType>
63{}
64
65
66// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67
68template<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 (
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 (
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
138template<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// ************************************************************************* //
const word cloudName(propsDict.get< word >("cloud"))
Base class for lagrangian averaging methods.
static autoPtr< AveragingMethod< Type > > New(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Selector.
virtual Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const =0
Interpolate.
const CloudType & owner() const
Return const access to the owner cloud.
Base class for collisional damping models.
autoPtr< TimeScaleModel > timeScaleModel_
Time scale model.
DampingModel(CloudType &owner)
Construct null from owner.
Relaxation collisional damping model.
Definition Relaxation.H:67
Relaxation(const dictionary &dict, CloudType &owner)
Construct from components.
Definition Relaxation.C:28
virtual void cacheFields(const bool store)
Member Functions.
Definition Relaxation.C:62
virtual vector velocityCorrection(typename CloudType::parcelType &p, const scalar deltaT) const
Calculate the velocity correction.
Definition Relaxation.C:133
virtual autoPtr< DampingModel< CloudType > > clone() const
Construct and return a clone.
Definition Relaxation.H:105
virtual ~Relaxation()
Destructor.
Definition Relaxation.C:55
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition IOobjectI.H:50
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Selector class for relaxation factors, solver type and solution.
Definition solution.H:95
const dictionary & dict() const
Return const access to the cloud dictionary.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition tetIndices.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
dynamicFvMesh & mesh
word timeName
Definition getTimeIndex.H:3
DSMCCloud< dsmcParcel > CloudType
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Vector< scalar > vector
Definition vector.H:57
dictionary dict