mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: foamToVTK : have surface fields on faceZones
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
surfaceMeshWriter.C
|
||||
|
||||
foamToVTK.C
|
||||
internalWriter.C
|
||||
lagrangianWriter.C
|
||||
patchWriter.C
|
||||
writeFuns.C
|
||||
writePatchGeom.C
|
||||
writeFaceSet.C
|
||||
writePointSet.C
|
||||
writeSurfFields.C
|
||||
|
||||
@ -157,7 +157,7 @@ Note
|
||||
|
||||
#include "writeFaceSet.H"
|
||||
#include "writePointSet.H"
|
||||
#include "writePatchGeom.H"
|
||||
#include "surfaceMeshWriter.H"
|
||||
#include "writeSurfFields.H"
|
||||
|
||||
|
||||
@ -963,20 +963,42 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (doFaceZones)
|
||||
{
|
||||
PtrList<surfaceScalarField> ssf;
|
||||
readFields
|
||||
(
|
||||
vMesh,
|
||||
vMesh.baseMesh(),
|
||||
objects,
|
||||
selectedFields,
|
||||
ssf
|
||||
);
|
||||
print(" surfScalarFields :", Info, ssf);
|
||||
|
||||
PtrList<surfaceVectorField> svf;
|
||||
readFields
|
||||
(
|
||||
vMesh,
|
||||
vMesh.baseMesh(),
|
||||
objects,
|
||||
selectedFields,
|
||||
svf
|
||||
);
|
||||
print(" surfVectorFields :", Info, svf);
|
||||
|
||||
const faceZoneMesh& zones = mesh.faceZones();
|
||||
|
||||
forAll(zones, zoneI)
|
||||
{
|
||||
const faceZone& pp = zones[zoneI];
|
||||
const faceZone& fz = zones[zoneI];
|
||||
|
||||
mkDir(fvPath/pp.name());
|
||||
mkDir(fvPath/fz.name());
|
||||
|
||||
fileName patchFileName;
|
||||
|
||||
if (vMesh.useSubMesh())
|
||||
{
|
||||
patchFileName =
|
||||
fvPath/pp.name()/cellSetName
|
||||
fvPath/fz.name()/cellSetName
|
||||
+ "_"
|
||||
+ timeDesc
|
||||
+ ".vtk";
|
||||
@ -984,7 +1006,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
patchFileName =
|
||||
fvPath/pp.name()/pp.name()
|
||||
fvPath/fz.name()/fz.name()
|
||||
+ "_"
|
||||
+ timeDesc
|
||||
+ ".vtk";
|
||||
@ -992,18 +1014,31 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< " FaceZone : " << patchFileName << endl;
|
||||
|
||||
std::ofstream ostr(patchFileName.c_str());
|
||||
|
||||
writeFuns::writeHeader(ostr, binary, pp.name());
|
||||
ostr<< "DATASET POLYDATA" << std::endl;
|
||||
|
||||
writePatchGeom
|
||||
indirectPrimitivePatch pp
|
||||
(
|
||||
binary,
|
||||
pp().localFaces(),
|
||||
pp().localPoints(),
|
||||
ostr
|
||||
IndirectList<face>(mesh.faces(), fz),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
surfaceMeshWriter writer
|
||||
(
|
||||
vMesh,
|
||||
binary,
|
||||
pp,
|
||||
fz.name(),
|
||||
patchFileName
|
||||
);
|
||||
|
||||
// Number of fields
|
||||
writeFuns::writeCellDataHeader
|
||||
(
|
||||
writer.os(),
|
||||
pp.size(),
|
||||
ssf.size()+svf.size()
|
||||
);
|
||||
|
||||
writer.write(ssf);
|
||||
writer.write(svf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,60 +23,63 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writePatchGeom.H"
|
||||
#include "OFstream.H"
|
||||
#include "floatScalar.H"
|
||||
#include "surfaceMeshWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writePatchGeom
|
||||
Foam::surfaceMeshWriter::surfaceMeshWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const faceList& faces,
|
||||
const pointField& points,
|
||||
std::ofstream& ostr
|
||||
const indirectPrimitivePatch& pp,
|
||||
const word& name,
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
pp_(pp),
|
||||
fName_(fName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
ostr<< "POINTS " << points.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*points.size());
|
||||
|
||||
writeFuns::insert(points, ptField);
|
||||
|
||||
writeFuns::write(ostr, binary, ptField);
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, name);
|
||||
|
||||
os_ << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
// Write topology
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(faces, faceI)
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
nFaceVerts += faces[faceI].size() + 1;
|
||||
nFaceVerts += pp[faceI].size() + 1;
|
||||
}
|
||||
ostr<< "POLYGONS " << faces.size() << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
os_ << "POINTS " << pp.nPoints() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*pp.nPoints());
|
||||
writeFuns::insert(pp.localPoints(), ptField);
|
||||
writeFuns::write(os_, binary, ptField);
|
||||
|
||||
|
||||
os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(faces, faceI)
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
const face& f = pp.localFaces()[faceI];
|
||||
|
||||
vertLabels.append(f.size());
|
||||
|
||||
writeFuns::insert(f, vertLabels);
|
||||
}
|
||||
writeFuns::write(ostr, binary, vertLabels);
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ 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::surfaceMeshWriter
|
||||
|
||||
Description
|
||||
Write faces with fields
|
||||
|
||||
SourceFiles
|
||||
surfaceMeshWriter.C
|
||||
surfaceMeshWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceMeshWriter_H
|
||||
#define surfaceMeshWriter_H
|
||||
|
||||
#include "pointMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceMeshWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceMeshWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const indirectPrimitivePatch& pp_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
// label nPoints_;
|
||||
//
|
||||
// label nFaces_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfaceMeshWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const indirectPrimitivePatch& pp,
|
||||
const word& name,
|
||||
const fileName&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
// label nPoints() const
|
||||
// {
|
||||
// return nPoints_;
|
||||
// }
|
||||
//
|
||||
// label nFaces() const
|
||||
// {
|
||||
// return nFaces_;
|
||||
// }
|
||||
//
|
||||
// //- Write cellIDs
|
||||
// void writePatchIDs();
|
||||
|
||||
//- Extract face data
|
||||
template<class Type>
|
||||
tmp<Field<Type> > getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>&
|
||||
) const;
|
||||
|
||||
//- Write surfaceFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "surfaceMeshWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ 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 "surfaceMeshWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Field<Type> > Foam::surfaceMeshWriter::getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
|
||||
|
||||
tmp<Field<Type> > tfld(new Field<Type>(pp_.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(pp_.addressing(), i)
|
||||
{
|
||||
label faceI = pp_.addressing()[i];
|
||||
|
||||
label patchI = patches.whichPatch(faceI);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
fld[i] = sfld[faceI];
|
||||
}
|
||||
else
|
||||
{
|
||||
label localFaceI = faceI - patches[patchI].start();
|
||||
fld[i] = sfld.boundaryField()[patchI][localFaceI];
|
||||
}
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::surfaceMeshWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& sflds
|
||||
)
|
||||
{
|
||||
forAll(sflds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& fld =
|
||||
sflds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< pp_.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*pp_.size());
|
||||
writeFuns::insert(getFaceField(fld)(), fField);
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,62 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
||||
\\/ 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::writePatchGeom
|
||||
|
||||
Description
|
||||
Write patch geometry to stream
|
||||
|
||||
SourceFiles
|
||||
writePatchGeom.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writePatchGeom_H
|
||||
#define writePatchGeom_H
|
||||
|
||||
#include "faceList.H"
|
||||
#include "pointField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write patch geometry
|
||||
void writePatchGeom
|
||||
(
|
||||
const bool binary,
|
||||
const faceList& faces,
|
||||
const pointField& points,
|
||||
std::ofstream&
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user