mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: replace writeFuncs in setSet with foamVtk library utilities
This commit is contained in:
@ -266,6 +266,10 @@ meshStructure/meshStructure.C
|
||||
meshStructure/topoDistanceData.C
|
||||
meshStructure/pointTopoDistanceData.C
|
||||
|
||||
output/foamVtkWriteFaceSet.C
|
||||
output/foamVtkWritePointSet.C
|
||||
output/foamVtkWriteCellSetFaces.C
|
||||
|
||||
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
|
||||
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledPolyPatch.C
|
||||
regionCoupled/patches/regionCoupledPolyPatch/regionCoupledWallPolyPatch.C
|
||||
|
||||
139
src/meshTools/output/foamVtkWriteCellSetFaces.C
Normal file
139
src/meshTools/output/foamVtkWriteCellSetFaces.C
Normal file
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "foamVtkWriteCellSetFaces.H"
|
||||
#include "foamVtkOutputOptions.H"
|
||||
#include "OFstream.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "cellSet.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkOutput::writeCellSetFaces
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const cellSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// External faces of cellset with OpenFOAM cellID as value
|
||||
|
||||
Map<label> cellFaces(2*set.size());
|
||||
|
||||
forAllConstIters(set, iter)
|
||||
{
|
||||
label celli = iter.key();
|
||||
const cell& cFaces = mesh.cells()[celli];
|
||||
|
||||
forAll(cFaces, i)
|
||||
{
|
||||
label facei = cFaces[i];
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
label otherCelli = mesh.faceOwner()[facei];
|
||||
|
||||
if (otherCelli == celli)
|
||||
{
|
||||
otherCelli = mesh.faceNeighbour()[facei];
|
||||
}
|
||||
|
||||
if (!set.found(otherCelli))
|
||||
{
|
||||
cellFaces.insert(facei, celli);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cellFaces.insert(facei, celli);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelList faceLabels = cellFaces.sortedToc();
|
||||
labelList faceValues(cellFaces.size());
|
||||
|
||||
forAll(faceLabels, facei)
|
||||
{
|
||||
faceValues[facei] = cellFaces[faceLabels[facei]]; // Cell ID
|
||||
}
|
||||
|
||||
uindirectPrimitivePatch pp
|
||||
(
|
||||
UIndirectList<face>(mesh.faces(), faceLabels),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Write points and faces as polygons
|
||||
os << "POINTS " << pp.nPoints() << " float" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), pp.localPoints());
|
||||
format().flush();
|
||||
|
||||
label count = pp.size();
|
||||
forAll(pp, facei)
|
||||
{
|
||||
count += pp.localFaces()[facei].size();
|
||||
}
|
||||
os << "POLYGONS " << pp.size() << ' ' << count << nl;
|
||||
|
||||
forAll(pp, facei)
|
||||
{
|
||||
const face& f = pp.localFaces()[facei];
|
||||
|
||||
format().write(f.size());
|
||||
foamVtkOutput::writeList(format(), f);
|
||||
}
|
||||
format().flush();
|
||||
|
||||
|
||||
// Write data - faceId/cellId
|
||||
foamVtkOutput::legacy::cellDataHeader(os, pp.size(), 1);
|
||||
|
||||
os << "cellID 1 " << pp.size() << " int" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), faceValues);
|
||||
format().flush();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
72
src/meshTools/output/foamVtkWriteCellSetFaces.H
Normal file
72
src/meshTools/output/foamVtkWriteCellSetFaces.H
Normal file
@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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/>.
|
||||
|
||||
InNamespace
|
||||
Foam::foamVtkOutput
|
||||
|
||||
Description
|
||||
Write faces of cellSet to vtk polydata file.
|
||||
|
||||
The data are the original cell ids
|
||||
|
||||
SourceFiles
|
||||
foamVtkWriteCellSetFaces.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkWriteCellSetFaces_H
|
||||
#define foamVtkWriteCellSetFaces_H
|
||||
|
||||
#include "primitiveMesh.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class primitiveMesh;
|
||||
class cellSet;
|
||||
class fileName;
|
||||
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
//- Write perimeter faces of cellset to vtk polydata file.
|
||||
// The data are the original cell ids
|
||||
void writeCellSetFaces
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const cellSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
97
src/meshTools/output/foamVtkWriteFaceSet.C
Normal file
97
src/meshTools/output/foamVtkWriteFaceSet.C
Normal file
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "foamVtkWriteFaceSet.H"
|
||||
#include "foamVtkOutputOptions.H"
|
||||
#include "OFstream.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "faceSet.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkOutput::writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Faces of set with OpenFOAM faceID as value
|
||||
labelList faceLabels = set.sortedToc();
|
||||
|
||||
uindirectPrimitivePatch pp
|
||||
(
|
||||
UIndirectList<face>(mesh.faces(), faceLabels),
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Write points and faces as polygons
|
||||
os << "POINTS " << pp.nPoints() << " float" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), pp.localPoints());
|
||||
format().flush();
|
||||
|
||||
label count = pp.size();
|
||||
forAll(pp, facei)
|
||||
{
|
||||
count += pp.localFaces()[facei].size();
|
||||
}
|
||||
os << "POLYGONS " << pp.size() << ' ' << count << nl;
|
||||
|
||||
forAll(pp, facei)
|
||||
{
|
||||
const face& f = pp.localFaces()[facei];
|
||||
|
||||
format().write(f.size());
|
||||
foamVtkOutput::writeList(format(), f);
|
||||
}
|
||||
format().flush();
|
||||
|
||||
// Write data - faceId/cellId
|
||||
os << "faceID 1 " << pp.size() << " int" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), faceLabels);
|
||||
format().flush();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
69
src/meshTools/output/foamVtkWriteFaceSet.H
Normal file
69
src/meshTools/output/foamVtkWriteFaceSet.H
Normal file
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::foamVtkOutput
|
||||
|
||||
Description
|
||||
Write faceSet to vtk polydata file.
|
||||
The data are the original point ids.
|
||||
|
||||
SourceFiles
|
||||
foamVtkWritePointSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkWriteFaceSet_H
|
||||
#define foamVtkWriteFaceSet_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class primitiveMesh;
|
||||
class faceSet;
|
||||
class fileName;
|
||||
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
//- Write pointSet to vtk polydata file.
|
||||
// Only one data which is original pointID.
|
||||
void writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
74
src/meshTools/output/foamVtkWritePointSet.C
Normal file
74
src/meshTools/output/foamVtkWritePointSet.C
Normal file
@ -0,0 +1,74 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "foamVtkWritePointSet.H"
|
||||
#include "foamVtkOutputOptions.H"
|
||||
#include "OFstream.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "pointSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkOutput::writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
const labelList pointLabels(set.sortedToc());
|
||||
|
||||
// Write points
|
||||
os << "POINTS " << pointLabels.size() << " float" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), mesh.points(), pointLabels);
|
||||
format().flush();
|
||||
|
||||
|
||||
// Write data - pointID
|
||||
foamVtkOutput::legacy::pointDataHeader(os, pointLabels.size(), 1);
|
||||
|
||||
os << "pointID 1 " << pointLabels.size() << " int" << nl;
|
||||
|
||||
foamVtkOutput::writeList(format(), pointLabels);
|
||||
format().flush();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
69
src/meshTools/output/foamVtkWritePointSet.H
Normal file
69
src/meshTools/output/foamVtkWritePointSet.H
Normal file
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::foamVtkOutput
|
||||
|
||||
Description
|
||||
Write pointSet to vtk polydata file.
|
||||
The data are the original point ids.
|
||||
|
||||
SourceFiles
|
||||
foamVtkWritePointSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkWritePointSet_H
|
||||
#define foamVtkWritePointSet_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class primitiveMesh;
|
||||
class pointSet;
|
||||
class fileName;
|
||||
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
//- Write pointSet to vtk polydata file.
|
||||
// The data are the original point ids.
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user