ENH: provide a 'dimensioned' null-like constructor for dimensionedType

- The null constructor already creates a dimensionless Zero,
  but named "undefined".

  Provide an constructor for a dimensioned Zero,
  but named "0" for universal clarity to its value.
This commit is contained in:
Mark Olesen
2016-12-02 08:48:01 +01:00
parent 8628ddac43
commit 8563f892a9
3 changed files with 22 additions and 3 deletions

View File

@ -81,6 +81,10 @@ int main(int argc, char *argv[])
}
Pout<< "zero scalar (time): " << dimensionedScalar(dimTime) << endl;
Pout<< "zero vector: " << dimensionedVector(dimLength) << endl;
Pout<< "zero tensor: " << dimensionedTensor(dimLength) << endl;
Info<< "End\n" << endl;
return 0;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -169,6 +169,18 @@ Foam::dimensioned<Type>::dimensioned
{}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const dimensionSet& dimSet
)
:
name_("0"),
dimensions_(dimSet),
value_(Zero)
{}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -117,9 +117,12 @@ public:
//- Construct from dictionary lookup with a given name and dimensions
dimensioned(const word&, const dimensionSet&, const dictionary&);
//- Null constructor
//- Null constructor - a dimensionless Zero, named "undefined"
dimensioned();
//- A dimensioned Zero, named "0"
explicit dimensioned(const dimensionSet&);
// Static member functions