Commit 22f6b4dc authored by Mark Olesen's avatar Mark Olesen
Browse files

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.
parent a4d0094e
......@@ -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");
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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