FunctionObjectValueI.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) 2021 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 "FunctionObjectValue.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const scalar /*unused*/
36 ) const
37 {
38  const auto& props = this->time().functionObjects().propsDict();
39 
40  if (!props.hasResultObject(foName_))
41  {
42  if (haveDefaultValue_)
43  {
44  DebugInfo
45  << " Function object " << foName_
46  << " not found; using default value " << defaultValue_
47  << endl;
48 
49  return defaultValue_;
50  }
51 
53  << "Function object " << foName_
54  << " results not found. Valid objects with results include: "
55  << props.objectResultNames()
56  << exit(FatalError);
57  }
58 
59  if (!props.hasResultObjectEntry(foName_, foResultName_))
60  {
61  if (haveDefaultValue_)
62  {
63  DebugInfo
64  << " Function object " << foName_
65  << " result " << foResultName_
66  << " not found; using default value " << defaultValue_
67  << endl;
68 
69  return defaultValue_;
70  }
71 
73  << "Function object " << foName_
74  << " does not have a result field " << foResultName_ << nl
75  << " Available result fields include: "
76  << props.objectResultEntries(foName_)
77  << exit(FatalError);
78  }
79 
80  Type value = props.template getObjectResult<Type>(foName_, foResultName_);
81 
82  DebugInfo
83  << " Using " << foName_ << " function object value: " << value
84  << endl;
85 
86  return value;
87 }
88 
89 
90 template<class Type>
92 (
93  const scalar x1,
94  const scalar x2
95 ) const
96 {
98  return pTraits<Type>::zero;
99 }
100 
101 
102 // ************************************************************************* //
Foam::Function1Types::FunctionObjectValue::value
virtual Type value(const scalar) const
Return value at current time.
Definition: FunctionObjectValueI.H:34
Foam::Function1Types::FunctionObjectValue::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values. Not implemented!
Definition: FunctionObjectValueI.H:92
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
FunctionObjectValue.H