Merge branch 'master' of github.com-OpenFOAM:OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry Weller
2021-06-18 16:37:54 +01:00
65 changed files with 764 additions and 705 deletions

View File

@ -10,6 +10,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/functionObjects/field/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \

View File

@ -444,7 +444,7 @@ Foam::functionObjects::sizeDistribution::sizeDistribution
}
}
scalarFormatter_ = writer<scalar>::New("raw");
scalarFormatter_ = setWriter<scalar>::New("raw");
}

View File

@ -76,7 +76,7 @@ SourceFiles
#include "logFiles.H"
#include "populationBalanceModel.H"
#include "writeFile.H"
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -135,7 +135,7 @@ protected:
writeFile file_;
//- Output formatter, set to raw
autoPtr<writer<scalar>> scalarFormatter_;
autoPtr<setWriter<scalar>> scalarFormatter_;
//- Reference to populationBalanceModel
const Foam::diameterModels::populationBalanceModel& popBal_;

View File

@ -101,7 +101,6 @@ int main(int argc, char *argv[])
(
100.0, // max size ratio
1e-9, // intersection tolerance
autoPtr<writer<scalar>>(new vtkSetWriter<scalar>()),
0.01, // min triangle quality
true
);

View File

@ -46,7 +46,6 @@ Description
#include "refinementParameters.H"
#include "snapParameters.H"
#include "layerParameters.H"
#include "vtkSetWriter.H"
#include "faceSet.H"
#include "motionSmoother.H"
#include "polyTopoChange.H"
@ -991,7 +990,6 @@ int main(int argc, char *argv[])
(
100.0, // max size ratio
1e-9, // intersection tolerance
autoPtr<writer<scalar>>(new vtkSetWriter<scalar>()),
0.01, // min triangle quality
true
);

View File

@ -10,7 +10,7 @@
#include "polyMeshTetDecomposition.H"
#include "vtkSurfaceWriter.H"
#include "writer.H"
#include "setWriter.H"
#include "checkTools.H"
#include "cyclicAMIPolyPatch.H"
@ -581,7 +581,7 @@ Foam::label Foam::checkGeometry
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>& surfWriter,
const autoPtr<writer<scalar>>& setWriter
const autoPtr<Foam::setWriter<scalar>>& setWriter
)
{
label noFailedChecks = 0;

View File

@ -1,7 +1,7 @@
#include "label.H"
#include "HashSet.H"
#include "labelVector.H"
#include "writer.H"
#include "setWriter.H"
namespace Foam
{
@ -40,6 +40,6 @@ namespace Foam
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>&,
const autoPtr<writer<scalar>>&
const autoPtr<setWriter<scalar>>&
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -160,7 +160,7 @@ int main(int argc, char *argv[])
autoPtr<surfaceWriter> surfWriter;
autoPtr<writer<scalar>> setWriter;
autoPtr<Foam::setWriter<scalar>> setWriter;
if (writeSets)
{
surfWriter = surfaceWriter::New
@ -168,7 +168,10 @@ int main(int argc, char *argv[])
surfaceFormat,
mesh.time().writeFormat()
);
setWriter = writer<scalar>::New(vtkSetWriter<scalar>::typeName);
setWriter = Foam::setWriter<scalar>::New
(
vtkSetWriter<scalar>::typeName
);
}

View File

@ -378,7 +378,7 @@ void Foam::mergeAndWrite
void Foam::mergeAndWrite
(
const writer<scalar>& writer,
const setWriter<scalar>& writer,
const pointSet& set
)
{

View File

@ -1,6 +1,6 @@
#include "scalar.H"
#include "indirectPrimitivePatch.H"
#include "writer.H"
#include "setWriter.H"
namespace Foam
{
@ -19,7 +19,7 @@ namespace Foam
void mergeAndWrite
(
const polyMesh& mesh,
const surfaceWriter& writer,
const surfaceWriter& setWriter,
const word& name,
const indirectPrimitivePatch setPatch,
const fileName& outputDir
@ -35,7 +35,7 @@ namespace Foam
//- Write vtk representation of (assembled) pointSet to 'set' file in
// postProcessing/ directory
void mergeAndWrite(const writer<scalar>&, const pointSet&);
void mergeAndWrite(const setWriter<scalar>&, const pointSet&);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,7 +44,7 @@ Foam::label Foam::checkTopology
const bool allTopology,
const bool allGeometry,
const autoPtr<surfaceWriter>& surfWriter,
const autoPtr<writer<scalar>>& setWriter
const autoPtr<Foam::setWriter<scalar>>& setWriter
)
{
label noFailedChecks = 0;

View File

@ -1,6 +1,6 @@
#include "label.H"
#include "autoPtr.H"
#include "writer.H"
#include "setWriter.H"
namespace Foam
{
@ -13,6 +13,6 @@ namespace Foam
const bool,
const bool,
const autoPtr<surfaceWriter>&,
const autoPtr<writer<scalar>>&
const autoPtr<setWriter<scalar>>&
);
}

View File

@ -1,5 +1,3 @@
writePointSet.C
writePatch.C
setSet.C
EXE = $(FOAM_APPBIN)/setSet

View File

@ -41,8 +41,7 @@ Description
#include "OFstream.H"
#include "IFstream.H"
#include "demandDrivenData.H"
#include "writePatch.H"
#include "writePointSet.H"
#include "vtkWritePolyData.H"
#include "IOobjectList.H"
#include "cellZoneSet.H"
#include "faceZoneSet.H"
@ -80,7 +79,7 @@ void writeVTK
// Faces of set with OpenFOAM faceID as value
faceList setFaces(currentSet.size());
labelList faceValues(currentSet.size());
labelField faceValues(currentSet.size());
label setFacei = 0;
forAllConstIter(topoSet, currentSet, iter)
@ -92,14 +91,18 @@ void writeVTK
primitiveFacePatch fp(setFaces, mesh.points());
vtkWriteOps::writePatch
vtkWritePolyData::write
(
true,
mesh.time().path()/vtkName,
currentSet.name(),
fp,
true,
fp.localPoints(),
labelList(),
edgeList(),
fp.localFaces(),
"faceID",
faceValues,
mesh.time().path()/vtkName
false,
faceValues
);
}
else if (isA<cellSet>(currentSet))
@ -140,7 +143,7 @@ void writeVTK
}
faceList setFaces(cellFaces.size());
labelList faceValues(cellFaces.size());
labelField faceValues(cellFaces.size());
label setFacei = 0;
forAllConstIter(Map<label>, cellFaces, iter)
@ -152,24 +155,32 @@ void writeVTK
primitiveFacePatch fp(setFaces, mesh.points());
vtkWriteOps::writePatch
vtkWritePolyData::write
(
true,
mesh.time().path()/vtkName,
currentSet.name(),
fp,
true,
fp.localPoints(),
labelList(),
edgeList(),
fp.localFaces(),
"cellID",
faceValues,
mesh.time().path()/vtkName
false,
faceValues
);
}
else if (isA<pointSet>(currentSet))
{
vtkWriteOps::writePointSet
std::ofstream os(mesh.time().path()/vtkName);
vtkWritePolyData::write
(
mesh.time().path()/vtkName,
currentSet.name(),
true,
mesh,
currentSet,
mesh.time().path()/vtkName
pointField(mesh.points(), currentSet.toc()),
identity(currentSet.size()),
edgeList(),
faceList()
);
}
else

View File

@ -1,119 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 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 "writePatch.H"
#include "OFstream.H"
#include "vtkWriteOps.H"
#include "primitiveFacePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::vtkWriteOps::writePatch
(
const bool binary,
const word& setName,
const primitiveFacePatch& fp,
const word& fieldName,
labelList& fieldValues,
const fileName& fileName
)
{
std::ofstream pStream(fileName.c_str());
pStream
<< "# vtk DataFile Version 2.0" << std::endl
<< setName << std::endl;
if (binary)
{
pStream << "BINARY" << std::endl;
}
else
{
pStream << "ASCII" << std::endl;
}
pStream << "DATASET POLYDATA" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
// Write points and faces as polygons
pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*fp.nPoints());
vtkWriteOps::insert(fp.localPoints(), ptField);
vtkWriteOps::write(pStream, binary, ptField);
label nFaceVerts = 0;
forAll(fp.localFaces(), facei)
{
nFaceVerts += fp.localFaces()[facei].size() + 1;
}
pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
<< std::endl;
DynamicList<label> vertLabels(nFaceVerts);
forAll(fp.localFaces(), facei)
{
const face& f = fp.localFaces()[facei];
vertLabels.append(f.size());
vtkWriteOps::insert(f, vertLabels);
}
vtkWriteOps::write(pStream, binary, vertLabels);
//-----------------------------------------------------------------
//
// Write data
//
//-----------------------------------------------------------------
// Write faceID
pStream
<< "CELL_DATA " << fp.size() << std::endl
<< "FIELD attributes 1" << std::endl;
// Cell ids first
pStream << fieldName << " 1 " << fp.size() << " int" << std::endl;
vtkWriteOps::write(pStream, binary, fieldValues);
}
// ************************************************************************* //

View File

@ -1,68 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 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::writePatch
Description
Write faceSet to vtk polydata file. Only one data which is original
faceID.
SourceFiles
writePatch.C
\*---------------------------------------------------------------------------*/
#ifndef writePatch_H
#define writePatch_H
#include "primitiveMesh.H"
#include "primitiveFacePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace vtkWriteOps
{
//- Write patch
void writePatch
(
const bool binary,
const word& setName,
const primitiveFacePatch& fp,
const word& fieldName,
labelList& fieldValues,
const fileName& fileName
);
} // End namespace vtkWriteOps
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 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 "writePointSet.H"
#include "OFstream.H"
#include "vtkWriteOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::vtkWriteOps::writePointSet
(
const bool binary,
const primitiveMesh& mesh,
const topoSet& set,
const fileName& fileName
)
{
std::ofstream pStream(fileName.c_str());
pStream
<< "# vtk DataFile Version 2.0" << std::endl
<< set.name() << std::endl;
if (binary)
{
pStream << "BINARY" << std::endl;
}
else
{
pStream << "ASCII" << std::endl;
}
pStream << "DATASET POLYDATA" << std::endl;
//------------------------------------------------------------------
//
// Write topology
//
//------------------------------------------------------------------
labelList pointLabels(set.toc());
pointField setPoints(mesh.points(), pointLabels);
// Write points
pStream << "POINTS " << pointLabels.size() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*pointLabels.size());
vtkWriteOps::insert(setPoints, ptField);
vtkWriteOps::write(pStream, binary, ptField);
// Write vertices
pStream << "VERTICES " << pointLabels.size() << ' '
<< 2*pointLabels.size() << std::endl;
DynamicList<label> vertexPoints(2*pointLabels.size());
forAll(pointLabels, pointi)
{
vertexPoints.append(1);
vertexPoints.append(pointi);
}
vtkWriteOps::write(pStream, binary, vertexPoints);
//-----------------------------------------------------------------
//
// Write data
//
//-----------------------------------------------------------------
// Write pointID
pStream
<< "POINT_DATA " << pointLabels.size() << std::endl
<< "FIELD attributes 1" << std::endl;
// Cell ids first
pStream << "pointID 1 " << pointLabels.size() << " int" << std::endl;
vtkWriteOps::write(pStream, binary, pointLabels);
}
// ************************************************************************* //

View File

@ -1,67 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 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/>.
InNamespace
Foam
Description
Write pointSet to vtk polydata file. Only one data which is original
pointID.
SourceFiles
writePointSet.C
\*---------------------------------------------------------------------------*/
#ifndef writePointSet_H
#define writePointSet_H
#include "primitiveMesh.H"
#include "pointSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace vtkWriteOps
{
//- Write pointSet to vtk polydata file.
// Only one data which is original pointID.
void writePointSet
(
const bool binary,
const primitiveMesh& mesh,
const topoSet& set,
const fileName& fileName
);
} // End namespace vtkWriteOps
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ License
#include "Time.H"
#include "patchZones.H"
#include "OStringStream.H"
#include "OSspecific.H"
// VTK includes
#include "vtkDataArraySelection.h"

View File

@ -2,11 +2,13 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lfileFormats \
-lsampling \
-lgenericPatchFields \
-llagrangian

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,7 +38,7 @@ Description
#include "timeSelector.H"
#include "OFstream.H"
#include "passiveParticleCloud.H"
#include "writer.H"
#include "setWriter.H"
using namespace Foam;
@ -210,10 +210,8 @@ int main(int argc, char *argv[])
tracks[trackI].transfer(allTracks[trackI]);
}
autoPtr<writer<scalar>> scalarFormatterPtr = writer<scalar>::New
(
setFormat
);
autoPtr<setWriter<scalar>> scalarFormatterPtr =
setWriter<scalar>::New(setFormat);
// OFstream vtkTracks(vtkPath/"particleTracks.vtk");
fileName vtkFile

View File

@ -4,17 +4,4 @@ nas/NASCore.C
starcd/STARCDCore.C
obj/OBJstream.C
coordSet/coordSet.C
setWriters = sampledSetWriters
$(setWriters)/writers.C
$(setWriters)/ensight/ensightSetWriterRunTime.C
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
$(setWriters)/jplot/jplotSetWriterRunTime.C
$(setWriters)/raw/rawSetWriterRunTime.C
$(setWriters)/vtk/vtkSetWriterRunTime.C
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
$(setWriters)/csv/csvSetWriterRunTime.C
LIB = $(FOAM_LIBBIN)/libfileFormats

View File

@ -0,0 +1,222 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 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::vtkWritePolyData
Description
General write functions for vtk polygonal data files
SourceFiles
vtkWritePolyData.C
\*---------------------------------------------------------------------------*/
#ifndef vtkWritePolyData_H
#define vtkWritePolyData_H
#include "vtkWriteOps.H"
#include "fileName.H"
#include "Field.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Namespace vtkWritePolyData Declaration
\*---------------------------------------------------------------------------*/
namespace vtkWritePolyData
{
//- Helper for templated write
template<class Types, class Type>
inline void setFieldTypeValue
(
UPtrList<const Field<Types>>& fieldTypeValues,
const label fieldi,
const Field<Type>& fieldTypeValue
)
{}
//- Helper for templated write
template<class Type>
inline void setFieldTypeValue
(
UPtrList<const Field<Type>>& fieldTypeValues,
const label fieldi,
const Field<Type>& fieldTypeValue
)
{
fieldTypeValues.set(fieldi, &fieldTypeValue);
}
//- Helper for templated write
inline void unpackFieldTypeValues
(
wordList& fieldNames,
boolList& fieldIsPointValues,
UPtrList<const Field<label>>& fieldLabelValues
#define FieldTypeValuesNonConstArg(Type, nullArg) \
, UPtrList<const Field<Type>>& field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesNonConstArg)
#undef FieldTypeValuesNonConstArg
)
{}
//- Helper for templated write
template<class Type, class ... Args>
inline void unpackFieldTypeValues
(
wordList& fieldNames,
boolList& fieldIsPointValues,
UPtrList<const Field<label>>& fieldLabelValues
#define FieldTypeValuesNonConstArg(Type, nullArg) \
, UPtrList<const Field<Type>>& field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesNonConstArg),
#undef FieldTypeValuesNonConstArg
const word& fieldName,
const bool fieldIsPointValue,
const Field<Type>& fieldTypeValue,
Args& ... args
)
{
const label fieldi = fieldNames.size() - 1 - sizeof...(Args)/3;
fieldNames[fieldi] = fieldName;
fieldIsPointValues[fieldi] = fieldIsPointValue;
setFieldTypeValue(fieldLabelValues, fieldi, fieldTypeValue);
#define SetFieldTypeValue(Type, nullArg) \
setFieldTypeValue(field##Type##Values, fieldi, fieldTypeValue);
FOR_ALL_FIELD_TYPES(SetFieldTypeValue);
#undef SetFieldTypeValue
unpackFieldTypeValues
(
fieldNames,
fieldIsPointValues,
fieldLabelValues
#define FieldTypeValuesParameter(Type, nullArg) , field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesParameter),
#undef FieldTypeValuesParameter
args ...
);
}
//- Write the field values out for a type
template<class Type, class DataType>
void writeFieldTypeValues
(
std::ostream& os,
const bool binary,
const wordList& fieldNames,
const boolList& fieldIsPointValues,
const UPtrList<const Field<Type>>& fieldTypeValues,
const bool writePointValues
);
//- Write VTK polygonal data to a file. Takes a PtrList of fields of labels and
// of every primitive type. Each PtrList should be the length of the total
// number of fields and only one PtrList should be non-null for each field
// index.
template<class PointField, class VertexList, class LineList, class FaceList>
void write
(
const fileName& file,
const word& title,
const bool binary,
const PointField& points,
const VertexList& vertices,
const LineList& lines,
const FaceList& faces,
const wordList& fieldNames,
const boolList& fieldIsPointValues,
const UPtrList<const Field<label>>& fieldLabelValues
#define FieldTypeValuesConstArg(Type, nullArg) \
, const UPtrList<const Field<Type>>& field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesConstArg)
#undef FieldTypeValuesConstArg
);
//- Write VTK polygonal data to a file. Takes any number of name,
// isPointValues, values arguments at the end. E.g.;
//
// write
// (
// // Output options
// "myPolyData.vtk", "myPolyData", false,
//
// // Geometry
// pp.localPoints(), labelList(), labelListList(), pp.localFaces(),
//
// // Fields
// "faceIDs", true, pp.addressing(),
// "facePressures", false, Field<scalar>(pp.size(), ...),
// "pointVelocities", true, Field<vector>(pp.nPoints(), ...)
// );
//
template
<
class PointField,
class VertexList,
class LineList,
class FaceList,
class ... Args
>
inline void write
(
const fileName& file,
const word& title,
const bool binary,
const PointField& points,
const VertexList& vertices,
const LineList& lines,
const FaceList& faces,
const Args& ... args
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "vtkWritePolyDataTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,297 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 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 "vtkWritePolyData.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, class DataType>
void Foam::vtkWritePolyData::writeFieldTypeValues
(
std::ostream& os,
const bool binary,
const wordList& fieldNames,
const boolList& fieldIsPointValues,
const UPtrList<const Field<Type>>& fieldTypeValues,
const bool writePointValues
)
{
forAll(fieldNames, fieldi)
{
if
(
fieldIsPointValues[fieldi] == writePointValues
&& fieldTypeValues.set(fieldi)
)
{
const label nCmpt = pTraits<Type>::nComponents;
os << fieldNames[fieldi] << ' ' << pTraits<Type>::nComponents
<< ' ' << fieldTypeValues[fieldi].size() << ' '
<< (std::is_integral<DataType>::value ? "int" : "float") << nl;
List<DataType> data(nCmpt*fieldTypeValues[fieldi].size());
label i = 0;
forAll(fieldTypeValues[fieldi], fieldValuei)
{
for (direction cmpt = 0; cmpt < nCmpt; ++ cmpt)
{
data[i ++] =
component
(
fieldTypeValues[fieldi][fieldValuei],
cmpt
);
}
}
vtkWriteOps::write(os, binary, data);
}
}
}
template<class PointField, class VertexList, class LineList, class FaceList>
void Foam::vtkWritePolyData::write
(
const fileName& file,
const word& title,
const bool binary,
const PointField& points,
const VertexList& vertices,
const LineList& lines,
const FaceList& faces,
const wordList& fieldNames,
const boolList& fieldIsPointValues,
const UPtrList<const Field<label>>& fieldLabelValues
#define FieldTypeValuesConstArg(Type, nullArg) \
, const UPtrList<const Field<Type>>& field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesConstArg)
#undef FieldTypeValuesConstArg
)
{
// Open the file
std::ofstream os(file, std::ios::binary);
// Write the header
vtkWriteOps::writeHeader(os, binary, title);
os << "DATASET POLYDATA" << nl;
// Write the points
{
os << "POINTS " << points.size() << " float" << nl;
List<floatScalar> coordinates(points.size()*3);
forAll(points, pointi)
{
const point& p = points[pointi];
forAll(p, i)
{
coordinates[3*pointi + i] = float(p[i]);
}
}
vtkWriteOps::write(os, binary, coordinates);
}
// Write the vertices
if (vertices.size())
{
os << "VERTICES " << vertices.size() << ' '
<< 2*vertices.size() << nl;
labelList data(2*vertices.size());
forAll(vertices, vertexi)
{
data[2*vertexi] = 1;
data[2*vertexi + 1] = vertices[vertexi];
}
vtkWriteOps::write(os, binary, data);
}
// Write the lines
if (lines.size())
{
label nLineNodes = 0;
forAll(lines, facei)
{
nLineNodes += lines[facei].size();
}
os << "LINES " << lines.size() << ' '
<< lines.size() + nLineNodes << nl;
labelList data(lines.size() + nLineNodes);
label i = 0;
forAll(lines, linei)
{
data[i ++] = lines[linei].size();
forAll(lines[linei], linePointi)
{
data[i ++] = lines[linei][linePointi];
}
}
vtkWriteOps::write(os, binary, data);
}
// Write the faces
if (faces.size())
{
label nFaceNodes = 0;
forAll(faces, facei)
{
nFaceNodes += faces[facei].size();
}
os << "POLYGONS " << faces.size() << ' '
<< faces.size() + nFaceNodes << nl;
labelList data(faces.size() + nFaceNodes);
label i = 0;
forAll(faces, facei)
{
data[i ++] = faces[facei].size();
forAll(faces[facei], facePointi)
{
data[i ++] = faces[facei][facePointi];
}
}
vtkWriteOps::write(os, binary, data);
}
// Write the fields
const label nPointFields = count(fieldIsPointValues, true);
const label nFaceFields = count(fieldIsPointValues, false);
if (nPointFields > 0)
{
os << "POINT_DATA " << points.size() << nl
<< "FIELD attributes " << nPointFields << nl;
writeFieldTypeValues<label, label>
(
os,
binary,
fieldNames,
fieldIsPointValues,
fieldLabelValues,
true
);
#define WriteFieldTypeValues(Type, nullArg) \
writeFieldTypeValues<Type, floatScalar> \
( \
os, \
binary, \
fieldNames, \
fieldIsPointValues, \
field##Type##Values, \
true \
);
FOR_ALL_FIELD_TYPES(WriteFieldTypeValues)
#undef WriteFieldTypeValues
}
if (nFaceFields > 0)
{
os << "CELL_DATA "
<< vertices.size() + lines.size() + faces.size() << nl
<< "FIELD attributes " << nFaceFields << nl;
writeFieldTypeValues<label, label>
(
os,
binary,
fieldNames,
fieldIsPointValues,
fieldLabelValues,
false
);
#define WriteFieldTypeValues(Type, nullArg) \
writeFieldTypeValues<Type, floatScalar> \
( \
os, \
binary, \
fieldNames, \
fieldIsPointValues, \
field##Type##Values, \
false \
);
FOR_ALL_FIELD_TYPES(WriteFieldTypeValues)
#undef WriteFieldTypeValues
}
}
template
<
class PointField,
class VertexList,
class LineList,
class FaceList,
class ... Args
>
inline void Foam::vtkWritePolyData::write
(
const fileName& file,
const word& title,
const bool binary,
const PointField& points,
const VertexList& vertices,
const LineList& lines,
const FaceList& faces,
const Args& ... args
)
{
const label nFields = sizeof...(Args)/3;
wordList fieldNames(nFields);
boolList fieldIsPointValues(nFields);
UPtrList<const Field<label>> fieldLabelValues(nFields);
#define DeclareFieldTypeValues(Type, nullArg) \
UPtrList<const Field<Type>> field##Type##Values(nFields);
FOR_ALL_FIELD_TYPES(DeclareFieldTypeValues);
#undef DeclareFieldTypeValues
unpackFieldTypeValues
(
fieldNames,
fieldIsPointValues,
fieldLabelValues
#define FieldTypeValuesParameter(Type, nullArg) , field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesParameter),
#undef FieldTypeValuesParameter
args ...
);
write
(
file,
title,
binary,
points,
vertices,
lines,
faces,
fieldNames,
fieldIsPointValues,
fieldLabelValues
#define FieldTypeValuesParameter(Type, nullArg) , field##Type##Values
FOR_ALL_FIELD_TYPES(FieldTypeValuesParameter)
#undef FieldTypeValuesParameter
);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -98,7 +98,7 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict)
dict.lookup("nBins") >> nBins_;
word format(dict.lookup("setFormat"));
formatterPtr_ = writer<scalar>::New(format);
formatterPtr_ = setWriter<scalar>::New(format);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,7 +69,7 @@ SourceFiles
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -103,7 +103,7 @@ class histogram
label nBins_;
//- Output formatter to write
autoPtr<writer<scalar>> formatterPtr_;
autoPtr<setWriter<scalar>> formatterPtr_;
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -358,7 +358,7 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
dict.lookup("fields") >> fields_;
word format(dict.lookup("setFormat"));
formatterPtr_ = writer<scalar>::New(format);
formatterPtr_ = setWriter<scalar>::New(format);
if (dict.found("coordinateSystem"))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -106,7 +106,7 @@ SourceFiles
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "writer.H"
#include "setWriter.H"
#include "Map.H"
#include "volFieldsFwd.H"
#include "wordReList.H"
@ -157,7 +157,7 @@ class regionSizeDistribution
wordReList fields_;
//- Output formatter to write
autoPtr<writer<scalar>> formatterPtr_;
autoPtr<setWriter<scalar>> formatterPtr_;
//- Optional coordinate system
autoPtr<coordinateSystem> coordSysPtr_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -421,8 +421,8 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict)
);
sampledSetAxis_ = sampledSetPtr_->axis();
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
scalarFormatterPtr_ = setWriter<scalar>::New(dict.lookup("setFormat"));
vectorFormatterPtr_ = setWriter<vector>::New(dict.lookup("setFormat"));
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -109,7 +109,7 @@ SourceFiles
#include "DynamicList.H"
#include "scalarList.H"
#include "vectorList.H"
#include "writer.H"
#include "setWriter.H"
#include "indirectPrimitivePatch.H"
#include "NamedEnum.H"
@ -205,10 +205,10 @@ private:
word sampledSetAxis_;
//- File writer for scalar data
autoPtr<writer<scalar>> scalarFormatterPtr_;
autoPtr<setWriter<scalar>> scalarFormatterPtr_;
//- File writer for vector data
autoPtr<writer<vector>> vectorFormatterPtr_;
autoPtr<setWriter<vector>> vectorFormatterPtr_;
// Generated data

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,6 +30,7 @@ License
#include "DynamicField.H"
#include "PatchTools.H"
#include "triSurfaceMesh.H"
#include "vtkWritePolyData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -583,7 +584,6 @@ bool Foam::searchableSurfaces::checkSizes
bool Foam::searchableSurfaces::checkIntersection
(
const scalar tolerance,
const autoPtr<writer<scalar>>& setWriter,
const bool report
) const
{
@ -667,43 +667,27 @@ bool Foam::searchableSurfaces::checkIntersection
<< " locations."
<< endl;
// vtkSetWriter<scalar> setWriter;
if (setWriter.valid())
{
scalarField dist(mag(intersections));
coordSet track
(
names()[i] + '_' + names()[j],
"xyz",
move(intersections),
dist
);
wordList valueSetNames(1, "edgeIndex");
List<const scalarField*> valueSets
(
1,
&intersectionEdge
);
const fileName fName
(
names()[i] + '_' + names()[j] + "_edgeIndex.vtk"
);
fileName fName
(
setWriter().getFileName(track, valueSetNames)
);
Info<< " Writing intersection locations to "
<< fName << endl;
OFstream os
(
s0.searchableSurface::time().path()
/fName
);
setWriter().write
(
track,
valueSetNames,
valueSets,
os
);
}
Info<< " Writing intersection locations to "
<< fName << endl;
vtkWritePolyData::write
(
fName,
names()[i] + '_' + names()[j],
false,
intersections,
identity(intersections.size()),
edgeList(),
faceList(),
"edgeIndex",
true,
intersectionEdge
);
}
hasError = true;
@ -811,7 +795,6 @@ Foam::label Foam::searchableSurfaces::checkGeometry
(
const scalar maxRatio,
const scalar tol,
const autoPtr<writer<scalar>>& setWriter,
const scalar minQuality,
const bool report
) const
@ -823,7 +806,7 @@ Foam::label Foam::searchableSurfaces::checkGeometry
noFailedChecks++;
}
if (checkIntersection(tol, setWriter, report))
if (checkIntersection(tol, report))
{
noFailedChecks++;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,7 +37,6 @@ SourceFiles
#include "searchableSurface.H"
#include "labelPair.H"
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -224,7 +223,6 @@ public:
bool checkIntersection
(
const scalar tol,
const autoPtr<writer<scalar>>&,
const bool report
) const;
@ -243,7 +241,6 @@ public:
(
const scalar maxRatio,
const scalar tolerance,
const autoPtr<writer<scalar>>& setWriter,
const scalar minQuality,
const bool report
) const;

View File

@ -2,6 +2,8 @@ probes/probes.C
probes/patchProbes.C
probes/probesGrouping.C
coordSet/coordSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSets/sampledSetsGrouping.C
@ -20,6 +22,17 @@ sampledSet/triSurfaceMeshSampledSet/triSurfaceMeshSampledSet.C
sampledSet/cellSetSampledSet/cellSetSampledSet.C
sampledSet/faceSetSampledSet/faceSetSampledSet.C
setWriters = sampledSet/writers
$(setWriters)/setWriters.C
$(setWriters)/ensight/ensightSetWriterRunTime.C
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
$(setWriters)/jplot/jplotSetWriterRunTime.C
$(setWriters)/raw/rawSetWriterRunTime.C
$(setWriters)/vtk/vtkSetWriterRunTime.C
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
$(setWriters)/csv/csvSetWriterRunTime.C
cuttingPlane/cuttingPlane.C
sampledSurface/sampledPatch/sampledPatch.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ License
#include "sampledSet.H"
#include "polyMesh.H"
#include "meshSearch.H"
#include "writer.H"
#include "setWriter.H"
#include "lineCell.H"
#include "lineCellFace.H"
#include "lineFace.H"

View File

@ -42,7 +42,7 @@ SourceFiles
#include "meshSearch.H"
#include "interpolation.H"
#include "coordSet.H"
#include "writer.H"
#include "setWriter.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,7 +76,7 @@ class sampledSets
public:
//- The set formatter
autoPtr<writer<Type>> formatter;
autoPtr<setWriter<Type>> formatter;
//- Construct null
fieldGroup()
@ -89,7 +89,7 @@ class sampledSets
fieldGroup(const word& writeFormat)
:
DynamicList<word>(0),
formatter(writer<Type>::New(writeFormat))
formatter(setWriter<Type>::New(writeFormat))
{}
//- Reset format and field list
@ -102,7 +102,7 @@ class sampledSets
//- Assign a new formatter
void operator=(const word& writeFormat)
{
formatter = writer<Type>::New(writeFormat);
formatter = setWriter<Type>::New(writeFormat);
}
};
@ -236,7 +236,7 @@ class sampledSets
const PtrList<volFieldSampler<Type>>& masterFields,
const label setI,
const fileName& timeDir,
const writer<Type>& formatter
const setWriter<Type>& formatter
);
template<class Type>

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -128,7 +128,7 @@ void Foam::sampledSets::writeSampleFile
const PtrList<volFieldSampler<Type>>& masterFields,
const label setI,
const fileName& timeDir,
const writer<Type>& formatter
const setWriter<Type>& formatter
)
{
wordList valueSetNames(masterFields.size());

View File

@ -33,7 +33,7 @@ License
template<class Type>
Foam::csvSetWriter<Type>::csvSetWriter()
:
writer<Type>()
setWriter<Type>()
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ SourceFiles
#ifndef csvSetWriter_H
#define csvSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +49,7 @@ namespace Foam
template<class Type>
class csvSetWriter
:
public writer<Type>
public setWriter<Type>
{
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "csvSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ License
template<class Type>
Foam::ensightSetWriter<Type>::ensightSetWriter()
:
writer<Type>()
setWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef ensightSetWriter_H
#define ensightSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +48,7 @@ namespace Foam
template<class Type>
class ensightSetWriter
:
public writer<Type>
public setWriter<Type>
{
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ensightSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ License
template<class Type>
Foam::gnuplotSetWriter<Type>::gnuplotSetWriter()
:
writer<Type>()
setWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef gnuplotSetWriter_H
#define gnuplotSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +48,7 @@ namespace Foam
template<class Type>
class gnuplotSetWriter
:
public writer<Type>
public setWriter<Type>
{
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "gnuplotSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,7 +47,7 @@ Foam::Ostream& Foam::jplotSetWriter<Type>::writeHeader(Ostream& os) const
template<class Type>
Foam::jplotSetWriter<Type>::jplotSetWriter()
:
writer<Type>()
setWriter<Type>()
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,7 +32,7 @@ SourceFiles
#ifndef jplotSetWriter_H
#define jplotSetWriter_H
#include "writer.H"
#include "setWriter.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,7 +47,7 @@ namespace Foam
template<class Type>
class jplotSetWriter
:
public writer<Type>
public setWriter<Type>
{
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "jplotSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,7 +33,7 @@ License
template<class Type>
Foam::rawSetWriter<Type>::rawSetWriter()
:
writer<Type>()
setWriter<Type>()
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef rawSetWriter_H
#define rawSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +48,7 @@ namespace Foam
template<class Type>
class rawSetWriter
:
public writer<Type>
public setWriter<Type>
{
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "rawSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "writer.H"
#include "setWriter.H"
#include "coordSet.H"
#include "OFstream.H"
#include "OSspecific.H"
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::writer<Type>> Foam::writer<Type>::New
Foam::autoPtr<Foam::setWriter<Type>> Foam::setWriter<Type>::New
(
const word& writeType
)
@ -49,14 +49,14 @@ Foam::autoPtr<Foam::writer<Type>> Foam::writer<Type>::New
<< exit(FatalError);
}
return autoPtr<writer<Type>>(cstrIter()());
return autoPtr<setWriter<Type>>(cstrIter()());
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::writer<Type>::getBaseName
Foam::fileName Foam::setWriter<Type>::getBaseName
(
const coordSet& points,
const wordList& valueSets
@ -74,7 +74,7 @@ Foam::fileName Foam::writer<Type>::getBaseName
template<class Type>
void Foam::writer<Type>::writeCoord
void Foam::setWriter<Type>::writeCoord
(
const coordSet& points,
const label pointi,
@ -93,7 +93,7 @@ void Foam::writer<Type>::writeCoord
template<class Type>
void Foam::writer<Type>::writeTable
void Foam::setWriter<Type>::writeTable
(
const coordSet& points,
const List<Type>& values,
@ -111,7 +111,7 @@ void Foam::writer<Type>::writeTable
template<class Type>
void Foam::writer<Type>::writeTable
void Foam::setWriter<Type>::writeTable
(
const coordSet& points,
const List<const List<Type>*>& valuesPtrList,
@ -137,21 +137,21 @@ void Foam::writer<Type>::writeTable
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::writer<Type>::writer()
Foam::setWriter<Type>::setWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::writer<Type>::~writer()
Foam::setWriter<Type>::~setWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::writer<Type>::write
void Foam::setWriter<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
@ -169,7 +169,7 @@ void Foam::writer<Type>::write
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
Foam::Ostream& Foam::setWriter<Type>::write
(
const scalar value,
Ostream& os
@ -181,7 +181,7 @@ Foam::Ostream& Foam::writer<Type>::write
template<class Type>
template<class VSType>
Foam::Ostream& Foam::writer<Type>::writeVS
Foam::Ostream& Foam::setWriter<Type>::writeVS
(
const VSType& value,
Ostream& os
@ -201,7 +201,7 @@ Foam::Ostream& Foam::writer<Type>::writeVS
template<class Type>
void Foam::writer<Type>::writeSeparator
void Foam::setWriter<Type>::writeSeparator
(
Ostream& os
) const
@ -211,7 +211,7 @@ void Foam::writer<Type>::writeSeparator
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
Foam::Ostream& Foam::setWriter<Type>::write
(
const vector& value,
Ostream& os
@ -222,7 +222,7 @@ Foam::Ostream& Foam::writer<Type>::write
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
Foam::Ostream& Foam::setWriter<Type>::write
(
const sphericalTensor& value,
Ostream& os
@ -233,7 +233,7 @@ Foam::Ostream& Foam::writer<Type>::write
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
Foam::Ostream& Foam::setWriter<Type>::write
(
const symmTensor& value,
Ostream& os
@ -244,7 +244,7 @@ Foam::Ostream& Foam::writer<Type>::write
template<class Type>
Foam::Ostream& Foam::writer<Type>::write
Foam::Ostream& Foam::setWriter<Type>::write
(
const tensor& value,
Ostream& os

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::writer
Foam::setWriter
Description
Base class for graphics format writing. Entry points are
@ -34,8 +34,9 @@ Description
Example:
\verbatim
// Construct writer of xmgr type
autoPtr<writer<scalar>> scalarFormatter(writer<scalar>::New("xmgr"));
// Construct setWriter of xmgr type
autoPtr<setWriter<scalar>> scalarFormatter =
setWriter<scalar>::New("xmgr");
// Output list of points and corresponding values
scalarFormatter().write
@ -47,12 +48,12 @@ Description
\endverbatim
SourceFiles
writer.C
setWriter.C
\*---------------------------------------------------------------------------*/
#ifndef writer_H
#define writer_H
#ifndef setWriter_H
#define setWriter_H
#include "fileName.H"
#include "wordList.H"
@ -72,11 +73,11 @@ namespace Foam
class coordSet;
/*---------------------------------------------------------------------------*\
Class writer Declaration
Class setWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class writer
class setWriter
{
protected:
@ -108,14 +109,14 @@ protected:
public:
//- Runtime type information
TypeName("writer");
TypeName("setWriter");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
writer,
setWriter,
word,
(),
()
@ -124,18 +125,18 @@ public:
// Selectors
//- Return a reference to the selected writer
static autoPtr<writer> New(const word& writeFormat);
//- Return a reference to the selected setWriter
static autoPtr<setWriter> New(const word& writeFormat);
// Constructors
//- Construct null
writer();
setWriter();
//- Destructor
virtual ~writer() = 0;
virtual ~setWriter() = 0;
// Member Functions
@ -209,7 +210,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "writer.C"
#include "setWriter.C"
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "writers.H"
#include "setWriters.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -33,8 +33,8 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define defineSetWriterType(dataType) \
defineNamedTemplateTypeNameAndDebug(writer<dataType >, 0); \
defineTemplatedRunTimeSelectionTable(writer, word, dataType);
defineNamedTemplateTypeNameAndDebug(setWriter<dataType >, 0); \
defineTemplatedRunTimeSelectionTable(setWriter, word, dataType);
defineSetWriterType(scalar);
defineSetWriterType(vector);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,17 +22,17 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InClass
Foam::writer
Foam::setWriter
SourceFiles
writers.C
setWriters.C
\*---------------------------------------------------------------------------*/
#ifndef writers_H
#define writers_H
#ifndef setWriters_H
#define setWriters_H
#include "writer.H"
#include "setWriter.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ SourceFiles
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType>, 0); \
addTemplatedToRunTimeSelectionTable \
( \
writer, typeWriter, dataType, word \
setWriter, typeWriter, dataType, word \
)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,7 +35,7 @@ License
template<class Type>
Foam::vtkSetWriter<Type>::vtkSetWriter()
:
writer<Type>()
setWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -102,7 +102,7 @@ void Foam::vtkSetWriter<Type>::write
{
os << ' ';
}
writer<Type>::write(fld[pointi], os);
setWriter<Type>::write(fld[pointi], os);
}
os << nl;
}
@ -190,7 +190,7 @@ void Foam::vtkSetWriter<Type>::write
{
os << ' ';
}
writer<Type>::write(vals[j], os);
setWriter<Type>::write(vals[j], os);
}
os << nl;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef vtkSetWriter_H
#define vtkSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +48,7 @@ namespace Foam
template<class Type>
class vtkSetWriter
:
public writer<Type>
public setWriter<Type>
{
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "vtkSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ License
template<class Type>
Foam::xmgraceSetWriter<Type>::xmgraceSetWriter()
:
writer<Type>()
setWriter<Type>()
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef xmgraceSetWriter_H
#define xmgraceSetWriter_H
#include "writer.H"
#include "setWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +48,7 @@ namespace Foam
template<class Type>
class xmgraceSetWriter
:
public writer<Type>
public setWriter<Type>
{
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "xmgraceSetWriter.H"
#include "writers.H"
#include "setWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,7 +27,7 @@ License
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H"
#include "vtkWriteOps.H"
#include "vtkWritePolyData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -39,59 +39,6 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkSurfaceWriter::writeGeometry
(
std::ostream& os,
const pointField& points,
const faceList& faces
) const
{
const bool binary = (writeFormat_ == IOstream::BINARY);
// VTK header
vtkWriteOps::writeHeader(os, binary, "sampleSurface");
os << "DATASET POLYDATA" << nl;
// Write vertex coords
os << "POINTS " << points.size() << " float" << nl;
List<floatScalar> po(points.size()*3);
label ind = 0;
forAll(points, pointi)
{
const point& pt = points[pointi];
forAll(pt, cmpt)
{
po[ind++] = float(pt[cmpt]);
}
}
vtkWriteOps::write(os, binary, po);
// Write faces
label nNodes = 0;
forAll(faces, facei)
{
nNodes += faces[facei].size();
}
os << "POLYGONS " << faces.size() << ' '
<< faces.size() + nNodes << nl;
labelList polygons(faces.size() + nNodes);
ind = 0;
forAll(faces, facei)
{
const face& f = faces[facei];
polygons[ind++] = f.size();
forAll(f, fp)
{
polygons[ind++] = f[fp];
}
}
vtkWriteOps::write(os, binary, polygons);
}
template<class Type>
void Foam::vtkSurfaceWriter::Write
(
@ -104,53 +51,24 @@ void Foam::vtkSurfaceWriter::Write
const bool isNodeValues
) const
{
const bool binary = (writeFormat_ == IOstream::BINARY);
if (!isDir(outputDir))
{
mkDir(outputDir);
}
const word filePath = outputDir/fieldName + '_' + surfaceName + ".vtk";
ofstream os(filePath, std::ios::binary);
if (debug)
{
Info<< "Writing field " << fieldName << " to " << filePath << endl;
}
writeGeometry(os, points, faces);
// Write data
if (isNodeValues)
{
os << "POINT_DATA ";
}
else
{
os << "CELL_DATA ";
}
os << values.size() << nl
<< "FIELD attributes 1" << nl
<< fieldName << " ";
const label nComp = pTraits<Type>::nComponents;
os << nComp << " " << values.size() << " float" << nl;
List<floatScalar> vals(values.size()*nComp);
label ind = 0;
forAll(values, elemI)
{
for (direction cmpt=0; cmpt < nComp; ++cmpt)
{
vals[ind++] = component(values[elemI], cmpt);
}
}
vtkWriteOps::write(os, binary, vals);
vtkWritePolyData::write
(
outputDir/fieldName + '_' + surfaceName + ".vtk",
"sampleSurface",
writeFormat_ == IOstream::BINARY,
points,
labelList(),
edgeList(),
faces,
fieldName,
isNodeValues,
values
);
}
@ -186,15 +104,16 @@ void Foam::vtkSurfaceWriter::write
mkDir(outputDir);
}
word filePath = outputDir/surfaceName + ".vtk";
ofstream os(filePath, std::ios::binary);
if (debug)
{
Info<< "Writing geometry to " << filePath << endl;
}
writeGeometry(os, points, faces);
vtkWritePolyData::write
(
outputDir/surfaceName + ".vtk",
"sampleSurface",
writeFormat_ == IOstream::BINARY,
points,
labelList(),
edgeList(),
faces
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,13 +53,6 @@ class vtkSurfaceWriter
{
// Private Member Functions
void writeGeometry
(
std::ostream&,
const pointField&,
const faceList&
) const;
//- Templated write operation
template<class Type>
void Write
@ -101,7 +94,6 @@ public:
const faceList& faces
) const;
//- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true)
virtual void write