Test-dimensionedType.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-2013 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 "dimensionedTensor.H"
27 using namespace Foam;
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 // Main program:
31 
32 int main(int argc, char *argv[])
33 {
34  dimensionedTensor dt("dt", dimLength, tensor(0, 1, 2, 3, 4, 5, 6, 7, 8));
35 
36  Info<< "dt.component(tensor::XX): " << dt.component(tensor::XX) << endl;
37 
38  dimensionedScalar ds("ds", dimTime, 1.0);
39 
40  Info<< "ds*dt dt*ds: " << ds*dt << " " << dt*ds << endl;
41 
42  dimensionedTensor dt2("dt2", dimLength, tensor(1, 1, 2, 3, 4, 5, 6, 7, 8));
43 
44  Info<< "cmptMultiply(dt, dt2): " << cmptMultiply(dt, dt2) << endl;
45  Info<< "cmptDivide(dt, dt2): " << cmptDivide(dt, dt2) << endl;
46 
47  {
48  Pout<< "dimensionSet construct from is:"
49  << dimensionSet(IStringStream("[Pa m^2 s^-2]")())
50  << endl;
51 
52  IStringStream is("[Pa m^2 s^-2]");
53  dimensionSet dset(dimless);
54  is >> dset;
55  Pout<< "dimensionSet read:" << dset << endl;
56  }
57 
58  {
59  Pout<< "construct from is:"
60  << dimensionedScalar(IStringStream("bla [Pa mm^2 s^-2] 3.0")())
61  << endl;
62  Pout<< "construct from name,is:"
64  (
65  "ABC",
66  IStringStream("[Pa mm^2 s^-2] 3.0")()
67  ) << endl;
68  Pout<< "construct from name,dimensionSet,is:"
70  (
71  "ABC",
72  dimLength,
73  IStringStream("bla [mm] 3.0")()
74  ) << endl;
75  {
76  IStringStream is("bla [mm] 3.0");
78  is >> ds;
79  Pout<< "read:" << ds << endl;
80  }
81  }
82 
83 
84  Info<< "End\n" << endl;
85 
86  return 0;
87 }
88 
89 
90 // ************************************************************************* //
Foam::dimensioned::component
dimensioned< cmptType > component(const direction) const
Return a component as a dimensioned<cmptType>
Definition: dimensionedType.C:276
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:116
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
main
int main(int argc, char *argv[])
Definition: Test-dimensionedType.C:32
Foam::Info
messageStream Info
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::IStringStream
Input from memory buffer stream.
Definition: IStringStream.H:49
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::cmptDivide
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
dimensionedTensor.H
Foam::Tensor::XX
@ XX
Definition: Tensor.H:88