surfMesh changes

- read 'ftr' triSurface format
- added 'ofs' (OpenFOAM Surface) as new all-in-one surface format candidate
- trying to get some sanity into the surface patch classes, but called it
  'surfGroup' (for now) to avoid conflict with existing 'surfacePatch'
- add read() member like Mattijs suggested
This commit is contained in:
Mark Olesen
2008-11-05 02:25:19 +01:00
parent 63298cbf0e
commit 9705520e24
30 changed files with 1728 additions and 333 deletions

View File

@ -1,3 +1,7 @@
surfGroup/surfGroup.C
surfGroup/surfGroupIOList.C
surfPatchIdentifier/surfPatchIdentifier.C
keyedSurface/keyedSurface.C keyedSurface/keyedSurface.C
keyedSurface/keyedSurfaceCleanup.C keyedSurface/keyedSurfaceCleanup.C
keyedSurface/newKeyedSurface.C keyedSurface/newKeyedSurface.C
@ -8,6 +12,7 @@ meshedSurface/newMeshedSurface.C
fileFormats = keyedSurface/fileFormats fileFormats = keyedSurface/fileFormats
$(fileFormats)/ac3d/AC3DfileFormat.C $(fileFormats)/ac3d/AC3DfileFormat.C
$(fileFormats)/ftr/FTRfileFormat.C
$(fileFormats)/gts/GTSfileFormat.C $(fileFormats)/gts/GTSfileFormat.C
$(fileFormats)/nas/NASfileFormat.C $(fileFormats)/nas/NASfileFormat.C
$(fileFormats)/obj/OBJfileFormat.C $(fileFormats)/obj/OBJfileFormat.C

View File

@ -417,7 +417,7 @@ Foam::fileFormats::AC3DfileFormat::AC3DfileFormat
void Foam::fileFormats::AC3DfileFormat::writeHeader void Foam::fileFormats::AC3DfileFormat::writeHeader
( (
Ostream& os, Ostream& os,
const List<surfacePatch>& patchLst const List<surfGroup>& patchLst
) )
{ {
// Write with patches as separate objects under "world" object. // Write with patches as separate objects under "world" object.
@ -467,22 +467,22 @@ void Foam::fileFormats::AC3DfileFormat::write
) )
{ {
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
writeHeader(os, patchLst); writeHeader(os, patchLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& sp = patchLst[patchI]; const surfGroup& p = patchLst[patchI];
os << "OBJECT poly" << nl os << "OBJECT poly" << nl
<< "name \"" << sp.name() << '"' << endl; << "name \"" << p.name() << '"' << endl;
// Create patch with only patch faces included for ease of addressing // Create patch with only patch faces included for ease of addressing
boolList include(surf.size(), false); boolList include(surf.size(), false);
forAll(sp, patchFaceI) forAll(p, patchFaceI)
{ {
const label faceI = faceMap[faceIndex++]; const label faceI = faceMap[faceIndex++];
@ -536,16 +536,16 @@ void Foam::fileFormats::AC3DfileFormat::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
writeHeader(os, patchLst); writeHeader(os, patchLst);
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& sp = patchLst[patchI]; const surfGroup& p = patchLst[patchI];
os << "OBJECT poly" << nl os << "OBJECT poly" << nl
<< "name \"" << sp.name() << '"' << endl; << "name \"" << p.name() << '"' << endl;
// Temporary primitivePatch to calculate compact points & faces // Temporary primitivePatch to calculate compact points & faces
primitivePatch patch primitivePatch patch
@ -553,8 +553,8 @@ void Foam::fileFormats::AC3DfileFormat::write
SubList<face> SubList<face>
( (
faceLst, faceLst,
sp.start(), p.start(),
sp.size() p.size()
), ),
pointLst pointLst
); );

View File

@ -87,7 +87,7 @@ class AC3DfileFormat
); );
//- Write header with materials //- Write header with materials
static void writeHeader(Ostream&, const List<surfacePatch>&); static void writeHeader(Ostream&, const List<surfGroup>&);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
AC3DfileFormat(const AC3DfileFormat&); AC3DfileFormat(const AC3DfileFormat&);

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 "FTRfileFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
addNamedToRunTimeSelectionTable
(
keyedSurface,
FTRfileFormat,
fileExtension,
ftr
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::FTRfileFormat::FTRfileFormat()
:
Foam::keyedSurface()
{}
Foam::fileFormats::FTRfileFormat::FTRfileFormat
(
const fileName& fName,
const bool triangulate
)
:
Foam::keyedSurface()
{
IFstream is(fName);
if (!is.good())
{
FatalErrorIn
(
"fileFormats::FTRfileFormat::FTRfileFormat(const fileName&)"
)
<< "Cannot read file " << fName
<< exit(FatalError);
}
List<ftrPatch> readPatches(is);
List<point> pointLst(is);
// transfer to normal list
points().transfer(pointLst);
// read face with keys
List<keyedFace> readFaces(is);
List<face> faceLst(readFaces.size());
List<label> regionLst(readFaces.size());
// disentangle faces/keys - already triangulated
forAll(readFaces, faceI)
{
faceLst[faceI].transfer(readFaces[faceI]);
regionLst[faceI] = readFaces[faceI].key();
}
faces().transfer(faceLst);
regions().transfer(regionLst);
Map<word> regionNames;
forAll(readPatches, patchI)
{
regionNames.insert(patchI, readPatches[patchI].name());
}
setPatches(regionNames, readPatches.size() - 1);
}
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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::fileFormats::FTRfileFormat
Description
Reading of Foam Trisurface Format
SourceFiles
FTRfileFormat.C
\*---------------------------------------------------------------------------*/
#ifndef FTRfileFormat_H
#define FTRfileFormat_H
#include "Ostream.H"
#include "OFstream.H"
#include "keyedSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class FTRfileFormat Declaration
\*---------------------------------------------------------------------------*/
class FTRfileFormat
:
public keyedSurface
{
// Private Member Functions
//- Disallow default bitwise copy construct
FTRfileFormat(const FTRfileFormat&);
//- Disallow default bitwise assignment
void operator=(const FTRfileFormat&);
//- read compatibility for ftr format
class ftrPatch
{
//- Name of patch
word name_;
//- Type of patch
word type_;
public:
const word& name() const
{
return name_;
}
friend Istream& operator>>(Istream& is, ftrPatch& p)
{
is >> p.name_ >> p.type_;
return is;
}
};
public:
// Constructors
//- Construct null
FTRfileFormat();
//- Construct from file name
FTRfileFormat(const fileName&, const bool triangulate=false);
// Selectors
//- Read file and return keyedSurface
static autoPtr<keyedSurface> New
(
const fileName& fName,
const bool triangulate=false
)
{
return autoPtr<keyedSurface>
(
new FTRfileFormat(fName, triangulate)
);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -289,7 +289,7 @@ void Foam::fileFormats::GTSfileFormat::write
} }
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
// Write header, print patch names as comment // Write header, print patch names as comment
@ -357,7 +357,7 @@ void Foam::fileFormats::GTSfileFormat::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
// It is too annoying to triangulate on-the-fly // It is too annoying to triangulate on-the-fly
// just issue a warning and get out // just issue a warning and get out
@ -425,7 +425,7 @@ void Foam::fileFormats::GTSfileFormat::write
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI) forAll(patch, patchFaceI)
{ {

View File

@ -120,7 +120,10 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::NASfileFormat::NASfileFormat(const fileName&)") FatalErrorIn
(
"fileFormats::NASfileFormat::NASfileFormat(const fileName&)"
)
<< "Cannot read file " << fName << "Cannot read file " << fName
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -73,7 +73,7 @@ void Foam::fileFormats::OBJfileFormat::writeHead
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const List<face>& faceLst, const List<face>& faceLst,
const List<surfacePatch>& patchLst const List<surfGroup>& patchLst
) )
{ {
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
@ -128,7 +128,10 @@ Foam::fileFormats::OBJfileFormat::OBJfileFormat
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::OBJfileFormat::OBJfileFormat(const fileName&)") FatalErrorIn
(
"fileFormats::OBJfileFormat::OBJfileFormat(const fileName&)"
)
<< "Cannot read file " << fName << "Cannot read file " << fName
<< exit(FatalError); << exit(FatalError);
} }
@ -282,7 +285,7 @@ void Foam::fileFormats::OBJfileFormat::write
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
writeHead(os, surf.points(), faceLst, patchLst); writeHead(os, surf.points(), faceLst, patchLst);
@ -290,7 +293,7 @@ void Foam::fileFormats::OBJfileFormat::write
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
os << "g " << patch.name() << endl; os << "g " << patch.name() << endl;
@ -318,14 +321,14 @@ void Foam::fileFormats::OBJfileFormat::write
) )
{ {
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
writeHead(os, surf.points(), faceLst, patchLst); writeHead(os, surf.points(), faceLst, patchLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
os << "g " << patch.name() << endl; os << "g " << patch.name() << endl;

View File

@ -72,7 +72,7 @@ class OBJfileFormat
Ostream&, Ostream&,
const pointField&, const pointField&,
const List<face>&, const List<face>&,
const List<surfacePatch>& const List<surfGroup>&
); );
public: public:

View File

@ -73,7 +73,7 @@ void Foam::fileFormats::OFFfileFormat::writeHead
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const List<face>& faceLst, const List<face>& faceLst,
const List<surfacePatch>& patchLst const List<surfGroup>& patchLst
) )
{ {
// Write header // Write header
@ -133,7 +133,10 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::OFFfileFormat(const fileName&)") FatalErrorIn
(
"fileFormats::OFFfileFormat(const fileName&)"
)
<< "Cannot read file " << fName << "Cannot read file " << fName
<< exit(FatalError); << exit(FatalError);
} }
@ -142,9 +145,11 @@ Foam::fileFormats::OFFfileFormat::OFFfileFormat
string hdr = getLineNoComment(is); string hdr = getLineNoComment(is);
if (hdr != "OFF") if (hdr != "OFF")
{ {
FatalErrorIn("fileFormats::OFFfileFormat(const fileName&)") FatalErrorIn
<< "OFF file " << fName (
<< " does not start with 'OFF'" "fileFormats::OFFfileFormat(const fileName&)"
)
<< "OFF file " << fName << " does not start with 'OFF'"
<< exit(FatalError); << exit(FatalError);
} }
@ -239,7 +244,7 @@ void Foam::fileFormats::OFFfileFormat::write
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
writeHead(os, surf.points(), faceLst, patchLst); writeHead(os, surf.points(), faceLst, patchLst);
@ -274,7 +279,7 @@ void Foam::fileFormats::OFFfileFormat::write
) )
{ {
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
writeHead(os, surf.points(), faceLst, patchLst); writeHead(os, surf.points(), faceLst, patchLst);

View File

@ -79,7 +79,7 @@ class OFFfileFormat
Ostream&, Ostream&,
const pointField&, const pointField&,
const List<face>&, const List<face>&,
const List<surfacePatch>& const List<surfGroup>&
); );
public: public:

