foamToVTK: Rationalised the low-level write function to avoid 3x duplication

Moved the writeFuns into the vtkWriteOps namespace which is extensible, see the
the write functions in setSet as an example of this.
This commit is contained in:
Henry Weller
2020-01-28 16:12:57 +00:00
parent a296733a76
commit 9ff1e2e168
30 changed files with 334 additions and 525 deletions

View File

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

View File

@ -1,7 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
$(COMP_FLAGS)
EXE_LIBS = \
-lmeshTools \
-lfileFormats \
$(LINK_FLAGS)

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -92,7 +92,7 @@ void writeVTK
primitiveFacePatch fp(setFaces, mesh.points());
writePatch
vtkWriteOps::writePatch
(
true,
currentSet.name(),
@ -152,7 +152,7 @@ void writeVTK
primitiveFacePatch fp(setFaces, mesh.points());
writePatch
vtkWriteOps::writePatch
(
true,
currentSet.name(),
@ -164,7 +164,7 @@ void writeVTK
}
else if (isA<pointSet>(currentSet))
{
writePointSet
vtkWriteOps::writePointSet
(
true,
mesh,

View File

@ -1,240 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 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 "writeFuns.H"
#if defined(__mips)
#include <standards.h>
#include <sys/endian.h>
#endif
#if defined(LITTLE_ENDIAN) \
|| defined(_LITTLE_ENDIAN) \
|| defined(__LITTLE_ENDIAN)
#define LITTLEENDIAN 1
#elif defined(BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN)
#undef LITTLEENDIAN
#else
#error "Cannot find LITTLE_ENDIAN or BIG_ENDIAN symbol defined."
#error "Please add to compilation options"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::writeFuns::swapWord(int32_t& word32)
{
char* mem = reinterpret_cast<char*>(&word32);
char a = mem[0];
mem[0] = mem[3];
mem[3] = a;
a = mem[1];
mem[1] = mem[2];
mem[2] = a;
}
void Foam::writeFuns::swapWords(const label nWords, int32_t* words32)
{
for (label i=0; i<nWords; i++)
{
swapWord(words32[i]);
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
List<floatScalar>& fField
)
{
if (binary)
{
#ifdef LITTLEENDIAN
swapWords(fField.size(), reinterpret_cast<int32_t*>(fField.begin()));
#endif
os.write
(
reinterpret_cast<char*>(fField.begin()),
fField.size()*sizeof(float)
);
os << std::endl;
}
else
{
forAll(fField, i)
{
os << fField[i] << ' ';
if (i > 0 && (i % 10) == 0)
{
os << std::endl;
}
}
os << std::endl;
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
DynamicList<floatScalar>& fField
)
{
List<floatScalar>& fld = fField.shrink();
write(os, binary, fld);
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
labelList& elems
)
{
if (binary)
{
#ifdef LITTLEENDIAN
swapWords
(
(sizeof(label)/4)*elems.size(),
reinterpret_cast<int32_t*>(elems.begin())
);
#endif
os.write
(
reinterpret_cast<char*>(elems.begin()),
elems.size()*sizeof(label)
);
os << std::endl;
}
else
{
forAll(elems, i)
{
os << elems[i] << ' ';
if (i > 0 && (i % 10) == 0)
{
os << std::endl;
}
}
os << std::endl;
}
}
void Foam::writeFuns::write
(
std::ostream& os,
const bool binary,
DynamicList<label>& elems
)
{
labelList& fld = elems.shrink();
write(os, binary, fld);
}
void Foam::writeFuns::insert(const point& pt, DynamicList<floatScalar>& dest)
{
dest.append(float(pt.x()));
dest.append(float(pt.y()));
dest.append(float(pt.z()));
}
void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest)
{
forAll(source, i)
{
dest.append(source[i]);
}
}
void Foam::writeFuns::insert
(
const List<scalar>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
dest.append(float(source[i]));
}
}
void Foam::writeFuns::insert
(
const labelList& map,
const List<scalar>& source,
DynamicList<floatScalar>& dest
)
{
forAll(map, i)
{
dest.append(float(source[map[i]]));
}
}
void Foam::writeFuns::insert
(
const List<point>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
insert(source[i], dest);
}
}
void Foam::writeFuns::insert
(
const labelList& map,
const List<point>& source,
DynamicList<floatScalar>& dest
)
{
forAll(map, i)
{
insert(source[map[i]], dest);
}
}
// ************************************************************************* //

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,17 +25,12 @@ License
#include "writePatch.H"
#include "OFstream.H"
#include "writeFuns.H"
#include "vtkWriteOps.H"
#include "primitiveFacePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void writePatch
void Foam::vtkWriteOps::writePatch
(
const bool binary,
const word& setName,
@ -74,9 +69,9 @@ void writePatch
DynamicList<floatScalar> ptField(3*fp.nPoints());
writeFuns::insert(fp.localPoints(), ptField);
vtkWriteOps::insert(fp.localPoints(), ptField);
writeFuns::write(pStream, binary, ptField);
vtkWriteOps::write(pStream, binary, ptField);
label nFaceVerts = 0;
@ -97,9 +92,9 @@ void writePatch
vertLabels.append(f.size());
writeFuns::insert(f, vertLabels);
vtkWriteOps::insert(f, vertLabels);
}
writeFuns::write(pStream, binary, vertLabels);
vtkWriteOps::write(pStream, binary, vertLabels);
//-----------------------------------------------------------------
@ -117,11 +112,8 @@ void writePatch
// Cell ids first
pStream << fieldName << " 1 " << fp.size() << " int" << std::endl;
writeFuns::write(pStream, binary, fieldValues);
vtkWriteOps::write(pStream, binary, fieldValues);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam
{
namespace vtkWriteOps
{
// Write faceSet
//- Write patch
void writePatch
(
const bool binary,
@ -55,6 +57,7 @@ void writePatch
const fileName& fileName
);
} // End namespace vtkWriteOps
} // End namespace Foam

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,16 +25,11 @@ License
#include "writePointSet.H"
#include "OFstream.H"
#include "writeFuns.H"
#include "vtkWriteOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void writePointSet
void Foam::vtkWriteOps::writePointSet
(
const bool binary,
const primitiveMesh& mesh,
@ -75,9 +70,9 @@ void writePointSet
DynamicList<floatScalar> ptField(3*pointLabels.size());
writeFuns::insert(setPoints, ptField);
vtkWriteOps::insert(setPoints, ptField);
writeFuns::write(pStream, binary, ptField);
vtkWriteOps::write(pStream, binary, ptField);
//-----------------------------------------------------------------
@ -95,11 +90,8 @@ void writePointSet
// Cell ids first
pStream << "pointID 1 " << pointLabels.size() << " int" << std::endl;
writeFuns::write(pStream, binary, pointLabels);
vtkWriteOps::write(pStream, binary, pointLabels);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,6 +43,8 @@ SourceFiles
namespace Foam
{
namespace vtkWriteOps
{
//- Write pointSet to vtk polydata file.
// Only one data which is original pointID.
@ -54,6 +56,7 @@ void writePointSet
const fileName& fileName
);
} // End namespace vtkWriteOps
} // End namespace Foam

View File

@ -3,10 +3,12 @@ EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfoamToVTK \
-ldynamicMesh \
-llagrangian \
-lgenericPatchFields
-lgenericPatchFields \
-lfileFormats

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -150,7 +150,7 @@ Note
#include "vtkMesh.H"
#include "readFields.H"
#include "writeFuns.H"
#include "vtkWriteOps.H"
#include "internalWriter.H"
#include "patchWriter.H"
@ -746,7 +746,7 @@ int main(int argc, char *argv[])
internalWriter writer(vMesh, binary, vtkFileName);
// cellID + volFields::Internal + VolFields
writeFuns::writeCellDataHeader
vtkWriteOps::writeCellDataHeader
(
writer.os(),
vMesh.nFieldCells(),
@ -772,7 +772,7 @@ int main(int argc, char *argv[])
if (!noPointValues)
{
writeFuns::writePointDataHeader
vtkWriteOps::writePointDataHeader
(
writer.os(),
vMesh.nFieldPoints(),
@ -909,7 +909,7 @@ int main(int argc, char *argv[])
);
// VolFields + patchID
writeFuns::writeCellDataHeader
vtkWriteOps::writeCellDataHeader
(
writer.os(),
writer.nFaces(),
@ -928,7 +928,7 @@ int main(int argc, char *argv[])
if (!noPointValues)
{
writeFuns::writePointDataHeader
vtkWriteOps::writePointDataHeader
(
writer.os(),
writer.nPoints(),
@ -986,7 +986,7 @@ int main(int argc, char *argv[])
if (!isA<emptyPolyPatch>(pp))
{
// VolFields + patchID
writeFuns::writeCellDataHeader
vtkWriteOps::writeCellDataHeader
(
writer.os(),
writer.nFaces(),
@ -1005,7 +1005,7 @@ int main(int argc, char *argv[])
if (!noPointValues)
{
writeFuns::writePointDataHeader
vtkWriteOps::writePointDataHeader
(
writer.os(),
writer.nPoints(),
@ -1111,7 +1111,7 @@ int main(int argc, char *argv[])
);
// Number of fields
writeFuns::writeCellDataHeader
vtkWriteOps::writeCellDataHeader
(
writer.os(),
pp.size(),

View File

@ -2,7 +2,6 @@ surfaceMeshWriter.C
internalWriter.C
lagrangianWriter.C
patchWriter.C
writeFuns.C
writeFaceSet.C
writePointSet.C
writeSurfFields.C

View File

@ -2,9 +2,11 @@ EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude
LIB_LIBS = \
-ldynamicMesh \
-llagrangian \
-lgenericPatchFields
-lgenericPatchFields \
-lfileFormats

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "internalWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -44,7 +44,7 @@ Foam::internalWriter::internalWriter
const vtkTopo& topo = vMesh_.topo();
// Write header
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
vtkWriteOps::writeHeader(os_, binary_, mesh.time().caseName());
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
@ -61,14 +61,14 @@ Foam::internalWriter::internalWriter
DynamicList<floatScalar> ptField(3*nTotPoints);
writeFuns::insert(mesh.points(), ptField);
vtkWriteOps::insert(mesh.points(), ptField);
const pointField& ctrs = mesh.cellCentres();
forAll(addPointCellLabels, api)
{
writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
vtkWriteOps::insert(ctrs[addPointCellLabels[api]], ptField);
}
writeFuns::write(os_, binary_, ptField);
vtkWriteOps::write(os_, binary_, ptField);
//
@ -95,9 +95,9 @@ Foam::internalWriter::internalWriter
vertLabels.append(vtkVerts.size());
writeFuns::insert(vtkVerts, vertLabels);
vtkWriteOps::insert(vtkVerts, vertLabels);
}
writeFuns::write(os_, binary_, vertLabels);
vtkWriteOps::write(os_, binary_, vertLabels);
const labelList& vtkCellTypes = topo.cellTypes();
@ -107,9 +107,9 @@ Foam::internalWriter::internalWriter
// Make copy since writing might swap stuff.
DynamicList<label> cellTypes(vtkCellTypes.size());
writeFuns::insert(vtkCellTypes, cellTypes);
vtkWriteOps::insert(vtkCellTypes, cellTypes);
writeFuns::write(os_, binary_, cellTypes);
vtkWriteOps::write(os_, binary_, cellTypes);
}
@ -158,7 +158,7 @@ void Foam::internalWriter::writeCellIDs()
}
}
writeFuns::write(os_, binary_, cellId);
vtkWriteOps::write(os_, binary_, cellId);
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "internalWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -36,7 +36,7 @@ void Foam::internalWriter::write
{
forAll(flds, i)
{
writeFuns::write(os_, binary_, flds[i], vMesh_);
vtkWriteOps::write(os_, binary_, flds[i], vMesh_);
}
}
@ -49,7 +49,7 @@ void Foam::internalWriter::write
{
forAll(flds, i)
{
writeFuns::write(os_, binary_, flds[i], vMesh_);
vtkWriteOps::write(os_, binary_, flds[i], vMesh_);
}
}
@ -63,7 +63,7 @@ void Foam::internalWriter::write
{
forAll(flds, i)
{
writeFuns::write
vtkWriteOps::write
(
os_,
binary_,

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "lagrangianWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
#include "Cloud.H"
#include "passiveParticle.H"
@ -48,7 +48,7 @@ Foam::lagrangianWriter::lagrangianWriter
const fvMesh& mesh = vMesh_.mesh();
// Write header
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
vtkWriteOps::writeHeader(os_, binary_, mesh.time().caseName());
os_ << "DATASET POLYDATA" << std::endl;
if (dummyCloud)
@ -69,9 +69,9 @@ Foam::lagrangianWriter::lagrangianWriter
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
{
writeFuns::insert(elmnt().position(), partField);
vtkWriteOps::insert(elmnt().position(), partField);
}
writeFuns::write(os_, binary_, partField);
vtkWriteOps::write(os_, binary_, partField);
}
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "lagrangianWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
#include "IOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,9 +54,9 @@ void Foam::lagrangianWriter::writeIOField(const wordList& objects)
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*fld.size());
writeFuns::insert(fld, fField);
vtkWriteOps::insert(fld, fField);
writeFuns::write(os_, binary_, fField);
vtkWriteOps::write(os_, binary_, fField);
}
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "patchWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -50,11 +50,11 @@ Foam::patchWriter::patchWriter
// Write header
if (patchIDs_.size() == 1)
{
writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
vtkWriteOps::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
}
else
{
writeFuns::writeHeader(os_, binary_, "patches");
vtkWriteOps::writeHeader(os_, binary_, "patches");
}
os_ << "DATASET POLYDATA" << std::endl;
@ -84,9 +84,9 @@ Foam::patchWriter::patchWriter
{
const polyPatch& pp = patches[patchIDs_[i]];
writeFuns::insert(pp.localPoints(), ptField);
vtkWriteOps::insert(pp.localPoints(), ptField);
}
writeFuns::write(os_, binary_, ptField);
vtkWriteOps::write(os_, binary_, ptField);
os_ << "POLYGONS " << nFaces_ << ' ' << nFaceVerts << std::endl;
@ -103,11 +103,11 @@ Foam::patchWriter::patchWriter
const face& f = pp.localFaces()[facei];
vertLabels.append(f.size());
writeFuns::insert(f + offset, vertLabels);
vtkWriteOps::insert(f + offset, vertLabels);
}
offset += pp.nPoints();
}
writeFuns::write(os_, binary_, vertLabels);
vtkWriteOps::write(os_, binary_, vertLabels);
}
@ -129,10 +129,10 @@ void Foam::patchWriter::writePatchIDs()
if (!isA<emptyPolyPatch>(pp))
{
writeFuns::insert(scalarField(pp.size(), patchi), fField);
vtkWriteOps::insert(scalarField(pp.size(), patchi), fField);
}
}
writeFuns::write(os_, binary_, fField);
vtkWriteOps::write(os_, binary_, fField);
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "patchWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,14 +51,14 @@ void Foam::patchWriter::write
if (nearCellValue_)
{
writeFuns::insert(pfld.patchInternalField()(), fField);
vtkWriteOps::insert(pfld.patchInternalField()(), fField);
}
else
{
writeFuns::insert(pfld, fField);
vtkWriteOps::insert(pfld, fField);
}
}
writeFuns::write(os_, binary_, fField);
vtkWriteOps::write(os_, binary_, fField);
}
}
@ -85,9 +85,9 @@ void Foam::patchWriter::write
const pointPatchField<Type>& pfld = fld.boundaryField()[patchi];
writeFuns::insert(pfld.patchInternalField()(), fField);
vtkWriteOps::insert(pfld.patchInternalField()(), fField);
}
writeFuns::write(os_, binary_, fField);
vtkWriteOps::write(os_, binary_, fField);
}
}
@ -116,7 +116,7 @@ void Foam::patchWriter::write
if (nearCellValue_)
{
writeFuns::insert
vtkWriteOps::insert
(
pInter.faceToPointInterpolate
(
@ -127,14 +127,14 @@ void Foam::patchWriter::write
}
else
{
writeFuns::insert
vtkWriteOps::insert
(
pInter.faceToPointInterpolate(pfld)(),
fField
);
}
}
writeFuns::write(os_, binary_, fField);
vtkWriteOps::write(os_, binary_, fField);
}
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceMeshWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -42,7 +42,7 @@ Foam::surfaceMeshWriter::surfaceMeshWriter
os_(fName.c_str())
{
// Write header
writeFuns::writeHeader(os_, binary_, name);
vtkWriteOps::writeHeader(os_, binary_, name);
os_ << "DATASET POLYDATA" << std::endl;
@ -57,8 +57,8 @@ Foam::surfaceMeshWriter::surfaceMeshWriter
os_ << "POINTS " << pp.nPoints() << " float" << std::endl;
DynamicList<floatScalar> ptField(3*pp.nPoints());
writeFuns::insert(pp.localPoints(), ptField);
writeFuns::write(os_, binary, ptField);
vtkWriteOps::insert(pp.localPoints(), ptField);
vtkWriteOps::write(os_, binary, ptField);
os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl;
@ -70,9 +70,9 @@ Foam::surfaceMeshWriter::surfaceMeshWriter
const face& f = pp.localFaces()[facei];
vertLabels.append(f.size());
writeFuns::insert(f, vertLabels);
vtkWriteOps::insert(f, vertLabels);
}
writeFuns::write(os_, binary_, vertLabels);
vtkWriteOps::write(os_, binary_, vertLabels);
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceMeshWriter.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -78,8 +78,8 @@ void Foam::surfaceMeshWriter::write
<< pp_.size() << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*pp_.size());
writeFuns::insert(getFaceField(fld)(), fField);
writeFuns::write(os_, binary_, fField);
vtkWriteOps::insert(getFaceField(fld)(), fField);
vtkWriteOps::write(os_, binary_, fField);
}
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,22 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::writeFuns
Foam::vtkWriteFieldOps
Description
Various functions for collecting and writing binary data.
VTK ASCII and binary write functions
SourceFiles
writeFuns.C
vtkWriteFieldOps.C
\*---------------------------------------------------------------------------*/
#ifndef writeFuns_H
#define writeFuns_H
#ifndef vtkWriteFieldOps_H
#define vtkWriteFieldOps_H
#include "floatScalar.H"
#include "DynamicList.H"
#include "volFieldsFwd.H"
#include "vtkWriteOps.H"
#include "pointFieldsFwd.H"
#include "vtkMesh.H"
#include "volPointInterpolation.H"
@ -48,68 +46,14 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class writeFuns Declaration
Namespace vtkWriteOps Declaration
\*---------------------------------------------------------------------------*/
class writeFuns
namespace vtkWriteOps
{
// Private Member Functions
// Swap halves of word.
static void swapWord(label& word32);
static void swapWords(const label nWords, label* words32);
public:
// Write ascii or binary. If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, List<floatScalar>&);
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
static void write(std::ostream&, const bool, labelList&);
static void write(std::ostream&, const bool, DynamicList<label>&);
// Write header
static void writeHeader
(
std::ostream&,
const bool isBinary,
const std::string& title
);
static void writeCellDataHeader
(
std::ostream&,
const label nCells,
const label nFields
);
static void writePointDataHeader
(
std::ostream&,
const label nPoints,
const label nFields
);
// Convert to VTK and store
static void insert(const scalar, DynamicList<floatScalar>&);
static void insert(const point&, DynamicList<floatScalar>&);
static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
static void insert(const symmTensor&, DynamicList<floatScalar>&);
static void insert(const tensor&, DynamicList<floatScalar>&);
//- Append elements to DynamicList
static void insert(const labelList&, DynamicList<label>&);
template<class Type>
static void insert(const List<Type>&, DynamicList<floatScalar>&);
//- Write volField with cell values (including decomposed cells)
template<class Type>
static void write
void write
(
std::ostream&,
const bool binary,
@ -120,7 +64,7 @@ public:
//- Write pointField on all mesh points. Interpolate to cell centre
// for decomposed cell centres.
template<class Type>
static void write
void write
(
std::ostream&,
const bool binary,
@ -131,7 +75,7 @@ public:
//- Write interpolated field on points and original cell values on
// decomposed cell centres.
template<class Type>
static void write
void write
(
std::ostream&,
const bool binary,
@ -142,7 +86,7 @@ public:
//- Write generic GeometricFields
template<class Type, template<class> class PatchField, class GeoMesh>
static void write
void write
(
std::ostream&,
const bool binary,
@ -152,7 +96,7 @@ public:
//- Interpolate and write volFields
template<class Type>
static void write
void write
(
std::ostream&,
const bool binary,
@ -160,7 +104,8 @@ public:
const PtrList<GeometricField<Type, fvPatchField, volMesh>>&,
const vtkMesh&
);
};
} // End namespace vtkWriteOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -170,7 +115,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "writeFunsTemplates.C"
#include "vtkWriteFieldOpsTemplates.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-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,27 +23,13 @@ License
\*---------------------------------------------------------------------------*/
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
#include "interpolatePointToCell.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::writeFuns::insert
(
const List<Type>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
insert(source[i], dest);
}
}
template<class Type>
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -75,7 +61,7 @@ void Foam::writeFuns::write
template<class Type>
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -107,7 +93,7 @@ void Foam::writeFuns::write
template<class Type>
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -140,7 +126,7 @@ void Foam::writeFuns::write
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -156,7 +142,7 @@ void Foam::writeFuns::write
template<class Type>
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ License
#include "writeFaceSet.H"
#include "OFstream.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -41,7 +41,7 @@ void Foam::writeFaceSet
std::ofstream ostr(fileName.c_str());
writeFuns::writeHeader
vtkWriteOps::writeHeader
(
ostr,
binary,
@ -78,9 +78,9 @@ void Foam::writeFaceSet
DynamicList<floatScalar> ptField(3*fp.nPoints());
writeFuns::insert(fp.localPoints(), ptField);
vtkWriteOps::insert(fp.localPoints(), ptField);
writeFuns::write(ostr, binary, ptField);
vtkWriteOps::write(ostr, binary, ptField);
label nFaceVerts = 0;
@ -100,9 +100,9 @@ void Foam::writeFaceSet
vertLabels.append(f.size());
writeFuns::insert(f, vertLabels);
vtkWriteOps::insert(f, vertLabels);
}
writeFuns::write(ostr, binary, vertLabels);
vtkWriteOps::write(ostr, binary, vertLabels);
//-----------------------------------------------------------------
@ -120,7 +120,7 @@ void Foam::writeFaceSet
// Cell ids first
ostr<< "faceID 1 " << fp.size() << " int" << std::endl;
writeFuns::write(ostr, binary, setFaceLabels);
vtkWriteOps::write(ostr, binary, setFaceLabels);
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ License
#include "writePointSet.H"
#include "OFstream.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,7 +44,7 @@ void writePointSet
{
std::ofstream ostr(fileName.c_str());
writeFuns::writeHeader
vtkWriteOps::writeHeader
(
ostr,
binary,
@ -66,13 +66,13 @@ void writePointSet
DynamicList<floatScalar> ptField(3*set.size());
writeFuns::insert
vtkWriteOps::insert
(
UIndirectList<point>(vMesh.mesh().points(), set.toc())(),
ptField
);
writeFuns::write(ostr, binary, ptField);
vtkWriteOps::write(ostr, binary, ptField);
//-----------------------------------------------------------------
@ -92,7 +92,7 @@ void writePointSet
labelList pointIDs(set.toc());
writeFuns::write(ostr, binary, pointIDs);
vtkWriteOps::write(ostr, binary, pointIDs);
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,7 @@ License
#include "writeSurfFields.H"
#include "OFstream.H"
#include "floatScalar.H"
#include "writeFuns.H"
#include "vtkWriteFieldOps.H"
#include "emptyFvsPatchFields.H"
#include "fvsPatchFields.H"
@ -44,7 +44,7 @@ void Foam::writeSurfFields
std::ofstream str(fileName.c_str());
writeFuns::writeHeader
vtkWriteOps::writeHeader
(
str,
binary,
@ -61,10 +61,10 @@ void Foam::writeSurfFields
for (label facei = 0; facei < mesh.nFaces(); facei++)
{
writeFuns::insert(fc[facei], pField);
vtkWriteOps::insert(fc[facei], pField);
}
writeFuns::write(str, binary, pField);
vtkWriteOps::write(str, binary, pField);
str << "POINT_DATA " << mesh.nFaces() << std::endl
<< "FIELD attributes " << surfVectorFields.size() << std::endl;
@ -81,7 +81,7 @@ void Foam::writeSurfFields
for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
{
writeFuns::insert(svf[facei], fField);
vtkWriteOps::insert(svf[facei], fField);
}
forAll(svf.boundaryField(), patchi)
@ -95,19 +95,19 @@ void Foam::writeSurfFields
// Note: loop over polypatch size, not fvpatch size.
forAll(pp.patch(), i)
{
writeFuns::insert(vector::zero, fField);
vtkWriteOps::insert(vector::zero, fField);
}
}
else
{
forAll(pf, i)
{
writeFuns::insert(pf[i], fField);
vtkWriteOps::insert(pf[i], fField);
}
}
}
writeFuns::write(str, binary, fField);
vtkWriteOps::write(str, binary, fField);
}
}

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -132,7 +132,7 @@ bool Foam::functionObjects::writeVTK::write()
UPtrList<const volTensorField> vtf(lookupFields<volTensorField>());
// Write header for cellID and volFields
writeFuns::writeCellDataHeader
vtkWriteOps::writeCellDataHeader
(
writer.os(),
vMesh.nFieldCells(),

View File

@ -1,3 +1,4 @@
vtk/vtkWriteOps.C
vtk/vtkUnstructuredReader.C
nas/NASCore.C
starcd/STARCDCore.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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,8 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "writeFuns.H"
#include "vtkTopo.H"
#include "vtkWriteOps.H"
#if defined(__mips)
#include <standards.h>
@ -53,7 +52,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::writeFuns::swapWord(label& word32)
void Foam::vtkWriteOps::swapWord(label& word32)
{
char* mem = reinterpret_cast<char*>(&word32);
@ -67,7 +66,7 @@ void Foam::writeFuns::swapWord(label& word32)
}
void Foam::writeFuns::swapWords(const label nWords, label* words32)
void Foam::vtkWriteOps::swapWords(const label nWords, label* words32)
{
for (label i = 0; i < nWords; i++)
{
@ -76,7 +75,7 @@ void Foam::writeFuns::swapWords(const label nWords, label* words32)
}
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -116,7 +115,7 @@ void Foam::writeFuns::write
}
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -129,7 +128,7 @@ void Foam::writeFuns::write
}
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -169,7 +168,7 @@ void Foam::writeFuns::write
}
void Foam::writeFuns::write
void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
@ -182,7 +181,7 @@ void Foam::writeFuns::write
}
void Foam::writeFuns::writeHeader
void Foam::vtkWriteOps::writeHeader
(
std::ostream& os,
const bool binary,
@ -203,7 +202,7 @@ void Foam::writeFuns::writeHeader
}
void Foam::writeFuns::writeCellDataHeader
void Foam::vtkWriteOps::writeCellDataHeader
(
std::ostream& os,
const label nCells,
@ -215,7 +214,7 @@ void Foam::writeFuns::writeCellDataHeader
}
void Foam::writeFuns::writePointDataHeader
void Foam::vtkWriteOps::writePointDataHeader
(
std::ostream& os,
const label nPoints,
@ -227,13 +226,17 @@ void Foam::writeFuns::writePointDataHeader
}
void Foam::writeFuns::insert(const scalar src, DynamicList<floatScalar>& dest)
void Foam::vtkWriteOps::insert(const scalar src, DynamicList<floatScalar>& dest)
{
dest.append(float(src));
}
void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest)
void Foam::vtkWriteOps::insert
(
const vector& src,
DynamicList<floatScalar>& dest
)
{
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{
@ -242,7 +245,7 @@ void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest)
}
void Foam::writeFuns::insert
void Foam::vtkWriteOps::insert
(
const sphericalTensor& src,
DynamicList<floatScalar>& dest
@ -255,7 +258,7 @@ void Foam::writeFuns::insert
}
void Foam::writeFuns::insert
void Foam::vtkWriteOps::insert
(
const symmTensor& src,
DynamicList<floatScalar>& dest
@ -270,7 +273,11 @@ void Foam::writeFuns::insert
}
void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest)
void Foam::vtkWriteOps::insert
(
const tensor& src,
DynamicList<floatScalar>& dest
)
{
for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt)
{
@ -279,10 +286,51 @@ void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest)
}
void Foam::writeFuns::insert(const labelList& src, DynamicList<label>& dest)
void Foam::vtkWriteOps::insert(const labelList& src, DynamicList<label>& dest)
{
dest.append(src);
}
void Foam::vtkWriteOps::insert
(
const labelList& map,
const List<scalar>& source,
DynamicList<floatScalar>& dest
)
{
forAll(map, i)
{
dest.append(float(source[map[i]]));
}
}
void Foam::vtkWriteOps::insert
(
const List<point>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
insert(source[i], dest);
}
}
void Foam::vtkWriteOps::insert
(
const labelList& map,
const List<point>& source,
DynamicList<floatScalar>& dest
)
{
forAll(map, i)
{
insert(source[map[i]], dest);
}
}
// ************************************************************************* //

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-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,30 +22,24 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::writeFuns
Foam::vtkWriteOps
Description
Various functions for collecting and writing binary data.
The LITTLE_ENDIAN is based on 32bit words.
It is not clear how 64bit labels should be handled, currently they are
split into two 32bit words and swapWord applied to these two.
writeFuns should be a namespace rather than a class.
VTK ASCII and binary write functions
SourceFiles
writeFuns.C
vtkWriteOps.C
\*---------------------------------------------------------------------------*/
#ifndef writeFuns_H
#define writeFuns_H
#ifndef vtkWriteOps_H
#define vtkWriteOps_H
#include "labelList.H"
#include "floatScalar.H"
#include "OFstream.H"
#include "DynamicList.H"
#include "point.H"
#include "tensor.H"
#include "labelList.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,49 +47,81 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class writeFuns Declaration
Namespace vtkWriteOps Declaration
\*---------------------------------------------------------------------------*/
class writeFuns
namespace vtkWriteOps
{
// Private Member Functions
//- Swap halves of word
void swapWord(label& word32);
//- Swap halves of word
static void swapWord(int32_t& word32);
//- Swap halves of word
void swapWords(const label nWords, label* words32);
//- Swap halves of word
static void swapWords(const label nWords, int32_t* words32);
//- Write header
void writeHeader
(
std::ostream&,
const bool isBinary,
const std::string& title
);
void writeCellDataHeader
(
std::ostream&,
const label nCells,
const label nFields
);
void writePointDataHeader
(
std::ostream&,
const label nPoints,
const label nFields
);
public:
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
//- Write labels ascii or binary.
// If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, DynamicList<label>&);
void write(std::ostream& os, const bool binary, List<floatScalar>& fField);
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, List<floatScalar>&);
void write(std::ostream&, const bool, DynamicList<floatScalar>&);
//- Write labels ascii or binary.
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
static void write(std::ostream&, const bool, labelList&);
void write(std::ostream&, const bool, labelList&);
//- Write floats ascii or binary.
// If binary optionally in-place swaps argument
void write(std::ostream&, const bool, DynamicList<label>&);
//- Append scalar to given DynamicList
void insert(const scalar, DynamicList<floatScalar>&);
//- Append point to given DynamicList
static void insert(const point&, DynamicList<floatScalar>& dest);
void insert(const point&, DynamicList<floatScalar>&);
//- Append elements of labelList to given DynamicList
static void insert(const labelList&, DynamicList<label>&);
//- Append sphericalTensor to given DynamicList
void insert(const sphericalTensor&, DynamicList<floatScalar>&);
//- Append elements of scalarList to given DynamicList
static void insert(const List<scalar>&, DynamicList<floatScalar>&);
//- Append symmTensor to given DynamicList
void insert(const symmTensor&, DynamicList<floatScalar>&);
//- Append tensor to given DynamicList
void insert(const tensor&, DynamicList<floatScalar>&);
//- Append elements to DynamicList
void insert(const labelList&, DynamicList<label>&);
//- Append elements to DynamicList
template<class Type>
void insert(const List<Type>&, DynamicList<floatScalar>&);
//- Append elements of scalarList to given DynamicList using map
static void insert
void insert
(
const labelList& map,
const List<scalar>& source,
@ -103,22 +129,28 @@ public:
);
//- Append points to given DynamicList of floats
static void insert(const List<point>& source, DynamicList<floatScalar>&);
void insert(const List<point>& source, DynamicList<floatScalar>&);
//- Append points to given DynamicList of floats using map
static void insert
void insert
(
const labelList& map,
const List<point>& source,
DynamicList<floatScalar>&
);
};
} // End namespace vtkWriteOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "vtkWriteOpsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "vtkWriteOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkWriteOps::insert
(
const List<Type>& source,
DynamicList<floatScalar>& dest
)
{
forAll(source, i)
{
insert(source[i], dest);
}
}
// ************************************************************************* //