FreeFOAM The Cross-Platform CFD Toolkit
doubleSigmoid.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 | Copyright (C) 2008-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "doubleSigmoid.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace energyScalingFunctions
34 {
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
39 
41 (
45 );
46 
47 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 
49 scalar doubleSigmoid::sigmoidScale
50  (
51  const scalar r,
52  const scalar shift,
53  const scalar scale
54  ) const
55 {
56  return 1.0 / (1.0 + exp( scale * (r - shift)));
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const dictionary& energyScalingFunctionProperties,
66  const pairPotential& pairPot
67 )
68 :
69  energyScalingFunction(name, energyScalingFunctionProperties, pairPot),
70  doubleSigmoidCoeffs_
71  (
72  energyScalingFunctionProperties.subDict(typeName + "Coeffs")
73  ),
74  shift1_(readScalar(doubleSigmoidCoeffs_.lookup("shift1"))),
75  scale1_(readScalar(doubleSigmoidCoeffs_.lookup("scale1"))),
76  shift2_(readScalar(doubleSigmoidCoeffs_.lookup("shift2"))),
77  scale2_(readScalar(doubleSigmoidCoeffs_.lookup("scale2")))
78 {}
79 
80 
81 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
82 
83 void doubleSigmoid::scaleEnergy(scalar& e, const scalar r) const
84 {
85  e *= sigmoidScale(r, shift1_, scale1_) * sigmoidScale(r, shift2_, scale2_);
86 }
87 
88 
89 bool doubleSigmoid::read(const dictionary& energyScalingFunctionProperties)
90 {
91  energyScalingFunction::read(energyScalingFunctionProperties);
92 
93  doubleSigmoidCoeffs_ =
94  energyScalingFunctionProperties.subDict(typeName + "Coeffs");
95 
96  doubleSigmoidCoeffs_.lookup("shift1") >> shift1_;
97  doubleSigmoidCoeffs_.lookup("scale1") >> scale1_;
98  doubleSigmoidCoeffs_.lookup("shift2") >> shift2_;
99  doubleSigmoidCoeffs_.lookup("scale2") >> scale2_;
100 
101  return true;
102 }
103 
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace energyScalingFunctions
108 } // End namespace Foam
109 
110 // ************************ vim: set sw=4 sts=4 et: ************************ //