CoulombForce.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) 2023 OpenCFD Ltd.
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 "CoulombForce.H"
29 #include "demandDrivenData.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  const word& fieldName
37 ) const
38 {
39  auto* ptr = this->mesh().template getObjectPtr<volVectorField>(fieldName);
40 
41  if (!ptr)
42  {
43  ptr = new volVectorField
44  (
45  IOobject
46  (
47  fieldName,
48  this->mesh().time().timeName(),
49  this->mesh(),
50  IOobject::MUST_READ,
51  IOobject::AUTO_WRITE
52  ),
53  this->mesh()
54  );
55  this->mesh().objectRegistry::store(ptr);
56  }
57 
58  return *ptr;
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 template<class CloudType>
66 (
67  CloudType& owner,
68  const fvMesh& mesh,
69  const dictionary& dict
70 )
71 :
72  ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
73  qPtr_
74  (
75  Function1<scalar>::New("q", this->coeffs(), &mesh)
76  ),
77  Ename_(this->coeffs().template getOrDefault<word>("E", "E")),
78  EInterpPtr_(nullptr)
79 {}
80 
81 
82 template<class CloudType>
84 (
85  const CoulombForce& pf
86 )
87 :
89  qPtr_(pf.qPtr_.clone()),
90  Ename_(pf.Ename_),
91  EInterpPtr_(nullptr)
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
97 template<class CloudType>
98 void Foam::CoulombForce<CloudType>::cacheFields(const bool store)
99 {
100  if (store)
101  {
102  const volVectorField& E = getOrReadField(Ename_);
103 
104  EInterpPtr_.reset
105  (
107  (
108  this->owner().solution().interpolationSchemes(),
109  E
110  ).ptr()
111  );
112  }
113  else
114  {
115  EInterpPtr_.reset(nullptr);
116  }
117 }
118 
119 
120 template<class CloudType>
122 (
123  const typename CloudType::parcelType& p,
124  const typename CloudType::parcelType::trackingData& td,
125  const scalar dt,
126  const scalar mass,
127  const scalar Re,
128  const scalar muc
129 ) const
130 {
131  const interpolation<vector>& EInterp = *EInterpPtr_;
132 
133  const scalar q = qPtr_->value(p.d());
134 
135  // (YSSD:Eq. 6 - left term)
136  return forceSuSp
137  (
138  q*EInterp.interpolate(p.coordinates(), p.currentTetIndices()),
139  Zero
140  );
141 }
142 
143 
144 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Abstract base class for particle forces.
Definition: ParticleForce.H:54
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:60
word timeName
Definition: getTimeIndex.H:3
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void cacheFields(const bool store)
Cache fields.
Definition: CoulombForce.C:91
virtual forceSuSp calcNonCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the non-coupled force.
Definition: CoulombForce.C:115
scalarField Re(const UList< complex > &cmplx)
Extract real component.
Definition: complexField.C:207
Template functions to aid in the implementation of demand driven data.
Particle electric force model involving the Coulomb force calculation.
Definition: CoulombForce.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Abstract base class for volume field interpolation.
CoulombForce(CloudType &owner, const fvMesh &mesh, const dictionary &dict)
Construct from mesh.
Definition: CoulombForce.C:59
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:92
volScalarField & p
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127