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-------------------------------------------------------------------------------
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 "ParticleTrap.H"
30#include "fvcGrad.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<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
53template<class CloudType>
55(
57)
58:
60 alphaName_(pt.alphaName_),
61 alphaPtr_(pt.alphaPtr_),
62 gradAlphaPtr_(nullptr),
63 threshold_(pt.threshold_)
64{}
65
66
67// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68
69template<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
95template<class CloudType>
97(
98 const typename parcelType::trackingData& td
99)
100{
101 gradAlphaPtr_.clear();
102}
103
104
105template<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// ************************************************************************* //
Templated cloud function object base class.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
virtual void postEvolve()
Post-evolve hook.
Traps particles within a given phase fraction for multi-phase cases.
Definition: ParticleTrap.H:70
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: ParticleTrap.C:107
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: ParticleTrap.C:71
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Class used to pass data into container.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Type & lookupObject(const word &name, const bool recursive=false) const
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
dynamicFvMesh & mesh
Calculate the gradient of the given field.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:83
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
volScalarField & alpha
dictionary dict