View File

@ -119,7 +119,7 @@ Foam::fileFormats::SMESHfileFormat::write
writeHead(os, surf.points(), faceLst); writeHead(os, surf.points(), faceLst);
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
@ -149,7 +149,7 @@ Foam::fileFormats::SMESHfileFormat::write
) )
{ {
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
writeHead(os, surf.points(), faceLst); writeHead(os, surf.points(), faceLst);

View File

@ -82,7 +82,10 @@ bool Foam::fileFormats::STARCDfileFormat::readHeader
{ {
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::STARCDfileFormat::readHeader()") FatalErrorIn
(
"fileFormats::STARCDfileFormat::readHeader()"
)
<< "cannot read " << signature << " " << is.name() << "cannot read " << signature << " " << is.name()
<< abort(FatalError); << abort(FatalError);
} }
@ -405,7 +408,7 @@ void Foam::fileFormats::STARCDfileFormat::write
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
osPtr.reset(new OFstream(baseName + ".cel")); osPtr.reset(new OFstream(baseName + ".cel"));
@ -414,7 +417,7 @@ void Foam::fileFormats::STARCDfileFormat::write
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI) forAll(patch, patchFaceI)
{ {
@ -433,7 +436,7 @@ void Foam::fileFormats::STARCDfileFormat::write
) )
{ {
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
fileName baseName = fName.lessExt(); fileName baseName = fName.lessExt();
@ -449,7 +452,7 @@ void Foam::fileFormats::STARCDfileFormat::write
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI) forAll(patch, patchFaceI)
{ {

View File

@ -162,7 +162,10 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
// Check that stream is OK, if not this may be an ASCII file // Check that stream is OK, if not this may be an ASCII file
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::STLfileFormat::readBINARY(Istream&)") FatalErrorIn
(
"fileFormats::STLfileFormat::readBINARY(Istream&)"
)
<< "problem reading header, perhaps file is not binary " << "problem reading header, perhaps file is not binary "
<< exit(FatalError); << exit(FatalError);
} }
@ -185,7 +188,10 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|| nTris > (fileSize - headerSize)/25 || nTris > (fileSize - headerSize)/25
) )
{ {
FatalErrorIn("fileFormats::STLfileFormat::readBINARY(Istream&)") FatalErrorIn
(
"fileFormats::STLfileFormat::readBINARY(Istream&)"
)
<< "problem reading number of triangles, perhaps file is not binary" << "problem reading number of triangles, perhaps file is not binary"
<< exit(FatalError); << exit(FatalError);
} }
@ -350,13 +356,13 @@ void Foam::fileFormats::STLfileFormat::writeASCII
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl; os << "solid " << patch.name() << endl;
@ -381,7 +387,7 @@ void Foam::fileFormats::STLfileFormat::writeASCII
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
// force triangulation, but just do the cheapest form possible // force triangulation, but just do the cheapest form possible
@ -389,7 +395,7 @@ void Foam::fileFormats::STLfileFormat::writeASCII
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfacePatch& patch = patchLst[patchI]; const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl; os << "solid " << patch.name() << endl;
@ -459,7 +465,7 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
const surfacePatchList& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
// Write the STL header // Write the STL header
string header("STL binary file", headerSize); string header("STL binary file", headerSize);

View File

@ -116,7 +116,10 @@ Foam::fileFormats::TRIfileFormat::TRIfileFormat
if (!is.good()) if (!is.good())
{ {
FatalErrorIn("fileFormats::TRIfileFormat(const fileName&)") FatalErrorIn
(
"fileFormats::TRIfileFormat(const fileName&)"
)
<< "Cannot read file " << fName << "Cannot read file " << fName
<< exit(FatalError); << exit(FatalError);
} }
@ -242,7 +245,7 @@ void Foam::fileFormats::TRIfileFormat::write
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
@ -264,7 +267,7 @@ void Foam::fileFormats::TRIfileFormat::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)

View File

