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 -------------------------------------------------------------------------------
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 "ParticleTrap.H"
29 #include "fvcGrad.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  const dictionary& dict,
37  CloudType& owner,
38  const word& modelName
39 )
40 :
41  CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
42  alphaName_
43  (
44  this->coeffDict().template lookupOrDefault<word>("alpha", "alpha")
45  ),
46  alphaPtr_(nullptr),
47  gradAlphaPtr_(nullptr),
48  threshold_(this->coeffDict().getScalar("threshold"))
49 {}
50 
51 
52 template<class CloudType>
54 (
55  const ParticleTrap<CloudType>& pt
56 )
57 :
59  alphaName_(pt.alphaName_),
60  alphaPtr_(pt.alphaPtr_),
61  gradAlphaPtr_(nullptr),
62  threshold_(pt.threshold_)
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 
68 template<class CloudType>
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
75 template<class CloudType>
77 {
78  if (alphaPtr_ == nullptr)
79  {
80  const fvMesh& mesh = this->owner().mesh();
81  const volScalarField& alpha =
82  mesh.lookupObject<volScalarField>(alphaName_);
83 
84  alphaPtr_ = &alpha;
85  }
86 
87  if (gradAlphaPtr_.valid())
88  {
89  gradAlphaPtr_() == fvc::grad(*alphaPtr_);
90  }
91  else
92  {
93  gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_)));
94  }
95 }
96 
97 
98 template<class CloudType>
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:62
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:66
Foam::ParticleTrap::postEvolve
virtual void postEvolve()
Post-evolve hook.
Definition: ParticleTrap.C:99
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::postMove
virtual void postMove(typename CloudType::parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: ParticleTrap.C:107
Foam::ParticleTrap::~ParticleTrap
virtual ~ParticleTrap()
Destructor.
Definition: ParticleTrap.C:69
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:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:60
ParticleTrap.H
Foam::Vector< scalar >
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:61
fvcGrad.H
Calculate the gradient of the given field.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::ParticleTrap::preEvolve
virtual void preEvolve()
Pre-evolve hook.
Definition: ParticleTrap.C:76
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::ParticleTrap::ParticleTrap
ParticleTrap(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: ParticleTrap.C:35