Commit 436b8f07 authored by henry's avatar henry
Browse files

Added support for sphericalTensor and symmTensor.

parent 700ba91e
......@@ -13,10 +13,10 @@ sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/writers/writer/writers.C
sampledSet/writers/raw/rawWriters.C
sampledSet/writers/xmgr/xmgrWriters.C
sampledSet/writers/gnuplot/gnuplotWriters.C
sampledSet/writers/jplot/jplotWriters.C
sampledSet/writers/raw/rawWriters.C
cuttingPlane/cuttingPlane.C
......
......@@ -63,28 +63,26 @@ public:
//- Construct null
gnuplot();
// Destructor
virtual ~gnuplot();
//- Destructor
virtual ~gnuplot();
// Member Functions
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
......
......@@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "gnuplotWriters.H"
......@@ -33,13 +31,7 @@ Description
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(gnuplot);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWriters(gnuplot)
}
// ************************************************************************* //
......@@ -25,12 +25,9 @@ License
InClass
Foam::gnuplotWriters
Description
SourceFiles
gnuplotWriters.C
\*---------------------------------------------------------------------------*/
#ifndef gnuplotWriters_H
......@@ -44,16 +41,8 @@ SourceFiles
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef gnuplot<scalar> gnuplotScalarWriter;
typedef gnuplot<vector> gnuplotVectorWriter;
typedef gnuplot<tensor> gnuplotTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWritersTypedefs(gnuplot)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -25,8 +25,6 @@ License
Class
Foam::jplot
Description
SourceFiles
jplot.C
......@@ -43,8 +41,6 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class jplot Declaration
\*---------------------------------------------------------------------------*/
......@@ -71,30 +67,26 @@ public:
//- Construct null
jplot();
// Destructor
virtual ~jplot();
//- Destructor
virtual ~jplot();
// Member Functions
// Access
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
......
......@@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "jplotWriters.H"
......@@ -33,13 +31,7 @@ Description
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(jplot);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWriters(jplot)
}
// ************************************************************************* //
......@@ -25,12 +25,9 @@ License
InClass
Foam::jplotWriters
Description
SourceFiles
jplotWriters.C
\*---------------------------------------------------------------------------*/
#ifndef jplotWriters_H
......@@ -44,16 +41,8 @@ SourceFiles
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef jplot<scalar> jplotScalarWriter;
typedef jplot<vector> jplotVectorWriter;
typedef jplot<tensor> jplotTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWritersTypedefs(jplot)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -64,28 +64,25 @@ public:
raw();
// Destructor
virtual ~raw();
//- Destructor
virtual ~raw();
// Member Functions
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
......
......@@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "rawWriters.H"
......@@ -33,13 +31,7 @@ Description
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(raw);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWriters(raw)
}
// ************************************************************************* //
......@@ -25,12 +25,9 @@ License
InClass
Foam::rawWriters
Description
SourceFiles
rawWriters.C
\*---------------------------------------------------------------------------*/
#ifndef rawWriters_H
......@@ -44,16 +41,8 @@ SourceFiles
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef raw<scalar> rawScalarWriter;
typedef raw<vector> rawVectorWriter;
typedef raw<tensor> rawTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makeWritersTypedefs(raw)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -31,11 +31,11 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
autoPtr<writer<Type> > writer<Type>::New(const word& writeType)
Foam::autoPtr<Foam::writer<Type> > Foam::writer<Type>::New
(
const word& writeType
)
{
typename wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
......@@ -60,7 +60,7 @@ autoPtr<writer<Type> > writer<Type>::New(const word& writeType)
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
fileName writer<Type>::getBaseName
Foam::fileName Foam::writer<Type>::getBaseName
(
const coordSet& points,
const wordList& valueSets
......@@ -78,7 +78,7 @@ fileName writer<Type>::getBaseName
template<class Type>
void writer<Type>::writeCoord
void Foam::writer<Type>::writeCoord
(
const coordSet& points,
const label pointI,
......@@ -97,7 +97,7 @@ void writer<Type>::writeCoord
template<class Type>
void writer<Type>::writeTable
void Foam::writer<Type>::writeTable
(
const coordSet& points,
const List<Type>& values,
......@@ -109,16 +109,14 @@ void writer<Type>::writeTable
writeCoord(points, pointI, os);
os << token::SPACE;
write(values[pointI], os);
os << endl;
}
}
template<class Type>
void writer<Type>::writeTable
void Foam::writer<Type>::writeTable
(
const coordSet& points,
const List<const List<Type>*>& valuesPtrList,
......@@ -132,9 +130,7 @@ void writer<Type>::writeTable
forAll(valuesPtrList, i)
{
os << token::SPACE;
const List<Type>& values = *valuesPtrList[i];
write(values[pointI], os);
}
os << endl;
......@@ -144,36 +140,44 @@ void writer<Type>::writeTable
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null
template<class Type>
writer<Type>::writer()
Foam::writer<Type>::writer()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
writer<Type>::~writer()
Foam::writer<Type>::~writer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const scalar value, Ostream& os) const
Foam::Ostream& Foam::writer<Type>::write
(
const scalar value,
Ostream& os
) const
{
return os << value;
}
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const vector& value, Ostream& os) const
template<class VSType>
Foam::Ostream& Foam::writer<Type>::writeVS
(
const VSType& value,
Ostream& os
) const
{
for (direction d=0; d<vector::nComponents; d++)
for (direction d=0; d<VSType::nComponents; d++)
{
os << value.component(d);
if (d <= vector::nComponents-1)
if (d <= VSType::nComponents-1)
{
os << token::TAB;
}
......@@ -183,23 +187,47 @@ Foam::Ostream& Foam::writer<Type>::write(const vector& value, Ostream& os) const
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const tensor& value, Ostream& os) const
Foam::Ostream& Foam::writer<Type>::write
(
const vector& value,
Ostream& os
) const
{
for (direction d=0; d<tensor::nComponents; d++)
{
os << value.component(d);
return writeVS(value, os);
}
if (d <= tensor::nComponents-1)
{
os << token::TAB;
}
}
return os;
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
(
const sphericalTensor& value,
Ostream& os
) const
{
return writeVS(value, os);
}
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
(
const symmTensor& value,
Ostream& os
) const
{
return writeVS(value, os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
(
const tensor& value,
Ostream& os
) const
{
return writeVS(value, os);
}
} // End namespace Foam
// ************************************************************************* //
......@@ -29,8 +29,8 @@ Description
Base class for graphics format writing. Entry points are
- write(..). \n
Write to an Ostream a table of points with corresponding values.
- write(scalar/vector/tensor). \n
Write single scalar/vector/tensor.
- write(scalar/vector/sphericalTensor/symmTensor/tensor). \n
Write single scalar/vector/sphericalTensor/symmTensor/tensor.
Default is to write space separated components.
Example:
......@@ -151,43 +151,47 @@ public:
writer();
// Destructor
virtual ~writer() = 0;
//- Destructor
virtual ~writer() = 0;
// Member Functions
// Access
//- Generate file name with correct extension
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const = 0;
//- General entry point for writing.
// The data is organized in a set of point with one or
// more values per point
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream&
) const = 0;
//- Write scalar as ascii
virtual Ostream& write(const scalar, Ostream&) const;
// Write
template<class VSType>
Ostream& writeVS(const VSType& value, Ostream& os) const;
//- Generate file name with correct extension
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const = 0;
//- General entry point for writing.
// The data is organized in a set of point with one or
// more values per point
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream&
) const = 0;
//- Write vector. Tab separated ascii
virtual Ostream& write(const vector&, Ostream&) const;
//- Write scalar as ascii
virtual Ostream& write(const scalar, Ostream&) const;
//- Write sphericalTensor. Tab separated ascii
virtual Ostream& write(const sphericalTensor&, Ostream&) const;
//- Write vector. Tab separated ascii
virtual Ostream& write(const vector&, Ostream&) const;
//- Write symmTensor. Tab separated ascii
virtual Ostream& write(const symmTensor&, Ostream&) const;
//- Write tensor. Tab separated ascii
virtual Ostream& write(const tensor&, Ostream&) const;
//- Write tensor. Tab separated ascii
virtual Ostream& write(const tensor&, Ostream&) const;
};
......@@ -202,34 +206,47 @@ public:
#endif
// Only used internally
#define makeTypeWritersTypeName(type) \
\
#define makeTypeWritersTypeName(type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0);
// Used externally sometimes
#define makeWritersTypeName(typeWriter) \
\
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
makeTypeWritersTypeName(typeWriter##VectorWriter); \
#define makeWritersTypeName(typeWriter) \