Commit d5cbc3bf authored by Mark Olesen's avatar Mark Olesen
Browse files

cosmetic cleanups

- grammar in comments, namespace qualifiers, etc.
parent 7aee58e5
......@@ -228,7 +228,7 @@ public:
};
//- Specify data associated with boundBox type are contiguous
//- Data associated with boundBox type are contiguous
template<>
inline bool contiguous<boundBox>() {return contiguous<point>();}
......
......@@ -45,7 +45,7 @@ namespace Foam
Class Hash Declaration
\*---------------------------------------------------------------------------*/
template<class primitive>
template<class PrimitiveType>
class Hash
{
......@@ -54,12 +54,12 @@ public:
Hash()
{}
label operator()(const primitive& p) const
label operator()(const PrimitiveType& p) const
{
return label(p);
}
label operator()(const primitive& p, const label tableSize) const
label operator()(const PrimitiveType& p, const label tableSize) const
{
return mag(operator()(p)) % tableSize;
}
......
......@@ -29,6 +29,9 @@ Description
An ordered pair of two objects of type \<T\> with first() and second()
elements.
SeeAlso
Foam::Tuple2 for storing two objects of dissimilar types.
\*---------------------------------------------------------------------------*/
#ifndef Pair_H
......@@ -136,15 +139,12 @@ public:
friend bool operator==(const Pair<Type>& a, const Pair<Type>& b)
{
return
(
(a.first() == b.first()) && (a.second() == b.second())
);
return (a.first() == b.first() && a.second() == b.second());
}
friend bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
{
return (!(a == b));
return !(a == b);
}
};
......
......@@ -26,18 +26,13 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const pTraits<Scalar>::typeName = "scalar";
const Scalar pTraits<Scalar>::zero = 0.0;
const Scalar pTraits<Scalar>::one = 1.0;
const char* const Foam::pTraits<Foam::Scalar>::typeName = "scalar";
const Foam::Scalar Foam::pTraits<Foam::Scalar>::zero(0.0);
const Foam::Scalar Foam::pTraits<Foam::Scalar>::one(1.0);
const char* pTraits<Scalar>::componentNames[] = { "x" };
const char* Foam::pTraits<Foam::Scalar>::componentNames[] = { "x" };
pTraits<Scalar>::pTraits(Istream& is)
Foam::pTraits<Foam::Scalar>::pTraits(Istream& is)
{
is >> p_;
}
......@@ -45,27 +40,26 @@ pTraits<Scalar>::pTraits(Istream& is)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- return a string representation of a Scalar
word name(const Scalar s)
Foam::word Foam::name(const Scalar s)
{
std::ostringstream osBuffer;
osBuffer << s;
return osBuffer.str();
std::ostringstream buf;
buf << s;
return buf.str();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Scalar readScalar(Istream& is)
Foam::Scalar Foam::readScalar(Istream& is)
{
Scalar rs;
is >> rs;
Scalar val;
is >> val;
return rs;
return val;
}
Istream& operator>>(Istream& is, Scalar& s)
Foam::Istream& Foam::operator>>(Istream& is, Scalar& s)
{
token t(is);
......@@ -96,7 +90,7 @@ Istream& operator>>(Istream& is, Scalar& s)
}
Ostream& operator<<(Ostream& os, const Scalar s)
Foam::Ostream& Foam::operator<<(Ostream& os, const Scalar s)
{
os.write(s);
os.check("Ostream& operator<<(Ostream&, const Scalar&)");
......@@ -104,8 +98,4 @@ Ostream& operator<<(Ostream& os, const Scalar s)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -51,7 +51,7 @@ public:
enum
{
dim = 3, // Dimensionality of space
rank = 0, // Rank od Scalar is 0
rank = 0, // Rank of Scalar is 0
nComponents = 1 // Number of components in Scalar is 1
};
......@@ -65,7 +65,8 @@ public:
// Constructors
//- Construct from Istream
pTraits(Istream& is);
pTraits(Istream&);
// Member Functions
......@@ -78,8 +79,8 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Return a string representation of a Scalar
word name(const Scalar s);
//- Return a string representation of a Scalar
word name(const Scalar);
inline Scalar& setComponent(Scalar& s, const direction)
......@@ -261,7 +262,7 @@ inline Scalar stabilise(const Scalar s, const Scalar small)
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Scalar readScalar(Istream& is);
Scalar readScalar(Istream&);
Istream& operator>>(Istream&, Scalar&);
Ostream& operator<<(Ostream&, const Scalar);
......
......@@ -28,6 +28,9 @@ Class
Description
A 2-tuple.
SeeAlso
Foam::Pair for storing two objects of identical types.
\*---------------------------------------------------------------------------*/
#ifndef Tuple2_H
......@@ -67,7 +70,7 @@ inline Ostream& operator<<(Ostream&, const Tuple2<Type1, Type2>&);
/*---------------------------------------------------------------------------*\
class Tuple2 Declaration
class Tuple2 Declaration
\*---------------------------------------------------------------------------*/
template<class Type1, class Type2>
......@@ -97,7 +100,7 @@ public:
//- Construct from Istream
inline Tuple2(Istream& is)
{
operator>>(is, *this);
is >> *this;
}
......@@ -186,10 +189,7 @@ inline bool operator==
const Tuple2<Type1, Type2>& b
)
{
return
(
(a.first() == b.first()) && (a.second() == b.second())
);
return (a.first() == b.first() && a.second() == b.second());
}
......@@ -200,7 +200,7 @@ inline bool operator!=
const Tuple2<Type1, Type2>& b
)
{
return (!(a == b));
return !(a == b);
}
......@@ -224,7 +224,7 @@ inline Ostream& operator<<(Ostream& os, const Tuple2<Type1, Type2>& t2)
os << token::BEGIN_LIST
<< t2.f_ << token::SPACE << t2.s_
<< token::END_LIST;
return os;
}
......
......@@ -29,16 +29,11 @@ License
#include <sstream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from Istream
template<class Form, class Cmpt, int nCmpt>
VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
(
Istream& is
)
......@@ -55,36 +50,37 @@ VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
is.readEnd("VectorSpace<Form, Cmpt, nCmpt>");
// Check state of Istream
is.check("VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(Istream& is)");
is.check("VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(Istream&)");
}
//- Return a string representation
// Return a string representation
template<class Form, class Cmpt, int nCmpt>
word name
Foam::word
Foam::name
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
)
{
std::ostringstream osBuffer;
std::ostringstream buf;
osBuffer << '(';
buf << '(';
for (int i=0; i<nCmpt-1; i++)
{
osBuffer << vs.v_[i] << ',';
buf << vs.v_[i] << ',';
}
osBuffer << vs.v_[nCmpt-1] << ')';
buf << vs.v_[nCmpt-1] << ')';
return osBuffer.str();
return buf.str();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Form, class Cmpt, int nCmpt>
Istream& operator>>
Foam::Istream& Foam::operator>>
(
Istream& is,
VectorSpace<Form, Cmpt, nCmpt>& vs
......@@ -109,7 +105,7 @@ Istream& operator>>
template<class Form, class Cmpt, int nCmpt>
Ostream& operator<<
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const VectorSpace<Form, Cmpt, nCmpt>& vs
......@@ -131,8 +127,4 @@ Ostream& operator<<
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -36,12 +36,7 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Istream& operator>>(Istream& is, char& c)
Foam::Istream& Foam::operator>>(Istream& is, char& c)
{
is.read(c);
is.check("Istream& operator>>(Istream& is, char& c)");
......@@ -49,7 +44,7 @@ Istream& operator>>(Istream& is, char& c)
}
Ostream& operator<<(Ostream& os, const char c)
Foam::Ostream& Foam::operator<<(Ostream& os, const char c)
{
os.write(c);
os.check("Ostream& operator<<(Ostream&, const char)");
......@@ -57,7 +52,7 @@ Ostream& operator<<(Ostream& os, const char c)
}
char readChar(Istream& is)
char Foam::readChar(Istream& is)
{
char c;
is.read(c);
......@@ -65,7 +60,7 @@ char readChar(Istream& is)
}
Ostream& operator<<(Ostream& os, const char* s)
Foam::Ostream& Foam::operator<<(Ostream& os, const char* s)
{
os.write(s);
os.check("Ostream& operator<<(Ostream&, const char*)");
......@@ -73,8 +68,4 @@ Ostream& operator<<(Ostream& os, const char* s)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -29,38 +29,33 @@ License
#include <sstream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const complex::typeName = "complex";
const complex complex::zero(0, 0);
const complex complex::one(1, 1);
const char* const Foam::complex::typeName = "complex";
const Foam::complex Foam::complex::zero(0, 0);
const Foam::complex Foam::complex::one(1, 1);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
complex::complex(Istream& is)
Foam::complex::complex(Istream& is)
{
operator>>(is, *this);
is >> *this;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
word name(const complex& c)
Foam::word Foam::name(const complex& c)
{
std::ostringstream osBuffer;
osBuffer << '(' << c.Re() << ',' << c.Im() << ')';
return osBuffer.str();
std::ostringstream buf;
buf << '(' << c.Re() << ',' << c.Im() << ')';
return buf.str();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Istream& operator>>(Istream& is, complex& c)
Foam::Istream& Foam::operator>>(Istream& is, complex& c)
{
// Read beginning of complex
is.readBegin("complex");
......@@ -77,7 +72,7 @@ Istream& operator>>(Istream& is, complex& c)
}
Ostream& operator<<(Ostream& os, const complex& c)
Foam::Ostream& Foam::operator<<(Ostream& os, const complex& c)
{
os << token::BEGIN_LIST
<< c.re << token::SPACE << c.im
......@@ -87,8 +82,4 @@ Ostream& operator<<(Ostream& os, const complex& c)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -174,8 +174,8 @@ public:
// IOstream operators
friend Istream& operator>>(Istream& is, complex&);
friend Ostream& operator<<(Ostream& os, const complex& C);
friend Istream& operator>>(Istream&, complex&);
friend Ostream& operator<<(Ostream&, const complex&);
};
......@@ -186,7 +186,7 @@ public:
word name(const complex&);
//- Specify data associated with complex type is contiguous
//- Data associated with complex type are contiguous
template<>
inline bool contiguous<complex>() {return true;}
......
......@@ -26,12 +26,10 @@ InClass
Foam::contiguous
Description
Template function which specifies if the data of the type is contiguous
or not.
Template function to specify if the data of a type are contiguous.
The default function specifies that data are not contiguous.
This is specialised for the types (e.g. primitives) for which their
data are contiguous.
This is specialised for the types (e.g. primitives) with contiguous data.
\*---------------------------------------------------------------------------*/
......@@ -52,14 +50,13 @@ template<class T, label Size> class FixedList;
template<class T> class Pair;
// Assume the data associated with type T is not contiguous
//- Assume the data associated with type T are not contiguous
template<class T>
inline bool contiguous() {return false;}
inline bool contiguous() {return false;}
// Specify data associated with primitive types (and simple fixed size
// containers - only size 2 defined here) is contiguous
// Data associated with primitive types (and simple fixed size containers
// - only size 2 defined here) are contiguous
template<>
inline bool contiguous<bool>() {return true;}
......@@ -143,7 +140,7 @@ inline bool contiguous<float>() {return true;}
template<>
inline bool contiguous<FixedList<float, 2> >() {return true;}
template<>
inline bool contiguous<Pair<float> >() {return true;}
inline bool contiguous<Pair<float> >() {return true;}
template<>
inline bool contiguous<double>() {return true;}
......
......@@ -49,7 +49,7 @@ namespace Foam
typedef DiagTensor<scalar> diagTensor;
//- Specify data associated with diagTensor type is contiguous
//- Data associated with diagTensor type are contiguous
template<>
inline bool contiguous<diagTensor>() {return true;}
......
......@@ -50,11 +50,11 @@ class Ostream;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Return a word representation of an int
word name(const int i);
word name(const int);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
int readInt(Istream& is);
int readInt(Istream&);
Istream& operator>>(Istream&, int&);
Ostream& operator<<(Ostream&, const int);
......
......@@ -39,22 +39,17 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
Foam::word Foam::name(const int val)
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Return a string representation of an int
word name(const int i)
{
std::ostringstream osBuffer;
osBuffer << i;
return osBuffer.str();
std::ostringstream buf;
buf << val;
return buf.str();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Istream& operator>>(Istream& is, int& i)
Foam::Istream& Foam::operator>>(Istream& is, int& i)
{
token t(is);
......@@ -85,16 +80,16 @@ Istream& operator>>(Istream& is, int& i)
}
int readInt(Istream& is)
int Foam::readInt(Istream& is)
{
int ri;
is >> ri;
int val;
is >> val;
return ri;
return val;
}
Ostream& operator<<(Ostream& os, const int i)
Foam::Ostream& Foam::operator<<(Ostream& os, const int i)
{
os.write(label(i));
os.check("Ostream& operator<<(Ostream&, const int)");
......@@ -102,8 +97,4 @@ Ostream& operator<<(Ostream& os, const int i)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -38,8 +38,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const pTraits<label>::typeName = "label";
const label pTraits<label>::zero = 0;
const label pTraits<label>::one = 1;
const label pTraits<label>::zero(0);
const label pTraits<label>::one(1);
const char* pTraits<label>::componentNames[] = { "x" };
......@@ -48,7 +48,6 @@ pTraits<label>::pTraits(Istream& is)
is >> p_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Raise one label to the power of another (overloaded function call)
......
......@@ -140,7 +140,7 @@ public:
enum
{
dim = 3, // Dimensionality of space
rank = 0, // Rank od label is 0
rank = 0, // Rank of label is 0
nComponents = 1 // Number of components in label is 1
};
......@@ -154,7 +154,7 @@ public:
// Constructors
//- Construct from Istream
pTraits(Istream& is);
pTraits(Istream&);
// Member Functions
......