ParticleTrap.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) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2020 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 "ParticleTrap.H"
30 #include "fvcGrad.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class CloudType>
36 (
37  const dictionary& dict,
38  CloudType& owner,
39  const word& modelName
40 )
41 :
42  CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
43  alphaName_
44  (
45  this->coeffDict().template getOrDefault<word>("alpha", "alpha")
46  ),
47  alphaPtr_(nullptr),
48  gradAlphaPtr_(nullptr),
49  threshold_(this->coeffDict().getScalar("threshold"))
50 {}
51 
52 
53 template<class CloudType>
55 (
56  const ParticleTrap<CloudType>& pt
57 )
58 :
60  alphaName_(pt.alphaName_),
61  alphaPtr_(pt.alphaPtr_),
62  gradAlphaPtr_(nullptr),
63  threshold_(pt.threshold_)
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
69 template<class CloudType>
71 (
72  const typename parcelType::trackingData& td
73 )
74 {
75  if (alphaPtr_ == nullptr)
76  {
77  const fvMesh& mesh = this->owner().mesh();
78  const volScalarField& alpha =
79  mesh.lookupObject<volScalarField>(alphaName_);
80 
81  alphaPtr_ = &alpha;
82  }
83 
84  if (gradAlphaPtr_)
85  {
86  *gradAlphaPtr_ == fvc::grad(*alphaPtr_);
87  }
88  else
89  {
90  gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_)));
91  }
92 }
93 
94 
95 template<class CloudType>
97 (
98  const typename parcelType::trackingData& td
99 )
100 {
101  gradAlphaPtr_.clear();
102 }
103 
104 
105 template<class CloudType>
107 (
108  parcelType& p,
109  const scalar,
110  const point&,
111  bool&
112 )
113 {
114  if (alphaPtr_->primitiveField()[p.cell()] < threshold_)
115  {
116  const vector& gradAlpha = gradAlphaPtr_()[p.cell()];
117  vector nHat = gradAlpha/mag(gradAlpha);
118  scalar nHatU = nHat & p.U();
119 
120  if (nHatU < 0)
121  {
122  p.U() -= 2*nHat*nHatU;
123  }
124  }
125 }
126 
127 
128 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::ParticleTrap
Traps particles within a given phase fraction for multi-phase cases.
Definition: ParticleTrap.H:67
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
Foam::ParticleTrap::preEvolve
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: ParticleTrap.C:71
Foam::DSMCCloud::mesh
const fvMesh & mesh() const
Return reference to the mesh.
Definition: DSMCCloudI.H:44
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
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::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
ParticleTrap.H
Foam::Vector< scalar >
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
fvcGrad.H
Calculate the gradient of the given field.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::ParticleTrap::postMove
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: ParticleTrap.C:107
Foam::ParticleTrap::postEvolve
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
Definition: ParticleTrap.C:97
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::ParticleTrap::ParticleTrap
ParticleTrap(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: ParticleTrap.C:36