surfMesh gets surfPointFields, surfaceFormats write() for surf mesh components

- add placeholder BoundaryMesh to surfMesh allows us to drop the
  SurfGeoMesh class and just reuse the GeoMesh class.
  Do the same for triSurface.
This commit is contained in:
Mark Olesen
2009-02-05 22:41:22 +01:00
parent a4d0094e48
commit 22f6b4dc06
46 changed files with 641 additions and 368 deletions

View File

@ -59,6 +59,7 @@ Note
#include "triSurface.H" #include "triSurface.H"
#include "surfMesh.H" #include "surfMesh.H"
#include "surfFields.H" #include "surfFields.H"
#include "surfPointFields.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "MeshedSurfaces.H" #include "MeshedSurfaces.H"
@ -312,6 +313,30 @@ int main(int argc, char *argv[])
Info<< "write zoneIds (for testing only): " Info<< "write zoneIds (for testing only): "
<< zoneIds.objectPath() << endl; << zoneIds.objectPath() << endl;
zoneIds.write(); zoneIds.write();
surfPointLabelField pointIds
(
IOobject
(
"pointIds",
surfOut.instance(),
"pointFields",
surfOut,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfOut,
dimless
);
forAll(pointIds, i)
{
pointIds[i] = i;
}
Info<< "write pointIds (for testing only): "
<< pointIds.objectPath() << endl;
pointIds.write();
} }
} }

View File

@ -8,6 +8,7 @@ UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
surfaceRegistry/surfaceRegistry.C surfaceRegistry/surfaceRegistry.C
surfFields/surfFields.C surfFields/surfFields.C
surfPointFields/surfPointFields.C
surfMesh/surfMesh.C surfMesh/surfMesh.C
surfMesh/surfMeshClear.C surfMesh/surfMeshClear.C
surfMesh/surfMeshIO.C surfMesh/surfMeshIO.C

View File

