Function1.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 "Function1.H"
30#include "Time.H"
31// Required by clang 5 for correct instantiation of Function1::New
32#include "Constant.H"
33
34// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
35
36template<class Type>
38(
39 const word& entryName,
40 const objectRegistry* obrPtr
41)
42:
43 function1Base(entryName, obrPtr)
44{}
45
46
47template<class Type>
49(
50 const word& entryName,
51 const dictionary& dict,
52 const objectRegistry* obrPtr
53)
54:
55 function1Base(entryName, dict, obrPtr)
56{}
57
58
59template<class Type>
60Foam::Function1<Type>::Function1(const Function1<Type>& rhs)
61:
62 function1Base(rhs)
63{}
64
65
66// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67
68template<class Type>
69Type Foam::Function1<Type>::value(const scalar x) const
70{
72 return Type();
73}
74
75
76template<class Type>
78(
79 const scalarField& x
80) const
81{
83 return nullptr;
84}
85
86
87template<class Type>
88Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
89{
91 return Type();
92}
93
94
95template<class Type>
97(
98 const scalarField& x1,
99 const scalarField& x2
100) const
101{
103 return nullptr;
104}
105
106
107template<class Function1Type>
110(
111 const scalarField& x
112) const
113{
114 auto tfld = tmp<Field<Type>>::New(x.size());
115 auto& fld = tfld.ref();
116
117 forAll(x, i)
118 {
119 fld[i] = Function1Type::value(x[i]);
120 }
121 return tfld;
122}
123
124
125template<class Function1Type>
127(
128 const word& entryName,
129 const dictionary& dict,
130 const objectRegistry* obrPtr
131)
132:
133 Function1Type(entryName, dict, obrPtr)
134{}
135
136
137template<class Function1Type>
140{
141 return tmp<Function1<Type>>
142 (
144 );
145}
146
147
148template<class Function1Type>
151(
152 const scalarField& x1,
153 const scalarField& x2
154) const
155{
156 auto tfld = tmp<Field<Type>>::New(x1.size());
157 auto& fld = tfld.ref();
158
159 forAll(x1, i)
160 {
161 fld[i] = Function1Type::integrate(x1[i], x2[i]);
162 }
163
164 return tfld;
165}
166
167
168template<class Type>
170{}
171
172
173template<class Type>
175{
176 os.writeKeyword(name_) << type();
177}
178
179
180// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
181
182template<class Type>
183Foam::Ostream& Foam::operator<<
184(
185 Ostream& os,
186 const Function1<Type>& rhs
187)
188{
190
191 os << rhs.name();
192 rhs.writeData(os);
193
194 return os;
195}
196
197
198// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
virtual tmp< Field< Type > > integrate(const scalarField &x1, const scalarField &x2) const
Integrate between two (scalar) values.
Definition: Function1.C:151
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: Function1.C:139
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: Function1.C:169
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: Function1.C:88
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
virtual const fileName & name() const
Read/write access to the name of the stream.
Definition: OSstream.H:107
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333