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/keyedSurfaceCleanup.C
keyedSurface/newKeyedSurface.C
@ -8,6 +12,7 @@ meshedSurface/newMeshedSurface.C
fileFormats = keyedSurface/fileFormats
$(fileFormats)/ac3d/AC3DfileFormat.C
$(fileFormats)/ftr/FTRfileFormat.C
$(fileFormats)/gts/GTSfileFormat.C
$(fileFormats)/nas/NASfileFormat.C
$(fileFormats)/obj/OBJfileFormat.C

View File

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

View File

@ -87,7 +87,7 @@ class AC3DfileFormat
);
//- Write header with materials
static void writeHeader(Ostream&, const List<surfacePatch>&);
static void writeHeader(Ostream&, const List<surfGroup>&);
//- Disallow default bitwise copy construct
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;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
// Write header, print patch names as comment
@ -357,7 +357,7 @@ void Foam::fileFormats::GTSfileFormat::write
{
const pointField& pointLst = surf.points();
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
// just issue a warning and get out
@ -425,7 +425,7 @@ void Foam::fileFormats::GTSfileFormat::write
label faceIndex = 0;
forAll(patchLst, patchI)
{
const surfacePatch& patch = patchLst[patchI];
const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI)
{

View File

@ -120,7 +120,10 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
if (!is.good())
{
FatalErrorIn("fileFormats::NASfileFormat::NASfileFormat(const fileName&)")
FatalErrorIn
(
"fileFormats::NASfileFormat::NASfileFormat(const fileName&)"
)
<< "Cannot read file " << fName
<< exit(FatalError);
}
@ -373,10 +376,10 @@ Foam::fileFormats::NASfileFormat::NASfileFormat
if (line[0] != '*')
{
FatalErrorIn
(
"fileFormats::NASfileFormat::NASfileFormat"
"(const fileName&)"
)
(
"fileFormats::NASfileFormat::NASfileFormat"
"(const fileName&)"
)
<< "Expected continuation symbol '*' when reading GRID*"
<< " (double precision coordinate) output" << nl
<< "Read:" << line << nl

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,7 +82,10 @@ bool Foam::fileFormats::STARCDfileFormat::readHeader
{
if (!is.good())
{
FatalErrorIn("fileFormats::STARCDfileFormat::readHeader()")
FatalErrorIn
(
"fileFormats::STARCDfileFormat::readHeader()"
)
<< "cannot read " << signature << " " << is.name()
<< abort(FatalError);
}
@ -405,7 +408,7 @@ void Foam::fileFormats::STARCDfileFormat::write
labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
osPtr.reset(new OFstream(baseName + ".cel"));
@ -414,7 +417,7 @@ void Foam::fileFormats::STARCDfileFormat::write
label faceIndex = 0;
forAll(patchLst, patchI)
{
const surfacePatch& patch = patchLst[patchI];
const surfGroup& patch = patchLst[patchI];
forAll(patch, patchFaceI)
{
@ -433,7 +436,7 @@ void Foam::fileFormats::STARCDfileFormat::write
)
{
const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches();
const List<surfGroup>& patchLst = surf.patches();
fileName baseName = fName.lessExt();
@ -449,7 +452,7 @@ void Foam::fileFormats::STARCDfileFormat::write
label faceIndex = 0;
forAll(patchLst, patchI)
{
const surfacePatch& patch = patchLst[patchI];
const surfGroup& patch = patchLst[patchI];
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
if (!is.good())
{
FatalErrorIn("fileFormats::STLfileFormat::readBINARY(Istream&)")
FatalErrorIn
(
"fileFormats::STLfileFormat::readBINARY(Istream&)"
)
<< "problem reading header, perhaps file is not binary "
<< exit(FatalError);
}
@ -185,7 +188,10 @@ bool Foam::fileFormats::STLfileFormat::readBINARY
|| nTris > (fileSize - headerSize)/25
)
{
FatalErrorIn("fileFormats::STLfileFormat::readBINARY(Istream&)")
FatalErrorIn
(
"fileFormats::STLfileFormat::readBINARY(Istream&)"
)
<< "problem reading number of triangles, perhaps file is not binary"
<< exit(FatalError);
}
@ -350,13 +356,13 @@ void Foam::fileFormats::STLfileFormat::writeASCII
const vectorField& normLst = surf.faceNormals();
labelList faceMap;
List<surfacePatch> patchLst = surf.sortedRegions(faceMap);
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
label faceIndex = 0;
forAll(patchLst, patchI)
{
// Print all faces belonging to this region
const surfacePatch& patch = patchLst[patchI];
const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl;
@ -381,7 +387,7 @@ void Foam::fileFormats::STLfileFormat::writeASCII
{
const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces();
const List<surfacePatch>& patchLst = surf.patches();
const List<surfGroup>& patchLst = surf.patches();
const vectorField& normLst = surf.faceNormals();
// force triangulation, but just do the cheapest form possible
@ -389,7 +395,7 @@ void Foam::fileFormats::STLfileFormat::writeASCII
forAll(patchLst, patchI)
{
// Print all faces belonging to this region
const surfacePatch& patch = patchLst[patchI];
const surfGroup& patch = patchLst[patchI];
os << "solid " << patch.name() << endl;
@ -459,7 +465,7 @@ void Foam::fileFormats::STLfileFormat::writeBINARY
const pointField& pointLst = surf.points();
const List<face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
const surfacePatchList& patchLst = surf.patches();
const List<surfGroup>& patchLst = surf.patches();
// Write the STL header
string header("STL binary file", headerSize);

View File

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

View File

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

View File

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

View File

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

View File

@ -50,8 +50,8 @@ SourceFiles
#include "pointField.H"
#include "PrimitivePatchExtra.H"
#include "boolList.H"
#include "geometricSurfacePatchList.H"
#include "surfacePatchList.H"
#include "surfPatchIdentifierList.H"
#include "surfGroupList.H"
#include "face.H"
#include "Keyed.H"
#include "xfer.H"
@ -63,11 +63,18 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
class Time;
class IFstream;
class keyedSurface;
class meshedSurface;
class polyBoundaryMesh;
Istream& operator>>(Istream&, keyedSurface&);
Ostream& operator<<(Ostream&, const keyedSurface&);
/*---------------------------------------------------------------------------*\
Class keyedSurface Declaration
\*---------------------------------------------------------------------------*/
@ -88,6 +95,9 @@ protected:
//- Typedef for similar code in keyedSurface and meshedSurface
typedef face FaceType;
//- Typedef for type holding the region (patch) informationm
typedef surfPatchIdentifier PatchRegionType;
private:
// Private typedefs
@ -108,17 +118,13 @@ private:
//- Patch information (face ordering nFaces/startFace only used
// during reading and writing)
geometricSurfacePatchList geoPatches_;
List<PatchRegionType> patches_;
// Private member functions
//- Read in Foam format
//- Read OpenFOAM Surface format
bool read(Istream&);
//- Generic read routine. Chooses reader based on extension.
//? bool read(const fileName&, const word& ext);
//- Disable setSize with value
void setSize(const label, const FaceType&);
@ -175,9 +181,6 @@ public:
//- Runtime type information
ClassName("keyedSurface");
//- Return the default geometric patch type (usually "empty")
static word defaultGeometricType;
// Static
//- Name of keyedSurface directory to use.
@ -199,7 +202,7 @@ public:
const xfer<pointField>&,
const xfer<List<face> >&,
const xfer<List<label> >& regionIds,
const xfer<geometricSurfacePatchList>&
const xfer<surfPatchIdentifierList>&
);
//- Construct by transferring points, faces and regionIds
@ -240,6 +243,13 @@ public:
//- Construct from a 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)
keyedSurface
(
@ -264,12 +274,6 @@ public:
//- Construct as copy
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
@ -334,116 +338,126 @@ public:
// Member Functions
// Access
// Access
//- Return the number of points
label nPoints() const
{
return points().size();
}
//- Return the number of points
label nPoints() const
{
return points().size();
}
//- Return the number of faces
label nFaces() const
{
return MeshStorage::size();
}
//- Return the number of faces
label nFaces() const
{
return MeshStorage::size();
}
//- The surface size is the number of faces
label size() const
{
return MeshStorage::size();
}
//- The surface size is the number of faces
label size() const
{
return MeshStorage::size();
}
//- Reset size of face and region list
void setSize(const label);
//- Reset size of face and region list
void setSize(const label);
//- Return const access to global points
const pointField& points() const
{
return MeshStorage::points();
}
//- Return const access to global points
const pointField& points() const
{
return MeshStorage::points();
}
//- Return const access to the faces
const List<FaceType>& faces() const
{
return static_cast<const List<FaceType> &>(*this);
}
//- Return const access to the faces
const List<FaceType>& faces() const
{
return static_cast<const List<FaceType> &>(*this);
}
//- Return const access to the regions
const List<label>& regions() const
{
return regions_;
}
//- Return const access to the regions
const List<label>& regions() const
{
return regions_;
}
const geometricSurfacePatchList& geoPatches() const
{
return geoPatches_;
}
const surfPatchIdentifierList& patches() const
{
return patches_;
}
geometricSurfacePatchList& geoPatches()
{
return geoPatches_;
}
surfPatchIdentifierList& patches()
{
return patches_;
}
//- Determine the sort order from the region list.
// Returns patch list and sets faceMap to indices within faceLst
static surfacePatchList sortedRegions
(
const List<label>& regionLst,
const Map<word>& patchNames,
labelList& faceMap
);
//- Determine the sort order from the region list.
// Returns patch list and sets faceMap to indices within faceLst
static surfGroupList sortedRegions
(
const List<label>& regionLst,
const Map<word>& patchNames,
labelList& faceMap
);
//- Sort faces according to region.
// Returns patch list and sets faceMap to index within faces()
surfacePatchList sortedRegions(labelList& faceMap) const;
//- Sort faces according to region.
// Returns patch list and sets faceMap to index within faces()
surfGroupList sortedRegions(labelList& faceMap) const;
// Edit
// Edit
//- Move points
virtual void movePoints(const pointField&);
//- Move points
virtual void movePoints(const pointField&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar&);
void checkFaces(const bool verbose);
void checkFaces(const bool verbose);
//- Remove invalid faces
void cleanup(const bool verbose);
//- Remove invalid faces
void cleanup(const bool verbose);
//- Return new surface. Returns pointMap, faceMap from
// subsetMeshMap
keyedSurface subsetMesh
(
const boolList& include,
labelList& pointMap,
labelList& faceMap
) const;
//- Return new surface. Returns pointMap, faceMap from
// subsetMeshMap
keyedSurface subsetMesh
(
const boolList& include,
labelList& pointMap,
labelList& faceMap
) const;
//- Transfer the contents of the argument and annull the argument
void transfer(keyedSurface&);
//- Transfer the contents of the argument and annull the argument
void transfer(keyedSurface&);
//- Transfer the contents of the argument and annull the argument
void transfer(meshedSurface&);
//- Transfer the contents of the argument and annull the argument
void transfer(meshedSurface&);
// Write
// Read
//- Write to Ostream in simple FOAM format
virtual void write(Ostream&) const;
//- Read from file. Chooses reader based on extension
bool read
(
const fileName&,
const word& ext,
const bool triangulate=false
);
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& fName) const
{
write(fName, *this);
}
//- Write to database
void write(const Time&) const;
// Write
//- Write some statistics
void writeStats(Ostream&) const;
//- Write to Ostream in simple FOAM format
virtual void write(Ostream&) const;
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& fName) const
{
write(fName, *this);
}
//- Write to database
void write(const Time&) const;
//- Write some statistics
void writeStats(Ostream&) const;
// Friend Functions
// Member operators
@ -452,6 +466,7 @@ public:
// Ostream Operator
// friend Istream& operator>>(Istream&, 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
//! @cond localscope
const char * const nativeExt = "ftr";
const char * const nativeExt = "ofs";
//! @endcond localscope
// * * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * //
@ -174,9 +173,8 @@ void Foam::meshedSurface::onePatch()
{
// set single default patch
patches_.setSize(1);
patches_[0] = surfacePatch
patches_[0] = surfGroup
(
defaultGeometricType,
"patch0",
size(), // patch size
0, // patch start
@ -255,7 +253,7 @@ void Foam::meshedSurface::sortFacesByRegion
else if (regionIds.size() == unsortedFaces.size())
{
labelList faceMap;
surfacePatchList newPatches = keyedSurface::sortedRegions
surfGroupList newPatches = keyedSurface::sortedRegions
(
regionIds,
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)
{
notImplemented("Foam::meshedSurface::read(Istream&)");
return false;
List<surfGroup> patchLst(is);
is >> points() >> faces();
//// is >> patches_ >> points() >> faces();
//// return true;
}
#if 0
// Read from file in given format
bool Foam::meshedSurface::read(const fileName& name, const word& ext)
{
if (ext == "gz")
// copy patch info:
patches_.setSize(patchLst.size());
forAll(patchLst, patchI)
{
fileName unzipName = name.lessExt();
return read(unzipName, unzipName.ext());
patches_[patchI] = surfGroup
(
patchLst[patchI],
patchI
);
}
}
#endif
return is.good();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -312,7 +306,7 @@ Foam::meshedSurface::meshedSurface
(
const xfer<pointField>& pointLst,
const xfer<List<FaceType> >& faceLst,
const xfer<surfacePatchList>& patchLst
const xfer<surfGroupList>& patchLst
)
:
MeshStorage(List<FaceType>(), pointField()),
@ -337,14 +331,13 @@ Foam::meshedSurface::meshedSurface
points().transfer(pointLst());
faces().transfer(faceLst());
surfacePatchList newPatches(patchSizes.size());
surfGroupList newPatches(patchSizes.size());
label start = 0;
forAll(newPatches, patchI)
{
newPatches[patchI] = surfacePatch
newPatches[patchI] = surfGroup
(
defaultGeometricType,
patchNames[patchI],
patchSizes[patchI],
start,
@ -477,16 +470,15 @@ Foam::meshedSurface::meshedSurface
}
// create patch list
surfacePatchList newPatches(bPatches.size());
surfGroupList newPatches(bPatches.size());
label startFaceI = 0;
forAll(bPatches, patchI)
{
const polyPatch& p = bPatches[patchI];
newPatches[patchI] = surfacePatch
newPatches[patchI] = surfGroup
(
defaultGeometricType,
p.name(),
p.size(),
startFaceI,
@ -512,16 +504,15 @@ Foam::meshedSurface::meshedSurface
const surfPatchList& sPatches = sMesh.boundaryMesh();
// create patch list
surfacePatchList newPatches(sPatches.size());
List<surfGroup> newPatches(sPatches.size());
label startFaceI = 0;
forAll(sPatches, patchI)
{
const surfPatch& p = sPatches[patchI];
newPatches[patchI] = surfacePatch
newPatches[patchI] = surfGroup
(
defaultGeometricType,
p.name(),
p.size(),
startFaceI,
@ -544,7 +535,7 @@ Foam::meshedSurface::meshedSurface
MeshStorage(List<FaceType>(), surf.points())
{
labelList faceMap;
surfacePatchList patchLst = surf.sortedRegions(faceMap);
surfGroupList patchLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst);
const List<FaceType>& origFaces = surf.faces();
@ -569,11 +560,10 @@ Foam::meshedSurface::meshedSurface
:
MeshStorage(List<FaceType>(), pointField())
{
// use selector mechanism
autoPtr<meshedSurface> surfPtr = New(fName, ext, triangulate);
transfer(surfPtr());
read(fName, ext, triangulate);
}
Foam::meshedSurface::meshedSurface
(
const fileName& fName,
@ -582,9 +572,7 @@ Foam::meshedSurface::meshedSurface
:
MeshStorage(List<FaceType>(), pointField())
{
// use selector mechanism
autoPtr<meshedSurface> surfPtr = New(fName, triangulate);
transfer(surfPtr());
read(fName, fName.ext(), triangulate);
}
@ -593,7 +581,6 @@ Foam::meshedSurface::meshedSurface(Istream& is)
MeshStorage(List<FaceType>(), pointField())
{
read(is);
// setDefaultPatches();
}
@ -694,7 +681,7 @@ Foam::meshedSurface Foam::meshedSurface::subsetMesh
}
// create a new patch list
surfacePatchList newPatches(patches_);
surfGroupList newPatches(patches_);
forAll(newPatches, patchI)
{
newPatches[patchI].size() = 0;
@ -769,10 +756,10 @@ void Foam::meshedSurface::transfer(keyedSurface& surf)
faces().clear();
labelList faceMap;
surfacePatchList patchLst = surf.sortedRegions(faceMap);
surfGroupList patchLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst);
surf.regions().clear();
surf.geoPatches_.clear();
surf.patches_.clear();
List<FaceType>& oldFaces = surf.faces();
List<FaceType> newFaces(oldFaces.size());
@ -820,8 +807,10 @@ bool Foam::meshedSurface::canWrite(const word& ext, const bool verbose)
{
if (verbose)
{
const wordList& known =
writefileExtensionMemberFunctionTablePtr_->toc();
SortableList<word> known
(
writefileExtensionMemberFunctionTablePtr_->toc()
);
Info<<"Unknown file extension for writing: " << fExt << nl;
// 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
(
const fileName& fName,
@ -883,20 +894,28 @@ void Foam::meshedSurface::write
void Foam::meshedSurface::write(Ostream& os) const
{
// quick-hack
os << "\n// regions:\n"
<< patches_.size() << nl << token::BEGIN_LIST;
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os);
os << "// OpenFOAM Surface format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patches_, patchI)
{
patches_[patchI].writeDict(os);
}
os << token::END_LIST << endl;
os << decrIndent << token::END_LIST << nl;
IOobject::writeDivider(os);
// Note: Write with global point numbering
os << "\n// points:\n"
<< points() << nl
<< "\n// faces:\n"
<< faces() << endl;
os << "\n// points:" << nl << points() << nl;
IOobject::writeDivider(os);
os << "\n// faces:" << nl << faces() << nl;
IOobject::writeDivider(os);
// Check state of Ostream
os.check("meshedSurface::write(Ostream&)");

View File

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