rampHoldFall.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-2015 OpenFOAM Foundation
9  Copyright (C) 2018 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 \*---------------------------------------------------------------------------*/
28 
29 #include "rampHoldFall.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(rampHoldFall, 0);
37  addToRunTimeSelectionTable(relaxationModel, rampHoldFall, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& relaxationDict,
46  const Time& runTime
47 )
48 :
49  relaxationModel(typeName, relaxationDict, runTime),
50  rampStartRelaxation_(coeffDict().get<scalar>("rampStartRelaxation")),
51  holdRelaxation_(coeffDict().get<scalar>("holdRelaxation")),
52  fallEndRelaxation_(coeffDict().get<scalar>("fallEndRelaxation")),
53  rampEndFraction_(coeffDict().get<scalar>("rampEndFraction")),
54  fallStartFraction_(coeffDict().get<scalar>("fallStartFraction")),
55  rampGradient_((holdRelaxation_ - rampStartRelaxation_)/(rampEndFraction_)),
56  fallGradient_
57  (
58  (fallEndRelaxation_ - holdRelaxation_)/(1 - fallStartFraction_)
59  )
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 Foam::scalar Foam::rampHoldFall::relaxation()
66 {
67  scalar t = runTime_.time().timeOutputValue();
68 
69  scalar tStart = runTime_.time().startTime().value();
70  scalar tEnd = runTime_.time().endTime().value();
71  scalar tSpan = tEnd - tStart;
72 
73  if (tSpan < VSMALL)
74  {
75  return rampStartRelaxation_;
76  }
77 
78  if (t - tStart < rampEndFraction_*tSpan)
79  {
80  // Ramp
81 
82  return rampGradient_*((t - tStart)/tSpan) + rampStartRelaxation_;
83  }
84  else if (t - tStart > fallStartFraction_*tSpan)
85  {
86  // Fall
87 
88  return
89  fallGradient_*((t - tStart)/tSpan)
90  + fallEndRelaxation_ - fallGradient_;
91  }
92  else
93  {
94  //Hold
95 
96  return holdRelaxation_;
97  }
98 }
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 
104 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
engineTime & runTime
Macros for easy insertion into run-time selection tables.
defineTypeNameAndDebug(combustionModel, 0)
virtual scalar relaxation()
Return the current relaxation coefficient.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
rampHoldFall(const dictionary &relaxationDict, const Time &runTime)
Construct from components.