mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: sampling: moved sampledSet writing to fileFormats
This commit is contained in:
@ -1,154 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "coordSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* Foam::NamedEnum
|
||||
<
|
||||
Foam::coordSet::coordFormat,
|
||||
5
|
||||
>::names[] =
|
||||
{
|
||||
"xyz",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"distance"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const Foam::NamedEnum<Foam::coordSet::coordFormat, 5>
|
||||
Foam::coordSet::coordFormatNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
//- Construct from components
|
||||
Foam::coordSet::coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis
|
||||
)
|
||||
:
|
||||
pointField(0),
|
||||
name_(name),
|
||||
axis_(coordFormatNames_[axis]),
|
||||
curveDist_(0)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from components
|
||||
Foam::coordSet::coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& points,
|
||||
const scalarList& curveDist
|
||||
)
|
||||
:
|
||||
pointField(points),
|
||||
name_(name),
|
||||
axis_(coordFormatNames_[axis]),
|
||||
curveDist_(curveDist)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::coordSet::hasVectorAxis() const
|
||||
{
|
||||
return axis_ == XYZ;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::coordSet::scalarCoord
|
||||
(
|
||||
const label index
|
||||
) const
|
||||
{
|
||||
const point& p = operator[](index);
|
||||
|
||||
if (axis_ == X)
|
||||
{
|
||||
return p.x();
|
||||
}
|
||||
else if (axis_ == Y)
|
||||
{
|
||||
return p.y();
|
||||
}
|
||||
else if (axis_ == Z)
|
||||
{
|
||||
return p.z();
|
||||
}
|
||||
else if (axis_ == DISTANCE)
|
||||
{
|
||||
// Use distance to reference point
|
||||
return curveDist_[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coordSet::scalarCoord(const label)"
|
||||
) << "Illegal axis specification " << axis_
|
||||
<< " for sampling line " << name_
|
||||
<< exit(FatalError);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::point Foam::coordSet::vectorCoord(const label index) const
|
||||
{
|
||||
const point& p = operator[](index);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::coordSet::write(Ostream& os) const
|
||||
{
|
||||
os << "name:" << name_ << " axis:" << axis_
|
||||
<< endl
|
||||
<< endl << "\t(coord)"
|
||||
<< endl;
|
||||
|
||||
forAll(*this, sampleI)
|
||||
{
|
||||
os << '\t' << operator[](sampleI) << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,150 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::coordSet
|
||||
|
||||
Description
|
||||
Holds list of sampling positions
|
||||
|
||||
SourceFiles
|
||||
coordSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordSet_H
|
||||
#define coordSet_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class coordSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class coordSet
|
||||
:
|
||||
public pointField
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration defining the output format for coordinates
|
||||
enum coordFormat
|
||||
{
|
||||
XYZ,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
DISTANCE
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- String representation of coordFormat enums
|
||||
static const NamedEnum<coordFormat, 5> coordFormatNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//- Name
|
||||
const word name_;
|
||||
|
||||
//- Axis write type
|
||||
const coordFormat axis_;
|
||||
|
||||
//- Cumulative distance "distance" write specifier.
|
||||
scalarList curveDist_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis
|
||||
);
|
||||
|
||||
|
||||
//- Construct from components
|
||||
coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& points,
|
||||
const scalarList& curveDist
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
word axis() const
|
||||
{
|
||||
return coordFormatNames_[axis_];
|
||||
}
|
||||
|
||||
//- Cumulative distance
|
||||
const scalarList& curveDist() const
|
||||
{
|
||||
return curveDist_;
|
||||
}
|
||||
|
||||
//- Is axis specification a vector
|
||||
bool hasVectorAxis() const;
|
||||
|
||||
//- Get coordinate of point according to axis specification.
|
||||
// If axis="distance" is the curveDist[index]
|
||||
scalar scalarCoord(const label index) const;
|
||||
|
||||
//- Get point according to axis="xyz" specification
|
||||
vector vectorCoord(const label index) const;
|
||||
|
||||
Ostream& write(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,202 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "csvSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::csvSetWriter<Type>::csvSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::csvSetWriter<Type>::~csvSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::csvSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".csv";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(points,valueSetNames,os);
|
||||
|
||||
// Collect sets into columns
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = valueSets[i];
|
||||
}
|
||||
|
||||
this->writeTable(points, columns, os);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(points[0],valueSetNames,os);
|
||||
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorIn("csvSetWriter<Type>::write(..)")
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(points, trackI)
|
||||
{
|
||||
// Collect sets into columns
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = &valueSets[i][trackI];
|
||||
}
|
||||
|
||||
this->writeTable(points[trackI], columns, os);
|
||||
os << nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvSetWriter<Type>::writeSeparator(Ostream& os) const
|
||||
{
|
||||
os << token::COMMA;
|
||||
}
|
||||
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// otherwise compiler complains about specialization
|
||||
template<>
|
||||
void csvSetWriter<scalar>::writeHeader
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeCoordHeader(points, os);
|
||||
|
||||
forAll(valueSetNames, i)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
writeSeparator(os);
|
||||
}
|
||||
os << valueSetNames[i];
|
||||
}
|
||||
|
||||
os << nl;
|
||||
}
|
||||
} // end namespace
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvSetWriter<Type>::writeHeader
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeCoordHeader(points, os);
|
||||
|
||||
forAll(valueSetNames, i)
|
||||
{
|
||||
for (label j=0; j<Type::nComponents; j++)
|
||||
{
|
||||
if (i>0 || j>0)
|
||||
{
|
||||
writeSeparator(os);
|
||||
}
|
||||
os << valueSetNames[i] << "_" << j;
|
||||
}
|
||||
}
|
||||
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvSetWriter<Type>::writeCoordHeader
|
||||
(
|
||||
const coordSet& points,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (points.hasVectorAxis())
|
||||
{
|
||||
forAll(points, i)
|
||||
{
|
||||
os << points.axis()[i];
|
||||
writeSeparator(os);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
os << points.axis();
|
||||
writeSeparator(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,124 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::csvSetWriter
|
||||
|
||||
Description
|
||||
Write set in csv format
|
||||
|
||||
SourceFiles
|
||||
csvSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef csvSetWriter_H
|
||||
#define csvSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class csvSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class csvSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeCoordHeader(const coordSet&, Ostream&) const;
|
||||
|
||||
void writeHeader(const coordSet&, const wordList&, Ostream&) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void writeSeparator(Ostream&) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("csv");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
csvSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~csvSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "csvSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "csvSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(csvSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,315 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "IOmanip.H"
|
||||
#include "foamVersion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::ensightSetWriter<Type>::ensightSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::ensightSetWriter<Type>::~ensightSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::ensightSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return
|
||||
this->getBaseName(points, valueSetNames)
|
||||
//+ '_'
|
||||
//+ pTraits<Type>::typeName
|
||||
+ ".case";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const fileName base(os.name().lessExt());
|
||||
const fileName meshFile(base + ".mesh");
|
||||
|
||||
// Write .case file
|
||||
os << "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||
<< nl
|
||||
<< "VARIABLE"
|
||||
<< nl;
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||
|
||||
os.setf(ios_base::left);
|
||||
os << pTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << valueSetNames[setI]
|
||||
<< " " << dataFile.name().c_str()
|
||||
<< nl;
|
||||
}
|
||||
os << nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< "0.00000e+00" << nl;
|
||||
|
||||
// Write .mesh file
|
||||
{
|
||||
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||
OFstream os(meshFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
|
||||
os << "EnSight Geometry File" << nl
|
||||
<< desc.c_str() << nl
|
||||
<< "node id assign" << nl
|
||||
<< "element id assign" << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl
|
||||
<< "internalMesh" << nl
|
||||
<< "coordinates" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const scalar comp = points[pointI][cmpt];
|
||||
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << comp << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
os << "point" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
forAll(points, pointI)
|
||||
{
|
||||
os << setw(10) << pointI+1 << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// Write data files
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||
OFstream os(dataFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
{
|
||||
os << pTraits<Type>::typeName << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl
|
||||
<< "coordinates" << nl;
|
||||
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
const scalarField fld(valueSets[setI]->component(cmpt));
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << fld[i] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& tracks,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const fileName base(os.name().lessExt());
|
||||
const fileName meshFile(base + ".mesh");
|
||||
|
||||
// Write .case file
|
||||
os << "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << meshFile.name().c_str() << nl
|
||||
<< nl
|
||||
<< "VARIABLE"
|
||||
<< nl;
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".***." + valueSetNames[setI]);
|
||||
|
||||
os.setf(ios_base::left);
|
||||
os << pTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << valueSetNames[setI]
|
||||
<< " " << dataFile.name().c_str()
|
||||
<< nl;
|
||||
}
|
||||
os << nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
<< "number of steps: 1" << nl
|
||||
<< "filename start number: 0" << nl
|
||||
<< "filename increment: 1" << nl
|
||||
<< "time values:" << nl
|
||||
<< "0.00000e+00" << nl;
|
||||
|
||||
// Write .mesh file
|
||||
{
|
||||
string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
|
||||
OFstream os(meshFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
os << "EnSight Geometry File" << nl
|
||||
<< desc.c_str() << nl
|
||||
<< "node id assign" << nl
|
||||
<< "element id assign" << nl;
|
||||
|
||||
forAll(tracks, trackI)
|
||||
{
|
||||
const coordSet& points = tracks[trackI];
|
||||
|
||||
os << "part" << nl
|
||||
<< setw(10) << trackI+1 << nl
|
||||
<< "internalMesh" << nl
|
||||
<< "coordinates" << nl
|
||||
<< setw(10) << points.size() << nl;
|
||||
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const scalar comp = points[pointI][cmpt];
|
||||
if (mag(comp) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << comp << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (writeTracks)
|
||||
{
|
||||
os << "bar2" << nl
|
||||
<< setw(10) << points.size()-1 << nl;
|
||||
for (label i = 0; i < points.size()-1; i++)
|
||||
{
|
||||
os << setw(10) << i+1
|
||||
<< setw(10) << i+2
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write data files
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
fileName dataFile(base + ".000." + valueSetNames[setI]);
|
||||
OFstream os(dataFile);
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
os.precision(5);
|
||||
{
|
||||
os << pTraits<Type>::typeName << nl;
|
||||
|
||||
const List<Field<Type> >& fieldVals = valueSets[setI];
|
||||
forAll(fieldVals, trackI)
|
||||
{
|
||||
os << "part" << nl
|
||||
<< setw(10) << trackI+1 << nl
|
||||
<< "coordinates" << nl;
|
||||
|
||||
for
|
||||
(
|
||||
direction cmpt = 0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
cmpt++
|
||||
)
|
||||
{
|
||||
const scalarField fld(fieldVals[trackI].component(cmpt));
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i]) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
os << setw(12) << fld[i] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ensightSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightSetWriter_H
|
||||
#define ensightSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class ensightSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ensight");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
ensightSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(ensightSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,142 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gnuplotSetWriter.H"
|
||||
#include "clock.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::gnuplotSetWriter<Type>::gnuplotSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::gnuplotSetWriter<Type>::~gnuplotSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::gnuplotSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".gplt";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::gnuplotSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "set term postscript color" << nl
|
||||
<< "set output \"" << points.name() << ".ps\"" << nl
|
||||
<< "plot";
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
os << ',';
|
||||
}
|
||||
|
||||
os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
|
||||
}
|
||||
os << nl;
|
||||
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
this->writeTable(points, *valueSets[i], os);
|
||||
os << "e" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::gnuplotSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& trackPoints,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (trackPoints.size() > 0)
|
||||
{
|
||||
os << "set term postscript color" << nl
|
||||
<< "set output \"" << trackPoints[0].name() << ".ps\"" << nl;
|
||||
|
||||
forAll(trackPoints, trackI)
|
||||
{
|
||||
os << "plot";
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
os << ',';
|
||||
}
|
||||
|
||||
os << " \"-\" title \"" << valueSetNames[i] << "\" with lines";
|
||||
}
|
||||
os << nl;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
this->writeTable(trackPoints[trackI], valueSets[i][trackI], os);
|
||||
os << "e" << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::gnuplotSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
gnuplotSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef gnuplotSetWriter_H
|
||||
#define gnuplotSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class gnuplotSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class gnuplotSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("gnuplot");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
gnuplotSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~gnuplotSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "gnuplotSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gnuplotSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(gnuplotSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,103 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "jplotSetWriter.H"
|
||||
#include "clock.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::jplotSetWriter<Type>::writeHeader(Ostream& os) const
|
||||
{
|
||||
return os
|
||||
<< "# JPlot input file" << nl
|
||||
<< "#" << nl << nl
|
||||
<< "# Generated by sample on " << clock::date().c_str() << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::jplotSetWriter<Type>::jplotSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::jplotSetWriter<Type>::~jplotSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::jplotSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".dat";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::jplotSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "# JPlot file" << nl
|
||||
<< "# column 1: " << points.name() << nl;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << "# column " << i + 2 << ": " << valueSetNames[i] << nl;
|
||||
}
|
||||
|
||||
// Collect sets into columns
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = valueSets[i];
|
||||
}
|
||||
|
||||
this->writeTable(points, columns, os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,128 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::jplotSetWriter
|
||||
|
||||
SourceFiles
|
||||
jplotSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef jplotSetWriter_H
|
||||
#define jplotSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
#include "vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class jplotSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class jplotSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write header
|
||||
Ostream& writeHeader(Ostream&) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("jplot");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
jplotSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~jplotSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"jplotSetWriter<Type>::write\n"
|
||||
"(\n"
|
||||
" const bool,\n"
|
||||
" const PtrList<coordSet>&,\n"
|
||||
" const wordList&,\n"
|
||||
" const List<List<Field<Type> > >&,\n"
|
||||
" Ostream&\n"
|
||||
") const"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "jplotSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "jplotSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(jplotSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,115 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::rawSetWriter<Type>::rawSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::rawSetWriter<Type>::~rawSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::rawSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".xy";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::rawSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Collect sets into columns
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = valueSets[i];
|
||||
}
|
||||
|
||||
this->writeTable(points, columns, os);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::rawSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorIn("rawSetWriter<Type>::write(..)")
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(points, trackI)
|
||||
{
|
||||
// Collect sets into columns
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = &valueSets[i][trackI];
|
||||
}
|
||||
|
||||
this->writeTable(points[trackI], columns, os);
|
||||
os << nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::rawSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
rawSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawSetWriter_H
|
||||
#define rawSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class rawSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class rawSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("raw");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
rawSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~rawSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "rawSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(rawSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,195 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::vtkSetWriter<Type>::vtkSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::vtkSetWriter<Type>::~vtkSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::vtkSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".vtk";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "# vtk DataFile Version 2.0" << nl
|
||||
<< points.name() << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl
|
||||
<< "POINTS " << points.size() << " float" << nl;
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
const vector& pt = points[i];
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
|
||||
|
||||
os << "POINT_DATA " << points.size() << nl
|
||||
<< " FIELD attributes " << valueSetNames.size() << nl;
|
||||
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
os << valueSetNames[setI] << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< points.size() << " float" << nl;
|
||||
|
||||
const Field<Type>& fld = *valueSets[setI];
|
||||
|
||||
forAll(fld, pointI)
|
||||
{
|
||||
if (pointI != 0)
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
writer<Type>::write(fld[pointI], os);
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtkSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& tracks,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorIn("vtkSetWriter<Type>::write(..)")
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
label nTracks = tracks.size();
|
||||
label nPoints = 0;
|
||||
forAll(tracks, i)
|
||||
{
|
||||
nPoints += tracks[i].size();
|
||||
}
|
||||
|
||||
os << "# vtk DataFile Version 2.0" << nl
|
||||
<< tracks[0].name() << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl
|
||||
<< "POINTS " << nPoints << " float" << nl;
|
||||
|
||||
forAll(tracks, trackI)
|
||||
{
|
||||
const coordSet& points = tracks[trackI];
|
||||
forAll(points, i)
|
||||
{
|
||||
const vector& pt = points[i];
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
if (writeTracks)
|
||||
{
|
||||
os << "LINES " << nTracks << ' ' << nPoints+nTracks << nl;
|
||||
|
||||
// Write ids of track points to file
|
||||
label globalPtI = 0;
|
||||
forAll(tracks, trackI)
|
||||
{
|
||||
const coordSet& points = tracks[trackI];
|
||||
|
||||
os << points.size();
|
||||
forAll(points, i)
|
||||
{
|
||||
os << ' ' << globalPtI;
|
||||
globalPtI++;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << "POINT_DATA " << nPoints << nl
|
||||
<< " FIELD attributes " << valueSetNames.size() << nl;
|
||||
|
||||
forAll(valueSetNames, setI)
|
||||
{
|
||||
os << valueSetNames[setI] << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nPoints << " float" << nl;
|
||||
|
||||
const List<Field<Type> >& fieldVals = valueSets[setI];
|
||||
|
||||
forAll(fieldVals, i)
|
||||
{
|
||||
const Field<Type>& vals = fieldVals[i];
|
||||
|
||||
forAll(vals, j)
|
||||
{
|
||||
if (j != 0)
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
writer<Type>::write(vals[j], os);
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::vtkSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
vtkSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkSetWriter_H
|
||||
#define vtkSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class vtkSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("vtk");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
vtkSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~vtkSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "vtkSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(vtkSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,260 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writer.H"
|
||||
#include "coordSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr< Foam::writer<Type> > Foam::writer<Type>::New
|
||||
(
|
||||
const word& writeType
|
||||
)
|
||||
{
|
||||
typename wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_->find(writeType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"writer::New(const word&)"
|
||||
) << "Unknown write type "
|
||||
<< writeType << nl << nl
|
||||
<< "Valid write types : " << endl
|
||||
<< wordConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<writer<Type> >(cstrIter()());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::writer<Type>::getBaseName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSets
|
||||
) const
|
||||
{
|
||||
fileName fName(points.name());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
fName += '_' + valueSets[i];
|
||||
}
|
||||
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writer<Type>::writeCoord
|
||||
(
|
||||
const coordSet& points,
|
||||
const label pointI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (points.hasVectorAxis())
|
||||
{
|
||||
write(points.vectorCoord(pointI), os);
|
||||
}
|
||||
else
|
||||
{
|
||||
write(points.scalarCoord(pointI), os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writer<Type>::writeTable
|
||||
(
|
||||
const coordSet& points,
|
||||
const List<Type>& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
writeCoord(points, pointI, os);
|
||||
writeSeparator(os);
|
||||
write(values[pointI], os);
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writer<Type>::writeTable
|
||||
(
|
||||
const coordSet& points,
|
||||
const List<const List<Type>*>& valuesPtrList,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
writeCoord(points, pointI, os);
|
||||
|
||||
forAll(valuesPtrList, i)
|
||||
{
|
||||
writeSeparator(os);
|
||||
|
||||
const List<Type>& values = *valuesPtrList[i];
|
||||
write(values[pointI], os);
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::writer<Type>::writer()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::writer<Type>::~writer()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::writer<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<Field<Type> >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
List<const Field<Type>*> valueSetPtrs(valueSets.size());
|
||||
forAll(valueSetPtrs, i)
|
||||
{
|
||||
valueSetPtrs[i] = &valueSets[i];
|
||||
}
|
||||
|
||||
write(points, valueSetNames, valueSetPtrs, os);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::writer<Type>::write
|
||||
(
|
||||
const scalar value,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
return os << value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class VSType>
|
||||
Foam::Ostream& Foam::writer<Type>::writeVS
|
||||
(
|
||||
const VSType& value,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
for (direction d=0; d<VSType::nComponents; d++)
|
||||
{
|
||||
if (d > 0)
|
||||
{
|
||||
writeSeparator(os);
|
||||
}
|
||||
|
||||
os << value.component(d);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writer<Type>::writeSeparator
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << token::SPACE << token::TAB;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::writer<Type>::write
|
||||
(
|
||||
const vector& value,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
return writeVS(value, 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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,220 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::writer
|
||||
|
||||
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/sphericalTensor/symmTensor/tensor). \n
|
||||
Write single scalar/vector/sphericalTensor/symmTensor/tensor.
|
||||
Default is to write space separated components.
|
||||
|
||||
Example:
|
||||
\verbatim
|
||||
// Construct writer of xmgr type
|
||||
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
|
||||
|
||||
// Output list of points and corresponding values
|
||||
scalarFormatter().write
|
||||
(
|
||||
coordSet(...)
|
||||
"U.component(0)", // name of values
|
||||
vals // values
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
writer.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writer_H
|
||||
#define writer_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "wordList.H"
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class coordSet;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class writer
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
//- Generates filename from coordSet and sampled fields
|
||||
fileName getBaseName(const coordSet&, const wordList&) const;
|
||||
|
||||
void writeCoord(const coordSet&, const label sampleI, Ostream&) const;
|
||||
|
||||
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
|
||||
// columns 2 is the value. Uses write() function
|
||||
// to write coordinate in correct format.
|
||||
void writeTable(const coordSet&, const List<Type>&, Ostream&) const;
|
||||
|
||||
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
|
||||
// columns 2..n are the values. Uses write() function
|
||||
// to write coordinate in correct format.
|
||||
void writeTable
|
||||
(
|
||||
const coordSet&,
|
||||
const List<const List<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Writes a separator. Used by write functions.
|
||||
virtual void writeSeparator(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("writer");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
writer,
|
||||
word,
|
||||
(),
|
||||
()
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected writer
|
||||
static autoPtr<writer> New(const word& writeFormat);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
writer();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~writer() = 0;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- 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;
|
||||
|
||||
//- 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<Field<Type> >&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
//- General entry point for writing of multiple coordSets.
|
||||
// Each coordSet (track) has same data variables.
|
||||
// The data is per variable, per track, per point of track.
|
||||
// If writeTracks adds connecting lines (wherever applicable)
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const = 0;
|
||||
|
||||
//- Write scalar as ascii
|
||||
virtual Ostream& write(const scalar, Ostream&) const;
|
||||
|
||||
template<class VSType>
|
||||
Ostream& writeVS(const VSType&, Ostream&) const;
|
||||
|
||||
//- Write vector. Tab separated ascii
|
||||
virtual Ostream& write(const vector&, Ostream&) const;
|
||||
|
||||
//- Write sphericalTensor. Tab separated ascii
|
||||
virtual Ostream& write(const sphericalTensor&, 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;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writer.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,49 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writers.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
#define defineSetWriterType(dataType) \
|
||||
defineNamedTemplateTypeNameAndDebug(writer<dataType >, 0); \
|
||||
defineTemplatedRunTimeSelectionTable(writer, word, dataType);
|
||||
|
||||
defineSetWriterType(scalar);
|
||||
defineSetWriterType(vector);
|
||||
defineSetWriterType(sphericalTensor);
|
||||
defineSetWriterType(symmTensor);
|
||||
defineSetWriterType(tensor);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,79 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
Foam::writer
|
||||
|
||||
SourceFiles
|
||||
writers.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writers_H
|
||||
#define writers_H
|
||||
|
||||
#include "writer.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Only used internally
|
||||
#define makeTypeSetWritersTypeName(typeWriter, dataType) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0)
|
||||
|
||||
// Sometimes used externally
|
||||
#define makeSetWritersTypeName(typeWriter) \
|
||||
\
|
||||
makeTypeSetWritersTypeName(typeWriter, scalar); \
|
||||
makeTypeSetWritersTypeName(typeWriter, vector); \
|
||||
makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \
|
||||
makeTypeSetWritersTypeName(typeWriter, symmTensor); \
|
||||
makeTypeSetWritersTypeName(typeWriter, tensor)
|
||||
|
||||
// Define type info for single dataType template instantiation (eg, vector)
|
||||
#define makeSetWriterType(typeWriter, dataType) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \
|
||||
addTemplatedToRunTimeSelectionTable \
|
||||
( \
|
||||
writer, typeWriter, dataType, word \
|
||||
)
|
||||
|
||||
|
||||
// Define type info for scalar, vector etc. instantiations
|
||||
#define makeSetWriters(typeWriter) \
|
||||
\
|
||||
makeSetWriterType(typeWriter, scalar); \
|
||||
makeSetWriterType(typeWriter, vector); \
|
||||
makeSetWriterType(typeWriter, sphericalTensor); \
|
||||
makeSetWriterType(typeWriter, symmTensor); \
|
||||
makeSetWriterType(typeWriter, tensor)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,131 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "xmgraceSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::xmgraceSetWriter<Type>::xmgraceSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::xmgraceSetWriter<Type>::~xmgraceSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::xmgraceSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".agr";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::xmgraceSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "@g0 on" << nl
|
||||
<< "@with g0" << nl
|
||||
<< "@ title \"" << points.name() << '"' << nl
|
||||
<< "@ xaxis label " << '"' << points.axis() << '"' << nl;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << "@ s" << i << " legend " << '"'
|
||||
<< valueSetNames[i] << '"' << nl
|
||||
<< "@target G0.S" << i << nl;
|
||||
|
||||
this->writeTable(points, *valueSets[i], os);
|
||||
|
||||
os << '&' << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::xmgraceSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& trackPoints,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorIn("gnuplotSetWriter<Type>::write(..)")
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (trackPoints.size() > 0)
|
||||
{
|
||||
os << "@g0 on" << nl
|
||||
<< "@with g0" << nl
|
||||
<< "@ title \"" << trackPoints[0].name() << '"' << nl
|
||||
<< "@ xaxis label " << '"' << trackPoints[0].axis() << '"' << nl;
|
||||
|
||||
// Data index.
|
||||
label sI = 0;
|
||||
|
||||
forAll(trackPoints, trackI)
|
||||
{
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << "@ s" << sI << " legend " << '"'
|
||||
<< valueSetNames[i] << "_track" << i << '"' << nl
|
||||
<< "@target G0.S" << sI << nl;
|
||||
this->writeTable(trackPoints[trackI], valueSets[i][trackI], os);
|
||||
os << '&' << nl;
|
||||
|
||||
sI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::xmgraceSetWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
xmgraceSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef xmgraceSetWriter_H
|
||||
#define xmgraceSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class xmgraceSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class xmgraceSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("xmgr");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
xmgraceSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~xmgraceSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type> > >&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "xmgraceSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "xmgraceSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(xmgraceSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user