DataEntry.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "DataEntry.H"
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
30 
31 template<class Type>
32 Foam::DataEntry<Type>::DataEntry(const word& entryName)
33 :
34  refCount(),
35  name_(entryName)
36 {}
37 
38 
39 template<class Type>
40 Foam::DataEntry<Type>::DataEntry(const DataEntry<Type>& de)
41 :
42  refCount(),
43  name_(de.name_)
44 {}
45 
46 
47 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
48 
49 template<class Type>
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55 
56 template<class Type>
58 {
59  return name_;
60 }
61 
62 
63 template<class Type>
65 {
66  // do nothing
67 }
68 
69 
70 template<class Type>
71 Type Foam::DataEntry<Type>::value(const scalar x) const
72 {
73  notImplemented("Type Foam::DataEntry<Type>::value(const scalar) const");
74 
75  return pTraits<Type>::zero;
76 }
77 
78 
79 template<class Type>
80 Type Foam::DataEntry<Type>::integrate(const scalar x1, const scalar x2) const
81 {
83  (
84  "Type Foam::DataEntry<Type>::integrate"
85  "("
86  "const scalar, "
87  "const scalar"
88  ") const"
89  );
90 
91  return pTraits<Type>::zero;
92 }
93 
94 
95 template<class Type>
97 (
98  const scalarField& x
99 ) const
100 {
101  tmp<Field<Type> > tfld(new Field<Type>(x.size()));
102  Field<Type>& fld = tfld();
103 
104  forAll(x, i)
105  {
106  fld[i] = this->value(x[i]);
107  }
108  return tfld;
109 }
110 
111 
112 template<class Type>
114 (
115  const scalarField& x1,
116  const scalarField& x2
117 ) const
118 {
119  tmp<Field<Type> > tfld(new Field<Type>(x1.size()));
120  Field<Type>& fld = tfld();
121 
122  forAll(x1, i)
123  {
124  fld[i] = this->integrate(x1[i], x2[i]);
125  }
126  return tfld;
127 }
128 
129 
130 
131 template<class Type>
133 {
135  (
136  "dimensioned<Type> Foam::DataEntry<dimensioned<Type> >::dimValue"
137  "(const scalar) const"
138  );
139 
141 }
142 
143 
144 template<class Type>
146 (
147  const scalar x1,
148  const scalar x2
149 ) const
150 {
152  (
153  "dimensioned<Type> Foam::DataEntry<Type>::dimIntegrate"
154  "("
155  "const scalar, "
156  "const scalar"
157  ") const"
158  );
159 
161 }
162 
163 
164 template<class Type>
167 (
168  const scalarField& x
169 ) const
170 {
171 
173  (
175  (
176  x.size(),
178  )
179  );
180 
181  Field<dimensioned<Type> >& fld = tfld();
182 
183  forAll(x, i)
184  {
185  fld[i] = this->dimValue(x[i]);
186  }
187  return tfld;
188 }
189 
190 
191 template<class Type>
194 (
195  const scalarField& x1,
196  const scalarField& x2
197 ) const
198 {
200  (
201  new Field<dimensioned<Type> >(x1.size())
202  );
203 
204  Field<dimensioned<Type> >& fld = tfld();
205 
206  forAll(x1, i)
207  {
208  fld[i] = this->dimIntegrate(x1[i], x2[i]);
209  }
210  return tfld;
211 }
212 
213 
214 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
215 
216 #include "DataEntryIO.C"
217 
218 // ************************************************************************* //
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: DataEntry.C:80
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: DataEntry.C:71
virtual dimensioned< Type > dimValue(const scalar x) const
Return dimensioned type.
Definition: DataEntry.C:132
A class for handling words, derived from string.
Definition: word.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
refCount()
Construct null with zero count.
Definition: refCount.H:65
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Generic dimensioned Type class.
#define forAll(list, i)
Definition: UList.H:421
const word & name() const
Return the name of the entry.
Definition: DataEntry.C:57
virtual dimensioned< Type > dimIntegrate(const scalar x1, const scalar x2) const
Integrate between two scalars and return a dimensioned type.
Definition: DataEntry.C:146
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: DataEntry.C:64
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
const word name_
Name of entry.
Definition: DataEntry.H:81
Traits class for primitives.
Definition: pTraits.H:50
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
virtual ~DataEntry()
Destructor.
Definition: DataEntry.C:50
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
A class for managing temporary objects.
Definition: PtrList.H:118