Loading...
Searching...
No Matches
cubicEqnI.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) 2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31:
32 VectorSpace<cubicEqn, scalar, 4>(Foam::zero{})
33{}
34
35
37(
38 const scalar a,
39 const scalar b,
40 const scalar c,
41 const scalar d
42)
43{
44 this->v_[A] = a;
45 this->v_[B] = b;
46 this->v_[C] = c;
47 this->v_[D] = d;
48}
49
50
51// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53inline Foam::scalar Foam::cubicEqn::value(const scalar x) const
54{
55 return x*(x*(x*a() + b()) + c()) + d();
56}
57
59inline Foam::scalar Foam::cubicEqn::derivative(const scalar x) const
60{
61 return x*(x*3*a() + 2*b()) + c();
62}
63
64
65inline Foam::scalar Foam::cubicEqn::error(const scalar x) const
66{
67 return
68 SMALL*magSqr(x)*(mag(x*a()) + mag(b()))
69 + SMALL*mag(x)*(mag(x*(x*a() + b())) + mag(c()))
70 + SMALL*(mag(x*(x*(x*a() + b()) + c())) + mag(d()));
71}
72
73
74// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
scalar c() const noexcept
Definition cubicEqn.H:150
scalar value(const scalar x) const
Evaluate the cubic equation at x.
Definition cubicEqnI.H:46
cubicEqn()=default
Default construct.
scalar derivative(const scalar x) const
Evaluate the derivative of the cubic equation at x.
Definition cubicEqnI.H:52
scalar d() const noexcept
Definition cubicEqn.H:151
scalar a() const noexcept
Definition cubicEqn.H:148
scalar b() const noexcept
Definition cubicEqn.H:149
scalar error(const scalar x) const
Estimate the error of evaluation of the cubic equation at x.
Definition cubicEqnI.H:58
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
volScalarField & b