SampleFunction1.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-------------------------------------------------------------------------------
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
26Class
27 Foam::Function1Types::sample
28
29Description
30 Minimal example by using \c system/controlDict.functions:
31 \verbatim
32
33 \verbatim
34 <entryName> sample;
35 <entryName>Coeffs
36 {
37 field <field name>;
38 position (0 0 0);
39 interpolationScheme cell;
40 }
41 \endverbatim
42
43SourceFiles
44 sampleFunction1.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef Function1Types_Sample_H
49#define Function1Types_Sample_H
50
51#include "Function1.H"
52#include "point.H"
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56namespace Foam
57{
58namespace Function1Types
59{
60
61/*---------------------------------------------------------------------------*\
62 Class Sample Declaration
63\*---------------------------------------------------------------------------*/
64
65template<class Type>
66class Sample
67:
68 public Function1<Type>
69{
70 // Private Data
71
72 //- Name of field to sample
73 const word fieldName_;
74
75 //- Sample position
76 const point position_;
77
78 //- Interpolation scheme name; default = "cell"
79 const word interpolationScheme_;
80
81 //- Sample cell
82 mutable label celli_;
83
84 //- Points event number used to determine if celli should be updated
85 mutable label pointEventNo_;
86
87
88 // Private Member Functions
89
90 //- Set the sample celli; error on not found
91 void setSampleCell() const;
92
93 //- No copy assignment
94 void operator=(const Sample<Type>&) = delete;
95
96
97public:
98
99 //- Runtime type information
100 TypeName("sample");
101
102
103 // Constructors
104
105 //- Construct from entry name, dictionary and optional registry
106 Sample
107 (
108 const word& entryName,
109 const dictionary& dict,
110 const objectRegistry* obrPtr = nullptr
111 );
112
113 //- Construct from components
114 Sample
115 (
116 const word& entryName,
117 const List<Tuple2<Type, Type>>& coeffs,
118 const objectRegistry* obrPtr = nullptr
119 );
120
121 //- Copy constructor
122 explicit Sample(const Sample& poly);
123
124 //- Construct and return a clone
125 virtual tmp<Function1<Type>> clone() const
126 {
127 return tmp<Function1<Type>>(new Sample<Type>(*this));
128 }
129
130
131 //- Destructor
132 virtual ~Sample() = default;
133
134
135 // Member Functions
136
137 //- Return Sample value
138 virtual Type value(const scalar x) const;
139
140 //- Integrate between two (scalar) values
141 virtual Type integrate(const scalar x1, const scalar x2) const;
142
143 //- Write as primitive (inline) format
144 virtual void writeData(Ostream& os) const;
145
146 //- Write coefficient entries in dictionary format
147 virtual void writeEntries(Ostream& os) const;
148};
149
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153} // End namespace Function1Types
154} // End namespace Foam
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158#ifdef NoRepository
159 #include "SampleFunction1.C"
160#endif
161
162// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163
164#endif
165
166// ************************************************************************* //
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
virtual void writeData(Ostream &os) const
Write as primitive (inline) format.
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
TypeName("sample")
Runtime type information.
Sample(const word &entryName, const List< Tuple2< Type, Type > > &coeffs, const objectRegistry *obrPtr=nullptr)
Construct from components.
virtual Type value(const scalar x) const
Return Sample value.
virtual ~Sample()=default
Destructor.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
const word & entryName
Definition: Function1.H:133
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73