@ -99,7 +99,7 @@ void Foam::fileFormats::VTKfileFormat::writeHead
void Foam::fileFormats::VTKfileFormat::writeTail void Foam::fileFormats::VTKfileFormat::writeTail
( (
Ostream& os, Ostream& os,
const List<surfacePatch>& patchLst const List<surfGroup>& patchLst
) )
{ {
label nFaces = 0; label nFaces = 0;
@ -158,7 +158,7 @@ void Foam::fileFormats::VTKfileFormat::write
writeHead(os, surf.points(), faceLst); writeHead(os, surf.points(), faceLst);
labelList faceMap; labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap); List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
@ -188,7 +188,7 @@ void Foam::fileFormats::VTKfileFormat::write
) )
{ {
const List<face>& faceLst = surf.faces(); const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches(); const List<surfGroup>& patchLst = surf.patches();
writeHead(os, surf.points(), faceLst); writeHead(os, surf.points(), faceLst);

View File

@ -66,7 +66,7 @@ class VTKfileFormat
void operator=(const VTKfileFormat&); void operator=(const VTKfileFormat&);
static void writeHead(Ostream&, const pointField&, const List<face>&); static void writeHead(Ostream&, const pointField&, const List<face>&);
static void writeTail(Ostream&, const List<surfacePatch>&); static void writeTail(Ostream&, const List<surfGroup>&);
public: public:

View File

@ -35,6 +35,7 @@ License
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "primitivePatch.H" #include "primitivePatch.H"
#include "SortableList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,13 +51,12 @@ defineMemberFunctionSelectionTable
write, write,
fileExtension fileExtension
); );
}
Foam::word Foam::keyedSurface::defaultGeometricType("empty"); }
// File extension for 'native' raw format // File extension for 'native' raw format
//! @cond localscope //! @cond localscope
const char * const nativeExt = "ftr"; const char * const nativeExt = "ofs";
//! @endcond localscope //! @endcond localscope
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -182,13 +182,12 @@ Foam::string Foam::keyedSurface::getLineNoComment(IFstream& is)
void Foam::keyedSurface::setPatches(const label maxPatch) void Foam::keyedSurface::setPatches(const label maxPatch)
{ {
geoPatches_.setSize(maxPatch+1); patches_.setSize(maxPatch+1);
forAll(geoPatches_, patchI) forAll(patches_, patchI)
{ {
geoPatches_[patchI] = geometricSurfacePatch patches_[patchI] = PatchRegionType
( (
defaultGeometricType,
"patch" + ::Foam::name(patchI), "patch" + ::Foam::name(patchI),
patchI patchI
); );
@ -240,9 +239,9 @@ void Foam::keyedSurface::setPatches
// Info<< "setPatches with maxPatch: " << maxPatch << endl; // Info<< "setPatches with maxPatch: " << maxPatch << endl;
geoPatches_.setSize(maxPatch+1); patches_.setSize(maxPatch+1);
forAll(geoPatches_, patchI) forAll(patches_, patchI)
{ {
Map<word>::const_iterator findPatch = regionNames.find(patchI); Map<word>::const_iterator findPatch = regionNames.find(patchI);
word patchName; word patchName;
@ -256,9 +255,8 @@ void Foam::keyedSurface::setPatches
patchName = "patch" + ::Foam::name(patchI); patchName = "patch" + ::Foam::name(patchI);
} }
geoPatches_[patchI] = geometricSurfacePatch patches_[patchI] = PatchRegionType
( (
defaultGeometricType,
patchName, patchName,
patchI patchI
); );
@ -287,36 +285,40 @@ void Foam::keyedSurface::setPatches
setPatches(regionNames, maxPatch); setPatches(regionNames, maxPatch);
} }
// Read triangles, points from Istream
// // Read surf grouping, points, faces directly from Istream
// FIXME: needs to handle labelledTri etc.
bool Foam::keyedSurface::read(Istream& is) bool Foam::keyedSurface::read(Istream& is)
{ {
notImplemented("Foam::keyedSurface::read(Istream&)"); List<surfGroup> patchLst(is);
return false; is >> points() >> faces();
//// is >> geoPatches_ >> points() >> faces(); patches_.setSize(patchLst.size());
//// return true; regions_.setSize(size());
}
#if 0 // copy patch info and set regions:
// Read from file in given format label faceIndex = 0;
bool Foam::keyedSurface::read(const fileName& name, const word& ext) forAll(patchLst, patchI)
{ {
if (ext == "gz") patches_[patchI] = PatchRegionType
{ (
fileName unzipName = name.lessExt(); patchLst[patchI],
patchI
);
return read(unzipName, unzipName.ext()); forAll(patchLst[patchI], patchFaceI)
{
regions_[faceIndex++] = patchI;
} }
} }
#endif
return is.good();
}
// Returns patch info. // Returns patch info.
// Sets faceMap to the indexing according to patch numbers. // Sets faceMap to the indexing according to patch numbers.
// Patch numbers start at 0. // Patch numbers start at 0.
Foam::surfacePatchList Foam::keyedSurface::sortedRegions Foam::surfGroupList Foam::keyedSurface::sortedRegions
( (
const List<label>& regionLst, const List<label>& regionLst,
const Map<word>& patchNames, const Map<word>& patchNames,
@ -348,7 +350,7 @@ Foam::surfacePatchList Foam::keyedSurface::sortedRegions
// step 2: assign start/size (and name) to the newPatches // step 2: assign start/size (and name) to the newPatches
// re-use the lookup to map (regionId => patchI) // re-use the lookup to map (regionId => patchI)
surfacePatchList surfPatches(regionLookup.size()); surfGroupList patchLst(regionLookup.size());
label patchStart = 0; label patchStart = 0;
label patchI = 0; label patchI = 0;
forAllIter(Map<label>, regionLookup, iter) forAllIter(Map<label>, regionLookup, iter)
@ -366,9 +368,8 @@ Foam::surfacePatchList Foam::keyedSurface::sortedRegions
patchName = iter2(); patchName = iter2();
} }
surfPatches[patchI] = surfacePatch patchLst[patchI] = surfGroup
( (
defaultGeometricType,
patchName, patchName,
0, // initialize with zero size 0, // initialize with zero size
patchStart, patchStart,
@ -389,25 +390,24 @@ Foam::surfacePatchList Foam::keyedSurface::sortedRegions
{ {
label patchI = regionLookup[regionLst[faceI]]; label patchI = regionLookup[regionLst[faceI]];
faceMap[faceI] = faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++;
surfPatches[patchI].start() + surfPatches[patchI].size()++;
} }
// with reordered faces // with reordered faces registered in faceMap
return surfPatches; return patchLst;
} }
Foam::surfacePatchList Foam::keyedSurface::sortedRegions Foam::surfGroupList Foam::keyedSurface::sortedRegions
( (
labelList& faceMap labelList& faceMap
) const ) const
{ {
// supply some patch names // supply some patch names
Map<word> patchNames; Map<word> patchNames;
forAll(geoPatches_, patchI) forAll(patches_, patchI)
{ {
patchNames.insert(patchI, geoPatches_[patchI].name()); patchNames.insert(patchI, patches_[patchI].name());
} }
return sortedRegions(regions_, patchNames, faceMap); return sortedRegions(regions_, patchNames, faceMap);
@ -427,12 +427,12 @@ Foam::keyedSurface::keyedSurface
const xfer<pointField>& pointLst, const xfer<pointField>& pointLst,
const xfer<List<face> >& faceLst, const xfer<List<face> >& faceLst,
const xfer<List<label> >& regionIds, const xfer<List<label> >& regionIds,
const xfer<geometricSurfacePatchList>& patchLst const xfer<surfPatchIdentifierList>& patchLst
) )
: :
MeshStorage(List<FaceType>(), pointField()), MeshStorage(List<FaceType>(), pointField()),
regions_(regionIds), regions_(regionIds),
geoPatches_(patchLst) patches_(patchLst)
{ {
points().transfer(pointLst()); points().transfer(pointLst());
faces().transfer(faceLst()); faces().transfer(faceLst());
@ -493,7 +493,7 @@ Foam::keyedSurface::keyedSurface
: :
MeshStorage(List<FaceType>(), pointField()), MeshStorage(List<FaceType>(), pointField()),
regions_(faceLst().size(), 0), // single default patch regions_(faceLst().size(), 0), // single default patch
geoPatches_() patches_()
{ {
points().transfer(pointLst()); points().transfer(pointLst());
faces().transfer(faceLst()); faces().transfer(faceLst());
@ -515,7 +515,7 @@ Foam::keyedSurface::keyedSurface
const polyPatchList& bPatches = bMesh; const polyPatchList& bPatches = bMesh;
const label nIntFaces = mesh.nInternalFaces(); const label nIntFaces = mesh.nInternalFaces();
geometricSurfacePatchList newPatches(bPatches.size()); List<PatchRegionType> newPatches(bPatches.size());
// Get patch for all of outside // Get patch for all of outside
primitivePatch allBoundary primitivePatch allBoundary
@ -556,9 +556,8 @@ Foam::keyedSurface::keyedSurface
{ {
const polyPatch& p = bPatches[patchI]; const polyPatch& p = bPatches[patchI];
newPatches[patchI] = geometricSurfacePatch newPatches[patchI] = PatchRegionType
( (
defaultGeometricType,
bPatches[patchI].name(), bPatches[patchI].name(),
patchI patchI
); );
@ -573,7 +572,7 @@ Foam::keyedSurface::keyedSurface
faces().transfer(newFaces); faces().transfer(newFaces);
regions_.transfer(newRegions); regions_.transfer(newRegions);
geoPatches_.transfer(newPatches); patches_.transfer(newPatches);
} }
@ -585,11 +584,11 @@ Foam::keyedSurface::keyedSurface
MeshStorage(List<FaceType>(), surf.points()) MeshStorage(List<FaceType>(), surf.points())
{ {
const List<face>& origFaces = surf.faces(); const List<face>& origFaces = surf.faces();
const surfacePatchList& patchLst = surf.patches(); const surfGroupList& patchLst = surf.patches();
List<FaceType> newFaces(origFaces.size()); List<FaceType> newFaces(origFaces.size());
List<label> newRegions(origFaces.size()); List<label> newRegions(origFaces.size());
geometricSurfacePatchList newPatches(patchLst.size()); List<PatchRegionType> newPatches(patchLst.size());
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
@ -605,7 +604,7 @@ Foam::keyedSurface::keyedSurface
faces().transfer(newFaces); faces().transfer(newFaces);
regions_.transfer(newRegions); regions_.transfer(newRegions);
geoPatches_.transfer(newPatches); patches_.transfer(newPatches);
} }
@ -618,9 +617,7 @@ Foam::keyedSurface::keyedSurface
: :
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
// use selector mechanism read(fName, ext, triangulate);
autoPtr<keyedSurface> surfPtr = New(fName, ext, triangulate);
transfer(surfPtr());
} }
@ -632,9 +629,7 @@ Foam::keyedSurface::keyedSurface
: :
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
// use selector mechanism read(fName, fName.ext(), triangulate);
autoPtr<keyedSurface> surfPtr = New(fName, triangulate);
transfer(surfPtr());
} }
@ -643,7 +638,6 @@ Foam::keyedSurface::keyedSurface(Istream& is)
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
read(is); read(is);
setPatches();
} }
@ -652,7 +646,6 @@ Foam::keyedSurface::keyedSurface(const Time& d)
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
read(IFstream(triSurfName(d))()); read(IFstream(triSurfName(d))());
setPatches();
} }
@ -660,7 +653,7 @@ Foam::keyedSurface::keyedSurface(const keyedSurface& surf)
: :
MeshStorage(surf.faces(), surf.points()), MeshStorage(surf.faces(), surf.points()),
regions_(surf.regions_), regions_(surf.regions_),
geoPatches_(surf.geoPatches_) patches_(surf.patches_)
{} {}
@ -668,7 +661,7 @@ Foam::keyedSurface::keyedSurface(const xfer<keyedSurface>& surf)
: :
MeshStorage(List<FaceType>(), pointField()), MeshStorage(List<FaceType>(), pointField()),
regions_(), regions_(),
geoPatches_() patches_()
{ {
transfer(surf()); transfer(surf());
} }
@ -678,7 +671,7 @@ Foam::keyedSurface::keyedSurface(const xfer<meshedSurface>& surf)
: :
MeshStorage(List<FaceType>(), pointField()), MeshStorage(List<FaceType>(), pointField()),
regions_(), regions_(),
geoPatches_() patches_()
{ {
transfer(surf()); transfer(surf());
} }
@ -781,7 +774,7 @@ Foam::keyedSurface Foam::keyedSurface::subsetMesh
subSurf.faces().transfer(newFaces); subSurf.faces().transfer(newFaces);
// copy // copy
subSurf.geoPatches_ = geoPatches_; subSurf.patches_ = patches_;
return subSurf; return subSurf;
} }
@ -793,25 +786,26 @@ void Foam::keyedSurface::transfer(keyedSurface& surf)
faces().transfer(surf.faces()); faces().transfer(surf.faces());
points().transfer(surf.points()); points().transfer(surf.points());
regions_.transfer(surf.regions_); regions_.transfer(surf.regions_);
geoPatches_.transfer(surf.geoPatches_); patches_.transfer(surf.patches_);
surf.clearOut(); surf.clearOut();
} }
void Foam::keyedSurface::transfer(meshedSurface& surf) void Foam::keyedSurface::transfer(meshedSurface& surf)
{ {
surfGroupList& patchLst = surf.patches();
clearOut(); clearOut();
points().transfer(surf.points()); points().transfer(surf.points());
faces().transfer(surf.faces()); faces().transfer(surf.faces());
regions_.setSize(size()); regions_.setSize(size());
patches_.setSize(patchLst.size());
surfacePatchList& patchLst = surf.patches();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(patchLst, patchI)
{ {
// copy info // copy info
geoPatches_[patchI] = patchLst[patchI]; patches_[patchI] = patchLst[patchI];
forAll(patchLst[patchI], patchFaceI) forAll(patchLst[patchI], patchFaceI)
{ {
@ -837,21 +831,24 @@ bool Foam::keyedSurface::canRead(const word& ext, const bool verbose)
fExt = fExt.substr(dot+1); fExt = fExt.substr(dot+1);
} }
fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(fExt);
// handle 'native' format directly // handle 'native' format directly
if (fExt == nativeExt) if (fExt == nativeExt)
{ {
return true; return true;
} }
fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(fExt);
// would be nice to have information about which format this actually is // would be nice to have information about which format this actually is
if (cstrIter == fileExtensionConstructorTablePtr_->end()) if (cstrIter == fileExtensionConstructorTablePtr_->end())
{ {
if (verbose) if (verbose)
{ {
const wordList& known = fileExtensionConstructorTablePtr_->toc(); SortableList<word> known
(
fileExtensionConstructorTablePtr_->toc()
);
Info<<"Unknown file extension for reading: " << fExt << nl; Info<<"Unknown file extension for reading: " << fExt << nl;
// compact output: // compact output:
@ -894,8 +891,10 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
{ {
if (verbose) if (verbose)
{ {
const wordList& known = SortableList<word> known
writefileExtensionMemberFunctionTablePtr_->toc(); (
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << fExt << nl; Info<<"Unknown file extension for writing: " << fExt << nl;
// compact output: // compact output:
@ -914,17 +913,26 @@ bool Foam::keyedSurface::canWrite(const word& ext, const bool verbose)
} }
// Read from file in given format
#if 0 bool Foam::keyedSurface::read
void Foam::keyedSurface::write
( (
const fileName& fName, const fileName& fName,
const bool sorted const word& ext,
) const const bool triangulate
)
{ {
write(fName, fName.ext(), sorted); // handle 'native' format directly
if (ext == nativeExt)
{
return read(IFstream(fName)());
}
else
{
// use selector mechanism
transfer(New(fName, ext, triangulate)());
return true;
}
} }
#endif
void Foam::keyedSurface::write void Foam::keyedSurface::write
@ -968,22 +976,54 @@ void Foam::keyedSurface::write
} }
// write sorted
void Foam::keyedSurface::write(Ostream& os) const void Foam::keyedSurface::write(Ostream& os) const
{ {
os << "\n// geometric regions:\n" const List<face>& faceLst = faces();
<< geoPatches_ << endl; labelList faceMap;
List<surfGroup> patchLst = sortedRegions(faceMap);
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os);
os << "// OpenFOAM Surface format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patchLst, patchI)
{
patchLst[patchI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl;
IOobject::writeDivider(os);
// Note: Write with global point numbering // Note: Write with global point numbering
os << "\n// points:\n" os << "\n// points:" << nl << points() << nl;
<< points() << nl
<< "\n// faces:\n" IOobject::writeDivider(os);
<< faces() << nl os << "\n// faces:" << nl;
<< "\n// regions:\n" os << faceLst.size() << nl << token::BEGIN_LIST << nl;
<< regions() << endl;
label faceIndex = 0;
forAll(patchLst, patchI)
{
// Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI)
{
const face& f = faceLst[faceMap[faceIndex++]];
os << f << nl;
}
}
os << token::END_LIST << nl;
IOobject::writeDivider(os);
// Check state of Ostream // Check state of Ostream
os.check("keyedSurface::write(Ostream&)"); os.check("meshedSurface::write(Ostream&)");
} }
@ -1009,7 +1049,7 @@ void Foam::keyedSurface::operator=(const keyedSurface& surf)
clearOut(); clearOut();
faces() = surf.faces(); faces() = surf.faces();
points() = surf.points(); points() = surf.points();
geoPatches_ = surf.geoPatches_; patches_ = surf.patches_;
} }

View File

@ -50,8 +50,8 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "PrimitivePatchExtra.H" #include "PrimitivePatchExtra.H"
#include "boolList.H" #include "boolList.H"
#include "geometricSurfacePatchList.H" #include "surfPatchIdentifierList.H"
#include "surfacePatchList.H" #include "surfGroupList.H"
#include "face.H" #include "face.H"
#include "Keyed.H" #include "Keyed.H"
#include "xfer.H" #include "xfer.H"
@ -63,11 +63,18 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators
class Time; class Time;
class IFstream; class IFstream;
class keyedSurface;
class meshedSurface; class meshedSurface;
class polyBoundaryMesh; class polyBoundaryMesh;
Istream& operator>>(Istream&, keyedSurface&);
Ostream& operator<<(Ostream&, const keyedSurface&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class keyedSurface Declaration Class keyedSurface Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -88,6 +95,9 @@ protected:
//- Typedef for similar code in keyedSurface and meshedSurface //- Typedef for similar code in keyedSurface and meshedSurface
typedef face FaceType; typedef face FaceType;
//- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType;
private: private:
// Private typedefs // Private typedefs
@ -108,17 +118,13 @@ private:
//- Patch information (face ordering nFaces/startFace only used //- Patch information (face ordering nFaces/startFace only used
// during reading and writing) // during reading and writing)
geometricSurfacePatchList geoPatches_; List<PatchRegionType> patches_;
// Private member functions // Private member functions
//- Read in Foam format //- Read OpenFOAM Surface format
bool read(Istream&); bool read(Istream&);
//- Generic read routine. Chooses reader based on extension.
//? bool read(const fileName&, const word& ext);
//- Disable setSize with value //- Disable setSize with value
void setSize(const label, const FaceType&); void setSize(const label, const FaceType&);
@ -175,9 +181,6 @@ public:
//- Runtime type information //- Runtime type information
ClassName("keyedSurface"); ClassName("keyedSurface");
//- Return the default geometric patch type (usually "empty")
static word defaultGeometricType;
// Static // Static
//- Name of keyedSurface directory to use. //- Name of keyedSurface directory to use.
@ -199,7 +202,7 @@ public:
const xfer<pointField>&, const xfer<pointField>&,
const xfer<List<face> >&, const xfer<List<face> >&,
const xfer<List<label> >& regionIds, const xfer<List<label> >& regionIds,
const xfer<geometricSurfacePatchList>& const xfer<surfPatchIdentifierList>&
); );
//- Construct by transferring points, faces and regionIds //- Construct by transferring points, faces and regionIds
@ -240,6 +243,13 @@ public:
//- Construct from a meshedSurface //- Construct from a meshedSurface
keyedSurface(const meshedSurface&); keyedSurface(const meshedSurface&);
//- Construct by transferring the contents from a keyedSurface
keyedSurface(const xfer<keyedSurface>&);
//- Construct by transferring the contents from a meshedSurface
keyedSurface(const xfer<meshedSurface>&);
//- Construct from file name (uses extension to determine type) //- Construct from file name (uses extension to determine type)
keyedSurface keyedSurface
( (
@ -264,12 +274,6 @@ public:
//- Construct as copy //- Construct as copy
keyedSurface(const keyedSurface&); keyedSurface(const keyedSurface&);
//- Construct by transferring the contents from a keyedSurface
keyedSurface(const xfer<keyedSurface>&);
//- Construct by transferring the contents from a meshedSurface
keyedSurface(const xfer<meshedSurface>&);
// Declare run-time constructor selection table // Declare run-time constructor selection table
@ -375,19 +379,19 @@ public:
return regions_; return regions_;
} }
const geometricSurfacePatchList& geoPatches() const const surfPatchIdentifierList& patches() const
{ {
return geoPatches_; return patches_;
} }
geometricSurfacePatchList& geoPatches() surfPatchIdentifierList& patches()
{ {
return geoPatches_; return patches_;
} }
//- Determine the sort order from the region list. //- Determine the sort order from the region list.
// Returns patch list and sets faceMap to indices within faceLst // Returns patch list and sets faceMap to indices within faceLst
static surfacePatchList sortedRegions static surfGroupList sortedRegions
( (
const List<label>& regionLst, const List<label>& regionLst,
const Map<word>& patchNames, const Map<word>& patchNames,
@ -396,7 +400,7 @@ public:
//- Sort faces according to region. //- Sort faces according to region.
// Returns patch list and sets faceMap to index within faces() // Returns patch list and sets faceMap to index within faces()
surfacePatchList sortedRegions(labelList& faceMap) const; surfGroupList sortedRegions(labelList& faceMap) const;
// Edit // Edit
@ -426,6 +430,17 @@ public:
//- Transfer the contents of the argument and annull the argument //- Transfer the contents of the argument and annull the argument
void transfer(meshedSurface&); void transfer(meshedSurface&);
// Read
//- Read from file. Chooses reader based on extension
bool read
(
const fileName&,
const word& ext,
const bool triangulate=false
);
// Write // Write
//- Write to Ostream in simple FOAM format //- Write to Ostream in simple FOAM format
@ -443,7 +458,6 @@ public:
//- Write some statistics //- Write some statistics
void writeStats(Ostream&) const; void writeStats(Ostream&) const;
// Friend Functions
// Member operators // Member operators
@ -452,6 +466,7 @@ public:
// Ostream Operator // Ostream Operator
// friend Istream& operator>>(Istream&, keyedSurface&);
friend Ostream& operator<<(Ostream&, const keyedSurface&); friend Ostream& operator<<(Ostream&, const keyedSurface&);
}; };

View File

@ -55,10 +55,9 @@ defineMemberFunctionSelectionTable
} }
Foam::word Foam::meshedSurface::defaultGeometricType("empty");
// File extension for 'native' raw format // File extension for 'native' raw format
//! @cond localscope //! @cond localscope
const char * const nativeExt = "ftr"; const char * const nativeExt = "ofs";
//! @endcond localscope //! @endcond localscope
// * * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * //
@ -174,9 +173,8 @@ void Foam::meshedSurface::onePatch()
{ {
// set single default patch // set single default patch
patches_.setSize(1); patches_.setSize(1);
patches_[0] = surfacePatch patches_[0] = surfGroup
( (
defaultGeometricType,
"patch0", "patch0",
size(), // patch size size(), // patch size
0, // patch start 0, // patch start
@ -255,7 +253,7 @@ void Foam::meshedSurface::sortFacesByRegion
else if (regionIds.size() == unsortedFaces.size()) else if (regionIds.size() == unsortedFaces.size())
{ {
labelList faceMap; labelList faceMap;
surfacePatchList newPatches = keyedSurface::sortedRegions surfGroupList newPatches = keyedSurface::sortedRegions
( (
regionIds, regionIds,
regionNames, regionNames,
@ -276,29 +274,25 @@ void Foam::meshedSurface::sortFacesByRegion
} }
// Read points, faces, from Istream // Read surf grouping, points, faces directly from Istream
bool Foam::meshedSurface::read(Istream& is) bool Foam::meshedSurface::read(Istream& is)
{ {
notImplemented("Foam::meshedSurface::read(Istream&)"); List<surfGroup> patchLst(is);
return false; is >> points() >> faces();
//// is >> patches_ >> points() >> faces(); // copy patch info:
//// return true; patches_.setSize(patchLst.size());
} forAll(patchLst, patchI)
#if 0
// Read from file in given format
bool Foam::meshedSurface::read(const fileName& name, const word& ext)
{ {
if (ext == "gz") patches_[patchI] = surfGroup
{ (
fileName unzipName = name.lessExt(); patchLst[patchI],
patchI
return read(unzipName, unzipName.ext()); );
} }
}
#endif
return is.good();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -312,7 +306,7 @@ Foam::meshedSurface::meshedSurface
( (
const xfer<pointField>& pointLst, const xfer<pointField>& pointLst,
const xfer<List<FaceType> >& faceLst, const xfer<List<FaceType> >& faceLst,
const xfer<surfacePatchList>& patchLst const xfer<surfGroupList>& patchLst
) )
: :
MeshStorage(List<FaceType>(), pointField()), MeshStorage(List<FaceType>(), pointField()),
@ -337,14 +331,13 @@ Foam::meshedSurface::meshedSurface
points().transfer(pointLst()); points().transfer(pointLst());
faces().transfer(faceLst()); faces().transfer(faceLst());
surfacePatchList newPatches(patchSizes.size()); surfGroupList newPatches(patchSizes.size());
label start = 0; label start = 0;
forAll(newPatches, patchI) forAll(newPatches, patchI)
{ {
newPatches[patchI] = surfacePatch newPatches[patchI] = surfGroup
( (
defaultGeometricType,
patchNames[patchI], patchNames[patchI],
patchSizes[patchI], patchSizes[patchI],
start, start,
@ -477,16 +470,15 @@ Foam::meshedSurface::meshedSurface
} }
// create patch list // create patch list
surfacePatchList newPatches(bPatches.size()); surfGroupList newPatches(bPatches.size());
label startFaceI = 0; label startFaceI = 0;
forAll(bPatches, patchI) forAll(bPatches, patchI)
{ {
const polyPatch& p = bPatches[patchI]; const polyPatch& p = bPatches[patchI];
newPatches[patchI] = surfacePatch newPatches[patchI] = surfGroup
( (
defaultGeometricType,
p.name(), p.name(),
p.size(), p.size(),
startFaceI, startFaceI,
@ -512,16 +504,15 @@ Foam::meshedSurface::meshedSurface
const surfPatchList& sPatches = sMesh.boundaryMesh(); const surfPatchList& sPatches = sMesh.boundaryMesh();
// create patch list // create patch list
surfacePatchList newPatches(sPatches.size()); List<surfGroup> newPatches(sPatches.size());
label startFaceI = 0; label startFaceI = 0;
forAll(sPatches, patchI) forAll(sPatches, patchI)
{ {
const surfPatch& p = sPatches[patchI]; const surfPatch& p = sPatches[patchI];
newPatches[patchI] = surfacePatch newPatches[patchI] = surfGroup
( (
defaultGeometricType,
p.name(), p.name(),
p.size(), p.size(),
startFaceI, startFaceI,
@ -544,7 +535,7 @@ Foam::meshedSurface::meshedSurface
MeshStorage(List<FaceType>(), surf.points()) MeshStorage(List<FaceType>(), surf.points())
{ {
labelList faceMap; labelList faceMap;
surfacePatchList patchLst = surf.sortedRegions(faceMap); surfGroupList patchLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst); patches_.transfer(patchLst);
const List<FaceType>& origFaces = surf.faces(); const List<FaceType>& origFaces = surf.faces();
@ -569,11 +560,10 @@ Foam::meshedSurface::meshedSurface
: :
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
// use selector mechanism read(fName, ext, triangulate);
autoPtr<meshedSurface> surfPtr = New(fName, ext, triangulate);
transfer(surfPtr());
} }
Foam::meshedSurface::meshedSurface Foam::meshedSurface::meshedSurface
( (
const fileName& fName, const fileName& fName,
@ -582,9 +572,7 @@ Foam::meshedSurface::meshedSurface
: :
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
// use selector mechanism read(fName, fName.ext(), triangulate);
autoPtr<meshedSurface> surfPtr = New(fName, triangulate);
transfer(surfPtr());
} }
@ -593,7 +581,6 @@ Foam::meshedSurface::meshedSurface(Istream& is)
MeshStorage(List<FaceType>(), pointField()) MeshStorage(List<FaceType>(), pointField())
{ {
read(is); read(is);
// setDefaultPatches();
} }
@ -694,7 +681,7 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
} }
// create a new patch list // create a new patch list
surfacePatchList newPatches(patches_); surfGroupList newPatches(patches_);
forAll(newPatches, patchI) forAll(newPatches, patchI)
{ {
newPatches[patchI].size() = 0; newPatches[patchI].size() = 0;
@ -769,10 +756,10 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
faces().clear(); faces().clear();
labelList faceMap; labelList faceMap;
surfacePatchList patchLst = surf.sortedRegions(faceMap); surfGroupList patchLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst); patches_.transfer(patchLst);
surf.regions().clear(); surf.regions().clear();
surf.geoPatches_.clear(); surf.patches_.clear();
List<FaceType>& oldFaces = surf.faces(); List<FaceType>& oldFaces = surf.faces();
List<FaceType> newFaces(oldFaces.size()); List<FaceType> newFaces(oldFaces.size());
@ -820,8 +807,10 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
{ {
if (verbose) if (verbose)
{ {
const wordList& known = SortableList<word> known
writefileExtensionMemberFunctionTablePtr_->toc(); (
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << fExt << nl; Info<<"Unknown file extension for writing: " << fExt << nl;
// compact output: // compact output:
@ -840,6 +829,28 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
} }
// Read from file in given format
bool Foam::meshedSurface::read
(
const fileName& fName,
const word& ext,
const bool triangulate
)
{
// handle 'native' format directly
if (ext == nativeExt)
{
return read(IFstream(fName)());
}
else
{
// use selector mechanism
transfer(New(fName, ext, triangulate)());
return true;
}
}
void Foam::meshedSurface::write void Foam::meshedSurface::write
( (
const fileName& fName, const fileName& fName,
@ -883,20 +894,28 @@ void Foam::meshedSurface::write
void Foam::meshedSurface::write(Ostream& os) const void Foam::meshedSurface::write(Ostream& os) const
{ {
// quick-hack // just emit some information until we get a nice IOobject
os << "\n// regions:\n" IOobject::writeBanner(os);
<< patches_.size() << nl << token::BEGIN_LIST; os << "// OpenFOAM Surface format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patches_, patchI) forAll(patches_, patchI)
{ {
patches_[patchI].writeDict(os); patches_[patchI].writeDict(os);
} }
os << token::END_LIST << endl; os << decrIndent << token::END_LIST << nl;
IOobject::writeDivider(os);
// Note: Write with global point numbering // Note: Write with global point numbering
os << "\n// points:\n" os << "\n// points:" << nl << points() << nl;
<< points() << nl
<< "\n// faces:\n" IOobject::writeDivider(os);
<< faces() << endl; os << "\n// faces:" << nl << faces() << nl;
IOobject::writeDivider(os);
// Check state of Ostream // Check state of Ostream
os.check("meshedSurface::write(Ostream&)"); os.check("meshedSurface::write(Ostream&)");

View File

@ -47,8 +47,7 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "PrimitivePatchExtra.H" #include "PrimitivePatchExtra.H"
#include "boolList.H" #include "boolList.H"
#include "geometricSurfacePatchList.H" #include "surfGroupList.H"
#include "surfacePatchList.H"
#include "face.H" #include "face.H"
#include "Keyed.H" #include "Keyed.H"
#include "xfer.H" #include "xfer.H"
@ -60,11 +59,17 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators
class Time; class Time;
class keyedSurface; class keyedSurface;
class meshedSurface;
class polyBoundaryMesh; class polyBoundaryMesh;
class surfMesh; class surfMesh;
Istream& operator>>(Istream&, meshedSurface&);
Ostream& operator<<(Ostream&, const meshedSurface&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class meshedSurface Declaration Class meshedSurface Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -100,11 +105,11 @@ private:
> >
MeshStorage; MeshStorage;
// Private data // Private Member Data
//- Patch information (face ordering nFaces/startFace only used //- Patch information (face ordering nFaces/startFace only used
// during reading and writing) // during reading and writing)
surfacePatchList patches_; List<surfGroup> patches_;
// Private member functions // Private member functions
@ -117,14 +122,11 @@ private:
//- basic sanity check on patches //- basic sanity check on patches
void checkPatches(); void checkPatches();
//- Read in Foam format //- Read OpenFOAM Surface format
bool read(Istream&); bool read(Istream&);
// Static private functions
public: protected:
// Protected Member Data
// Protected Member functions // Protected Member functions
@ -145,10 +147,6 @@ public:
//- Runtime type information //- Runtime type information
ClassName("meshedSurface"); ClassName("meshedSurface");
//- Return the default geometric patch type (usually "empty")
static word defaultGeometricType;
// Static // Static
//- Name of meshedSurface directory to use. //- Name of meshedSurface directory to use.
@ -158,7 +156,6 @@ public:
static fileName triSurfName(const Time&); static fileName triSurfName(const Time&);
// Constructors // Constructors
//- Construct null //- Construct null
@ -170,7 +167,7 @@ public:
( (
const xfer<pointField>&, const xfer<pointField>&,
const xfer<List<face> >&, const xfer<List<face> >&,
const xfer<surfacePatchList>& const xfer<surfGroupList>&
); );
//- Construct from points, faces, and patch information //- Construct from points, faces, and patch information
@ -235,7 +232,7 @@ public:
meshedSurface meshedSurface
( (
const fileName&, const fileName&,
const word&, const word& ext,
const bool triangulate=false const bool triangulate=false
); );
@ -295,6 +292,7 @@ public:
//- Can we write this file format? //- Can we write this file format?
static bool canWrite(const word& ext, const bool verbose=false); static bool canWrite(const word& ext, const bool verbose=false);
// Member Functions // Member Functions
// Access // Access
@ -329,12 +327,12 @@ public:
return static_cast<const List<FaceType> &>(*this); return static_cast<const List<FaceType> &>(*this);
} }
const surfacePatchList& patches() const const surfGroupList& patches() const
{ {
return patches_; return patches_;
} }
surfacePatchList& patches() surfGroupList& patches()
{ {
return patches_; return patches_;
} }
@ -377,6 +375,17 @@ public:
void transfer(keyedSurface&); void transfer(keyedSurface&);
// Read
//- Read from file. Chooses reader based on extension
bool read
(
const fileName&,
const word& ext,
const bool triangulate=false
);
// Write // Write
//- Write to Ostream in simple FOAM format //- Write to Ostream in simple FOAM format
@ -401,6 +410,7 @@ public:
// Ostream Operator // Ostream Operator
// friend Istream& operator>>(Istream&, meshedSurface&);
friend Ostream& operator<<(Ostream&, const meshedSurface&); friend Ostream& operator<<(Ostream&, const meshedSurface&);
}; };

View File

@ -74,12 +74,12 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
label newFaceI = 0; label newFaceI = 0;
forAll (patches_, patchI) forAll (patches_, patchI)
{ {
surfacePatch& surfPatch = patches_[patchI]; surfGroup& p = patches_[patchI];
// adjust patch start // adjust patch start
surfPatch.start() = newFaceI; p.start() = newFaceI;
label patchEnd = oldFaceI + surfPatch.size(); label patchEnd = oldFaceI + p.size();
for (; oldFaceI < patchEnd; ++oldFaceI) for (; oldFaceI < patchEnd; ++oldFaceI)
{ {
FaceType& f = faceLst[oldFaceI]; FaceType& f = faceLst[oldFaceI];
@ -105,7 +105,7 @@ bool Foam::meshedSurface::stitchFaces(const scalar tol, const bool verbose)
} }
// adjust patch size // adjust patch size
surfPatch.size() = newFaceI - surfPatch.size(); p.size() = newFaceI - p.size();
} }
if (newFaceI != faceLst.size()) if (newFaceI != faceLst.size())
@ -165,12 +165,12 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
label newFaceI = 0; label newFaceI = 0;
forAll (patches_, patchI) forAll (patches_, patchI)
{ {
surfacePatch& surfPatch = patches_[patchI]; surfGroup& p = patches_[patchI];
// correct the patch start // correct the patch start
surfPatch.start() = newFaceI; p.start() = newFaceI;
label patchEnd = oldFaceI + surfPatch.size(); label patchEnd = oldFaceI + p.size();
for (; oldFaceI < patchEnd; ++oldFaceI) for (; oldFaceI < patchEnd; ++oldFaceI)
{ {
FaceType& f = faceLst[oldFaceI]; FaceType& f = faceLst[oldFaceI];
@ -239,7 +239,7 @@ void Foam::meshedSurface::checkFaces(const bool verbose)
} }
// adjust patch size // adjust patch size
surfPatch.size() = newFaceI - surfPatch.start(); p.size() = newFaceI - p.start();
} }
if (newFaceI < faceLst.size()) if (newFaceI < faceLst.size())
@ -288,12 +288,12 @@ Foam::label Foam::meshedSurface::triangulate()
label newFaceI = 0; label newFaceI = 0;
forAll (patches_, patchI) forAll (patches_, patchI)
{ {
surfacePatch& surfPatch = patches_[patchI]; surfGroup& p = patches_[patchI];
// adjust patch start // adjust patch start
surfPatch.start() = newFaceI; p.start() = newFaceI;
label patchEnd = oldFaceI + surfPatch.size(); label patchEnd = oldFaceI + p.size();
for (; oldFaceI < patchEnd; ++oldFaceI) for (; oldFaceI < patchEnd; ++oldFaceI)
{ {
const FaceType& f = faceLst[oldFaceI]; const FaceType& f = faceLst[oldFaceI];
@ -314,7 +314,7 @@ Foam::label Foam::meshedSurface::triangulate()
} }
// adjust patch size // adjust patch size
surfPatch.size() = newFaceI - surfPatch.start(); p.size() = newFaceI - p.start();
} }
faceLst.transfer(newFaces); faceLst.transfer(newFaces);

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "surfGroup.H"
#include "dictionary.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfGroup, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfGroup::surfGroup()
:
surfPatchIdentifier(),
size_(0),
start_(0)
{}
Foam::surfGroup::surfGroup
(
const word& name,
const label size,
const label start,
const label index,
const word& geometricType
)
:
surfPatchIdentifier(name, index, geometricType),
size_(size),
start_(start)
{}
Foam::surfGroup::surfGroup(Istream& is, const label index)
:
surfPatchIdentifier(),
size_(0),
start_(0)
{
word name(is);
dictionary dict(is);
operator=(surfGroup(name, dict, index));
}
Foam::surfGroup::surfGroup
(
const word& name,
const dictionary& dict,
const label index
)
:
surfPatchIdentifier(name, dict, index),
size_(readLabel(dict.lookup("nFaces"))),
start_(readLabel(dict.lookup("startFace")))
{}
Foam::surfGroup::surfGroup(const Foam::surfGroup& p)
:
surfPatchIdentifier(p, p.index()),
size_(p.size()),
start_(p.start())
{}
Foam::surfGroup::surfGroup(const Foam::surfGroup& p, const label index)
:
surfPatchIdentifier(p, index),
size_(p.size()),
start_(p.start())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfGroup::write(Ostream& os) const
{
writeDict(os);
}
void Foam::surfGroup::writeDict(Ostream& os) const
{
os << indent << name() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
surfPatchIdentifier::write(os);
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
bool Foam::surfGroup::operator!=(const surfGroup& p) const
{
return !(*this == p);
}
bool Foam::surfGroup::operator==(const surfGroup& p) const
{
return
(
(geometricType() == p.geometricType())
&& (size() == p.size())
&& (start() == p.start())
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfGroup& p)
{
p = surfGroup(is, 0);
is.check("Istream& operator>>(Istream&, surfGroup&)");
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroup& p)
{
p.write(os);
os.check("Ostream& operator<<(Ostream& f, const surfGroup& p");
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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::surfGroup
Description
'Patch' on surface as subset of triSurface.
SourceFiles
surfGroup.C
\*---------------------------------------------------------------------------*/
#ifndef surfGroup_H
#define surfGroup_H
#include "word.H"
#include "label.H"
#include "className.H"
#include "surfPatchIdentifier.H"
#include "autoPtr.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class surfGroup;
Istream& operator>>(Istream&, surfGroup&);
Ostream& operator<<(Ostream&, const surfGroup&);
/*---------------------------------------------------------------------------*\
Class surfGroup Declaration
\*---------------------------------------------------------------------------*/
class surfGroup
:
public surfPatchIdentifier
{
// Private data
//- size of this group in the face list
label size_;
//- Start label of this group in the face list
label start_;
public:
//- Runtime type information
ClassName("surfGroup");
// Constructors
//- Construct null
surfGroup();
//- Construct from components
surfGroup
(
const word& name,
const label size,
const label start,
const label index,
const word& geometricType = word::null
);
//- Construct from Istream
surfGroup(Istream& is, const label index);
//- Construct from dictionary
surfGroup
(
const word& name,
const dictionary& dict,
const label index
);
//- Construct as copy
surfGroup(const surfGroup&);
//- Construct from another patch, resetting the index
surfGroup
(
const surfGroup&,
const label index
);
//- Return clone
autoPtr<surfGroup> clone() const
{
notImplemented("autoPtr<surfGroup> clone() const");
return autoPtr<surfGroup>(NULL);
}
static autoPtr<surfGroup> New(Istream& is)
{
word name(is);
dictionary dict(is);
return autoPtr<surfGroup>(new surfGroup(name, dict, 0));
}
// Member Functions
//- Return start label of this patch in the face list
label start() const
{
return start_;
}
//- Return start label of this patch in the face list
label& start()
{
return start_;
}
//- Return size of this patch in the face list
label size() const
{
return size_;
}
//- Return size of this patch in the face list
label& size()
{
return size_;
}
//- Write
void write(Ostream&) const;
//- Write dictionary
void writeDict(Ostream&) const;
// Member Operators
bool operator!=(const surfGroup&) const;
//- compare.
bool operator==(const surfGroup&) const;
// IOstream Operators
friend Istream& operator>>(Istream&, surfGroup&);
friend Ostream& operator<<(Ostream&, const surfGroup&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,152 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 "surfGroupIOList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfGroupIOList, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfGroupIOList::surfGroupIOList
(
const IOobject& io
)
:
surfGroupList(),
regIOobject(io)
{
Foam::string functionName =
"surfGroupIOList::surfGroupIOList"
"(const IOobject& io)";
if (readOpt() == IOobject::MUST_READ)
{
surfGroupList& patches = *this;
// read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size());
label faceI = 0;
forAll(patches, patchI)
{
const dictionary& dict = patchEntries[patchI].dict();
label patchSize = readLabel(dict.lookup("nFaces"));
label startFaceI = readLabel(dict.lookup("startFace"));
patches[patchI] = surfGroup
(
patchEntries[patchI].keyword(),
patchSize,
startFaceI,
patchI
);
word geoType;
if (dict.readIfPresent("geometricType", geoType))
{
patches[patchI].geometricType() = geoType;
}
if (startFaceI != faceI)
{
FatalErrorIn(functionName)
<< "Patches are not ordered. Start of patch " << patchI
<< " does not correspond to sum of preceding patches."
<< endl
<< "while reading " << io.objectPath()
<< exit(FatalError);
}
faceI += patchSize;
}
// Check state of IOstream
is.check(functionName.c_str());
close();
}
}
// Construct from IOObject
Foam::surfGroupIOList::surfGroupIOList
(
const IOobject& io,
const surfGroupList& patches
)
:
surfGroupList(patches),
regIOobject(io)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfGroupIOList::~surfGroupIOList()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// writeData member function required by regIOobject
bool Foam::surfGroupIOList::writeData(Ostream& os) const
{
os << *this;
return os.good();
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroupIOList& patches)
{
os << patches.size() << nl << token::BEGIN_LIST;
forAll(patches, patchI)
{
patches[patchI].writeDict(os);
}
os << token::END_LIST;
return os;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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::surfGroupIOList
Description
IOobject for a surfGroupList
SourceFiles
surfGroupIOList.C
\*---------------------------------------------------------------------------*/
#ifndef surfGroupIOList_H
#define surfGroupIOList_H
#include "surfGroupList.H"
#include "regIOobject.H"
#include "faceList.H"
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class surfGroupIOList Declaration
\*---------------------------------------------------------------------------*/
class surfGroupIOList
:
public surfGroupList,
public regIOobject
{
// Private data
// Private Member Functions
//- Disallow default bitwise copy construct
surfGroupIOList(const surfGroupIOList&);
//- Disallow default bitwise assignment
void operator=(const surfGroupIOList&);
public:
//- Runtime type information
TypeName("surfGroupIOList");
// Constructors
//- Construct from IOobject
explicit surfGroupIOList(const IOobject& io);
//- Construct from IOobject
surfGroupIOList(const IOobject& io, const surfGroupList&);
// Destructor
~surfGroupIOList();
// Member Functions
//- writeData member function required by regIOobject
bool writeData(Ostream&) const;
// Member Operators
// Friend Functions
// Friend Operators
// IOstream Operators
friend Ostream& operator<<(Ostream&, const surfGroupIOList&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Typedef
Foam::surfGroupList
Description
\*---------------------------------------------------------------------------*/
#ifndef surfGroupList_H
#define surfGroupList_H
#include "surfGroup.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfGroup> surfGroupList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 "surfPatchIdentifier.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfPatchIdentifier::surfPatchIdentifier()
:
name_(word::null),
boundaryIndex_(0),
geometricType_(word::null)
{}
Foam::surfPatchIdentifier::surfPatchIdentifier
(
const word& name,
const label index,
const word& geometricType
)
:
name_(name),
boundaryIndex_(index),
geometricType_(geometricType)
{}
Foam::surfPatchIdentifier::surfPatchIdentifier
(
const word& name,
const dictionary& dict,
const label index
)
:
name_(name),
boundaryIndex_(index)
{
dict.readIfPresent("geometricType", geometricType_);
}
Foam::surfPatchIdentifier::surfPatchIdentifier
(
const surfPatchIdentifier& p,
const label index
)
:
name_(p.name()),
boundaryIndex_(index),
geometricType_(p.geometricType())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfPatchIdentifier::~surfPatchIdentifier()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfPatchIdentifier::write(Ostream& os) const
{
if (geometricType_.size())
{
os.writeKeyword("geometricType") << geometricType_
<< token::END_STATEMENT << nl;
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// bool Foam::surfPatchIdentifier::operator!=
// (
// const surfPatchIdentifier& p
// ) const
// {
// return !(*this == p);
// }
//
//
// bool Foam::surfPatchIdentifier::operator==
// (
// const surfPatchIdentifier& p
// ) const
// {
// return geometricType() == p.geometricType() && name() == p.name();
// }
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// Foam::Istream& Foam::operator>>(Istream& is, surfPatchIdentifier& p)
// {
// is >> p.name_ >> p.geometricType_;
//
// return is;
// }
Foam::Ostream& Foam::operator<<(Ostream& os, const surfPatchIdentifier& p)
{
p.write(os);
os.check
(
"Ostream& operator<<(Ostream&, const surfPatchIdentifier&)"
);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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::surfPatchIdentifier
Description
Like patchIdentifier but for surfaces with "geometricType" rather
than "physicalType".
SourceFiles
surfPatchIdentifier.C
\*---------------------------------------------------------------------------*/
#ifndef surfPatchIdentifier_H
#define surfPatchIdentifier_H
#include "word.H"
#include "label.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class dictionary;
// Forward declaration of friend functions and operators
class surfPatchIdentifier;
Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
/*---------------------------------------------------------------------------*\
Class surfPatchIdentifier Declaration
\*---------------------------------------------------------------------------*/
class surfPatchIdentifier
{
// Private data
//- Name of patch
word name_;
//- Index of patch in boundary
label boundaryIndex_;
//- Type name of patch
mutable word geometricType_;
public:
// Constructors
//- Construct null
surfPatchIdentifier();
//- Construct from components
surfPatchIdentifier
(
const word& name,
const label index,
const word& geometricType = word::null
);
//- Construct from dictionary
surfPatchIdentifier
(
const word& name,
const dictionary&,
const label index
);
//- Construct from another patch, resetting the index
surfPatchIdentifier
(
const surfPatchIdentifier&,
const label index
);
// Destructor
virtual ~surfPatchIdentifier();
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Return name for modification
word& name()
{
return name_;
}
//- Return the geometric type of the patch
const word& geometricType() const
{
return geometricType_;
}
//- Return the geometric type of the patch for modification
word& geometricType()
{
return geometricType_;
}
//- Return the index of this patch in the boundaryMesh
label index() const
{
return boundaryIndex_;
}
//- Write surfPatchIdentifier as a dictionary
void write(Ostream&) const;
//- Write surfPatchIdentifier as a dictionary
// void writeDict(Ostream&) const;
// Member Operators
// bool operator!=(const surfPatchIdentifier&) const;
//
// //- compare.
// bool operator==(const surfPatchIdentifier&) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
// friend Istream& operator>>(Istream&, surfPatchIdentifier&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
Typedef
Foam::surfPatchIdentifierList
Description
\*---------------------------------------------------------------------------*/
#ifndef surfPatchIdentifierList_H
#define surfPatchIdentifierList_H
#include "surfPatchIdentifier.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfPatchIdentifier> surfPatchIdentifierList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //