Test-DynamicField.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 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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "point.H"
29 #include "DynamicField.H"
30 #include "IOstreams.H"
31 
32 using namespace Foam;
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // Main program:
36 
37 int main(int argc, char *argv[])
38 {
41 
42  testField.setSize(5);
43  testField2.setSize(5);
44 
45  testField[0] = testField2[0] = vector(1.0, 4.5, 6.3);
46  testField[1] = testField2[1] = vector(5.2, 2.3, 3.5);
47  testField[2] = testField2[2] = vector(7.5, 4.7, 7.7);
48  testField[3] = testField2[3] = vector(2.8, 8.2, 2.3);
49  testField[4] = testField2[4] = vector(6.1, 1.7, 8.8);
50 
51  Info << "testField:" << testField << endl;
52 
53  testField.append(vector(0.5, 4.8, 6.2));
54 
55  Info << "testField after appending:" << testField << endl;
56 
57  testField.append(vector(2.7, 2.3, 6.1));
58 
59  Info << "testField after appending:" << testField << endl;
60 
61  vector elem = testField.remove();
62 
63  Info << "removed element:" << elem << endl;
64  Info << "testField:" << testField << endl;
65 
66  testField.append(vector(3.0, 1.3, 9.2));
67 
68  Info << "testField:" << testField << endl;
69 
70  testField.setSize(10, vector(1.5, 0.6, -1.0));
71 
72  Info << "testField after setSize:" << testField << endl;
73 
74  testField.append(testField2);
75 
76  Info << "testField after appending testField2:" << testField << endl;
77 
78  testField = testField2;
79 
80  Info << "testField after assignment:" << testField << endl;
81 
82  testField += testField2;
83 
84  Info << "testField after field algebra:" << testField << endl;
85 
86  testField.clear();
87 
88  testField.append(vector(3.0, 1.3, 9.2));
89 
90  Info << "testField after clear and append:" << testField << endl;
91 
92  testField.clearStorage();
93 
94  Info << "testField after clearStorage:" << testField << endl;
95 
96  return 0;
97 }
98 
99 
100 // ************************************************************************* //
Foam::DynamicField::clear
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicFieldI.H:277
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::DynamicField::clearStorage
void clearStorage()
Clear the list and delete storage.
Definition: DynamicFieldI.H:284
Foam::DynamicField::setSize
void setSize(const label)
Alter the addressed list size.
point.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::DynamicField
Dynamically sized Field.
Definition: DynamicField.H:49
Foam::Info
messageStream Info
Foam::DynamicField::append
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
DynamicField.H
Foam::DynamicField::remove
T remove()
Remove and return the top element.
Definition: DynamicFieldI.H:358
Foam::Vector< scalar >
main
int main(int argc, char *argv[])
Definition: Test-DynamicField.C:37