mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -59,6 +59,7 @@ Note
|
||||
#include "triSurface.H"
|
||||
#include "surfMesh.H"
|
||||
#include "surfFields.H"
|
||||
#include "surfPointFields.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
@ -312,6 +313,30 @@ int main(int argc, char *argv[])
|
||||
Info<< "write zoneIds (for testing only): "
|
||||
<< zoneIds.objectPath() << endl;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
surfaceRegistry/surfaceRegistry.C
|
||||
surfFields/surfFields.C
|
||||
surfPointFields/surfPointFields.C
|
||||
surfMesh/surfMesh.C
|
||||
surfMesh/surfMeshClear.C
|
||||
surfMesh/surfMeshIO.C
|
||||
|
||||
@ -51,30 +51,6 @@ const word surfSymmTensorField::typeName("surfSymmTensorField");
|
||||
template<>
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,14 +27,15 @@ Class
|
||||
|
||||
Description
|
||||
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
|
||||
#define surfGeoMesh_H
|
||||
|
||||
#include "SurfGeoMesh.H"
|
||||
#include "GeoMesh.H"
|
||||
#include "surfMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -48,7 +49,7 @@ namespace Foam
|
||||
|
||||
class surfGeoMesh
|
||||
:
|
||||
public SurfGeoMesh<surfMesh>
|
||||
public GeoMesh<surfMesh>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -58,7 +59,7 @@ public:
|
||||
//- Construct from surfMesh reference
|
||||
explicit surfGeoMesh(const surfMesh& mesh)
|
||||
:
|
||||
SurfGeoMesh<surfMesh>(mesh)
|
||||
GeoMesh<surfMesh>(mesh)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -166,6 +166,9 @@ public:
|
||||
|
||||
typedef surfMesh Mesh;
|
||||
|
||||
//- Placeholder only, but do not remove - it is needed for GeoMesh
|
||||
typedef bool BoundaryMesh;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfMesh");
|
||||
|
||||
58
src/surfMesh/surfPointFields/surfPointFields.C
Normal file
58
src/surfMesh/surfPointFields/surfPointFields.C
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
47
src/surfMesh/surfPointFields/surfPointFields.H
Normal file
47
src/surfMesh/surfPointFields/surfPointFields.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
65
src/surfMesh/surfPointFields/surfPointFieldsFwd.H
Normal file
65
src/surfMesh/surfPointFields/surfPointFieldsFwd.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,20 +23,20 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::SurfGeoMesh
|
||||
Foam::surfPointGeoMesh
|
||||
|
||||
Description
|
||||
Generic mesh wrapper used by surfMesh etc.
|
||||
The surfMesh GeoMesh (for holding fields).
|
||||
|
||||
Similar to Foam::GeoMesh, but for meshes without an underlying
|
||||
BoundaryMesh.
|
||||
Similar to surfGeoMesh, but refers to the surface points.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SurfGeoMesh_H
|
||||
#define SurfGeoMesh_H
|
||||
#ifndef surfPointGeoMesh_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 SurfGeoMesh
|
||||
class surfPointGeoMesh
|
||||
:
|
||||
public GeoMesh<surfMesh>
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to Mesh
|
||||
const MESH& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
// Public typedefs
|
||||
|
||||
typedef MESH Mesh;
|
||||
// typedef typename MESH::BoundaryMesh BoundaryMesh;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from MESH reference
|
||||
explicit SurfGeoMesh(const MESH& mesh)
|
||||
//- Construct from surfMesh reference
|
||||
explicit surfPointGeoMesh(const surfMesh& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
GeoMesh<surfMesh>(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the object registry
|
||||
const objectRegistry& thisDb() const
|
||||
//- Return size
|
||||
static label size(const surfMesh& mesh)
|
||||
{
|
||||
return mesh_;
|
||||
return mesh.nPoints();
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return reference to underlying mesh
|
||||
const MESH& operator()() const
|
||||
//- Return size
|
||||
label size() const
|
||||
{
|
||||
return mesh_;
|
||||
return size(mesh_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -282,13 +282,11 @@ template<class Face>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
(
|
||||
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);
|
||||
|
||||
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>
|
||||
void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
(
|
||||
|
||||
@ -56,7 +56,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
Class AC3DsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -102,6 +102,15 @@ public:
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
Class AC3DsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AC3DsurfaceFormatCore
|
||||
|
||||
@ -65,11 +65,11 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||
|
||||
List<ftrPatch> ftrPatches(is);
|
||||
|
||||
// read points directly
|
||||
// points read directly
|
||||
is >> this->storedPoints();
|
||||
|
||||
// faces read with keys
|
||||
List<Keyed<triFace> > facesRead(is);
|
||||
// triFaces read with attached keys
|
||||
List< Keyed<triFace> > facesRead(is);
|
||||
|
||||
List<Face> faceLst(facesRead.size());
|
||||
List<label> zoneIds(facesRead.size());
|
||||
@ -78,12 +78,13 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||
forAll(facesRead, faceI)
|
||||
{
|
||||
// unfortunately cannot transfer to save memory
|
||||
faceLst[faceI] = facesRead[faceI];
|
||||
faceLst[faceI] = facesRead[faceI];
|
||||
zoneIds[faceI] = facesRead[faceI].key();
|
||||
}
|
||||
|
||||
this->storedFaces().transfer(faceLst);
|
||||
this->storedZoneIds().transfer(zoneIds);
|
||||
facesRead.clear();
|
||||
|
||||
// change ftrPatch into surfZoneIdentifier
|
||||
List<surfZoneIdentifier> newZones(ftrPatches.size());
|
||||
|
||||
@ -26,7 +26,7 @@ Class
|
||||
Foam::fileFormats::FTRsurfaceFormat
|
||||
|
||||
Description
|
||||
Reading of the (now deprecated) Foam Trisurface Format.
|
||||
Reading of the (now deprecated and barely used) Foam Trisurface Format.
|
||||
|
||||
SourceFiles
|
||||
FTRsurfaceFormat.C
|
||||
@ -48,7 +48,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FTRsurfaceFormat Declaration
|
||||
Class FTRsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
|
||||
@ -50,7 +50,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class GTSsurfaceFormat Declaration
|
||||
Class GTSsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
|
||||
@ -58,7 +58,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class NASsurfaceFormat Declaration
|
||||
Class NASsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
|
||||
@ -47,7 +47,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class NASsurfaceFormatCore Declaration
|
||||
Class NASsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class NASsurfaceFormatCore
|
||||
|
||||
@ -214,13 +214,12 @@ template<class Face>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfZone>& zoneLst
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfZone>& zoneLst = surf.zones();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
|
||||
writeHeader(os, pointLst, faceLst.size(), zoneLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
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>
|
||||
void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
(
|
||||
|
||||
@ -52,7 +52,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OBJsurfaceFormat Declaration
|
||||
Class OBJsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -98,6 +98,15 @@ public:
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OBJsurfaceFormatCore Declaration
|
||||
Class OBJsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OBJsurfaceFormatCore
|
||||
|
||||
@ -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>
|
||||
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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -60,7 +60,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFFsurfaceFormat Declaration
|
||||
Class OFFsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -104,6 +104,15 @@ public:
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFFsurfaceFormatCore Declaration
|
||||
Class OFFsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OFFsurfaceFormatCore
|
||||
|
||||
@ -42,13 +42,12 @@ template<class Face>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfZone>& zoneLst
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfZone>& zoneLst = surf.zones();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
writeHeader(os, pointLst, faceLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
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>
|
||||
void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
(
|
||||
|
||||
@ -57,7 +57,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SMESHsurfaceFormat Declaration
|
||||
Class SMESHsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -91,6 +91,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -48,7 +48,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SMESHsurfaceFormatCore Declaration
|
||||
Class SMESHsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class SMESHsurfaceFormatCore
|
||||
|
||||
@ -221,18 +221,17 @@ template<class Face>
|
||||
void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& filename,
|
||||
const MeshedSurface<Face>& surf
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfZone>& zoneLst
|
||||
)
|
||||
{
|
||||
fileName baseName = filename.lessExt();
|
||||
|
||||
writePoints(OFstream(baseName + ".vrt")(), surf.points());
|
||||
writePoints(OFstream(baseName + ".vrt")(), pointLst);
|
||||
OFstream os(baseName + ".cel");
|
||||
writeHeader(os, "CELL");
|
||||
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfZone>& zoneLst = surf.zones();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(zoneLst, zoneI)
|
||||
{
|
||||
@ -249,10 +248,22 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
writeCase
|
||||
(
|
||||
OFstream(baseName + ".inp")(),
|
||||
surf.points(),
|
||||
surf.size(),
|
||||
pointLst,
|
||||
faceLst.size(),
|
||||
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();
|
||||
|
||||
writePoints(OFstream(baseName + ".vrt")(), surf.points());
|
||||
|
||||
OFstream os(baseName + ".cel");
|
||||
writeHeader(os, "CELL");
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STARCDsurfaceFormat Declaration
|
||||
Class STARCDsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -66,6 +66,7 @@ class STARCDsurfaceFormat
|
||||
public STARCDsurfaceFormatCore
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- STAR-CD identifier for shell shapes (2d elements)
|
||||
static const int starcdShellShape_ = 3;
|
||||
|
||||
@ -116,6 +117,15 @@ public:
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STARCDsurfaceFormatCore Declaration
|
||||
Class STARCDsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STARCDsurfaceFormatCore
|
||||
|
||||
@ -38,7 +38,6 @@ SourceFiles
|
||||
|
||||
#include "point.H"
|
||||
#include "Istream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,7 +45,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLpoint Declaration
|
||||
Class STLpoint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class STLpoint
|
||||
@ -83,7 +82,7 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return point
|
||||
//- Conversion to point
|
||||
inline operator point() const
|
||||
{
|
||||
return point(x(), y(), z());
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "STLsurfaceFormat.H"
|
||||
#include "ListOps.H"
|
||||
#include "triPointRef.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -36,10 +37,18 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
(
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm
|
||||
const Face& f
|
||||
)
|
||||
{
|
||||
// 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].
|
||||
// better triangulation should have been done before
|
||||
const point& p0 = pointLst[f[0]];
|
||||
@ -69,10 +78,18 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
ostream& os,
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm,
|
||||
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].
|
||||
// better triangulation should have been done before
|
||||
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>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
(
|
||||
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;
|
||||
if (surf.isTri())
|
||||
if (BasicMeshedSurface<Face>::isTri())
|
||||
{
|
||||
nTris = faceLst.size();
|
||||
}
|
||||
@ -208,18 +146,14 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
(
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceIndex],
|
||||
normLst[faceIndex],
|
||||
faceLst[faceIndex++],
|
||||
zoneI
|
||||
);
|
||||
|
||||
++faceIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write unsorted:
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
(
|
||||
@ -230,7 +164,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& zoneIds = surf.zoneIds();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
if (surf.isTri())
|
||||
@ -257,7 +190,6 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
os,
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
zoneIds[faceI]
|
||||
);
|
||||
}
|
||||
@ -346,10 +278,24 @@ template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
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
|
||||
)
|
||||
{
|
||||
writeASCII(os, surf);
|
||||
write(os, surf.points(), surf.faces(), surf.zones());
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
(
|
||||
const fileName& filename,
|
||||
Ostream& os,
|
||||
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 (ext == "stlb")
|
||||
if (surf.zoneToc().size() == 1)
|
||||
{
|
||||
std::ofstream ofs(filename.c_str(), std::ios::binary);
|
||||
writeBINARY(ofs, surf);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeASCII(OFstream(filename)(), surf);
|
||||
// a single zone - we can skip sorting
|
||||
os << "solid " << surf.zoneToc()[0].name() << endl;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell(os, pointLst, faceLst[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]);
|
||||
}
|
||||
os << "endsolid " << zone.name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -403,8 +370,37 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::write
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -68,8 +68,7 @@ class STLsurfaceFormat
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const Face&,
|
||||
const vector& norm
|
||||
const Face&
|
||||
);
|
||||
|
||||
//- Write Face in BINARY
|
||||
@ -78,24 +77,22 @@ class STLsurfaceFormat
|
||||
ostream&,
|
||||
const pointField&,
|
||||
const Face&,
|
||||
const vector&,
|
||||
const label zoneI
|
||||
);
|
||||
|
||||
|
||||
//- Write UnsortedMeshedSurface
|
||||
static void writeASCII(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
//- Write surface mesh components (as BINARY)
|
||||
static void writeBINARY
|
||||
(
|
||||
ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write UnsortedMeshedSurface
|
||||
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
|
||||
STLsurfaceFormat(const STLsurfaceFormat<Face>&);
|
||||
|
||||
@ -128,6 +125,15 @@ public:
|
||||
//- Read from file
|
||||
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)
|
||||
static void write
|
||||
(
|
||||
@ -135,7 +141,7 @@ public:
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
//- Write MeshedSurface (ASCII or BINARY, depending on the extension)
|
||||
static void write
|
||||
(
|
||||
const fileName&,
|
||||
|
||||
@ -56,8 +56,13 @@ class STLtriangle
|
||||
//- Attribute is 16-bit
|
||||
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_;
|
||||
|
||||
public:
|
||||
|
||||
@ -56,7 +56,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceFormatsCore Declaration
|
||||
Class surfaceFormatsCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceFormatsCore
|
||||
|
||||
@ -132,13 +132,11 @@ template<class Face>
|
||||
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
(
|
||||
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;
|
||||
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>
|
||||
void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
||||
(
|
||||
|
||||
@ -54,7 +54,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TRIsurfaceFormat Declaration
|
||||
Class TRIsurfaceFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Face>
|
||||
@ -105,6 +105,15 @@ public:
|
||||
//- Read from file
|
||||
virtual bool read(const fileName&);
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -50,7 +50,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TRIsurfaceFormatCore Declaration
|
||||
Class TRIsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class TRIsurfaceFormatCore
|
||||
|
||||
@ -62,13 +62,12 @@ template<class Face>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
(
|
||||
Ostream& os,
|
||||
const MeshedSurface<Face>& surf
|
||||
const pointField& pointLst,
|
||||
const List<Face>& faceLst,
|
||||
const List<surfZone>& zoneLst
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfZone>& zoneLst = surf.zones();
|
||||
|
||||
writeHeader(os, surf.points());
|
||||
writeHeader(os, pointLst);
|
||||
writeHeaderPolygons(os, faceLst);
|
||||
|
||||
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>
|
||||
void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
||||
(
|
||||
|
||||
@ -89,6 +89,15 @@ public:
|
||||
|
||||
// Write
|
||||
|
||||
//- Write surface mesh components
|
||||
static void write
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfZone>&
|
||||
);
|
||||
|
||||
//- Write MeshedSurface
|
||||
static void write
|
||||
(
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class VTKsurfaceFormatCore Declaration
|
||||
Class VTKsurfaceFormatCore Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class VTKsurfaceFormatCore
|
||||
|
||||
@ -54,7 +54,7 @@ bool triSurface::stitchTriangles
|
||||
<< " points down to " << newPoints.size() << endl;
|
||||
}
|
||||
|
||||
pointField& ps = const_cast<pointField&>(points());
|
||||
pointField& ps = storedPoints();
|
||||
|
||||
// Set the coordinates to the merged ones
|
||||
ps = newPoints;
|
||||
|
||||
@ -471,8 +471,7 @@ Foam::boolList Foam::triSurface::checkOrientation(const bool verbose)
|
||||
// Read triangles, points from Istream
|
||||
bool Foam::triSurface::read(Istream& is)
|
||||
{
|
||||
is >> patches_ >> const_cast<pointField&>(points())
|
||||
>> static_cast<List<labelledTri>&>(*this);
|
||||
is >> patches_ >> storedPoints() >> storedFaces();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -724,7 +723,7 @@ void Foam::triSurface::setDefaultPatches()
|
||||
|
||||
Foam::triSurface::triSurface()
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
patches_(0),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -739,7 +738,7 @@ Foam::triSurface::triSurface
|
||||
const pointField& points
|
||||
)
|
||||
:
|
||||
MeshStorage(triangles, points),
|
||||
ParentType(triangles, points),
|
||||
patches_(patches),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -754,7 +753,7 @@ Foam::triSurface::triSurface
|
||||
const bool reUse
|
||||
)
|
||||
:
|
||||
MeshStorage(triangles, points, reUse),
|
||||
ParentType(triangles, points, reUse),
|
||||
patches_(patches),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -767,7 +766,7 @@ Foam::triSurface::triSurface
|
||||
const pointField& points
|
||||
)
|
||||
:
|
||||
MeshStorage(triangles, points),
|
||||
ParentType(triangles, points),
|
||||
patches_(),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -782,7 +781,7 @@ Foam::triSurface::triSurface
|
||||
const pointField& points
|
||||
)
|
||||
:
|
||||
MeshStorage(convertToTri(triangles, 0), points),
|
||||
ParentType(convertToTri(triangles, 0), points),
|
||||
patches_(),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -793,7 +792,7 @@ Foam::triSurface::triSurface
|
||||
|
||||
Foam::triSurface::triSurface(const fileName& name)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
patches_(),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -808,7 +807,7 @@ Foam::triSurface::triSurface(const fileName& name)
|
||||
|
||||
Foam::triSurface::triSurface(Istream& is)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
patches_(),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -821,7 +820,7 @@ Foam::triSurface::triSurface(Istream& is)
|
||||
|
||||
Foam::triSurface::triSurface(const Time& d)
|
||||
:
|
||||
MeshStorage(List<FaceType>(), pointField()),
|
||||
ParentType(List<Face>(), pointField()),
|
||||
patches_(),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -840,7 +839,7 @@ Foam::triSurface::triSurface(const Time& d)
|
||||
|
||||
Foam::triSurface::triSurface(const triSurface& ts)
|
||||
:
|
||||
MeshStorage(ts, ts.points()),
|
||||
ParentType(ts, ts.points()),
|
||||
patches_(ts.patches()),
|
||||
sortedEdgeFacesPtr_(NULL),
|
||||
edgeOwnerPtr_(NULL)
|
||||
@ -859,7 +858,7 @@ Foam::triSurface::~triSurface()
|
||||
|
||||
void Foam::triSurface::clearTopology()
|
||||
{
|
||||
MeshStorage::clearTopology();
|
||||
ParentType::clearTopology();
|
||||
deleteDemandDrivenData(sortedEdgeFacesPtr_);
|
||||
deleteDemandDrivenData(edgeOwnerPtr_);
|
||||
}
|
||||
@ -867,13 +866,13 @@ void Foam::triSurface::clearTopology()
|
||||
|
||||
void Foam::triSurface::clearPatchMeshAddr()
|
||||
{
|
||||
MeshStorage::clearPatchMeshAddr();
|
||||
ParentType::clearPatchMeshAddr();
|
||||
}
|
||||
|
||||
|
||||
void Foam::triSurface::clearOut()
|
||||
{
|
||||
MeshStorage::clearOut();
|
||||
ParentType::clearOut();
|
||||
|
||||
clearTopology();
|
||||
clearPatchMeshAddr();
|
||||
@ -909,10 +908,10 @@ void Foam::triSurface::movePoints(const pointField& newPoints)
|
||||
deleteDemandDrivenData(sortedEdgeFacesPtr_);
|
||||
|
||||
// Adapt for new point position
|
||||
MeshStorage::movePoints(newPoints);
|
||||
ParentType::movePoints(newPoints);
|
||||
|
||||
// Copy new points
|
||||
const_cast<pointField&>(points()) = newPoints;
|
||||
storedPoints() = newPoints;
|
||||
}
|
||||
|
||||
|
||||
@ -926,9 +925,9 @@ void Foam::triSurface::scalePoints(const scalar& scaleFactor)
|
||||
clearTopology();
|
||||
|
||||
// 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);
|
||||
clearOut();
|
||||
const_cast<pointField&>(points()) = ts.points();
|
||||
storedPoints() = ts.points();
|
||||
patches_ = ts.patches();
|
||||
}
|
||||
|
||||
|
||||
@ -58,27 +58,21 @@ class IFstream;
|
||||
|
||||
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
|
||||
|
||||
//- Typedefs for convenience
|
||||
typedef labelledTri Face;
|
||||
typedef PrimitivePatch
|
||||
<
|
||||
FaceType,
|
||||
labelledTri,
|
||||
::Foam::List,
|
||||
pointField,
|
||||
point
|
||||
>
|
||||
MeshStorage;
|
||||
ParentType;
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
@ -201,17 +195,39 @@ private:
|
||||
//- helper function to print triangle info
|
||||
static void printTriangle
|
||||
(
|
||||
Ostream& os,
|
||||
Ostream&,
|
||||
const Foam::string& pre,
|
||||
const labelledTri& f,
|
||||
const pointField& points
|
||||
const labelledTri&,
|
||||
const pointField&
|
||||
);
|
||||
|
||||
//- read non-comment line
|
||||
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 typedefs
|
||||
|
||||
//- Placeholder only, but do not remove - it is needed for GeoMesh
|
||||
typedef bool BoundaryMesh;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("triSurface");
|
||||
|
||||
|
||||
@ -25,8 +25,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "triSurfaceFields.H"
|
||||
#include "DimensionedField.H"
|
||||
#include "triSurfaceGeoMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -26,13 +26,16 @@ Class
|
||||
Foam::triSurfaceGeoMesh
|
||||
|
||||
Description
|
||||
The triSurface geoMesh
|
||||
The triSurface GeoMesh (for holding fields).
|
||||
|
||||
Similar to the volGeoMesh used for the Finite Volume discretization.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef triSurfaceGeoMesh_H
|
||||
#define triSurfaceGeoMesh_H
|
||||
|
||||
#include "GeoMesh.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -43,52 +46,33 @@ namespace Foam
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class triSurfaceGeoMesh
|
||||
:
|
||||
public GeoMesh<triSurface>
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to Mesh
|
||||
const triSurface& mesh_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Public typedefs
|
||||
|
||||
typedef triSurface Mesh;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Mesh
|
||||
//- Construct from triSurface reference
|
||||
explicit triSurfaceGeoMesh(const triSurface& mesh)
|
||||
:
|
||||
mesh_(mesh)
|
||||
GeoMesh<triSurface>(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return size
|
||||
label size() const
|
||||
{
|
||||
return size(mesh_);
|
||||
}
|
||||
|
||||
//- Return size
|
||||
static label size(const triSurface& mesh)
|
||||
{
|
||||
return mesh.size();
|
||||
}
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return reference to triSurface
|
||||
const triSurface& operator()() const
|
||||
//- Return size
|
||||
label size() const
|
||||
{
|
||||
return mesh_;
|
||||
return size(mesh_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user