diff --git a/applications/test/dimensionedType/Test-dimensionedType.C b/applications/test/dimensionedType/Test-dimensionedType.C index ccf56fff6b..965de25ead 100644 --- a/applications/test/dimensionedType/Test-dimensionedType.C +++ b/applications/test/dimensionedType/Test-dimensionedType.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,8 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - \*---------------------------------------------------------------------------*/ #include "dimensionedTensor.H" @@ -33,16 +31,19 @@ using namespace Foam; int main(int argc, char *argv[]) { - dimensionedTensor dt("dt", dimless, tensor(0, 1, 2, 3, 4, 5, 6, 7, 8)); + dimensionedTensor dt("dt", dimLength, tensor(0, 1, 2, 3, 4, 5, 6, 7, 8)); - Info<< dt.component(tensor::XX) << endl; + Info<< "dt.component(tensor::XX): " << dt.component(tensor::XX) << endl; - dimensionedScalar ds("ds", dimless, 1.0); + dimensionedScalar ds("ds", dimTime, 1.0); - Info<< ds*dt << " " << dt*ds << endl; + Info<< "ds*dt dt*ds: " << ds*dt << " " << dt*ds << endl; + dimensionedTensor dt2("dt2", dimLength, tensor(1, 1, 2, 3, 4, 5, 6, 7, 8)); + + Info<< "cmptMultiply(dt, dt2): " << cmptMultiply(dt, dt2) << endl; + Info<< "cmptDivide(dt, dt2): " << cmptDivide(dt, dt2) << endl; - // dimensionSet { Pout<< "dimensionSet construct from is:" << dimensionSet(IStringStream("[Pa m^2 s^-2]")()) @@ -53,7 +54,7 @@ int main(int argc, char *argv[]) is >> dset; Pout<< "dimensionSet read:" << dset << endl; } - // dimensionedType + { Pout<< "construct from is:" << dimensionedScalar(IStringStream("bla [Pa mm^2 s^-2] 3.0")()) diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index b78fbed97a..d062c8ec3a 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -27,15 +27,10 @@ License #include "pTraits.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template -dimensioned dimensioned::lookupOrDefault +Foam::dimensioned Foam::dimensioned::lookupOrDefault ( const word& name, const dictionary& dict, @@ -49,7 +44,7 @@ dimensioned dimensioned::lookupOrDefault template -dimensioned dimensioned::lookupOrAddToDict +Foam::dimensioned Foam::dimensioned::lookupOrAddToDict ( const word& name, dictionary& dict, @@ -65,7 +60,7 @@ dimensioned dimensioned::lookupOrAddToDict // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -dimensioned::dimensioned +Foam::dimensioned::dimensioned ( const word& name, const dimensionSet& dimSet, @@ -79,7 +74,7 @@ dimensioned::dimensioned template -dimensioned::dimensioned +Foam::dimensioned::dimensioned ( const word& name, const dimensioned& dt @@ -92,7 +87,7 @@ dimensioned::dimensioned template -dimensioned::dimensioned +Foam::dimensioned::dimensioned ( Istream& is ) @@ -104,7 +99,7 @@ dimensioned::dimensioned template -dimensioned::dimensioned +Foam::dimensioned::dimensioned ( const word& name, Istream& is @@ -121,7 +116,7 @@ dimensioned::dimensioned template -dimensioned::dimensioned +Foam::dimensioned::dimensioned ( const word& name, const dimensionSet& dimSet, @@ -172,7 +167,7 @@ dimensioned::dimensioned template -dimensioned::dimensioned +Foam::dimensioned::dimensioned () : name_("undefined"), @@ -184,46 +179,47 @@ dimensioned::dimensioned // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -const word& dimensioned::name() const +const Foam::word& Foam::dimensioned::name() const { return name_; } template -word& dimensioned::name() +Foam::word& Foam::dimensioned::name() { return name_; } template -const dimensionSet& dimensioned::dimensions() const +const Foam::dimensionSet& Foam::dimensioned::dimensions() const { return dimensions_; } template -dimensionSet& dimensioned::dimensions() +Foam::dimensionSet& Foam::dimensioned::dimensions() { return dimensions_; } template -const Type& dimensioned::value() const +const Type& Foam::dimensioned::value() const { return value_; } template -Type& dimensioned::value() +Type& Foam::dimensioned::value() { return value_; } template -dimensioned::cmptType> dimensioned::component +Foam::dimensioned::cmptType> +Foam::dimensioned::component ( const direction d ) const @@ -238,7 +234,7 @@ dimensioned::cmptType> dimensioned::component template -void dimensioned::replace +void Foam::dimensioned::replace ( const direction d, const dimensioned::cmptType>& dc @@ -250,14 +246,15 @@ void dimensioned::replace template -bool dimensioned::readIfPresent(const dictionary& dict) +bool Foam::dimensioned::readIfPresent(const dictionary& dict) { return dict.readIfPresent(name_, value_); } template -Foam::Istream& dimensioned::read(Istream& is, const dictionary& readSet) +Foam::Istream& +Foam::dimensioned::read(Istream& is, const dictionary& readSet) { // Read name is >> name_; @@ -281,7 +278,7 @@ Foam::Istream& dimensioned::read(Istream& is, const dictionary& readSet) template -Foam::Istream& dimensioned::read +Foam::Istream& Foam::dimensioned::read ( Istream& is, const HashTable& readSet @@ -310,7 +307,7 @@ Foam::Istream& dimensioned::read template -Foam::Istream& dimensioned::read(Istream& is) +Foam::Istream& Foam::dimensioned::read(Istream& is) { // Read name is >> name_; @@ -336,7 +333,8 @@ Foam::Istream& dimensioned::read(Istream& is) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -dimensioned::cmptType> dimensioned::operator[] +Foam::dimensioned::cmptType> +Foam::dimensioned::operator[] ( const direction d ) const @@ -346,7 +344,7 @@ dimensioned::cmptType> dimensioned::operator[] template -void dimensioned::operator+= +void Foam::dimensioned::operator+= ( const dimensioned& dt ) @@ -357,7 +355,7 @@ void dimensioned::operator+= template -void dimensioned::operator-= +void Foam::dimensioned::operator-= ( const dimensioned& dt ) @@ -368,7 +366,7 @@ void dimensioned::operator-= template -void dimensioned::operator*= +void Foam::dimensioned::operator*= ( const scalar s ) @@ -378,7 +376,7 @@ void dimensioned::operator*= template -void dimensioned::operator/= +void Foam::dimensioned::operator/= ( const scalar s ) @@ -390,8 +388,8 @@ void dimensioned::operator/= // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // template -dimensioned::type> -pow(const dimensioned& dt, typename powProduct::type) +Foam::dimensioned::type> +Foam::pow(const dimensioned& dt, typename powProduct::type) { return dimensioned::type> ( @@ -401,9 +399,10 @@ pow(const dimensioned& dt, typename powProduct::type) ); } + template -dimensioned::type> -sqr(const dimensioned& dt) +Foam::dimensioned::type> +Foam::sqr(const dimensioned& dt) { return dimensioned::type> ( @@ -414,7 +413,7 @@ sqr(const dimensioned& dt) } template -dimensioned magSqr(const dimensioned& dt) +Foam::dimensioned Foam::magSqr(const dimensioned& dt) { return dimensioned ( @@ -425,7 +424,7 @@ dimensioned magSqr(const dimensioned& dt) } template -dimensioned mag(const dimensioned& dt) +Foam::dimensioned Foam::mag(const dimensioned& dt) { return dimensioned ( @@ -437,7 +436,38 @@ dimensioned mag(const dimensioned& dt) template -dimensioned max +Foam::dimensioned Foam::cmptMultiply +( + const dimensioned& dt1, + const dimensioned& dt2 +) +{ + return dimensioned + ( + "cmptMultiply(" + dt1.name() + ',' + dt2.name() + ')', + cmptMultiply(dt1.dimensions(), dt2.dimensions()), + cmptMultiply(dt1.value(), dt2.value()) + ); +} + +template +Foam::dimensioned Foam::cmptDivide +( + const dimensioned& dt1, + const dimensioned& dt2 +) +{ + return dimensioned + ( + "cmptDivide(" + dt1.name() + ',' + dt2.name() + ')', + cmptDivide(dt1.dimensions(), dt2.dimensions()), + cmptDivide(dt1.value(), dt2.value()) + ); +} + + +template +Foam::dimensioned Foam::max ( const dimensioned& dt1, const dimensioned& dt2 @@ -460,7 +490,7 @@ dimensioned max template -dimensioned min +Foam::dimensioned Foam::min ( const dimensioned& dt1, const dimensioned& dt2 @@ -485,7 +515,7 @@ dimensioned min // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template -Istream& operator>>(Istream& is, dimensioned& dt) +Foam::Istream& Foam::operator>>(Istream& is, dimensioned& dt) { token nextToken(is); is.putBack(nextToken); @@ -518,7 +548,7 @@ Istream& operator>>(Istream& is, dimensioned& dt) template -Ostream& operator<<(Ostream& os, const dimensioned& dt) +Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned& dt) { // Write the name os << dt.name() << token::SPACE; @@ -542,7 +572,7 @@ Ostream& operator<<(Ostream& os, const dimensioned& dt) // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // template -bool operator> +bool Foam::operator> ( const dimensioned& dt1, const dimensioned& dt2 @@ -553,7 +583,7 @@ bool operator> template -bool operator< +bool Foam::operator< ( const dimensioned& dt1, const dimensioned& dt2 @@ -564,7 +594,7 @@ bool operator< template -dimensioned operator+ +Foam::dimensioned Foam::operator+ ( const dimensioned& dt1, const dimensioned& dt2 @@ -580,7 +610,7 @@ dimensioned operator+ template -dimensioned operator-(const dimensioned& dt) +Foam::dimensioned Foam::operator-(const dimensioned& dt) { return dimensioned ( @@ -592,7 +622,7 @@ dimensioned operator-(const dimensioned& dt) template -dimensioned operator- +Foam::dimensioned Foam::operator- ( const dimensioned& dt1, const dimensioned& dt2 @@ -608,7 +638,7 @@ dimensioned operator- template -dimensioned operator* +Foam::dimensioned Foam::operator* ( const dimensioned& ds, const dimensioned& dt @@ -624,7 +654,7 @@ dimensioned operator* template -dimensioned operator/ +Foam::dimensioned Foam::operator/ ( const dimensioned& dt, const dimensioned& ds @@ -645,8 +675,12 @@ dimensioned operator/ #define PRODUCT_OPERATOR(product, op, opFunc) \ \ template \ -dimensioned::type> \ -operator op(const dimensioned& dt1, const dimensioned& dt2) \ +Foam::dimensioned::type> \ +Foam::operator op \ +( \ + const dimensioned& dt1, \ + const dimensioned& dt2 \ +) \ { \ return dimensioned::type> \ ( \ @@ -657,8 +691,8 @@ operator op(const dimensioned& dt1, const dimensioned& dt2) \ } \ \ template \ -dimensioned::type> \ -operator op \ +Foam::dimensioned::type> \ +Foam::operator op \ ( \ const dimensioned& dt1, \ const VectorSpace& t2 \ @@ -673,8 +707,8 @@ operator op \ } \ \ template \ -dimensioned::type> \ -operator op \ +Foam::dimensioned::type> \ +Foam::operator op \ ( \ const VectorSpace& t1, \ const dimensioned& dt2 \ @@ -697,8 +731,4 @@ PRODUCT_OPERATOR(scalarProduct, &&, dotdot) #undef PRODUCT_OPERATOR -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* //