mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
foamToVTK.C
|
||||
internalWriter.C
|
||||
lagrangianWriter.C
|
||||
patchWriter.C
|
||||
writeFuns.C
|
||||
writePatchGeom.C
|
||||
writeFaceSet.C
|
||||
writePointSet.C
|
||||
writeSurfFields.C
|
||||
|
||||
vtkMesh.C
|
||||
vtkTopo.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToVTK
|
||||
@ -0,0 +1,10 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lmeshTools \
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "internalWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::internalWriter::internalWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
fName_(fName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const vtkTopo& topo = vMesh_.topo();
|
||||
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
|
||||
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Write topology
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os_ << "POINTS " << nTotPoints
|
||||
<< " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*nTotPoints);
|
||||
|
||||
writeFuns::insert(mesh.points(), ptField);
|
||||
|
||||
const pointField& ctrs = mesh.cellCentres();
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, ptField);
|
||||
|
||||
|
||||
//
|
||||
// Write cells
|
||||
//
|
||||
|
||||
const labelListList& vtkVertLabels = topo.vertLabels();
|
||||
|
||||
// Count total number of vertices referenced.
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(vtkVertLabels, cellI)
|
||||
{
|
||||
nFaceVerts += vtkVertLabels[cellI].size() + 1;
|
||||
}
|
||||
|
||||
os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts
|
||||
<< std::endl;
|
||||
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(vtkVertLabels, cellI)
|
||||
{
|
||||
const labelList& vtkVerts = vtkVertLabels[cellI];
|
||||
|
||||
vertLabels.append(vtkVerts.size());
|
||||
|
||||
writeFuns::insert(vtkVerts, vertLabels);
|
||||
}
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
|
||||
|
||||
|
||||
const labelList& vtkCellTypes = topo.cellTypes();
|
||||
|
||||
os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl;
|
||||
|
||||
// Make copy since writing might swap stuff.
|
||||
DynamicList<label> cellTypes(vtkCellTypes.size());
|
||||
|
||||
writeFuns::insert(vtkCellTypes, cellTypes);
|
||||
|
||||
writeFuns::write(os_, binary_, cellTypes);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::internalWriter::writeCellIDs()
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const vtkTopo& topo = vMesh_.topo();
|
||||
const labelList& vtkCellTypes = topo.cellTypes();
|
||||
const labelList& superCells = topo.superCells();
|
||||
|
||||
// Cell ids first
|
||||
os_ << "cellID 1 " << vtkCellTypes.size() << " int"
|
||||
<< std::endl;
|
||||
|
||||
labelList cellId(vtkCellTypes.size());
|
||||
label labelI = 0;
|
||||
|
||||
|
||||
if (vMesh_.useSubMesh())
|
||||
{
|
||||
const labelList& cMap = vMesh_.subsetter().cellMap();
|
||||
|
||||
forAll(mesh.cells(), cellI)
|
||||
{
|
||||
cellId[labelI++] = cMap[cellI];
|
||||
}
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = cMap[superCells[superCellI]];
|
||||
|
||||
cellId[labelI++] = origCellI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(mesh.cells(), cellI)
|
||||
{
|
||||
cellId[labelI++] = cellI;
|
||||
}
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = superCells[superCellI];
|
||||
|
||||
cellId[labelI++] = origCellI;
|
||||
}
|
||||
}
|
||||
|
||||
writeFuns::write(os_, binary_, cellId);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,123 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::internalWriter
|
||||
|
||||
Description
|
||||
Write fields (internal).
|
||||
|
||||
SourceFiles
|
||||
internalWriter.C
|
||||
internalWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef internalWriter_H
|
||||
#define internalWriter_H
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class internalWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class internalWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
internalWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const fileName&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
//- Write cellIDs
|
||||
void writeCellIDs();
|
||||
|
||||
//- Write generic GeometricFields
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const volPointInterpolation&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "internalWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "internalWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::internalWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
writeFuns::write(os_, binary_, flds[i], vMesh_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::internalWriter::write
|
||||
(
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
writeFuns::write
|
||||
(
|
||||
os_,
|
||||
binary_,
|
||||
flds[i],
|
||||
pInterp.interpolate(flds[i])(),
|
||||
vMesh_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "lagrangianWriter.H"
|
||||
#include "writeFuns.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::lagrangianWriter::lagrangianWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const fileName& fName,
|
||||
const word& cloudName
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
fName_(fName),
|
||||
cloudName_(cloudName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
|
||||
os_ << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName_, false);
|
||||
|
||||
nParcels_ = parcels.size();
|
||||
|
||||
os_ << "POINTS " << parcels.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> partField(3*parcels.size());
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
writeFuns::insert(elmnt().position(), partField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, partField);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::lagrangianWriter::writeParcelHeader(const label nFields)
|
||||
{
|
||||
os_ << "POINT_DATA " << nParcels_ << std::endl
|
||||
<< "FIELD attributes " << nFields
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::lagrangianWriter
|
||||
|
||||
Description
|
||||
Write fields (internal).
|
||||
|
||||
SourceFiles
|
||||
lagrangianWriter.C
|
||||
lagrangianWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef lagrangianWriter_H
|
||||
#define lagrangianWriter_H
|
||||
|
||||
#include "globalPointPatch.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class lagrangianWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class lagrangianWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
const word cloudName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
label nParcels_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
lagrangianWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const fileName&,
|
||||
const word&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
void writeParcelHeader(const label nFields);
|
||||
|
||||
//- Write IOField
|
||||
template<class Type>
|
||||
void writeIOField(const wordList&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "lagrangianWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "lagrangianWriter.H"
|
||||
#include "writeFuns.H"
|
||||
#include "IOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::lagrangianWriter::writeIOField(const wordList& objects)
|
||||
{
|
||||
forAll(objects, i)
|
||||
{
|
||||
const word& object = objects[i];
|
||||
|
||||
IOobject header
|
||||
(
|
||||
object,
|
||||
vMesh_.mesh().time().timeName(),
|
||||
"lagrangian"/cloudName_,
|
||||
vMesh_.mesh(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
IOField<Type> fld(header);
|
||||
|
||||
os_ << object << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< fld.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*fld.size());
|
||||
|
||||
writeFuns::insert(fld, fField);
|
||||
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "patchWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::patchWriter::patchWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const bool nearCellValue,
|
||||
const fileName& fName,
|
||||
const labelList& patchIDs
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
nearCellValue_(nearCellValue),
|
||||
fName_(fName),
|
||||
patchIDs_(patchIDs),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Write header
|
||||
if (patchIDs_.size() == 1)
|
||||
{
|
||||
writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::writeHeader(os_, binary_, "patches");
|
||||
}
|
||||
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
|
||||
|
||||
// Write topology
|
||||
nPoints_ = 0;
|
||||
nFaces_ = 0;
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
nPoints_ += pp.nPoints();
|
||||
nFaces_ += pp.size();
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
nFaceVerts += pp[faceI].size() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
os_ << "POINTS " << nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*nPoints_);
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
writeFuns::insert(pp.localPoints(), ptField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, ptField);
|
||||
|
||||
os_ << "CELLS " << nFaces_ << ' ' << nFaceVerts
|
||||
<< std::endl;
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
DynamicList<label> faceTypes(nFaceVerts);
|
||||
|
||||
label offset = 0;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
const face& f = pp.localFaces()[faceI];
|
||||
|
||||
const label fSize = f.size();
|
||||
vertLabels.append(fSize);
|
||||
|
||||
writeFuns::insert(f + offset, vertLabels);
|
||||
|
||||
if (fSize == 3)
|
||||
{
|
||||
faceTypes.append(vtkTopo::VTK_TRIANGLE);
|
||||
}
|
||||
else if (fSize == 4)
|
||||
{
|
||||
faceTypes.append(vtkTopo::VTK_QUAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceTypes.append(vtkTopo::VTK_POLYGON);
|
||||
}
|
||||
}
|
||||
offset += pp.nPoints();
|
||||
}
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
|
||||
os_ << "CELL_TYPES " << nFaces_ << std::endl;
|
||||
|
||||
writeFuns::write(os_, binary_, faceTypes);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::patchWriter::writePatchIDs()
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
|
||||
DynamicList<floatScalar> fField(nFaces_);
|
||||
|
||||
os_ << "patchID 1 " << nFaces_ << " float" << std::endl;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
label patchI = patchIDs_[i];
|
||||
|
||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||
|
||||
if (!isType<emptyPolyPatch>(pp))
|
||||
{
|
||||
writeFuns::insert(scalarField(pp.size(), patchI), fField);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::patchWriter
|
||||
|
||||
Description
|
||||
Write patch fields
|
||||
|
||||
SourceFiles
|
||||
patchWriter.C
|
||||
patchWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchWriter_H
|
||||
#define patchWriter_H
|
||||
|
||||
#include "pointMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class patchWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const bool nearCellValue_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
const labelList patchIDs_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
label nPoints_;
|
||||
|
||||
label nFaces_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
patchWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const bool nearCellValue,
|
||||
const fileName&,
|
||||
const labelList& patchIDs
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
label nPoints() const
|
||||
{
|
||||
return nPoints_;
|
||||
}
|
||||
|
||||
label nFaces() const
|
||||
{
|
||||
return nFaces_;
|
||||
}
|
||||
|
||||
//- Write cellIDs
|
||||
void writePatchIDs();
|
||||
|
||||
//- Write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
|
||||
//- Write pointFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, pointPatchField, pointMesh> >&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PrimitivePatchInterpolation<primitivePatch>&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "patchWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,143 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "patchWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nFaces_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
if (nearCellValue_)
|
||||
{
|
||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::insert(pfld, fField);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, pointPatchField, pointMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& fld =
|
||||
flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const pointPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PrimitivePatchInterpolation<primitivePatch>& pInter,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
if (nearCellValue_)
|
||||
{
|
||||
writeFuns::insert
|
||||
(
|
||||
pInter.faceToPointInterpolate
|
||||
(
|
||||
pfld.patchInternalField()()
|
||||
)(),
|
||||
fField
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::insert
|
||||
(
|
||||
pInter.faceToPointInterpolate(pfld)(),
|
||||
fField
|
||||
);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readFields.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
//template<class GeoField, class Mesh>
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Construct the vol scalar fields
|
||||
fields.setSize(fieldObjects.size());
|
||||
label nFields = 0;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::iterator iter = fieldObjects.begin();
|
||||
iter != fieldObjects.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
if (!selectedFields.size() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields,
|
||||
new GeoField
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Construct the vol scalar fields
|
||||
fields.setSize(fieldObjects.size());
|
||||
label nFields = 0;
|
||||
|
||||
for
|
||||
(
|
||||
IOobjectList::iterator iter = fieldObjects.begin();
|
||||
iter != fieldObjects.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
if (!selectedFields.size() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields,
|
||||
vMesh.interpolate
|
||||
(
|
||||
GeoField
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
)
|
||||
)
|
||||
);
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::readFields
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
readFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef readFields_H
|
||||
#define readFields_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "PtrList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Read the fields and put on the pointer list
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
);
|
||||
|
||||
// Read the fields and optionally subset and put on the pointer list
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "readFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "Time.H"
|
||||
#include "cellSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::vtkMesh::vtkMesh
|
||||
(
|
||||
fvMesh& baseMesh,
|
||||
const word& setName
|
||||
)
|
||||
:
|
||||
baseMesh_(baseMesh),
|
||||
subsetter_(baseMesh),
|
||||
setName_(setName),
|
||||
topoPtr_(NULL)
|
||||
{
|
||||
if (setName.size() > 0)
|
||||
{
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
// Set current subset
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkMesh::~vtkMesh()
|
||||
{
|
||||
deleteDemandDrivenData(topoPtr_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
|
||||
{
|
||||
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
|
||||
|
||||
if (meshState != polyMesh::UNCHANGED)
|
||||
{
|
||||
// Note: since fvMeshSubset has no movePoints() functionality reconstruct
|
||||
// the subset even if only movement.
|
||||
|
||||
deleteDemandDrivenData(topoPtr_);
|
||||
|
||||
if (setName_.size() > 0)
|
||||
{
|
||||
Pout<< "Subsetting mesh based on cellSet " << setName_ << endl;
|
||||
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
return meshState;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,186 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::vtkMesh
|
||||
|
||||
Description
|
||||
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
|
||||
polyhedral-cell decomposition on it.
|
||||
|
||||
SourceFiles
|
||||
vtkMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkMesh_H
|
||||
#define vtkMesh_H
|
||||
|
||||
#include "vtkTopo.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkMesh
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
fvMesh& baseMesh_;
|
||||
|
||||
//- Subsetting engine
|
||||
fvMeshSubset subsetter_;
|
||||
|
||||
//- Current cellSet (or empty)
|
||||
const word setName_;
|
||||
|
||||
//- Current decomposition of topology
|
||||
mutable vtkTopo* topoPtr_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkMesh(const vtkMesh&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkMesh&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkMesh(fvMesh& baseMesh, const word& setName = "");
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~vtkMesh();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- whole mesh
|
||||
const fvMesh& baseMesh() const
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
|
||||
const fvMeshSubset& subsetter() const
|
||||
{
|
||||
return subsetter_;
|
||||
}
|
||||
|
||||
//- Check if running subMesh
|
||||
bool useSubMesh() const
|
||||
{
|
||||
return setName_.size() > 0;
|
||||
}
|
||||
|
||||
//- topology
|
||||
const vtkTopo& topo() const
|
||||
{
|
||||
if (!topoPtr_)
|
||||
{
|
||||
topoPtr_ = new vtkTopo(mesh());
|
||||
}
|
||||
return *topoPtr_;
|
||||
}
|
||||
|
||||
//- Access either mesh or submesh
|
||||
const fvMesh& mesh() const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
return subsetter_.subMesh();
|
||||
}
|
||||
else
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
}
|
||||
|
||||
//- Number of field cells
|
||||
label nFieldCells() const
|
||||
{
|
||||
return topo().cellTypes().size();
|
||||
}
|
||||
|
||||
//- Number of field points
|
||||
label nFieldPoints() const
|
||||
{
|
||||
return mesh().nPoints() + topo().addPointCellLabels().size();
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Read mesh
|
||||
polyMesh::readUpdateState readUpdate();
|
||||
|
||||
|
||||
//- Map volume field (does in fact do very little interpolation;
|
||||
// just copied from fvMeshSubset)
|
||||
template<class GeoField>
|
||||
tmp<GeoField> interpolate(const GeoField& fld) const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
tmp<GeoField> subFld = subsetter_.interpolate(fld);
|
||||
subFld().rename(fld.name());
|
||||
return subFld;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fld;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,299 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
Note: bug in vtk displaying wedges? Seems to display ok if we decompose
|
||||
them. Should be thoroughly tested!
|
||||
(they appear rarely in polyhedral meshes, do appear in some cut meshes)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkTopo.H"
|
||||
#include "polyMesh.H"
|
||||
#include "cellShape.H"
|
||||
#include "cellModeller.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::vtkTopo::vtkTopo(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh),
|
||||
vertLabels_(),
|
||||
cellTypes_(),
|
||||
addPointCellLabels_(),
|
||||
superCells_()
|
||||
{
|
||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
||||
const cellModel& prism = *(cellModeller::lookup("prism"));
|
||||
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||
|
||||
|
||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||
|
||||
|
||||
// Number of additional points needed by the decomposition of polyhedra
|
||||
label nAddPoints = 0;
|
||||
|
||||
// Number of additional cells generated by the decomposition of polyhedra
|
||||
label nAddCells = 0;
|
||||
|
||||
// Scan for cells which need to be decomposed and count additional points
|
||||
// and cells
|
||||
|
||||
forAll(cellShapes, cellI)
|
||||
{
|
||||
const cellModel& model = cellShapes[cellI].model();
|
||||
|
||||
if
|
||||
(
|
||||
model != hex
|
||||
// && model != wedge // See above.
|
||||
&& model != prism
|
||||
&& model != pyr
|
||||
&& model != tet
|
||||
&& model != tetWedge
|
||||
)
|
||||
{
|
||||
const cell& cFaces = mesh_.cells()[cellI];
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||
|
||||
label nQuads = 0;
|
||||
label nTris = 0;
|
||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
||||
|
||||
nAddCells += nQuads + nTris;
|
||||
}
|
||||
|
||||
nAddCells--;
|
||||
nAddPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set size of additional point addressing array
|
||||
// (from added point to original cell)
|
||||
addPointCellLabels_.setSize(nAddPoints);
|
||||
|
||||
// Set size of additional cells mapping array
|
||||
// (from added cell to original cell)
|
||||
superCells_.setSize(nAddCells);
|
||||
|
||||
// List of vertex labels in VTK ordering
|
||||
vertLabels_.setSize(cellShapes.size() + nAddCells);
|
||||
|
||||
// Label of vtk type
|
||||
cellTypes_.setSize(cellShapes.size() + nAddCells);
|
||||
|
||||
// Set counters for additional points and additional cells
|
||||
label api = 0, aci = 0;
|
||||
|
||||
forAll(cellShapes, cellI)
|
||||
{
|
||||
const cellShape& cellShape = cellShapes[cellI];
|
||||
const cellModel& cellModel = cellShape.model();
|
||||
|
||||
labelList& vtkVerts = vertLabels_[cellI];
|
||||
|
||||
if (cellModel == tet)
|
||||
{
|
||||
vtkVerts = cellShape;
|
||||
|
||||
cellTypes_[cellI] = VTK_TETRA;
|
||||
}
|
||||
else if (cellModel == pyr)
|
||||
{
|
||||
vtkVerts = cellShape;
|
||||
|
||||
cellTypes_[cellI] = VTK_PYRAMID;
|
||||
}
|
||||
else if (cellModel == prism)
|
||||
{
|
||||
vtkVerts.setSize(6);
|
||||
vtkVerts[0] = cellShape[0];
|
||||
vtkVerts[1] = cellShape[2];
|
||||
vtkVerts[2] = cellShape[1];
|
||||
vtkVerts[3] = cellShape[3];
|
||||
vtkVerts[4] = cellShape[5];
|
||||
vtkVerts[5] = cellShape[4];
|
||||
|
||||
// VTK calls this a wedge.
|
||||
cellTypes_[cellI] = VTK_WEDGE;
|
||||
}
|
||||
else if (cellModel == tetWedge)
|
||||
{
|
||||
// Treat as squeezed prism
|
||||
vtkVerts.setSize(6);
|
||||
vtkVerts[0] = cellShape[0];
|
||||
vtkVerts[1] = cellShape[2];
|
||||
vtkVerts[2] = cellShape[1];
|
||||
vtkVerts[3] = cellShape[3];
|
||||
vtkVerts[4] = cellShape[4];
|
||||
vtkVerts[5] = cellShape[4];
|
||||
|
||||
cellTypes_[cellI] = VTK_WEDGE;
|
||||
}
|
||||
// else if (cellModel == wedge)
|
||||
// {
|
||||
// // Treat as squeezed hex
|
||||
// vtkVerts.setSize(8);
|
||||
// vtkVerts[0] = cellShape[0];
|
||||
// vtkVerts[1] = cellShape[1];
|
||||
// vtkVerts[2] = cellShape[2];
|
||||
// vtkVerts[3] = cellShape[0];
|
||||
// vtkVerts[4] = cellShape[3];
|
||||
// vtkVerts[5] = cellShape[4];
|
||||
// vtkVerts[6] = cellShape[5];
|
||||
// vtkVerts[7] = cellShape[6];
|
||||
//
|
||||
// cellTypes_[cellI] = VTK_HEXAHEDRON;
|
||||
// }
|
||||
else if (cellModel == hex)
|
||||
{
|
||||
vtkVerts.setSize(8);
|
||||
vtkVerts[0] = cellShape[0];
|
||||
vtkVerts[1] = cellShape[1];
|
||||
vtkVerts[2] = cellShape[2];
|
||||
vtkVerts[3] = cellShape[3];
|
||||
vtkVerts[4] = cellShape[4];
|
||||
vtkVerts[5] = cellShape[5];
|
||||
vtkVerts[6] = cellShape[6];
|
||||
vtkVerts[7] = cellShape[7];
|
||||
|
||||
cellTypes_[cellI] = VTK_HEXAHEDRON;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Polyhedral cell. Decompose into tets + prisms.
|
||||
// (see dxFoamExec/createDxConnections.C)
|
||||
|
||||
// Mapping from additional point to cell
|
||||
addPointCellLabels_[api] = cellI;
|
||||
|
||||
// Whether to insert cell in place of original or not.
|
||||
bool substituteCell = true;
|
||||
|
||||
const labelList& cFaces = mesh_.cells()[cellI];
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||
|
||||
// Number of triangles and quads in decomposition
|
||||
label nTris = 0;
|
||||
label nQuads = 0;
|
||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
||||
|
||||
// Do actual decomposition into triFcs and quadFcs.
|
||||
faceList triFcs(nTris);
|
||||
faceList quadFcs(nQuads);
|
||||
label trii = 0;
|
||||
label quadi = 0;
|
||||
f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs);
|
||||
|
||||
forAll(quadFcs, quadi)
|
||||
{
|
||||
label thisCellI = -1;
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = cellI;
|
||||
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh_.nCells() + aci;
|
||||
|
||||
superCells_[aci] = cellI;
|
||||
|
||||
aci++;
|
||||
}
|
||||
|
||||
labelList& addVtkVerts = vertLabels_[thisCellI];
|
||||
|
||||
addVtkVerts.setSize(5);
|
||||
|
||||
const face& quad = quadFcs[quadi];
|
||||
|
||||
addVtkVerts[0] = quad[0];
|
||||
addVtkVerts[1] = quad[1];
|
||||
addVtkVerts[2] = quad[2];
|
||||
addVtkVerts[3] = quad[3];
|
||||
addVtkVerts[4] = mesh_.nPoints() + api;
|
||||
|
||||
cellTypes_[thisCellI] = VTK_PYRAMID;
|
||||
}
|
||||
|
||||
forAll(triFcs, trii)
|
||||
{
|
||||
label thisCellI = -1;
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = cellI;
|
||||
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh_.nCells() + aci;
|
||||
|
||||
superCells_[aci] = cellI;
|
||||
|
||||
aci++;
|
||||
}
|
||||
|
||||
|
||||
labelList& addVtkVerts = vertLabels_[thisCellI];
|
||||
|
||||
const face& tri = triFcs[trii];
|
||||
|
||||
addVtkVerts.setSize(4);
|
||||
addVtkVerts[0] = tri[0];
|
||||
addVtkVerts[1] = tri[1];
|
||||
addVtkVerts[2] = tri[2];
|
||||
addVtkVerts[3] = mesh_.nPoints() + api;
|
||||
|
||||
cellTypes_[thisCellI] = VTK_TETRA;
|
||||
}
|
||||
}
|
||||
|
||||
api++;
|
||||
}
|
||||
}
|
||||
|
||||
Pout<< " Original cells:" << mesh_.nCells()
|
||||
<< " points:" << mesh_.nPoints()
|
||||
<< " Additional cells:" << superCells_.size()
|
||||
<< " additional points:" << addPointCellLabels_.size()
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,133 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::vtkTopo
|
||||
|
||||
Description
|
||||
Polyhedral cell decomposition for VTK.
|
||||
|
||||
SourceFiles
|
||||
vtkTopo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkTopo_H
|
||||
#define vtkTopo_H
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkTopo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkTopo
|
||||
{
|
||||
// Private data
|
||||
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Vertices per cell (including added cells) in vtk ordering
|
||||
labelListList vertLabels_;
|
||||
|
||||
//- Cell types (including added cells) in vtk numbering
|
||||
labelList cellTypes_;
|
||||
|
||||
labelList addPointCellLabels_;
|
||||
|
||||
labelList superCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkTopo(const vtkTopo&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkTopo&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Public static data
|
||||
|
||||
static const label VTK_TRIANGLE = 5;
|
||||
static const label VTK_POLYGON = 9;
|
||||
static const label VTK_QUAD = 10;
|
||||
|
||||
static const label VTK_TETRA = 10;
|
||||
static const label VTK_PYRAMID = 14;
|
||||
static const label VTK_WEDGE = 13;
|
||||
static const label VTK_HEXAHEDRON = 12;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkTopo(const polyMesh& mesh);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const labelListList& vertLabels() const
|
||||
{
|
||||
return vertLabels_;
|
||||
}
|
||||
|
||||
const labelList& cellTypes() const
|
||||
{
|
||||
return cellTypes_;
|
||||
}
|
||||
|
||||
const labelList& addPointCellLabels() const
|
||||
{
|
||||
return addPointCellLabels_;
|
||||
}
|
||||
|
||||
const labelList& superCells() const
|
||||
{
|
||||
return superCells_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeFaceSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
const faceList& faces = vMesh.mesh().faces();
|
||||
|
||||
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
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// Construct primitivePatch of faces in faceSet.
|
||||
|
||||
faceList setFaces(set.size());
|
||||
labelList setFaceLabels(set.size());
|
||||
label setFaceI = 0;
|
||||
|
||||
for
|
||||
(
|
||||
faceSet::const_iterator iter = set.begin();
|
||||
iter != set.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
setFaceLabels[setFaceI] = iter.key();
|
||||
setFaces[setFaceI] = faces[iter.key()];
|
||||
setFaceI++;
|
||||
}
|
||||
primitiveFacePatch fp(setFaces, vMesh.mesh().points());
|
||||
|
||||
|
||||
// Write points and faces as polygons
|
||||
|
||||
pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*fp.nPoints());
|
||||
|
||||
writeFuns::insert(fp.localPoints(), ptField);
|
||||
|
||||
writeFuns::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());
|
||||
|
||||
writeFuns::insert(f, vertLabels);
|
||||
}
|
||||
writeFuns::write(pStream, binary, vertLabels);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// Write data
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
// Write faceID
|
||||
|
||||
pStream
|
||||
<< "CELL_DATA " << fp.size() << std::endl
|
||||
<< "FIELD attributes 1" << std::endl;
|
||||
|
||||
// Cell ids first
|
||||
pStream << "faceID 1 " << fp.size() << " int" << std::endl;
|
||||
|
||||
writeFuns::write(pStream, binary, setFaceLabels);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::writeFaceSet
|
||||
|
||||
Description
|
||||
Write faceSet to vtk polydata file. Only one data which is original
|
||||
faceID.
|
||||
|
||||
SourceFiles
|
||||
writeFaceSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeFaceSet_H
|
||||
#define writeFaceSet_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "faceSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write lagrangian fields.
|
||||
void writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,282 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeFuns.H"
|
||||
#include "vtkTopo.H"
|
||||
|
||||
#ifdef __mips
|
||||
#include <standards.h>
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
// MacOSX
|
||||
#ifdef __DARWIN_BYTE_ORDER
|
||||
#if __DARWIN_BYTE_ORDER==__DARWIN_BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#else
|
||||
#undef BIG_ENDIAN
|
||||
#endif
|
||||
#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(label& 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, label* 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<label*>(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(elems.size(), reinterpret_cast<label*>(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::writeHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const string& name
|
||||
)
|
||||
{
|
||||
os << "# vtk DataFile Version 2.0" << std::endl
|
||||
<< name << std::endl;
|
||||
|
||||
if (binary)
|
||||
{
|
||||
os << "BINARY" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "ASCII" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::writeCellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "CELL_DATA " << nCells << std::endl
|
||||
<< "FIELD attributes " << nFields << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::writePointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "POINT_DATA " << nPoints << std::endl
|
||||
<< "FIELD attributes " << nFields << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const scalar& pt, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
dest.append(float(pt));
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const vector& pt, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
|
||||
{
|
||||
dest.append(float(pt[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const sphericalTensor& pt,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; cmpt++)
|
||||
{
|
||||
dest.append(float(pt[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const symmTensor& pt,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < symmTensor::nComponents; cmpt++)
|
||||
{
|
||||
dest.append(float(pt[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const tensor& pt, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < tensor::nComponents; cmpt++)
|
||||
{
|
||||
dest.append(float(pt[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const labelList& source, DynamicList<label>& dest)
|
||||
{
|
||||
forAll(source, i)
|
||||
{
|
||||
dest.append(source[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::writeFunctions
|
||||
|
||||
Description
|
||||
Various functions for collecting and writing binary data.
|
||||
|
||||
SourceFiles
|
||||
writeFunctions.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeFunctions_H
|
||||
#define writeFunctions_H
|
||||
|
||||
#include "floatScalar.H"
|
||||
#include "DynamicList.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldsFwd.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeFuns Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeFuns
|
||||
{
|
||||
// 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, const string&);
|
||||
static void writeCellDataHeader(std::ostream&, const label, const label);
|
||||
static void writePointDataHeader
|
||||
(
|
||||
std::ostream&,
|
||||
const label,
|
||||
const label
|
||||
);
|
||||
|
||||
|
||||
// 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
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write pointField on all mesh points. Interpolate to cell centre
|
||||
// for decomposed cell centres.
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write interpolated field on points and original cell values on
|
||||
// decomposed cell centres.
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write generic GeometricFields
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const volPointInterpolation&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
const vtkMesh&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeFunsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,195 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeFuns.H"
|
||||
#include "interpolatePointToCell.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Store List in dest
|
||||
template<class Type>
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const List<Type>& source,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
forAll(source, i)
|
||||
{
|
||||
insert(source[i], dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// Store List (indexed through map) in dest
|
||||
//template<class Type>
|
||||
//void Foam::writeFuns::insert
|
||||
//(
|
||||
// const labelList& map,
|
||||
// const List<Type>& source,
|
||||
// DynamicList<floatScalar>& dest
|
||||
//)
|
||||
//{
|
||||
// forAll(map, i)
|
||||
// {
|
||||
// insert(source[map[i]], dest);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
|
||||
const labelList& superCells = vMesh.topo().superCells();
|
||||
|
||||
label nValues = mesh.nCells() + superCells.size();
|
||||
|
||||
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nValues << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
|
||||
|
||||
insert(vvf.internalField(), fField);
|
||||
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = superCells[superCellI];
|
||||
|
||||
insert(vvf[origCellI], fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
const vtkTopo& topo = vMesh.topo();
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nTotPoints << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||
|
||||
insert(pvf, fField);
|
||||
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
label origCellI = addPointCellLabels[api];
|
||||
|
||||
insert(interpolatePointToCell(pvf, origCellI), fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vvf,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
const vtkTopo& topo = vMesh.topo();
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nTotPoints << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||
|
||||
insert(pvf, fField);
|
||||
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
label origCellI = addPointCellLabels[api];
|
||||
|
||||
insert(vvf[origCellI], fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
write(os, binary, flds[i], vMesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writePatchGeom.H"
|
||||
#include "OFstream.H"
|
||||
#include "floatScalar.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writePatchGeom
|
||||
(
|
||||
const bool binary,
|
||||
const faceList& faces,
|
||||
const pointField& points,
|
||||
std::ofstream& pStream
|
||||
)
|
||||
{
|
||||
pStream << "POINTS " << points.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*points.size());
|
||||
|
||||
writeFuns::insert(points, ptField);
|
||||
|
||||
writeFuns::write(pStream, binary, ptField);
|
||||
|
||||
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
nFaceVerts += faces[faceI].size() + 1;
|
||||
}
|
||||
pStream << "POLYGONS " << faces.size() << ' ' << nFaceVerts
|
||||
<< std::endl;
|
||||
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
vertLabels.append(f.size());
|
||||
|
||||
writeFuns::insert(f, vertLabels);
|
||||
}
|
||||
writeFuns::write(pStream, binary, vertLabels);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
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 lagrangian fields.
|
||||
void writePatchGeom
|
||||
(
|
||||
const bool binary,
|
||||
const faceList& faces,
|
||||
const pointField& points,
|
||||
std::ofstream& pStream
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writePointSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const pointSet& 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
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// Write points
|
||||
|
||||
pStream << "POINTS " << set.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*set.size());
|
||||
|
||||
writeFuns::insert
|
||||
(
|
||||
IndirectList<point>(vMesh.mesh().points(), set.toc())(),
|
||||
ptField
|
||||
);
|
||||
|
||||
writeFuns::write(pStream, binary, ptField);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// Write data
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
// Write faceID
|
||||
|
||||
pStream
|
||||
<< "POINT_DATA " << set.size() << std::endl
|
||||
<< "FIELD attributes 1" << std::endl;
|
||||
|
||||
// Cell ids first
|
||||
pStream << "pointID 1 " << set.size() << " int" << std::endl;
|
||||
|
||||
labelList pointIDs(set.toc());
|
||||
|
||||
writeFuns::write(pStream, binary, pointIDs);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::writePointSet
|
||||
|
||||
Description
|
||||
Write pointSet to vtk polydata file. Only one data which is original
|
||||
pointID.
|
||||
|
||||
SourceFiles
|
||||
writePointSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writePointSet_H
|
||||
#define writePointSet_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "pointSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write lagrangian fields.
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeSurfFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "floatScalar.H"
|
||||
#include "writeFuns.H"
|
||||
#include "emptyFvPatchFields.H"
|
||||
#include "fvsPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writeSurfFields
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const fileName& fileName,
|
||||
const PtrList<surfaceVectorField>& surfVectorFields
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
|
||||
std::ofstream str(fileName.c_str());
|
||||
|
||||
str << "# vtk DataFile Version 2.0" << std::endl
|
||||
<< "surfaceFields" << std::endl;
|
||||
|
||||
if (binary)
|
||||
{
|
||||
str << "BINARY" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
str << "ASCII" << std::endl;
|
||||
}
|
||||
str << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
const pointField& fc = mesh.faceCentres();
|
||||
|
||||
str << "POINTS " << mesh.nFaces() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> pField(3*mesh.nFaces());
|
||||
|
||||
for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
|
||||
{
|
||||
writeFuns::insert(fc[faceI], pField);
|
||||
}
|
||||
|
||||
writeFuns::write(str, binary, pField);
|
||||
|
||||
str << "POINT_DATA " << mesh.nFaces() << std::endl
|
||||
<< "FIELD attributes " << surfVectorFields.size() << std::endl;
|
||||
|
||||
// surfVectorFields
|
||||
forAll(surfVectorFields, fieldI)
|
||||
{
|
||||
const surfaceVectorField& svf = surfVectorFields[fieldI];
|
||||
|
||||
str << svf.name() << " 3 "
|
||||
<< mesh.nFaces() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(3*mesh.nFaces());
|
||||
|
||||
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||
{
|
||||
writeFuns::insert(svf[faceI], fField);
|
||||
}
|
||||
|
||||
forAll(svf.boundaryField(), patchI)
|
||||
{
|
||||
const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
|
||||
|
||||
const fvPatch& pp = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<emptyFvPatchVectorField>(pf))
|
||||
{
|
||||
// Note: loop over polypatch size, not fvpatch size.
|
||||
forAll(pp.patch(), i)
|
||||
{
|
||||
writeFuns::insert(vector::zero, fField);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(pf, i)
|
||||
{
|
||||
writeFuns::insert(pf[i], fField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeFuns::write(str, binary, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::writeSurfFields
|
||||
|
||||
Description
|
||||
Write a patch with its data.
|
||||
|
||||
SourceFiles
|
||||
writeSurfFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeSurfFields_H
|
||||
#define writeSurfFields_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "surfaceMesh.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write lagrangian fields.
|
||||
void writeSurfFields
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const fileName& fileName,
|
||||
const PtrList<surfaceVectorField>& surfVectorFields
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user