From 22f6b4dc06d5b486e986efad72bfea1bcc55c280 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 5 Feb 2009 22:41:22 +0100 Subject: [PATCH 1/2] 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. --- .../surfaceMeshConvertTesting.C | 25 +++ src/surfMesh/Make/files | 1 + src/surfMesh/surfFields/surfFields.C | 24 -- src/surfMesh/surfFields/surfFields.H | 26 --- src/surfMesh/surfFields/surfGeoMesh.H | 9 +- src/surfMesh/surfMesh/surfMesh.H | 3 + .../surfPointFields/surfPointFields.C | 58 +++++ .../surfPointFields/surfPointFields.H | 47 ++++ .../surfPointFields/surfPointFieldsFwd.H | 65 ++++++ .../surfPointGeoMesh.H} | 56 ++--- .../surfaceFormats/ac3d/AC3DsurfaceFormat.C | 19 +- .../surfaceFormats/ac3d/AC3DsurfaceFormat.H | 11 +- .../ac3d/AC3DsurfaceFormatCore.H | 2 +- .../surfaceFormats/ftr/FTRsurfaceFormat.C | 9 +- .../surfaceFormats/ftr/FTRsurfaceFormat.H | 4 +- .../surfaceFormats/gts/GTSsurfaceFormat.H | 2 +- .../surfaceFormats/nas/NASsurfaceFormat.H | 2 +- .../surfaceFormats/nas/NASsurfaceFormatCore.H | 2 +- .../surfaceFormats/obj/OBJsurfaceFormat.C | 20 +- .../surfaceFormats/obj/OBJsurfaceFormat.H | 11 +- .../surfaceFormats/obj/OBJsurfaceFormatCore.H | 2 +- .../surfaceFormats/off/OFFsurfaceFormat.C | 81 ++++--- .../surfaceFormats/off/OFFsurfaceFormat.H | 11 +- .../surfaceFormats/off/OFFsurfaceFormatCore.H | 2 +- .../surfaceFormats/smesh/SMESHsurfaceFormat.C | 20 +- .../surfaceFormats/smesh/SMESHsurfaceFormat.H | 11 +- .../smesh/SMESHsurfaceFormatCore.H | 2 +- .../starcd/STARCDsurfaceFormat.C | 26 ++- .../starcd/STARCDsurfaceFormat.H | 12 +- .../starcd/STARCDsurfaceFormatCore.H | 2 +- src/surfMesh/surfaceFormats/stl/STLpoint.H | 5 +- .../surfaceFormats/stl/STLsurfaceFormat.C | 210 +++++++++--------- .../surfaceFormats/stl/STLsurfaceFormat.H | 32 +-- src/surfMesh/surfaceFormats/stl/STLtriangle.H | 7 +- .../surfaceFormats/surfaceFormatsCore.H | 2 +- .../surfaceFormats/tri/TRIsurfaceFormat.C | 19 +- .../surfaceFormats/tri/TRIsurfaceFormat.H | 11 +- .../surfaceFormats/tri/TRIsurfaceFormatCore.H | 2 +- .../surfaceFormats/vtk/VTKsurfaceFormat.C | 20 +- .../surfaceFormats/vtk/VTKsurfaceFormat.H | 9 + .../surfaceFormats/vtk/VTKsurfaceFormatCore.H | 2 +- src/triSurface/triSurface/stitchTriangles.C | 2 +- src/triSurface/triSurface/triSurface.C | 37 ++- src/triSurface/triSurface/triSurface.H | 46 ++-- .../triSurfaceFields/triSurfaceFields.C | 2 - .../triSurfaceFields/triSurfaceGeoMesh.H | 38 +--- 46 files changed, 641 insertions(+), 368 deletions(-) create mode 100644 src/surfMesh/surfPointFields/surfPointFields.C create mode 100644 src/surfMesh/surfPointFields/surfPointFields.H create mode 100644 src/surfMesh/surfPointFields/surfPointFieldsFwd.H rename src/surfMesh/{SurfGeoMesh/SurfGeoMesh.H => surfPointFields/surfPointGeoMesh.H} (68%) diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C index d5a21f396f..ccd85d8e5a 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -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(); } } diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index d46a2bec0f..2a51d95fbf 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -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 diff --git a/src/surfMesh/surfFields/surfFields.C b/src/surfMesh/surfFields/surfFields.C index 06100ee231..57c295c397 100644 --- a/src/surfMesh/surfFields/surfFields.C +++ b/src/surfMesh/surfFields/surfFields.C @@ -51,30 +51,6 @@ const word surfSymmTensorField::typeName("surfSymmTensorField"); template<> const word surfTensorField::typeName("surfTensorField"); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<> -tmp > -DimensionedField::component -( - const direction -) const -{ - return *this; -} - - -template<> -void DimensionedField::replace -( - const direction, - const DimensionedField& sf -) -{ - *this == sf; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/surfMesh/surfFields/surfFields.H b/src/surfMesh/surfFields/surfFields.H index 756dc4a088..e016bbe04d 100644 --- a/src/surfMesh/surfFields/surfFields.H +++ b/src/surfMesh/surfFields/surfFields.H @@ -42,32 +42,6 @@ SourceFiles // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<> -tmp > -DimensionedField::component -( - const direction -) const; - -template<> -void DimensionedField::replace -( - const direction, - const DimensionedField& sf -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/surfMesh/surfFields/surfGeoMesh.H b/src/surfMesh/surfFields/surfGeoMesh.H index 47c06bb381..8ced148e4f 100644 --- a/src/surfMesh/surfFields/surfGeoMesh.H +++ b/src/surfMesh/surfFields/surfGeoMesh.H @@ -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 + public GeoMesh { public: @@ -58,7 +59,7 @@ public: //- Construct from surfMesh reference explicit surfGeoMesh(const surfMesh& mesh) : - SurfGeoMesh(mesh) + GeoMesh(mesh) {} diff --git a/src/surfMesh/surfMesh/surfMesh.H b/src/surfMesh/surfMesh/surfMesh.H index 2d2e053cf0..f69672a345 100644 --- a/src/surfMesh/surfMesh/surfMesh.H +++ b/src/surfMesh/surfMesh/surfMesh.H @@ -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"); diff --git a/src/surfMesh/surfPointFields/surfPointFields.C b/src/surfMesh/surfPointFields/surfPointFields.C new file mode 100644 index 0000000000..871ecd1524 --- /dev/null +++ b/src/surfMesh/surfPointFields/surfPointFields.C @@ -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 + +// ************************************************************************* // diff --git a/src/surfMesh/surfPointFields/surfPointFields.H b/src/surfMesh/surfPointFields/surfPointFields.H new file mode 100644 index 0000000000..855cc4efca --- /dev/null +++ b/src/surfMesh/surfPointFields/surfPointFields.H @@ -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 + +// ************************************************************************* // diff --git a/src/surfMesh/surfPointFields/surfPointFieldsFwd.H b/src/surfMesh/surfPointFields/surfPointFieldsFwd.H new file mode 100644 index 0000000000..62cc746df4 --- /dev/null +++ b/src/surfMesh/surfPointFields/surfPointFieldsFwd.H @@ -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 DimensionedField; + +typedef DimensionedField + surfPointLabelField; +typedef DimensionedField + surfPointScalarField; +typedef DimensionedField + surfPointVectorField; +typedef DimensionedField + surfPointSphericalTensorField; +typedef DimensionedField + surfPointSymmTensorField; +typedef DimensionedField + surfPointTensorField; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/surfMesh/SurfGeoMesh/SurfGeoMesh.H b/src/surfMesh/surfPointFields/surfPointGeoMesh.H similarity index 68% rename from src/surfMesh/SurfGeoMesh/SurfGeoMesh.H rename to src/surfMesh/surfPointFields/surfPointGeoMesh.H index f4de6e9380..188b3dd6bd 100644 --- a/src/surfMesh/SurfGeoMesh/SurfGeoMesh.H +++ b/src/surfMesh/surfPointFields/surfPointGeoMesh.H @@ -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 SurfGeoMesh +class surfPointGeoMesh +: + public GeoMesh { -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(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_); } + }; diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C index b5de791846..167a98003b 100644 --- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.C @@ -282,13 +282,11 @@ template void Foam::fileFormats::AC3DsurfaceFormat::write ( Ostream& os, - const MeshedSurface& surf + const pointField& pointLst, + const List& faceLst, + const List& zoneLst ) { - const pointField& pointLst = surf.points(); - const List& faceLst = surf.faces(); - const List& zoneLst = surf.zones(); - writeHeader(os, zoneLst); forAll(zoneLst, zoneI) @@ -336,6 +334,17 @@ void Foam::fileFormats::AC3DsurfaceFormat::write } +template +void Foam::fileFormats::AC3DsurfaceFormat::write +( + Ostream& os, + const MeshedSurface& surf +) +{ + write(os, surf.points(), surf.faces(), surf.zones()); +} + + template void Foam::fileFormats::AC3DsurfaceFormat::write ( diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H index a7b43ac323..24aa25df18 100644 --- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H +++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormat.H @@ -56,7 +56,7 @@ namespace fileFormats { /*---------------------------------------------------------------------------*\ - Class AC3DfileFormat Declaration + Class AC3DsurfaceFormat Declaration \*---------------------------------------------------------------------------*/ template @@ -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&, + const List& + ); + //- Write MeshedSurface static void write ( diff --git a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H index 21044417cd..93619e5a9b 100644 --- a/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H +++ b/src/surfMesh/surfaceFormats/ac3d/AC3DsurfaceFormatCore.H @@ -49,7 +49,7 @@ namespace fileFormats { /*---------------------------------------------------------------------------*\ - Class AC3DfileFormat Declaration + Class AC3DsurfaceFormatCore Declaration \*---------------------------------------------------------------------------*/ class AC3DsurfaceFormatCore diff --git a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C index 60f3de0ae4..372427f4ad 100644 --- a/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/ftr/FTRsurfaceFormat.C @@ -65,11 +65,11 @@ bool Foam::fileFormats::FTRsurfaceFormat::read List ftrPatches(is); - // read points directly + // points read directly is >> this->storedPoints(); - // faces read with keys - List > facesRead(is); + // triFaces read with attached keys + List< Keyed > facesRead(is); List faceLst(facesRead.size()); List