@ -51,30 +51,6 @@ const word surfSymmTensorField::typeName("surfSymmTensorField");
template<> template<>
const word surfTensorField::typeName("surfTensorField"); const word surfTensorField::typeName("surfTensorField");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<DimensionedField<scalar, surfMesh> >
DimensionedField<scalar, surfMesh>::component
(
const direction
) const
{
return *this;
}
template<>
void DimensionedField<scalar, surfMesh>::replace
(
const direction,
const DimensionedField<scalar, surfMesh>& sf
)
{
*this == sf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -42,32 +42,6 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<DimensionedField<scalar, surfMesh> >
DimensionedField<scalar, surfMesh>::component
(
const direction
) const;
template<>
void DimensionedField<scalar, surfMesh>::replace
(
const direction,
const DimensionedField<scalar, surfMesh>& sf
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,14 +27,15 @@ Class
Description Description
The surfMesh GeoMesh (for holding fields). The surfMesh GeoMesh (for holding fields).
Similar to a volGeoMesh needed to do the Finite Volume discretisation.
Similar to the volGeoMesh used for the Finite Volume discretization.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfGeoMesh_H #ifndef surfGeoMesh_H
#define surfGeoMesh_H #define surfGeoMesh_H
#include "SurfGeoMesh.H" #include "GeoMesh.H"
#include "surfMesh.H" #include "surfMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +49,7 @@ namespace Foam
class surfGeoMesh class surfGeoMesh
: :
public SurfGeoMesh<surfMesh> public GeoMesh<surfMesh>
{ {
public: public:
@ -58,7 +59,7 @@ public:
//- Construct from surfMesh reference //- Construct from surfMesh reference
explicit surfGeoMesh(const surfMesh& mesh) explicit surfGeoMesh(const surfMesh& mesh)
: :
SurfGeoMesh<surfMesh>(mesh) GeoMesh<surfMesh>(mesh)
{} {}

View File

@ -166,6 +166,9 @@ public:
typedef surfMesh Mesh; typedef surfMesh Mesh;
//- Placeholder only, but do not remove - it is needed for GeoMesh
typedef bool BoundaryMesh;
//- Runtime type information //- Runtime type information
TypeName("surfMesh"); TypeName("surfMesh");

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "surfPointFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const word surfPointLabelField::typeName("surfPointLabelField");
template<>
const word surfPointScalarField::typeName("surfPointScalarField");
template<>
const word surfPointVectorField::typeName("surfPointVectorField");
template<>
const word surfPointSphericalTensorField::typeName("surfPointSphericalTensorField");
template<>
const word surfPointSymmTensorField::typeName("surfPointSymmTensorField");
template<>
const word surfPointTensorField::typeName("surfPointTensorField");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::surfPointFields
Description
Point fields for surfMesh
SourceFiles
surfPointFields.C
\*---------------------------------------------------------------------------*/
#ifndef surfPointFields_H
#define surfPointFields_H
#include "DimensionedField.H"
#include "surfPointGeoMesh.H"
#include "surfPointFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#ifndef surfPointFieldsFwd_H
#define surfPointFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class surfPointGeoMesh;
template<class Type, class GeoMesh>
class DimensionedField;
typedef DimensionedField<label, surfPointGeoMesh>
surfPointLabelField;
typedef DimensionedField<scalar, surfPointGeoMesh>
surfPointScalarField;
typedef DimensionedField<vector, surfPointGeoMesh>
surfPointVectorField;
typedef DimensionedField<sphericalTensor, surfPointGeoMesh>
surfPointSphericalTensorField;
typedef DimensionedField<symmTensor, surfPointGeoMesh>
surfPointSymmTensorField;
typedef DimensionedField<tensor, surfPointGeoMesh>
surfPointTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,20 +23,20 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::SurfGeoMesh Foam::surfPointGeoMesh
Description Description
Generic mesh wrapper used by surfMesh etc. The surfMesh GeoMesh (for holding fields).
Similar to Foam::GeoMesh, but for meshes without an underlying Similar to surfGeoMesh, but refers to the surface points.
BoundaryMesh.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef SurfGeoMesh_H #ifndef surfPointGeoMesh_H
#define SurfGeoMesh_H #define surfPointGeoMesh_H
#include "objectRegistry.H" #include "GeoMesh.H"
#include "surfMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,53 +44,39 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class SurfGeoMesh Declaration Class surfPointGeoMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class MESH> class surfPointGeoMesh
class SurfGeoMesh :
public GeoMesh<surfMesh>
{ {
protected:
// Protected data
//- Reference to Mesh
const MESH& mesh_;
public: public:
// Public typedefs
typedef MESH Mesh;
// typedef typename MESH::BoundaryMesh BoundaryMesh;
// Constructors // Constructors
//- Construct from MESH reference //- Construct from surfMesh reference
explicit SurfGeoMesh(const MESH& mesh) explicit surfPointGeoMesh(const surfMesh& mesh)
: :
mesh_(mesh) GeoMesh<surfMesh>(mesh)
{} {}
// Member Functions // Member Functions
//- Return the object registry //- Return size
const objectRegistry& thisDb() const static label size(const surfMesh& mesh)
{ {
return mesh_; return mesh.nPoints();
} }
//- Return size
// Member Operators label size() const
//- Return reference to underlying mesh
const MESH& operator()() const
{ {
return mesh_; return size(mesh_);
} }
}; };

View File

@ -282,13 +282,11 @@ template<class Face>
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, zoneLst); writeHeader(os, zoneLst);
forAll(zoneLst, zoneI) forAll(zoneLst, zoneI)
@ -336,6 +334,17 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
( (

View File

@ -56,7 +56,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class AC3DfileFormat Declaration Class AC3DsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -102,6 +102,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -49,7 +49,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class AC3DfileFormat Declaration Class AC3DsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class AC3DsurfaceFormatCore class AC3DsurfaceFormatCore

View File

@ -65,11 +65,11 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
List<ftrPatch> ftrPatches(is); List<ftrPatch> ftrPatches(is);
// read points directly // points read directly
is >> this->storedPoints(); is >> this->storedPoints();
// faces read with keys // triFaces read with attached keys
List<Keyed<triFace> > facesRead(is); List< Keyed<triFace> > facesRead(is);
List<Face> faceLst(facesRead.size()); List<Face> faceLst(facesRead.size());
List<label> zoneIds(facesRead.size()); List<label> zoneIds(facesRead.size());
@ -78,12 +78,13 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
forAll(facesRead, faceI) forAll(facesRead, faceI)
{ {
// unfortunately cannot transfer to save memory // unfortunately cannot transfer to save memory
faceLst[faceI] = facesRead[faceI]; faceLst[faceI] = facesRead[faceI];
zoneIds[faceI] = facesRead[faceI].key(); zoneIds[faceI] = facesRead[faceI].key();
} }
this->storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
this->storedZoneIds().transfer(zoneIds); this->storedZoneIds().transfer(zoneIds);
facesRead.clear();
// change ftrPatch into surfZoneIdentifier // change ftrPatch into surfZoneIdentifier
List<surfZoneIdentifier> newZones(ftrPatches.size()); List<surfZoneIdentifier> newZones(ftrPatches.size());

View File

@ -26,7 +26,7 @@ Class
Foam::fileFormats::FTRsurfaceFormat Foam::fileFormats::FTRsurfaceFormat
Description Description
Reading of the (now deprecated) Foam Trisurface Format. Reading of the (now deprecated and barely used) Foam Trisurface Format.
SourceFiles SourceFiles
FTRsurfaceFormat.C FTRsurfaceFormat.C
@ -48,7 +48,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class FTRsurfaceFormat Declaration Class FTRsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>

View File

@ -50,7 +50,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class GTSsurfaceFormat Declaration Class GTSsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>

View File

@ -58,7 +58,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class NASsurfaceFormat Declaration Class NASsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>

View File

@ -47,7 +47,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class NASsurfaceFormatCore Declaration Class NASsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class NASsurfaceFormatCore class NASsurfaceFormatCore

View File

@ -214,13 +214,12 @@ template<class Face>
void Foam::fileFormats::OBJsurfaceFormat<Face>::write void Foam::fileFormats::OBJsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const List<Face>& faceLst = surf.faces(); writeHeader(os, pointLst, faceLst.size(), zoneLst);
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0; label faceIndex = 0;
forAll(zoneLst, zoneI) forAll(zoneLst, zoneI)
@ -245,6 +244,17 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::OBJsurfaceFormat<Face>::write void Foam::fileFormats::OBJsurfaceFormat<Face>::write
( (

View File

@ -52,7 +52,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class OBJsurfaceFormat Declaration Class OBJsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -98,6 +98,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -49,7 +49,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class OBJsurfaceFormatCore Declaration Class OBJsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class OBJsurfaceFormatCore class OBJsurfaceFormatCore

View File

@ -151,6 +151,52 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
} }
template<class Face>
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
(
Ostream& os,
const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
)
{
writeHeader(os, pointLst, faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(zoneLst, zoneI)
{
os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
// add optional zone information
os << ' ' << zoneI << endl;
}
os << "# </zone>" << endl;
}
os << "# </faces>" << endl;
}
template<class Face>
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::OFFsurfaceFormat<Face>::write void Foam::fileFormats::OFFsurfaceFormat<Face>::write
( (
@ -189,39 +235,4 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::OFFsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
const List<Face>& faceLst = surf.faces();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(zoneLst, zoneI)
{
os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
os << f.size();
forAll(f, fp)
{
os << ' ' << f[fp];
}
// add optional zone information
os << ' ' << zoneI << endl;
}
os << "# </zone>" << endl;
}
os << "# </faces>" << endl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -60,7 +60,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class OFFsurfaceFormat Declaration Class OFFsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -104,6 +104,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -49,7 +49,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class OFFsurfaceFormatCore Declaration Class OFFsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class OFFsurfaceFormatCore class OFFsurfaceFormatCore

View File

@ -42,13 +42,12 @@ template<class Face>
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const List<Face>& faceLst = surf.faces(); writeHeader(os, pointLst, faceLst.size());
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size());
label faceIndex = 0; label faceIndex = 0;
forAll(zoneLst, zoneI) forAll(zoneLst, zoneI)
@ -70,6 +69,17 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
( (

View File

@ -57,7 +57,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class SMESHsurfaceFormat Declaration Class SMESHsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -91,6 +91,15 @@ public:
// Member Functions // Member Functions
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -48,7 +48,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class SMESHsurfaceFormatCore Declaration Class SMESHsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class SMESHsurfaceFormatCore class SMESHsurfaceFormatCore

View File

@ -221,18 +221,17 @@ template<class Face>
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
( (
const fileName& filename, const fileName& filename,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
fileName baseName = filename.lessExt(); fileName baseName = filename.lessExt();
writePoints(OFstream(baseName + ".vrt")(), surf.points()); writePoints(OFstream(baseName + ".vrt")(), pointLst);
OFstream os(baseName + ".cel"); OFstream os(baseName + ".cel");
writeHeader(os, "CELL"); writeHeader(os, "CELL");
const List<Face>& faceLst = surf.faces();
const List<surfZone>& zoneLst = surf.zones();
label faceIndex = 0; label faceIndex = 0;
forAll(zoneLst, zoneI) forAll(zoneLst, zoneI)
{ {
@ -249,10 +248,22 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
writeCase writeCase
( (
OFstream(baseName + ".inp")(), OFstream(baseName + ".inp")(),
surf.points(), pointLst,
surf.size(), faceLst.size(),
zoneLst zoneLst
); );
}
template<class Face>
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
(
const fileName& filename,
const MeshedSurface<Face>& surf
)
{
write(filename, surf.points(), surf.faces(), surf.zones());
} }
@ -266,7 +277,6 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
fileName baseName = filename.lessExt(); fileName baseName = filename.lessExt();
writePoints(OFstream(baseName + ".vrt")(), surf.points()); writePoints(OFstream(baseName + ".vrt")(), surf.points());
OFstream os(baseName + ".cel"); OFstream os(baseName + ".cel");
writeHeader(os, "CELL"); writeHeader(os, "CELL");

View File

@ -56,7 +56,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class STARCDsurfaceFormat Declaration Class STARCDsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -66,6 +66,7 @@ class STARCDsurfaceFormat
public STARCDsurfaceFormatCore public STARCDsurfaceFormatCore
{ {
// Private Data // Private Data
//- STAR-CD identifier for shell shapes (2d elements) //- STAR-CD identifier for shell shapes (2d elements)
static const int starcdShellShape_ = 3; static const int starcdShellShape_ = 3;
@ -116,6 +117,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components
static void write
(
const fileName&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -49,7 +49,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class STARCDsurfaceFormatCore Declaration Class STARCDsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class STARCDsurfaceFormatCore class STARCDsurfaceFormatCore

View File

@ -38,7 +38,6 @@ SourceFiles
#include "point.H" #include "point.H"
#include "Istream.H" #include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,7 +45,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class STLpoint Declaration Class STLpoint Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class STLpoint class STLpoint
@ -83,7 +82,7 @@ public:
// Member Operators // Member Operators
//- Return point //- Conversion to point
inline operator point() const inline operator point() const
{ {
return point(x(), y(), z()); return point(x(), y(), z());

View File

@ -26,6 +26,7 @@ License
#include "STLsurfaceFormat.H" #include "STLsurfaceFormat.H"
#include "ListOps.H" #include "ListOps.H"
#include "triPointRef.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -36,10 +37,18 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
( (
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const Face& f, const Face& f
const vector& norm
) )
{ {
// calculate the normal ourselves, for flexibility and speed
vector norm = triPointRef
(
pointLst[f[0]],
pointLst[f[1]],
pointLst[f[2]]
).normal();
norm /= mag(norm) + VSMALL;
// simple triangulation about f[0]. // simple triangulation about f[0].
// better triangulation should have been done before // better triangulation should have been done before
const point& p0 = pointLst[f[0]]; const point& p0 = pointLst[f[0]];
@ -69,10 +78,18 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
ostream& os, ostream& os,
const pointField& pointLst, const pointField& pointLst,
const Face& f, const Face& f,
const vector& norm,
const label zoneI const label zoneI
) )
{ {
// calculate the normal ourselves, for flexibility and speed
vector norm = triPointRef
(
pointLst[f[0]],
pointLst[f[1]],
pointLst[f[2]]
).normal();
norm /= mag(norm) + VSMALL;
// simple triangulation about f[0]. // simple triangulation about f[0].
// better triangulation should have been done before // better triangulation should have been done before
const point& p0 = pointLst[f[0]]; const point& p0 = pointLst[f[0]];
@ -94,96 +111,17 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
} }
// write sorted:
template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfZone>& zoneLst = surf.zones();
const vectorField& normLst = surf.faceNormals();
label faceIndex = 0;
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
const label faceI = faceIndex++;
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << zone.name() << endl;
}
}
// write sorted:
template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
(
Ostream& os,
const UnsortedMeshedSurface<Face>& surf
)
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
if (surf.zoneToc().size() == 1)
{
// a single zone - we can skip sorting
os << "solid " << surf.zoneToc()[0].name() << endl;
forAll(faceLst, faceI)
{
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << surf.zoneToc()[0].name() << endl;
}
else
{
labelList faceMap;
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << zone.name() << endl;
}
}
}
template<class Face> template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
( (
ostream& os, ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
const List<surfZone>& zoneLst = surf.zones();
unsigned int nTris = 0; unsigned int nTris = 0;
if (surf.isTri()) if (BasicMeshedSurface<Face>::isTri())
{ {
nTris = faceLst.size(); nTris = faceLst.size();
} }
@ -208,18 +146,14 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
( (
os, os,
pointLst, pointLst,
faceLst[faceIndex], faceLst[faceIndex++],
normLst[faceIndex],
zoneI zoneI
); );
++faceIndex;
} }
} }
} }
// write unsorted:
template<class Face> template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
( (
@ -230,7 +164,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<label>& zoneIds = surf.zoneIds(); const List<label>& zoneIds = surf.zoneIds();
const vectorField& normLst = surf.faceNormals();
unsigned int nTris = 0; unsigned int nTris = 0;
if (surf.isTri()) if (surf.isTri())
@ -257,7 +190,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
os, os,
pointLst, pointLst,
faceLst[faceI], faceLst[faceI],
normLst[faceI],
zoneIds[faceI] zoneIds[faceI]
); );
} }
@ -346,10 +278,24 @@ template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::write void Foam::fileFormats::STLsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const UnsortedMeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
writeASCII(os, surf); label faceIndex = 0;
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
writeShell(os, pointLst, faceLst[faceIndex++]);
}
os << "endsolid " << zone.name() << endl;
}
} }
@ -360,29 +306,50 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
const MeshedSurface<Face>& surf const MeshedSurface<Face>& surf
) )
{ {
writeASCII(os, surf); write(os, surf.points(), surf.faces(), surf.zones());
} }
template<class Face> template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::write void Foam::fileFormats::STLsurfaceFormat<Face>::write
( (
const fileName& filename, Ostream& os,
const UnsortedMeshedSurface<Face>& surf const UnsortedMeshedSurface<Face>& surf
) )
{ {
word ext = filename.ext(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
// handle 'stlb' as binary directly if (surf.zoneToc().size() == 1)
if (ext == "stlb")
{ {
std::ofstream ofs(filename.c_str(), std::ios::binary); // a single zone - we can skip sorting
writeBINARY(ofs, surf); os << "solid " << surf.zoneToc()[0].name() << endl;
} forAll(faceLst, faceI)
else {
{ writeShell(os, pointLst, faceLst[faceI]);
writeASCII(OFstream(filename)(), surf); }
os << "endsolid " << surf.zoneToc()[0].name() << endl;
} }
else
{
labelList faceMap;
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI]);
}
os << "endsolid " << zone.name() << endl;
}
}
} }
@ -403,8 +370,37 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
} }
else else
{ {
writeASCII(OFstream(filename)(), surf); write
(
OFstream(filename)(),
surf.points(),
surf.faces(),
surf.zones()
);
} }
} }
template<class Face>
void Foam::fileFormats::STLsurfaceFormat<Face>::write
(
const fileName& filename,
const UnsortedMeshedSurface<Face>& surf
)
{
word ext = filename.ext();
// handle 'stlb' as binary directly
if (ext == "stlb")
{
std::ofstream ofs(filename.c_str(), std::ios::binary);
writeBINARY(ofs, surf);
}
else
{
write(OFstream(filename)(), surf);
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -68,8 +68,7 @@ class STLsurfaceFormat
( (
Ostream&, Ostream&,
const pointField&, const pointField&,
const Face&, const Face&
const vector& norm
); );
//- Write Face in BINARY //- Write Face in BINARY
@ -78,24 +77,22 @@ class STLsurfaceFormat
ostream&, ostream&,
const pointField&, const pointField&,
const Face&, const Face&,
const vector&,
const label zoneI const label zoneI
); );
//- Write UnsortedMeshedSurface //- Write surface mesh components (as BINARY)
static void writeASCII(Ostream&, const UnsortedMeshedSurface<Face>&); static void writeBINARY
(
ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write UnsortedMeshedSurface //- Write UnsortedMeshedSurface
static void writeBINARY(ostream&, const UnsortedMeshedSurface<Face>&); static void writeBINARY(ostream&, const UnsortedMeshedSurface<Face>&);
//- Write MeshedSurface
static void writeASCII(Ostream&, const MeshedSurface<Face>&);
//- Write MeshedSurface
static void writeBINARY(ostream&, const MeshedSurface<Face>&);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
STLsurfaceFormat(const STLsurfaceFormat<Face>&); STLsurfaceFormat(const STLsurfaceFormat<Face>&);
@ -128,6 +125,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components (as ASCII)
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface (as ASCII) //- Write MeshedSurface (as ASCII)
static void write static void write
( (
@ -135,7 +141,7 @@ public:
const MeshedSurface<Face>& const MeshedSurface<Face>&
); );
//- Write MeshedSurface //- Write MeshedSurface (ASCII or BINARY, depending on the extension)
static void write static void write
( (
const fileName&, const fileName&,

View File

@ -56,8 +56,13 @@ class STLtriangle
//- Attribute is 16-bit //- Attribute is 16-bit
typedef unsigned short STLattrib; typedef unsigned short STLattrib;
STLpoint normal_, a_, b_, c_; //- The face normal, many programs write zore or other junk
STLpoint normal_;
//- The three points defining the triangle
STLpoint a_, b_, c_;
//- The attribute information could for colour or solid id, etc
STLattrib attrib_; STLattrib attrib_;
public: public:

View File

@ -56,7 +56,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfaceFormatsCore Declaration Class surfaceFormatsCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class surfaceFormatsCore class surfaceFormatsCore

View File

@ -132,13 +132,11 @@ template<class Face>
void Foam::fileFormats::TRIsurfaceFormat<Face>::write void Foam::fileFormats::TRIsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfZone>& zoneLst = surf.zones();
label faceIndex = 0; label faceIndex = 0;
forAll(zoneLst, zoneI) forAll(zoneLst, zoneI)
{ {
@ -151,6 +149,17 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::TRIsurfaceFormat<Face>::write void Foam::fileFormats::TRIsurfaceFormat<Face>::write
( (

View File

@ -54,7 +54,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class TRIsurfaceFormat Declaration Class TRIsurfaceFormat Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Face> template<class Face>
@ -105,6 +105,15 @@ public:
//- Read from file //- Read from file
virtual bool read(const fileName&); virtual bool read(const fileName&);
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -50,7 +50,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class TRIsurfaceFormatCore Declaration Class TRIsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class TRIsurfaceFormatCore class TRIsurfaceFormatCore

View File

@ -62,13 +62,12 @@ template<class Face>
void Foam::fileFormats::VTKsurfaceFormat<Face>::write void Foam::fileFormats::VTKsurfaceFormat<Face>::write
( (
Ostream& os, Ostream& os,
const MeshedSurface<Face>& surf const pointField& pointLst,
const List<Face>& faceLst,
const List<surfZone>& zoneLst
) )
{ {
const List<Face>& faceLst = surf.faces(); writeHeader(os, pointLst);
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points());
writeHeaderPolygons(os, faceLst); writeHeaderPolygons(os, faceLst);
label faceIndex = 0; label faceIndex = 0;
@ -91,6 +90,17 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
} }
template<class Face>
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
(
Ostream& os,
const MeshedSurface<Face>& surf
)
{
write(os, surf.points(), surf.faces(), surf.zones());
}
template<class Face> template<class Face>
void Foam::fileFormats::VTKsurfaceFormat<Face>::write void Foam::fileFormats::VTKsurfaceFormat<Face>::write
( (

View File

@ -89,6 +89,15 @@ public:
// Write // Write
//- Write surface mesh components
static void write
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfZone>&
);
//- Write MeshedSurface //- Write MeshedSurface
static void write static void write
( (

View File

@ -49,7 +49,7 @@ namespace fileFormats
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class VTKsurfaceFormatCore Declaration Class VTKsurfaceFormatCore Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class VTKsurfaceFormatCore class VTKsurfaceFormatCore

View File

@ -54,7 +54,7 @@ bool triSurface::stitchTriangles
<< " points down to " << newPoints.size() << endl; << " points down to " << newPoints.size() << endl;
} }
pointField& ps = const_cast<pointField&>(points()); pointField& ps = storedPoints();
// Set the coordinates to the merged ones // Set the coordinates to the merged ones
ps = newPoints; ps = newPoints;

View File

@ -471,8 +471,7 @@ Foam::boolList Foam::triSurface::checkOrientation(const bool verbose)
// Read triangles, points from Istream // Read triangles, points from Istream
bool Foam::triSurface::read(Istream& is) bool Foam::triSurface::read(Istream& is)
{ {
is >> patches_ >> const_cast<pointField&>(points()) is >> patches_ >> storedPoints() >> storedFaces();
>> static_cast<List<labelledTri>&>(*this);
return true; return true;
} }
@ -724,7 +723,7 @@ void Foam::triSurface::setDefaultPatches()
Foam::triSurface::triSurface() Foam::triSurface::triSurface()
: :
MeshStorage(List<FaceType>(), pointField()), ParentType(List<Face>(), pointField()),
patches_(0), patches_(0),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -739,7 +738,7 @@ Foam::triSurface::triSurface
const pointField& points const pointField& points
) )
: :
MeshStorage(triangles, points), ParentType(triangles, points),
patches_(patches), patches_(patches),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -754,7 +753,7 @@ Foam::triSurface::triSurface
const bool reUse const bool reUse
) )
: :
MeshStorage(triangles, points, reUse), ParentType(triangles, points, reUse),
patches_(patches), patches_(patches),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -767,7 +766,7 @@ Foam::triSurface::triSurface
const pointField& points const pointField& points
) )
: :
MeshStorage(triangles, points), ParentType(triangles, points),
patches_(), patches_(),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -782,7 +781,7 @@ Foam::triSurface::triSurface
const pointField& points const pointField& points
) )
: :
MeshStorage(convertToTri(triangles, 0), points), ParentType(convertToTri(triangles, 0), points),
patches_(), patches_(),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -793,7 +792,7 @@ Foam::triSurface::triSurface
Foam::triSurface::triSurface(const fileName& name) Foam::triSurface::triSurface(const fileName& name)
: :
MeshStorage(List<FaceType>(), pointField()), ParentType(List<Face>(), pointField()),
patches_(), patches_(),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -808,7 +807,7 @@ Foam::triSurface::triSurface(const fileName& name)
Foam::triSurface::triSurface(Istream& is) Foam::triSurface::triSurface(Istream& is)
: :
MeshStorage(List<FaceType>(), pointField()), ParentType(List<Face>(), pointField()),
patches_(), patches_(),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -821,7 +820,7 @@ Foam::triSurface::triSurface(Istream& is)
Foam::triSurface::triSurface(const Time& d) Foam::triSurface::triSurface(const Time& d)
: :
MeshStorage(List<FaceType>(), pointField()), ParentType(List<Face>(), pointField()),
patches_(), patches_(),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -840,7 +839,7 @@ Foam::triSurface::triSurface(const Time& d)
Foam::triSurface::triSurface(const triSurface& ts) Foam::triSurface::triSurface(const triSurface& ts)
: :
MeshStorage(ts, ts.points()), ParentType(ts, ts.points()),
patches_(ts.patches()), patches_(ts.patches()),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
@ -859,7 +858,7 @@ Foam::triSurface::~triSurface()
void Foam::triSurface::clearTopology() void Foam::triSurface::clearTopology()
{ {
MeshStorage::clearTopology(); ParentType::clearTopology();
deleteDemandDrivenData(sortedEdgeFacesPtr_); deleteDemandDrivenData(sortedEdgeFacesPtr_);
deleteDemandDrivenData(edgeOwnerPtr_); deleteDemandDrivenData(edgeOwnerPtr_);
} }
@ -867,13 +866,13 @@ void Foam::triSurface::clearTopology()
void Foam::triSurface::clearPatchMeshAddr() void Foam::triSurface::clearPatchMeshAddr()
{ {
MeshStorage::clearPatchMeshAddr(); ParentType::clearPatchMeshAddr();
} }
void Foam::triSurface::clearOut() void Foam::triSurface::clearOut()
{ {
MeshStorage::clearOut(); ParentType::clearOut();
clearTopology(); clearTopology();
clearPatchMeshAddr(); clearPatchMeshAddr();
@ -909,10 +908,10 @@ void Foam::triSurface::movePoints(const pointField& newPoints)
deleteDemandDrivenData(sortedEdgeFacesPtr_); deleteDemandDrivenData(sortedEdgeFacesPtr_);
// Adapt for new point position // Adapt for new point position
MeshStorage::movePoints(newPoints); ParentType::movePoints(newPoints);
// Copy new points // Copy new points
const_cast<pointField&>(points()) = newPoints; storedPoints() = newPoints;
} }
@ -926,9 +925,9 @@ void Foam::triSurface::scalePoints(const scalar& scaleFactor)
clearTopology(); clearTopology();
// Adapt for new point position // Adapt for new point position
MeshStorage::movePoints(pointField()); ParentType::movePoints(pointField());
const_cast<pointField&>(points()) *= scaleFactor; storedPoints() *= scaleFactor;
} }
} }
@ -1240,7 +1239,7 @@ void Foam::triSurface::operator=(const triSurface& ts)
{ {
List<labelledTri>::operator=(ts); List<labelledTri>::operator=(ts);
clearOut(); clearOut();
const_cast<pointField&>(points()) = ts.points(); storedPoints() = ts.points();
patches_ = ts.patches(); patches_ = ts.patches();
} }

