diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C index d634b78ade..4129c50262 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C @@ -30,44 +30,44 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -Foam::VectorSpace::VectorSpace +template +Foam::VectorSpace::VectorSpace ( Istream& is ) { // Read beginning of VectorSpace - is.readBegin("VectorSpace"); + is.readBegin("VectorSpace"); - for (direction i=0; i> v_[i]; } // Read end of VectorSpace - is.readEnd("VectorSpace"); + is.readEnd("VectorSpace"); // Check state of Istream - is.check("VectorSpace::VectorSpace(Istream&)"); + is.check("VectorSpace::VectorSpace(Istream&)"); } -template +template Foam::word Foam::name ( - const VectorSpace& vs + const VectorSpace& vs ) { std::ostringstream buf; buf << '('; - for (direction i=0; i +template Foam::Istream& Foam::operator>> ( Istream& is, - VectorSpace& vs + VectorSpace& vs ) { - // Read beginning of VectorSpace - is.readBegin("VectorSpace"); + // Read beginning of VectorSpace + is.readBegin("VectorSpace"); - for (direction i=0; i> vs.v_[i]; } - // Read end of VectorSpace - is.readEnd("VectorSpace"); + // Read end of VectorSpace + is.readEnd("VectorSpace"); // Check state of Istream - is.check("operator>>(Istream&, VectorSpace&)"); + is.check("operator>>(Istream&, VectorSpace&)"); return is; } -template +template Foam::Ostream& Foam::operator<< ( Ostream& os, - const VectorSpace& vs + const VectorSpace& vs ) { os << token::BEGIN_LIST << vs.v_[0]; - for (direction i=1; i&)"); + os.check("operator<<(Ostream&, const VectorSpace&)"); return os; } diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H index e8c4cbf16a..27c1bff3c1 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H @@ -51,20 +51,20 @@ namespace Foam // Forward declaration of friend functions and operators -template class VectorSpace; +template class VectorSpace; -template +template Istream& operator>> ( Istream&, - VectorSpace& + VectorSpace& ); -template +template Ostream& operator<< ( Ostream&, - const VectorSpace& + const VectorSpace& ); @@ -72,18 +72,17 @@ Ostream& operator<< Class VectorSpace Declaration \*---------------------------------------------------------------------------*/ -template +template class VectorSpace { public: //- The components of this vector space - Cmpt v_[nCmpt]; - + Cmpt v_[Ncmpts]; //- VectorSpace type - typedef VectorSpace vsType; + typedef VectorSpace vsType; //- Component type typedef Cmpt cmptType; @@ -91,11 +90,11 @@ public: // Member constants - enum - { - dim = 3, //!< Dimensionality of space - nComponents = nCmpt //!< Number of components in this vector space - }; + //- Dimensionality of space + static const direction dim = 3; + + //- Number of components in this vector space + static const direction nComponents = Ncmpts; // Static data members @@ -116,23 +115,23 @@ public: inline VectorSpace(); //- Construct initialized to zero - inline VectorSpace(const Foam::zero); + inline explicit VectorSpace(const Foam::zero); //- Construct from Istream VectorSpace(Istream&); //- Construct as copy - inline VectorSpace(const VectorSpace&); + inline VectorSpace(const VectorSpace&); //- Construct as copy of another VectorSpace type of the same rank template - inline VectorSpace(const VectorSpace&); + inline VectorSpace(const VectorSpace&); // Member Functions - //- Return the number of elements in the VectorSpace = nCmpt. - inline label size() const; + //- Return the number of elements in the VectorSpace = Ncmpts. + inline static direction size(); inline const Cmpt& component(const direction) const; inline Cmpt& component(const direction); @@ -149,9 +148,9 @@ public: inline const Cmpt& operator[](const direction) const; inline Cmpt& operator[](const direction); - inline void operator=(const VectorSpace&); - inline void operator+=(const VectorSpace&); - inline void operator-=(const VectorSpace&); + inline void operator=(const VectorSpace&); + inline void operator+=(const VectorSpace&); + inline void operator-=(const VectorSpace&); inline void operator=(const Foam::zero); inline void operator*=(const scalar); @@ -160,16 +159,16 @@ public: // IOstream Operators - friend Istream& operator>> + friend Istream& operator>> ( Istream&, - VectorSpace& + VectorSpace& ); - friend Ostream& operator<< + friend Ostream& operator<< ( Ostream&, - const VectorSpace& + const VectorSpace& ); }; @@ -177,8 +176,8 @@ public: // * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * * // //- Return a string representation of a VectorSpace -template -word name(const VectorSpace&); +template +word name(const VectorSpace&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H index 1b9c62798a..fe4a47be48 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H @@ -35,56 +35,56 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline VectorSpace::VectorSpace() +template +inline VectorSpace::VectorSpace() {} -template -inline VectorSpace::VectorSpace(const Foam::zero z) +template +inline VectorSpace::VectorSpace(const Foam::zero z) { - VectorSpaceOps::eqOpS(*this, 0, eqOp()); + VectorSpaceOps::eqOpS(*this, 0, eqOp()); } -template -inline VectorSpace::VectorSpace +template +inline VectorSpace::VectorSpace ( - const VectorSpace& vs + const VectorSpace& vs ) { - VectorSpaceOps::eqOp(*this, vs, eqOp()); + VectorSpaceOps::eqOp(*this, vs, eqOp()); } -template +template template -inline VectorSpace::VectorSpace +inline VectorSpace::VectorSpace ( - const VectorSpace& vs + const VectorSpace& vs ) { - VectorSpaceOps::eqOp(*this, vs, eqOp()); + VectorSpaceOps::eqOp(*this, vs, eqOp()); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline label VectorSpace::size() const +template +inline direction VectorSpace::size() { - return nCmpt; + return Ncmpts; } -template -inline const Cmpt& VectorSpace::component +template +inline const Cmpt& VectorSpace::component ( const direction d ) const { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -96,14 +96,14 @@ inline const Cmpt& VectorSpace::component } -template -inline Cmpt& VectorSpace::component +template +inline Cmpt& VectorSpace::component ( const direction d ) { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -115,15 +115,15 @@ inline Cmpt& VectorSpace::component } -template -inline void VectorSpace::component +template +inline void VectorSpace::component ( Cmpt& c, const direction d ) const { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -135,15 +135,15 @@ inline void VectorSpace::component } -template -inline void VectorSpace::replace +template +inline void VectorSpace::replace ( const direction d, const Cmpt& c ) { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -155,25 +155,25 @@ inline void VectorSpace::replace } -template -inline Form VectorSpace::uniform(const Cmpt& s) +template +inline Form VectorSpace::uniform(const Cmpt& s) { Form v; - VectorSpaceOps::eqOpS(v, s, eqOp()); + VectorSpaceOps::eqOpS(v, s, eqOp()); return v; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template -inline const Cmpt& VectorSpace::operator[] +template +inline const Cmpt& VectorSpace::operator[] ( const direction d ) const { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -185,14 +185,14 @@ inline const Cmpt& VectorSpace::operator[] } -template -inline Cmpt& VectorSpace::operator[] +template +inline Cmpt& VectorSpace::operator[] ( const direction d ) { #ifdef FULLDEBUG - if (d >= nCmpt) + if (d >= Ncmpts) { FatalErrorInFunction << "index out of range" @@ -204,69 +204,69 @@ inline Cmpt& VectorSpace::operator[] } -template -inline void VectorSpace::operator= +template +inline void VectorSpace::operator= ( - const VectorSpace& vs + const VectorSpace& vs ) { - VectorSpaceOps::eqOp(*this, vs, eqOp()); + VectorSpaceOps::eqOp(*this, vs, eqOp()); } -template -inline void VectorSpace::operator+= +template +inline void VectorSpace::operator+= ( - const VectorSpace& vs + const VectorSpace& vs ) { - VectorSpaceOps::eqOp(*this, vs, plusEqOp()); + VectorSpaceOps::eqOp(*this, vs, plusEqOp()); } -template -inline void VectorSpace::operator-= +template +inline void VectorSpace::operator-= ( - const VectorSpace& vs + const VectorSpace& vs ) { - VectorSpaceOps::eqOp(*this, vs, minusEqOp()); + VectorSpaceOps::eqOp(*this, vs, minusEqOp()); } -template -inline void VectorSpace::operator=(const Foam::zero) +template +inline void VectorSpace::operator=(const Foam::zero) { - VectorSpaceOps::eqOpS(*this, 0, eqOp()); + VectorSpaceOps::eqOpS(*this, 0, eqOp()); } -template -inline void VectorSpace::operator*= +template +inline void VectorSpace::operator*= ( const scalar s ) { - VectorSpaceOps::eqOpS(*this, s, multiplyEqOp2()); + VectorSpaceOps::eqOpS(*this, s, multiplyEqOp2()); } -template -inline void VectorSpace::operator/= +template +inline void VectorSpace::operator/= ( const scalar s ) { - VectorSpaceOps::eqOpS(*this, s, divideEqOp2()); + VectorSpaceOps::eqOpS(*this, s, divideEqOp2()); } // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // -template +template inline Cmpt& setComponent ( - VectorSpace& vs, + VectorSpace& vs, const direction d ) { @@ -274,10 +274,10 @@ inline Cmpt& setComponent } -template +template inline const Cmpt& component ( - const VectorSpace& vs, + const VectorSpace& vs, const direction d ) { @@ -288,10 +288,10 @@ inline const Cmpt& component // Powers of a Form // Equivalent to outer-products between the Form and itself // Form^0 = 1.0 -template +template inline typename powProduct::type pow ( - const VectorSpace&, + const VectorSpace&, typename powProduct::type = pTraits::type>::zero ) @@ -300,10 +300,10 @@ inline typename powProduct::type pow } // Form^1 = Form -template +template inline typename powProduct::type pow ( - const VectorSpace& v, + const VectorSpace& v, typename powProduct::type = pTraits::type>::zero ) @@ -313,10 +313,10 @@ inline typename powProduct::type pow // Form^2 = sqr(Form) -template +template inline typename powProduct::type pow ( - const VectorSpace& v, + const VectorSpace& v, typename powProduct::type = pTraits::type>::zero ) @@ -325,184 +325,184 @@ inline typename powProduct::type pow } -template +template inline scalar magSqr ( - const VectorSpace& vs + const VectorSpace& vs ) { scalar ms = magSqr(vs.v_[0]); - VectorSpaceOps::SeqOp(ms, vs, plusEqMagSqrOp2()); + VectorSpaceOps::SeqOp(ms, vs, plusEqMagSqrOp2()); return ms; } -template +template inline scalar mag ( - const VectorSpace& vs + const VectorSpace& vs ) { return ::sqrt(magSqr(static_cast(vs))); } -template -inline VectorSpace cmptMultiply +template +inline VectorSpace cmptMultiply ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, cmptMultiplyOp()); + VectorSpaceOps::op(v, vs1, vs2, cmptMultiplyOp()); return v; } -template -inline VectorSpace cmptPow +template +inline VectorSpace cmptPow ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, cmptPowOp()); + VectorSpaceOps::op(v, vs1, vs2, cmptPowOp()); return v; } -template -inline VectorSpace cmptDivide +template +inline VectorSpace cmptDivide ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, cmptDivideOp()); + VectorSpaceOps::op(v, vs1, vs2, cmptDivideOp()); return v; } -template -inline VectorSpace stabilise +template +inline VectorSpace stabilise ( - const VectorSpace& vs, + const VectorSpace& vs, const Cmpt& small ) { Form v; - VectorSpaceOps::opVS(v, vs, small, stabiliseOp()); + VectorSpaceOps::opVS(v, vs, small, stabiliseOp()); return v; } -template +template inline Cmpt cmptMax ( - const VectorSpace& vs + const VectorSpace& vs ) { Cmpt cMax = vs.v_[0]; - VectorSpaceOps::SeqOp(cMax, vs, maxEqOp()); + VectorSpaceOps::SeqOp(cMax, vs, maxEqOp()); return cMax; } -template +template inline Cmpt cmptMin ( - const VectorSpace& vs + const VectorSpace& vs ) { Cmpt cMin = vs.v_[0]; - VectorSpaceOps::SeqOp(cMin, vs, minEqOp()); + VectorSpaceOps::SeqOp(cMin, vs, minEqOp()); return cMin; } -template +template inline Cmpt cmptSum ( - const VectorSpace& vs + const VectorSpace& vs ) { Cmpt sum = vs.v_[0]; - VectorSpaceOps::SeqOp(sum, vs, plusEqOp()); + VectorSpaceOps::SeqOp(sum, vs, plusEqOp()); return sum; } -template +template inline Cmpt cmptAv ( - const VectorSpace& vs + const VectorSpace& vs ) { - return cmptSum(vs)/nCmpt; + return cmptSum(vs)/Ncmpts; } -template +template inline Cmpt cmptProduct ( - const VectorSpace& vs + const VectorSpace& vs ) { Cmpt product = vs.v_[0]; - VectorSpaceOps::SeqOp(product, vs, multiplyEqOp()); + VectorSpaceOps::SeqOp(product, vs, multiplyEqOp()); return product; } -template +template inline Form cmptMag ( - const VectorSpace& vs + const VectorSpace& vs ) { Form v; - VectorSpaceOps::eqOp(v, vs, eqMagOp()); + VectorSpaceOps::eqOp(v, vs, eqMagOp()); return v; } -template +template inline Form max ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, maxOp()); + VectorSpaceOps::op(v, vs1, vs2, maxOp()); return v; } -template +template inline Form min ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, minOp()); + VectorSpaceOps::op(v, vs1, vs2, minOp()); return v; } -template +template inline Form minMod ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, minModOp()); + VectorSpaceOps::op(v, vs1, vs2, minModOp()); return v; } @@ -523,13 +523,13 @@ inline Type dot(const Type& t, const scalar s) template < - class Form1, class Cmpt1, direction nCmpt1, - class Form2, class Cmpt2, direction nCmpt2 + class Form1, class Cmpt1, direction Ncmpts1, + class Form2, class Cmpt2, direction Ncmpts2 > inline typename innerProduct::type dot ( - const VectorSpace& t1, - const VectorSpace& t2 + const VectorSpace& t1, + const VectorSpace& t2 ) { return static_cast(t1) & static_cast(t2); @@ -538,118 +538,118 @@ inline typename innerProduct::type dot // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // -template +template inline Form operator- ( - const VectorSpace& vs + const VectorSpace& vs ) { Form v; - VectorSpaceOps::eqOp(v, vs, eqMinusOp()); + VectorSpaceOps::eqOp(v, vs, eqMinusOp()); return v; } -template +template inline Form operator+ ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, plusOp()); + VectorSpaceOps::op(v, vs1, vs2, plusOp()); return v; } -template +template inline Form operator- ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, minusOp()); + VectorSpaceOps::op(v, vs1, vs2, minusOp()); return v; } -template +template inline Form operator* ( scalar s, - const VectorSpace& vs + const VectorSpace& vs ) { Form v; - VectorSpaceOps::opSV(v, s, vs, multiplyOp3()); + VectorSpaceOps::opSV(v, s, vs, multiplyOp3()); return v; } -template +template inline Form operator* ( - const VectorSpace& vs, + const VectorSpace& vs, scalar s ) { Form v; - VectorSpaceOps::opVS(v, vs, s, multiplyOp3()); + VectorSpaceOps::opVS(v, vs, s, multiplyOp3()); return v; } -template +template inline Form operator/ ( - const VectorSpace& vs, + const VectorSpace& vs, scalar s ) { Form v; - VectorSpaceOps::opVS(v, vs, s, divideOp3()); + VectorSpaceOps::opVS(v, vs, s, divideOp3()); return v; } /* -template +template inline Form operator/ ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Form v; - VectorSpaceOps::op(v, vs1, vs2, divideOp()); + VectorSpaceOps::op(v, vs1, vs2, divideOp()); return v; } -template +template inline Form operator/ ( scalar s, - const VectorSpace& vs + const VectorSpace& vs ) { Form v; - VectorSpaceOps::opSV(v, s, vs, divideOp2()); + VectorSpaceOps::opSV(v, s, vs, divideOp2()); return v; } */ -template +template inline Cmpt operator&& ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { Cmpt ddProd = vs1.v_[0]*vs2.v_[0]; - for (direction i=1; i +template inline bool operator== ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { bool eq = true; - for (direction i=0; i +template inline bool operator!= ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { return !(vs1 == vs2); } -template +template inline bool operator> ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { bool gt = true; - for (direction i=0; i vs2.v_[i])) break; } @@ -700,15 +700,15 @@ inline bool operator> } -template +template inline bool operator< ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { bool lt = true; - for (direction i=0; i +template inline bool operator>= ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { return !(vs1 < vs2); } -template +template inline bool operator<= ( - const VectorSpace& vs1, - const VectorSpace& vs2 + const VectorSpace& vs1, + const VectorSpace& vs2 ) { return !(vs1 > vs2);