pairPotential.H
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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 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 Class
28  Foam::pairPotential
29 
30 Description
31 
32 SourceFiles
33  pairPotential.C
34  pairPotentialNew.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef pairPotential_H
39 #define pairPotential_H
40 
41 #include "IOdictionary.H"
42 #include "typeInfo.H"
43 #include "runTimeSelectionTables.H"
44 #include "autoPtr.H"
45 #include "List.H"
46 #include "Pair.H"
47 #include "Switch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 class energyScalingFunction;
56 
57 /*---------------------------------------------------------------------------*\
58  Class pairPotential Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class pairPotential
62 {
63 
64 protected:
65 
66  // Protected member data
67 
70 
71  scalar rCut_;
72  scalar rCutSqr_;
73 
74  scalar rMin_;
75  scalar dr_;
76 
79 
81 
82  bool writeTables_;
83 
84 
85  // Protected member functions
86 
87  void scaleEnergy(scalar& e, const scalar r) const;
88 
89  //- No copy construct
90  pairPotential(const pairPotential&) = delete;
91 
92  //- No copy assignment
93  void operator=(const pairPotential&) = delete;
94 
95 
96 public:
97 
98  //- Runtime type information
99  TypeName("pairPotential");
100 
101 
102  // Declare run-time constructor selection table
103 
105  (
106  autoPtr,
108  dictionary,
109  (
110  const word& name,
112  ),
114  );
115 
116 
117  // Selectors
118 
119  //- Return a reference to the selected viscosity model
121  (
122  const word& name,
124  );
125 
126 
127  // Constructors
128 
129  //- Construct from components
131  (
132  const word& name,
134  );
135 
136 
137  //- Destructor
138  virtual ~pairPotential() = default;
139 
140 
141  // Member Functions
142 
143  void setLookupTables();
144 
145  inline scalar rMin() const;
146 
147  inline scalar dr() const;
148 
149  inline scalar rCut() const;
150 
151  inline scalar rCutSqr() const;
152 
153  scalar energy (const scalar r) const;
154 
155  scalar force (const scalar r) const;
156 
158 
159  List<Pair<scalar>> forceTable() const;
160 
161  inline bool writeTables() const;
162 
163  virtual scalar unscaledEnergy(const scalar r) const = 0;
164 
165  scalar scaledEnergy(const scalar r) const;
166 
167  scalar energyDerivative
168  (
169  const scalar r,
170  const bool scaledEnergyDerivative = true
171  ) const;
172 
173  const dictionary& pairPotentialProperties() const
174  {
176  }
177 
178  bool writeEnergyAndForceTables(Ostream& os) const;
179 
180  //- Read pairPotential dictionary
181  virtual bool read(const dictionary& pairPotentialProperties) = 0;
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #include "pairPotentialI.H"
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
Foam::pairPotential::New
static autoPtr< pairPotential > New(const word &name, const dictionary &pairPotentialProperties)
Return a reference to the selected viscosity model.
Definition: pairPotentialNew.C:35
Foam::pairPotential::dr_
scalar dr_
Definition: pairPotential.H:74
Foam::pairPotential::writeTables_
bool writeTables_
Definition: pairPotential.H:81
Foam::pairPotential::scaleEnergy
void scaleEnergy(scalar &e, const scalar r) const
Definition: pairPotential.C:42
Foam::pairPotential::esfPtr_
energyScalingFunction * esfPtr_
Definition: pairPotential.H:79
Foam::pairPotential::name_
word name_
Definition: pairPotential.H:67
List.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
typeInfo.H
Foam::pairPotential::~pairPotential
virtual ~pairPotential()=default
Destructor.
Foam::pairPotential::rCutSqr
scalar rCutSqr() const
Definition: pairPotentialI.H:48
Foam::pairPotential::TypeName
TypeName("pairPotential")
Runtime type information.
Foam::pairPotential::energyTable
List< Pair< scalar > > energyTable() const
Definition: pairPotential.C:155
pairPotentialI.H
Foam::pairPotential::force
scalar force(const scalar r) const
Definition: pairPotential.C:96
Pair.H
Foam::pairPotential::energy
scalar energy(const scalar r) const
Definition: pairPotential.C:133
Foam::pairPotential::forceTable
List< Pair< scalar > > forceTable() const
Definition: pairPotential.C:118
Foam::pairPotential::rCut
scalar rCut() const
Definition: pairPotentialI.H:42
Foam::pairPotential::rMin
scalar rMin() const
Definition: pairPotentialI.H:30
Foam::pairPotential::pairPotential
pairPotential(const pairPotential &)=delete
No copy construct.
Foam::pairPotential::setLookupTables
void setLookupTables()
Definition: pairPotential.C:79
Foam::pairPotential::rCut_
scalar rCut_
Definition: pairPotential.H:70
Switch.H
Foam::pairPotential::pairPotentialProperties_
dictionary pairPotentialProperties_
Definition: pairPotential.H:68
Foam::pairPotential::energyDerivative
scalar energyDerivative(const scalar r, const bool scaledEnergyDerivative=true) const
Definition: pairPotential.C:181
Foam::pairPotential::forceLookup_
List< scalar > forceLookup_
Definition: pairPotential.H:76
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::pairPotential
Definition: pairPotential.H:60
os
OBJstream os(runTime.globalPath()/outputName)
Foam::pairPotential::pairPotentialProperties
const dictionary & pairPotentialProperties() const
Definition: pairPotential.H:172
Foam::pairPotential::rCutSqr_
scalar rCutSqr_
Definition: pairPotential.H:71
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
IOdictionary.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::pairPotential::unscaledEnergy
virtual scalar unscaledEnergy(const scalar r) const =0
Foam::pairPotential::dr
scalar dr() const
Definition: pairPotentialI.H:36
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List< scalar >
Foam::pairPotential::read
virtual bool read(const dictionary &pairPotentialProperties)=0
Read pairPotential dictionary.
Definition: pairPotential.C:224
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::pairPotential::rMin_
scalar rMin_
Definition: pairPotential.H:73
Foam::pairPotential::scaledEnergy
scalar scaledEnergy(const scalar r) const
Definition: pairPotential.C:170
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::energyScalingFunction
Definition: energyScalingFunction.H:55
Foam::pairPotential::operator=
void operator=(const pairPotential &)=delete
No copy assignment.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::pairPotential::energyLookup_
List< scalar > energyLookup_
Definition: pairPotential.H:77
Foam::pairPotential::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, pairPotential, dictionary,(const word &name, const dictionary &pairPotentialProperties),(name, pairPotentialProperties))
Foam::pairPotential::writeTables
bool writeTables() const
Definition: pairPotentialI.H:54
Foam::pairPotential::writeEnergyAndForceTables
bool writeEnergyAndForceTables(Ostream &os) const
Definition: pairPotentialIO.C:31
autoPtr.H