View File

@ -58,27 +58,21 @@ class IFstream;
class triSurface class triSurface
: :
public PrimitivePatch<labelledTri, List, pointField, point> public PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
{ {
protected:
// Protected Member Data
//- Typedef for similar code in keyedSurface and meshedSurface
typedef labelledTri FaceType;
private:
// Private typedefs // Private typedefs
//- Typedefs for convenience
typedef labelledTri Face;
typedef PrimitivePatch typedef PrimitivePatch
< <
FaceType, labelledTri,
::Foam::List, ::Foam::List,
pointField, pointField,
point point
> >
MeshStorage; ParentType;
// Private data // Private data
@ -201,17 +195,39 @@ private:
//- helper function to print triangle info //- helper function to print triangle info
static void printTriangle static void printTriangle
( (
Ostream& os, Ostream&,
const Foam::string& pre, const Foam::string& pre,
const labelledTri& f, const labelledTri&,
const pointField& points const pointField&
); );
//- read non-comment line //- read non-comment line
static string getLineNoComment(IFstream&); static string getLineNoComment(IFstream&);
protected:
// Protected Member Functions
//- Non-const access to global points
pointField& storedPoints()
{
return const_cast<pointField&>(ParentType::points());
}
//- Non-const access to the faces
List<Face>& storedFaces()
{
return static_cast<List<Face>&>(*this);
}
public: public:
// Public typedefs
//- Placeholder only, but do not remove - it is needed for GeoMesh
typedef bool BoundaryMesh;
//- Runtime type information //- Runtime type information
ClassName("triSurface"); ClassName("triSurface");

View File

@ -25,8 +25,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "triSurfaceFields.H" #include "triSurfaceFields.H"
#include "DimensionedField.H"
#include "triSurfaceGeoMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,13 +26,16 @@ Class
Foam::triSurfaceGeoMesh Foam::triSurfaceGeoMesh
Description Description
The triSurface geoMesh The triSurface GeoMesh (for holding fields).
Similar to the volGeoMesh used for the Finite Volume discretization.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef triSurfaceGeoMesh_H #ifndef triSurfaceGeoMesh_H
#define triSurfaceGeoMesh_H #define triSurfaceGeoMesh_H
#include "GeoMesh.H"
#include "triSurface.H" #include "triSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,52 +46,33 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class triSurfaceGeoMesh class triSurfaceGeoMesh
:
public GeoMesh<triSurface>
{ {
protected:
// Protected data
//- Reference to Mesh
const triSurface& mesh_;
public: public:
// Public typedefs
typedef triSurface Mesh;
// Constructors // Constructors
//- Construct from Mesh //- Construct from triSurface reference
explicit triSurfaceGeoMesh(const triSurface& mesh) explicit triSurfaceGeoMesh(const triSurface& mesh)
: :
mesh_(mesh) GeoMesh<triSurface>(mesh)
{} {}
// Member Functions // Member Functions
//- Return size
label size() const
{
return size(mesh_);
}
//- Return size //- Return size
static label size(const triSurface& mesh) static label size(const triSurface& mesh)
{ {
return mesh.size(); return mesh.size();
} }
// Member Operators //- Return size
label size() const
//- Return reference to triSurface
const triSurface& operator()() const
{ {
return mesh_; return size(mesh_);
} }
}; };