PatchCollisionDensity.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) 2018 OpenFOAM Foundation
9 Copyright (C) 2020 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
30#include "Pstream.H"
31#include "stringListOps.H"
32#include "ListOps.H"
33#include "ListListOps.H"
34
35// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
36
37template<class CloudType>
39{
40 const scalarField z(this->owner().mesh().nCells(), Zero);
41
43 (
45 (
46 this->owner().name() + ":collisionDensity",
47 this->owner().mesh().time().timeName(),
48 this->owner().mesh()
49 ),
50 this->owner().mesh(),
52 z,
53 collisionDensity_
54 )
55 .write();
56
58 (
60 (
61 this->owner().name() + ":collisionDensityRate",
62 this->owner().mesh().time().timeName(),
63 this->owner().mesh()
64 ),
65 this->owner().mesh(),
67 z,
68 (collisionDensity_ - collisionDensity0_)
69 /(this->owner().mesh().time().value() - time0_)
70 )
71 .write();
72
73 collisionDensity0_ == collisionDensity_;
74 time0_ = this->owner().mesh().time().value();
75}
76
77
78// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
79
80template<class CloudType>
82(
83 const dictionary& dict,
84 CloudType& owner,
85 const word& modelName
86)
87:
88 CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
89 minSpeed_(dict.getOrDefault<scalar>("minSpeed", -1)),
90 collisionDensity_
91 (
92 this->owner().mesh().boundary(),
93 volScalarField::Internal::null(),
94 calculatedFvPatchField<scalar>::typeName
95 ),
96 collisionDensity0_
97 (
98 this->owner().mesh().boundary(),
99 volScalarField::Internal::null(),
100 calculatedFvPatchField<scalar>::typeName
101 ),
102 time0_(this->owner().mesh().time().value())
103{
104 collisionDensity_ == 0;
105 collisionDensity0_ == 0;
106
108 (
109 this->owner().name() + ":collisionDensity",
110 this->owner().mesh().time().timeName(),
111 this->owner().mesh(),
114 );
115
117 {
118 const volScalarField collisionDensity(io, this->owner().mesh());
119 collisionDensity_ == collisionDensity.boundaryField();
120 collisionDensity0_ == collisionDensity.boundaryField();
121 }
122}
123
124
125template<class CloudType>
127(
129)
130:
132 minSpeed_(ppm.minSpeed_),
133 collisionDensity_(ppm.collisionDensity_),
134 collisionDensity0_(ppm.collisionDensity0_),
135 time0_(ppm.time0_)
136{}
137
138
139// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140
141template<class CloudType>
143(
144 const parcelType& p,
145 const polyPatch& pp,
146 bool&
147)
148{
149 const label patchi = pp.index();
150 const label patchFacei = p.face() - pp.start();
151
152 vector nw, Up;
153 this->owner().patchData(p, pp, nw, Up);
154
155 const scalar speed = (p.U() - Up) & nw;
156 if (speed > minSpeed_)
157 {
158 collisionDensity_[patchi][patchFacei] +=
159 1/this->owner().mesh().magSf().boundaryField()[patchi][patchFacei];
160 }
161}
162
163
164// ************************************************************************* //
Various functions to operate on Lists.
Templated cloud function object base class.
const CloudType & owner() const
Return const access to the owner cloud.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
Function object which generates fields of the number and rate of collisions per unit area on all patc...
virtual void postPatch(const parcelType &p, const polyPatch &pp, bool &keepParticle)
Post-patch hook.
void write()
Write post-processing info.
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
label index() const noexcept
The index of this patch in the boundaryMesh.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:364
virtual bool write(const bool valid=true) const
Write using setting from DB.
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
faceListList boundary
dynamicFvMesh & mesh
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word timeName
Definition: getTimeIndex.H:3
const dimensionSet dimless
Dimensionless.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
Operations on lists of strings.