added surfMesh, reworked MeshedSurface

- renamed surface regions (formerly patches or groups) to surfZone.

- added surfMesh, but without any of the patch information needed to make it
  useful for finiteArea.

- promoted coordinateSystem transformation to surfaceMeshConvert and moved
  old to surfaceMeshConvertTesting.
This commit is contained in:
Mark Olesen
2009-02-04 16:17:14 +01:00
parent bf6915455d
commit a43df3bddd
77 changed files with 3097 additions and 1358 deletions

View File

@ -1,3 +0,0 @@
surfaceCoordinateSystemTransform.C
EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -lmeshTools -lsurfMesh

View File

@ -1,257 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
surfaceMeshCoordinateSystemTransform
Description
Transform (scale/rotate/translate) a surface based on
a coordinateSystem.
Usage
- surfaceMeshCoordinateSystemTransform inputFile outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface.
@param -scaleIn \<scale\> \n
Specify a scaling factor when reading files.
@param -scaleOut \<scale\> \n
Specify a scaling factor when writing files.
@param -dict \<dictionary\> \n
Specify an alternative dictionary for coordinateSystems.
@param -from \<coordinateSystem\> \n
Specify a coordinate System when reading files.
@param -to \<coordinateSystem\> \n
Specify a coordinate System when writing files.
Note
The filename extensions are used to determine the file format type.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "MeshedSurfaces.H"
#include "coordinateSystems.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs();
fileName importName(params[0]);
fileName exportName(params[1]);
// disable inplace editing
if (importName == exportName)
{
FatalErrorIn(args.executable())
<< "Output file " << exportName << " would overwrite input file."
<< exit(FatalError);
}
// check that reading/writing is supported
if
(
!MeshedSurface<face>::canRead(importName, true)
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
)
{
return 1;
}
// get the coordinate transformations
autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to"))
{
autoPtr<IOobject> csDictIoPtr;
if (args.options().found("dict"))
{
fileName dictPath(args.options()["dict"]);
csDictIoPtr.set
(
new IOobject
(
( dictPath.isDir() ? dictPath/coordinateSystems::typeName : dictPath ),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
csDictIoPtr.set
(
new IOobject
(
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
if (!csDictIoPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
if (args.options().found("from"))
{
const word csName(args.options()["from"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -from " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
fromCsys.reset(new coordinateSystem(csLst[csId]));
}
if (args.options().found("to"))
{
const word csName(args.options()["to"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -to " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
toCsys.reset(new coordinateSystem(csLst[csId]));
}
// maybe fix this later
if (fromCsys.valid() && toCsys.valid())
{
FatalErrorIn(args.executable())
<< "Only allowed '-from' or '-to' option at the moment."
<< exit(FatalError);
}
}
scalar scaleIn = 0;
scalar scaleOut = 0;
if (args.options().found("scaleIn"))
{
IStringStream(args.options()["scaleIn"])() >> scaleIn;
}
if (args.options().found("scaleOut"))
{
IStringStream(args.options()["scaleOut"])() >> scaleOut;
}
{
MeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{
surf.cleanup(true);
}
if (scaleIn > 0)
{
Info<< " -scaleIn " << scaleIn << endl;
surf.scalePoints(scaleIn);
}
if (fromCsys.valid())
{
Info<< " -from " << fromCsys().name() << endl;
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
Info<< " -to " << toCsys().name() << endl;
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
if (scaleOut > 0)
{
Info<< " -scaleOut " << scaleOut << endl;
surf.scalePoints(scaleOut);
}
Info<< "writing " << exportName;
surf.write(exportName);
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -lsurfMesh
EXE_LIBS = -lmeshTools -lsurfMesh

View File

@ -26,25 +26,30 @@ Application
surfaceMeshConvert
Description
Converts from one surface mesh format to another
Convert between surface formats with optional scaling or
transformations (rotate/translate) on a coordinateSystem.
Usage
- surfaceMeshConvert inputFile outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface
Perform some surface checking/cleanup on the input surface.
@param -orient \n
Check face orientation on the input surface
@param -scaleIn \<scale\> \n
Specify a scaling factor when reading files.
@param -scale \<scale\> \n
Specify a scaling factor for writing the files
@param -scaleOut \<scale\> \n
Specify a scaling factor when writing files.
@param -triSurface \n
Use triSurface library for input/output
@param -dict \<dictionary\> \n
Specify an alternative dictionary for constant/coordinateSystems.
@param -keyed \n
Use keyedSurface for input/output
@param -from \<coordinateSystem\> \n
Specify a coordinate System when reading files.
@param -to \<coordinateSystem\> \n
Specify a coordinate System when writing files.
Note
The filename extensions are used to determine the file format type.
@ -54,12 +59,9 @@ Note
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "triSurface.H"
#include "PackedBoolList.H"
#include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H"
#include "coordinateSystems.H"
using namespace Foam;
@ -71,24 +73,21 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("orient", "");
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("triSurface", "");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("triFace", "");
# include "setRootCase.H"
const stringList& params = args.additionalArgs();
argList::validOptions.insert("clean", "scale");
argList::validOptions.insert("scaleIn", "scale");
argList::validOptions.insert("scaleOut", "scale");
argList::validOptions.insert("dict", "coordinateSystemsDict");
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
scalar scaleFactor = 0;
if (args.options().found("scale"))
{
IStringStream(args.options()["scale"])() >> scaleFactor;
}
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs();
fileName importName(params[0]);
fileName exportName(params[1]);
// disable inplace editing
if (importName == exportName)
{
FatalErrorIn(args.executable())
@ -96,165 +95,157 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
// check that reading/writing is supported
if
(
!meshedSurface::canRead(importName, true)
|| !meshedSurface::canWriteType(exportName.ext(), true)
!MeshedSurface<face>::canRead(importName, true)
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
)
{
return 1;
}
if (args.options().found("triSurface"))
// get the coordinate transformations
autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to"))
{
triSurface surf(importName);
autoPtr<IOobject> csDictIoPtr;
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
if (args.options().found("dict"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
fileName dictPath(args.options()["dict"]);
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
csDictIoPtr.set
(
new IOobject
(
( dictPath.isDir() ? dictPath/coordinateSystems::typeName : dictPath ),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
csDictIoPtr.set
(
new IOobject
(
coordinateSystems::typeName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
// write sorted by region
surf.write(exportName, true);
if (!csDictIoPtr->headerOk())
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
if (args.options().found("from"))
{
const word csName(args.options()["from"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -from " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
fromCsys.reset(new coordinateSystem(csLst[csId]));
}
if (args.options().found("to"))
{
const word csName(args.options()["to"]);
label csId = csLst.find(csName);
if (csId < 0)
{
FatalErrorIn(args.executable())
<< "Cannot find -to " << csName << nl
<< "available coordinateSystems: " << csLst.toc() << nl
<< exit(FatalError);
}
toCsys.reset(new coordinateSystem(csLst[csId]));
}
// maybe fix this later
if (fromCsys.valid() && toCsys.valid())
{
FatalErrorIn(args.executable())
<< "Only allowed '-from' or '-to' option at the moment."
<< exit(FatalError);
}
}
else if (args.options().found("unsorted"))
scalar scaleIn = 0;
scalar scaleOut = 0;
if (args.options().found("scaleIn"))
{
UnsortedMeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
IStringStream(args.options()["scaleIn"])() >> scaleIn;
}
#if 1
else if (args.options().found("triFace"))
if (args.options().found("scaleOut"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
IStringStream(args.options()["scaleOut"])() >> scaleOut;
}
#endif
else
{
MeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
if (scaleIn > 0)
{
Info<< " -scaleIn " << scaleIn << endl;
surf.scalePoints(scaleIn);
}
if (fromCsys.valid())
{
Info<< " -from " << fromCsys().name() << endl;
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
surf.movePoints(tpf());
}
if (toCsys.valid())
{
Info<< " -to " << toCsys().name() << endl;
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
surf.movePoints(tpf());
}
if (scaleOut > 0)
{
Info<< " -scaleOut " << scaleOut << endl;
surf.scalePoints(scaleOut);
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}

View File

@ -0,0 +1,3 @@
surfaceMeshConvertTesting.C
EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
EXE_LIBS = -lsurfMesh

View File

@ -0,0 +1,323 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
surfaceMeshConvertTesting
Description
Converts from one surface mesh format to another, but primarily
used for testing functionality.
Usage
- surfaceMeshConvertTesting inputFile outputFile [OPTION]
@param -clean \n
Perform some surface checking/cleanup on the input surface
@param -orient \n
Check face orientation on the input surface
@param -scale \<scale\> \n
Specify a scaling factor for writing the files
@param -triSurface \n
Use triSurface library for input/output
@param -keyed \n
Use keyedSurface for input/output
Note
The filename extensions are used to determine the file format type.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "polyMesh.H"
#include "triSurface.H"
#include "surfMesh.H"
#include "surfFields.H"
#include "PackedBoolList.H"
#include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("inputFile");
argList::validArgs.append("outputFile");
argList::validOptions.insert("clean", "");
argList::validOptions.insert("orient", "");
argList::validOptions.insert("surfMesh", "");
argList::validOptions.insert("scale", "scale");
argList::validOptions.insert("triSurface", "");
argList::validOptions.insert("unsorted", "");
argList::validOptions.insert("triFace", "");
# include "setRootCase.H"
const stringList& params = args.additionalArgs();
scalar scaleFactor = 0;
if (args.options().found("scale"))
{
IStringStream(args.options()["scale"])() >> scaleFactor;
}
fileName importName(params[0]);
fileName exportName(params[1]);
if (importName == exportName)
{
FatalErrorIn(args.executable())
<< "Output file " << exportName << " would overwrite input file."
<< exit(FatalError);
}
if
(
!meshedSurface::canRead(importName, true)
|| !meshedSurface::canWriteType(exportName.ext(), true)
)
{
return 1;
}
if (args.options().found("triSurface"))
{
triSurface surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
// write sorted by region
surf.write(exportName, true);
}
else if (args.options().found("unsorted"))
{
UnsortedMeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
#if 1
else if (args.options().found("triFace"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
#endif
else
{
MeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("orient"))
{
Info<< "Checking surface orientation" << endl;
PatchTools::checkOrientation(surf, true);
Info<< endl;
}
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
if (args.options().found("surfMesh"))
{
Foam::Time runTime
(
args.rootPath(),
args.caseName()
);
surfMesh surfOut
(
IOobject
(
"mySurf",
runTime.instance(),
runTime
),
surf.xfer()
);
Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
surfOut.write();
surfLabelField zoneIds
(
IOobject
(
"zoneIds",
surfOut.instance(),
surfOut,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfOut,
dimless
);
const surfZoneList& zones = surfOut.surfZones();
forAll(zones, zoneI)
{
SubList<label>
(
zoneIds,
zones[zoneI].size(),
zones[zoneI].start()
) = zoneI;
}
Info<< "write zoneIds (for testing only): "
<< zoneIds.objectPath() << endl;
zoneIds.write();
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -84,7 +84,7 @@ protected:
return static_cast<List<Face> &>(*this);
}
//- Set new regions from faceMap
//- Set new zones from faceMap
virtual void remapFaces(const UList<label>& faceMap);
public:

View File

@ -1,10 +1,16 @@
surfRegion/surfRegion/surfRegion.C
surfRegion/surfRegion/surfRegionIOList.C
surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
surfZone/surfZone/surfZone.C
surfZone/surfZone/surfZoneIOList.C
surfZone/surfZoneIdentifier/surfZoneIdentifier.C
MeshedSurface/MeshedSurfaces.C
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
surfaceRegistry/surfaceRegistry.C
surfFields/surfFields.C
surfMesh/surfMesh.C
surfMesh/surfMeshClear.C
surfMesh/surfMeshIO.C
surfaceFormats = surfaceFormats
$(surfaceFormats)/surfaceFormatsCore.C

View File

@ -32,7 +32,7 @@ License
#include "ListOps.H"
#include "polyBoundaryMesh.H"
#include "polyMesh.H"
// #include "surfMesh.H"
#include "surfMesh.H"
#include "primitivePatch.H"
#include "addToRunTimeSelectionTable.H"
@ -166,11 +166,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer<surfRegionList>& regionLst
const Xfer<surfZoneList>& zoneLst
)
:
ParentType(pointLst, faceLst),
regions_(regionLst)
zones_(zoneLst)
{}
@ -179,26 +179,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const UList<label>& regionSizes,
const UList<word>& regionNames
const UList<label>& zoneSizes,
const UList<word>& zoneNames
)
:
ParentType(pointLst, faceLst)
{
if (&regionSizes)
if (&zoneSizes)
{
if (&regionNames)
if (&zoneNames)
{
addRegions(regionSizes, regionNames);
addZones(zoneSizes, zoneNames);
}
else
{
addRegions(regionSizes);
addZones(zoneSizes);
}
}
else
{
oneRegion();
oneZone();
}
}
@ -238,15 +238,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
);
// create region list
surfRegionList newRegions(bPatches.size());
// create zone list
surfZoneList newZones(bPatches.size());
label startFaceI = 0;
forAll(bPatches, patchI)
{
const polyPatch& p = bPatches[patchI];
newRegions[patchI] = surfRegion
newZones[patchI] = surfZone
(
p.name(),
p.size(),
@ -262,7 +262,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
(
xferCopy(bPoints),
xferCopy(bFaces),
xferMove(newRegions)
xferMove(newZones)
);
@ -285,7 +285,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
origFaces.clear();
this->storedFaces().transfer(newFaces);
regions_.transfer(surf.regions_);
zones_.transfer(surf.zones_);
}
else
{
@ -294,39 +294,46 @@ Foam::MeshedSurface<Face>::MeshedSurface
}
#if 0
// in preparation
template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface
(
const surfMesh& sMesh
const surfMesh& mesh
)
:
ParentType(xferCopy(sMesh.points()), xferCopy(sMesh.faces()))
{
const surfPatchList& sPatches = sMesh.boundaryMesh();
// must create with the same face type as surfMesh
MeshedSurface<face> surf
(
xferCopy(mesh.points()),
xferCopy(mesh.faces()),
xferCopy(mesh.surfZones())
);
// create regions list
List<surfRegion> newRegions(sPatches.size());
label startFaceI = 0;
forAll(sPatches, patchI)
// must triangulate?
if (this->isTri())
{
const surfPatch& p = sPatches[patchI];
surf.triangulate();
this->storedPoints().transfer(surf.storedPoints());
newRegions[patchI] = surfRegion
(
p.name(),
p.size(),
startFaceI,
patchI
);
// transcribe from face -> triFace
List<face>& origFaces = surf.storedFaces();
List<triFace> newFaces(origFaces.size());
forAll(origFaces, faceI)
{
newFaces[faceI] = Face
(
static_cast<const UList<label>&>(origFaces[faceI])
);
}
origFaces.clear();
startFaceI += p.size();
this->storedFaces().transfer(newFaces);
zones_.transfer(surf.zones_);
}
else
{
this->transfer(surf);
}
regions_.transfer(newRegions);
}
#endif
template<class Face>
@ -336,8 +343,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
)
{
labelList faceMap;
surfRegionList regionLst = surf.sortedRegions(faceMap);
regions_.transfer(regionLst);
surfZoneList zoneLst = surf.sortedZones(faceMap);
zones_.transfer(zoneLst);
const List<Face>& origFaces = surf.faces();
List<Face> newFaces(origFaces.size());
@ -388,7 +395,7 @@ template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
:
ParentType(surf),
regions_(surf.regions_)
zones_(surf.zones_)
{}
@ -420,70 +427,70 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::MeshedSurface<Face>::oneRegion(const word& name)
void Foam::MeshedSurface<Face>::oneZone(const word& name)
{
word regionName(name);
if (regionName.empty())
word zoneName(name);
if (zoneName.empty())
{
if (regions_.size())
if (zones_.size())
{
regionName = regions_[0].name();
zoneName = zones_[0].name();
}
if (regionName.empty())
if (zoneName.empty())
{
regionName = "region0";
zoneName = "zone0";
}
}
// set single default region
regions_.setSize(1);
regions_[0] = surfRegion
// set single default zone
zones_.setSize(1);
zones_[0] = surfZone
(
regionName,
size(), // region size
0, // region start
0 // region index
zoneName,
size(), // zone size
0, // zone start
0 // zone index
);
}
template<class Face>
void Foam::MeshedSurface<Face>::checkRegions()
void Foam::MeshedSurface<Face>::checkZones()
{
// extra safety, ensure we have at some regions
// extra safety, ensure we have at some zones
// and they cover all the faces - fix start silently
if (regions_.size() <= 1)
if (zones_.size() <= 1)
{
oneRegion();
oneZone();
}
else
{
label count = 0;
forAll(regions_, regionI)
forAll(zones_, zoneI)
{
regions_[regionI].start() = count;
count += regions_[regionI].size();
zones_[zoneI].start() = count;
count += zones_[zoneI].size();
}
if (count < size())
{
WarningIn
(
"MeshedSurface::checkRegions()\n"
"MeshedSurface::checkZones()\n"
)
<< "more face " << size() << " than regions " << count
<< " ... extending final region"
<< "more faces " << size() << " than zones " << count
<< " ... extending final zone"
<< endl;
regions_[regions_.size()-1].size() += count - size();
zones_[zones_.size()-1].size() += count - size();
}
else if (count > size())
{
FatalErrorIn
(
"MeshedSurface::checkRegions()\n"
"MeshedSurface::checkZones()\n"
)
<< "more regions " << count << " than faces " << size()
<< "more zones " << count << " than faces " << size()
<< exit(FatalError);
}
}
@ -494,12 +501,12 @@ template<class Face>
void Foam::MeshedSurface<Face>::sortFacesAndStore
(
const Xfer<List<Face> >& unsortedFaces,
const Xfer<List<label> >& regionIds,
const Xfer<List<label> >& zoneIds,
const bool sorted
)
{
List<Face> oldFaces(unsortedFaces);
List<label> regions(regionIds);
List<label> zones(zoneIds);
if (sorted)
{
@ -511,8 +518,8 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
// unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow
List<label> faceMap;
sortedOrder(regions, faceMap);
regions.clear();
sortedOrder(zones, faceMap);
zones.clear();
// sorted faces
List<Face> newFaces(faceMap.size());
@ -524,7 +531,7 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
this->storedFaces().transfer(newFaces);
}
regions.clear();
zones.clear();
}
@ -534,29 +541,29 @@ void Foam::MeshedSurface<Face>::remapFaces
const UList<label>& faceMap
)
{
// recalculate the region start/size
// recalculate the zone start/size
if (&faceMap && faceMap.size())
{
if (regions_.empty())
if (zones_.empty())
{
oneRegion();
oneZone();
}
else if (regions_.size() == 1)
else if (zones_.size() == 1)
{
// optimized for single region case
regions_[0].size() = faceMap.size();
// optimized for single zone case
zones_[0].size() = faceMap.size();
}
else
{
label newFaceI = 0;
label origEndI = 0;
forAll(regions_, regionI)
forAll(zones_, zoneI)
{
surfRegion& reg = regions_[regionI];
surfZone& zone = zones_[zoneI];
// adjust region start
reg.start() = newFaceI;
origEndI += reg.size();
// adjust zone start
zone.start() = newFaceI;
origEndI += zone.size();
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
{
@ -570,8 +577,8 @@ void Foam::MeshedSurface<Face>::remapFaces
}
}
// adjust region size
reg.size() = newFaceI - reg.start();
// adjust zone size
zone.size() = newFaceI - zone.start();
}
}
}
@ -586,7 +593,7 @@ template<class Face>
void Foam::MeshedSurface<Face>::clear()
{
ParentType::clear();
regions_.clear();
zones_.clear();
}
@ -614,11 +621,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
oldToNew[pointMap[pointI]] = pointI;
}
// create/copy a new region list, each region with zero size
surfRegionList newRegions(regions_);
forAll(newRegions, regionI)
// create/copy a new zones list, each zone with zero size
surfZoneList newZones(zones_);
forAll(newZones, zoneI)
{
newRegions[regionI].size() = 0;
newZones[zoneI].size() = 0;
}
// Renumber face node labels
@ -637,18 +644,18 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
}
oldToNew.clear();
// recalculate the region start/size
// recalculate the zones start/size
label newFaceI = 0;
label origEndI = 0;
// adjust region sizes
forAll(newRegions, regionI)
// adjust zone sizes
forAll(newZones, zoneI)
{
surfRegion& reg = newRegions[regionI];
surfZone& zone = newZones[zoneI];
// adjust region start
reg.start() = newFaceI;
origEndI += reg.size();
// adjust zone start
zone.start() = newFaceI;
origEndI += zone.size();
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
{
@ -662,8 +669,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
}
}
// adjust region size
reg.size() = newFaceI - reg.start();
// adjust zone size
zone.size() = newFaceI - zone.start();
}
@ -672,7 +679,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
(
xferMove(newPoints),
xferMove(newFaces),
xferMove(newRegions)
xferMove(newZones)
);
}
@ -690,29 +697,29 @@ Foam::MeshedSurface<Face>::subsetMesh
template<class Face>
void Foam::MeshedSurface<Face>::addRegions
void Foam::MeshedSurface<Face>::addZones
(
const UList<surfRegion>& regions,
const UList<surfZone>& zones,
const bool cullEmpty
)
{
label nRegion = 0;
label nZone = 0;
regions_.setSize(regions.size());
forAll(regions_, regionI)
zones_.setSize(zones.size());
forAll(zones_, zoneI)
{
if (regions[regionI].size() || !cullEmpty)
if (zones[zoneI].size() || !cullEmpty)
{
regions_[nRegion] = surfRegion(regions[regionI], nRegion);
nRegion++;
zones_[nZone] = surfZone(zones[zoneI], nZone);
nZone++;
}
}
regions_.setSize(nRegion);
zones_.setSize(nZone);
}
template<class Face>
void Foam::MeshedSurface<Face>::addRegions
void Foam::MeshedSurface<Face>::addZones
(
const UList<label>& sizes,
const UList<word>& names,
@ -720,55 +727,55 @@ void Foam::MeshedSurface<Face>::addRegions
)
{
label start = 0;
label nRegion = 0;
label nZone = 0;
regions_.setSize(sizes.size());
forAll(regions_, regionI)
zones_.setSize(sizes.size());
forAll(zones_, zoneI)
{
if (sizes[regionI] || !cullEmpty)
if (sizes[zoneI] || !cullEmpty)
{
regions_[nRegion] = surfRegion
zones_[nZone] = surfZone
(
names[regionI],
sizes[regionI],
names[zoneI],
sizes[zoneI],
start,
nRegion
nZone
);
start += sizes[regionI];
nRegion++;
start += sizes[zoneI];
nZone++;
}
}
regions_.setSize(nRegion);
zones_.setSize(nZone);
}
template<class Face>
void Foam::MeshedSurface<Face>::addRegions
void Foam::MeshedSurface<Face>::addZones
(
const UList<label>& sizes,
const bool cullEmpty
)
{
label start = 0;
label nRegion = 0;
label nZone = 0;
regions_.setSize(sizes.size());
forAll(regions_, regionI)
zones_.setSize(sizes.size());
forAll(zones_, zoneI)
{
if (sizes[regionI] || !cullEmpty)
if (sizes[zoneI] || !cullEmpty)
{
regions_[nRegion] = surfRegion
zones_[nZone] = surfZone
(
word("region") + ::Foam::name(nRegion),
sizes[regionI],
word("zone") + ::Foam::name(nZone),
sizes[zoneI],
start,
nRegion
nZone
);
start += sizes[regionI];
nRegion++;
start += sizes[zoneI];
nZone++;
}
}
regions_.setSize(nRegion);
zones_.setSize(nZone);
}
@ -779,7 +786,7 @@ void Foam::MeshedSurface<Face>::transfer
)
{
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
regions_.transfer(surf.regions_);
zones_.transfer(surf.zones_);
surf.clear();
}
@ -794,7 +801,7 @@ void Foam::MeshedSurface<Face>::transfer
clear();
labelList faceMap;
surfRegionList regionLst = surf.sortedRegions(faceMap);
surfZoneList zoneLst = surf.sortedZones(faceMap);
List<Face>& oldFaces = surf.storedFaces();
List<Face> newFaces(faceMap.size());
@ -805,12 +812,20 @@ void Foam::MeshedSurface<Face>::transfer
faceMap.clear();
reset(xferMove(surf.storedPoints()), xferMove(newFaces));
regions_.transfer(regionLst);
zones_.transfer(zoneLst);
surf.clear();
}
template<class Face>
Foam::Xfer< Foam::MeshedSurface<Face> >
Foam::MeshedSurface<Face>::xfer()
{
return xferMove(*this);
}
// Read from file, determine format from extension
template<class Face>
bool Foam::MeshedSurface<Face>::read(const fileName& name)
@ -865,7 +880,7 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
this->storedPoints() = surf.points();
this->storedFaces() = surf.faces();
regions_ = surf.regions_;
zones_ = surf.zones_;
}
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //

View File

@ -26,13 +26,13 @@ Class
Foam::MeshedSurface
Description
A surface geometry mesh with region information, not to be confused
A surface geometry mesh with zone information, not to be confused
with a similarily named surfaceMesh, which actually refers to
the cell faces of a volume mesh.
The MeshedSurface is intended to surfaces from a variety of sources.
- A set of points and faces without any region information.
- A set of points and faces with randomly sorted region information.
The MeshedSurface is intended for surfaces from a variety of sources.
- A set of points and faces without any surface zone information.
- A set of points and faces with randomly ordered zone information.
This could arise, for example, from reading external file formats
such as STL, etc.
@ -45,7 +45,7 @@ SourceFiles
#define MeshedSurface_H
#include "BasicMeshedSurface.H"
#include "surfRegionList.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
@ -59,6 +59,7 @@ namespace Foam
// Forward declaration of friend functions and operators
class Time;
class surfMesh;
template<class Face> class MeshedSurface;
template<class Face> class UnsortedMeshedSurface;
@ -79,6 +80,7 @@ class MeshedSurface
public fileFormats::surfaceFormatsCore
{
friend class UnsortedMeshedSurface<Face>;
friend class surfMesh;
private:
@ -88,9 +90,9 @@ private:
// Private Member Data
//- Region information
//- Zone information
// (face ordering nFaces/startFace only used during reading/writing)
List<surfRegion> regions_;
List<surfZone> zones_;
// Private member functions
@ -101,18 +103,24 @@ protected:
// Protected Member functions
//- basic sanity check on regions
void checkRegions();
//- basic sanity check on zones
void checkZones();
//- sort faces by regions and store sorted faces
//- Non-const access to the zones
surfZoneList& storedZones()
{
return zones_;
}
//- sort faces by zones and store sorted faces
void sortFacesAndStore
(
const Xfer<List<Face> >& unsortedFaces,
const Xfer<List<label> >& regionIds,
const Xfer<List<label> >& zoneIds,
const bool sorted
);
//- Set new regions from faceMap
//- Set new zones from faceMap
virtual void remapFaces(const UList<label>& faceMap);
public:
@ -139,22 +147,22 @@ public:
//- Construct null
MeshedSurface();
//- Construct by transferring components (points, faces, regions).
//- Construct by transferring components (points, faces, zones).
MeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<surfRegionList>&
const Xfer<surfZoneList>&
);
//- Construct by transferring points, faces.
// Use region information, or set single default region.
// Use zone information, or set single default zone.
MeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const UList<label>& regionSizes = UList<label>::null(),
const UList<word>& regionNames = UList<word>::null()
const UList<label>& zoneSizes = UList<label>::null(),
const UList<word>& zoneNames = UList<word>::null()
);
//- Construct from a boundary mesh with local points/faces
@ -250,31 +258,31 @@ public:
return ParentType::size();
}
const List<surfRegion>& regions() const
const List<surfZone>& zones() const
{
return regions_;
return zones_;
}
//- set a single region, optionally with a specific name
void oneRegion(const word& name = word::null);
//- set a single zone, optionally with a specific name
void oneZone(const word& name = word::null);
//- Add regions
void addRegions
//- Add zones
void addZones
(
const UList<surfRegion>&,
const UList<surfZone>&,
const bool cullEmpty=false
);
//- Add regions
void addRegions
//- Add zones
void addZones
(
const UList<label>& sizes,
const UList<word>& names,
const bool cullEmpty=false
);
//- Add regions
void addRegions
//- Add zones
void addZones
(
const UList<label>& sizes,
const bool cullEmpty=false
@ -306,6 +314,8 @@ public:
//- Transfer the contents of the argument and annull the argument
void transfer(UnsortedMeshedSurface<Face>&);
//- Transfer contents to the Xfer container
Xfer< MeshedSurface<Face> > xfer();
// Read

View File

@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
{
clear();
List<surfRegion> regionLst(is);
List<surfZone> newZones(is);
// copy and set the indices
regions_.setSize(regionLst.size());
forAll(regionLst, regionI)
zones_.setSize(newZones.size());
forAll(newZones, zoneI)
{
regions_[regionI] = surfRegion
zones_[zoneI] = surfZone
(
regionLst[regionI],
regionI
newZones[zoneI],
zoneI
);
}
@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
Xfer<pointField>::null(),
faceLst.xfer()
);
surf.addRegions(regions_);
surf.addZones(zones_);
// this will break if the triangulation needed points
surf.triangulate();
regions_ = surf.regions();
zones_ = surf.zones();
// transcribe from face -> triFace (Face)
const List<face>& origFaces = surf.faces();
@ -101,12 +101,12 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
IOobject::writeBanner(os);
os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< regions_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
<< "// zones:" << nl
<< zones_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(regions_, regionI)
forAll(zones_, zoneI)
{
regions_[regionI].writeDict(os);
zones_[zoneI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl;

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::SurfGeoMesh
Description
Generic mesh wrapper used by surfMesh etc.
Similar to Foam::GeoMesh, but for meshes without an underlying
BoundaryMesh.
\*---------------------------------------------------------------------------*/
#ifndef SurfGeoMesh_H
#define SurfGeoMesh_H
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class SurfGeoMesh Declaration
\*---------------------------------------------------------------------------*/
template<class MESH>
class SurfGeoMesh
{
protected:
// Protected data
//- Reference to Mesh
const MESH& mesh_;
public:
// Public typedefs
typedef MESH Mesh;
// typedef typename MESH::BoundaryMesh BoundaryMesh;
// Constructors
//- Construct from MESH reference
explicit SurfGeoMesh(const MESH& mesh)
:
mesh_(mesh)
{}
// Member Functions
//- Return the object registry
const objectRegistry& thisDb() const
{
return mesh_;
}
// Member Operators
//- Return reference to underlying mesh
const MESH& operator()() const
{
return mesh_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -163,13 +163,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer<List<label> >& regionIds,
const Xfer<surfRegionIdentifierList>& regionTofc
const Xfer<List<label> >& zoneIds,
const Xfer<surfZoneIdentifierList>& zoneTofc
)
:
ParentType(pointLst, faceLst),
regionIds_(regionIds),
regionToc_(regionTofc)
zoneIds_(zoneIds),
zoneToc_(zoneTofc)
{}
@ -178,26 +178,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const UList<label>& regionSizes,
const UList<word>& regionNames
const UList<label>& zoneSizes,
const UList<word>& zoneNames
)
:
ParentType(pointLst, faceLst)
{
if (&regionSizes)
if (&zoneSizes)
{
if (&regionNames)
if (&zoneNames)
{
setRegions(regionSizes, regionNames);
setZones(zoneSizes, zoneNames);
}
else
{
setRegions(regionSizes);
setZones(zoneSizes);
}
}
else
{
oneRegion();
oneZone();
}
}
@ -223,7 +223,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
:
ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
{
setRegions(surf.regions());
setZones(surf.zones());
}
@ -266,8 +266,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
)
:
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
regionIds_(surf.regionIds_),
regionToc_(surf.regionToc_)
zoneIds_(surf.zoneIds_),
zoneToc_(surf.zoneToc_)
{}
@ -302,99 +302,99 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
void Foam::UnsortedMeshedSurface<Face>::oneZone(const word& name)
{
regionIds_.setSize(size());
regionIds_ = 0;
zoneIds_.setSize(size());
zoneIds_ = 0;
word regionName(name);
if (regionName.empty())
word zoneName(name);
if (zoneName.empty())
{
if (regionToc_.size())
if (zoneToc_.size())
{
regionName = regionToc_[0].name();
zoneName = zoneToc_[0].name();
}
if (regionName.empty())
if (zoneName.empty())
{
regionName = "region0";
zoneName = "zone0";
}
}
// set single default region
regionToc_.setSize(1);
regionToc_[0] = surfRegionIdentifier(regionName, 0);
// set single default zone
zoneToc_.setSize(1);
zoneToc_[0] = surfZoneIdentifier(zoneName, 0);
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setRegions
void Foam::UnsortedMeshedSurface<Face>::setZones
(
const surfRegionList& regionLst
const surfZoneList& zoneLst
)
{
regionIds_.setSize(size());
regionToc_.setSize(regionLst.size());
zoneIds_.setSize(size());
zoneToc_.setSize(zoneLst.size());
forAll(regionToc_, regionI)
forAll(zoneToc_, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
regionToc_[regionI] = reg;
zoneToc_[zoneI] = zone;
// assign sub-region Ids
SubList<label> subRegion(regionIds_, reg.size(), reg.start());
subRegion = regionI;
// assign sub-zone Ids
SubList<label> subZone(zoneIds_, zone.size(), zone.start());
subZone = zoneI;
}
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setRegions
void Foam::UnsortedMeshedSurface<Face>::setZones
(
const UList<label>& sizes,
const UList<word>& names
)
{
regionIds_.setSize(size());
regionToc_.setSize(sizes.size());
zoneIds_.setSize(size());
zoneToc_.setSize(sizes.size());
label start = 0;
forAll(regionToc_, regionI)
forAll(zoneToc_, zoneI)
{
regionToc_[regionI] = surfRegionIdentifier(names[regionI], regionI);
zoneToc_[zoneI] = surfZoneIdentifier(names[zoneI], zoneI);
// assign sub-region Ids
SubList<label> subRegion(regionIds_, sizes[regionI], start);
subRegion = regionI;
// assign sub-zone Ids
SubList<label> subZone(zoneIds_, sizes[zoneI], start);
subZone = zoneI;
start += sizes[regionI];
start += sizes[zoneI];
}
}
template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setRegions
void Foam::UnsortedMeshedSurface<Face>::setZones
(
const UList<label>& sizes
)
{
regionIds_.setSize(size());
regionToc_.setSize(sizes.size());
zoneIds_.setSize(size());
zoneToc_.setSize(sizes.size());
label start = 0;
forAll(regionToc_, regionI)
forAll(zoneToc_, zoneI)
{
regionToc_[regionI] = surfRegionIdentifier
zoneToc_[zoneI] = surfZoneIdentifier
(
word("region") + ::Foam::name(regionI),
regionI
word("zone") + ::Foam::name(zoneI),
zoneI
);
// assign sub-region Ids
SubList<label> subRegion(regionIds_, sizes[regionI], start);
subRegion = regionI;
// assign sub-zone Ids
SubList<label> subZone(zoneIds_, sizes[zoneI], start);
subZone = zoneI;
start += sizes[regionI];
start += sizes[zoneI];
}
}
@ -405,27 +405,27 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
const UList<label>& faceMap
)
{
// re-assign the region Ids
// re-assign the zone Ids
if (&faceMap && faceMap.size())
{
if (regionToc_.empty())
if (zoneToc_.empty())
{
oneRegion();
oneZone();
}
else if (regionToc_.size() == 1)
else if (zoneToc_.size() == 1)
{
// optimized for single-region case
regionIds_ = 0;
// optimized for single-zone case
zoneIds_ = 0;
}
else
{
List<label> newRegions(faceMap.size());
List<label> newZones(faceMap.size());
forAll(faceMap, faceI)
{
newRegions[faceI] = regionIds_[faceMap[faceI]];
newZones[faceI] = zoneIds_[faceMap[faceI]];
}
regionIds_.transfer(newRegions);
zoneIds_.transfer(newZones);
}
}
}
@ -437,8 +437,8 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
{
ParentType::setSize(s);
// if regions extend: set with last regionId
regionIds_.setSize(s, regionToc_.size() - 1);
// if zones extend: set with last zoneId
zoneIds_.setSize(s, zoneToc_.size() - 1);
}
@ -446,25 +446,25 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::clear()
{
ParentType::clear();
regionIds_.clear();
regionToc_.clear();
zoneIds_.clear();
zoneToc_.clear();
}
template<class Face>
Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
(
labelList& faceMap
) const
{
// supply some region names
Map<word> regionNames;
forAll(regionToc_, regionI)
// supply some zone names
Map<word> zoneNames;
forAll(zoneToc_, zoneI)
{
regionNames.insert(regionI, regionToc_[regionI].name());
zoneNames.insert(zoneI, zoneToc_[zoneI].name());
}
return sortedRegionsById(regionIds_, regionNames, faceMap);
return sortedZonesById(zoneIds_, zoneNames, faceMap);
}
@ -493,7 +493,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
// Renumber face node labels and compact
List<Face> newFaces(faceMap.size());
List<label> newRegions(faceMap.size());
List<label> newZones(faceMap.size());
forAll(faceMap, faceI)
{
@ -507,7 +507,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
f[fp] = oldToNew[f[fp]];
}
newRegions[faceI] = regionIds_[origFaceI];
newZones[faceI] = zoneIds_[origFaceI];
}
oldToNew.clear();
@ -516,8 +516,8 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
(
xferMove(newPoints),
xferMove(newFaces),
xferMove(newRegions),
xferCopy(regionToc_)
xferMove(newZones),
xferCopy(zoneToc_)
);
}
@ -538,14 +538,14 @@ void Foam::UnsortedMeshedSurface<Face>::reset
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst,
const Xfer<List<label> >& regionIds
const Xfer<List<label> >& zoneIds
)
{
ParentType::reset(pointLst, faceLst);
if (&regionIds)
if (&zoneIds)
{
regionIds_.transfer(regionIds());
zoneIds_.transfer(zoneIds());
}
}
@ -560,9 +560,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
(
xferMove(surf.storedPoints()),
xferMove(surf.storedFaces()),
xferMove(surf.regionIds_)
xferMove(surf.zoneIds_)
);
regionToc_.transfer(surf.regionToc_);
zoneToc_.transfer(surf.zoneToc_);
surf.clear();
}
@ -575,11 +575,20 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
)
{
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
setRegions(surf.regions());
setZones(surf.zones());
surf.clear();
}
template<class Face>
Foam::Xfer< Foam::UnsortedMeshedSurface<Face> >
Foam::UnsortedMeshedSurface<Face>::xfer()
{
return xferMove(*this);
}
// Read from file, determine format from extension
template<class Face>
bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& name)
@ -638,8 +647,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
this->storedPoints() = surf.points();
this->storedFaces() = surf.faces();
regionIds_ = surf.regionIds_;
regionToc_ = surf.regionToc_;
zoneIds_ = surf.zoneIds_;
zoneToc_ = surf.zoneToc_;
}

View File

@ -26,18 +26,18 @@ Class
Foam::UnsortedMeshedSurface
Description
A surface geometry mesh, in which the region information is conveyed by
the 'regionId' associated with each face.
A surface geometry mesh, in which the surface zone information is
conveyed by the 'zoneId' associated with each face.
This form of surface description is particularly useful for reading in
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
can also be particularly useful for situations in which the surface
many be adjusted in an arbitrary manner without worrying about needed
to adjust the region information (eg, surface refinement).
to adjust the zone information (eg, surface refinement).
See Also
The Foam::MeshedSurface - which is organized as a surface mesh, but
with independent region information.
with independent zone information.
SourceFiles
UnsortedMeshedSurface.C
@ -48,8 +48,8 @@ SourceFiles
#define UnsortedMeshedSurface_H
#include "BasicMeshedSurface.H"
#include "surfRegionIdentifierList.H"
#include "surfRegionList.H"
#include "surfZoneIdentifierList.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
@ -93,12 +93,12 @@ private:
// Private Member Data
//- The region Ids associated with the faces
labelList regionIds_;
//- The zone Id associated with each face
labelList zoneIds_;
//- Region information (face ordering nFaces/startFace only used
//- Zone information (face ordering nFaces/startFace only used
// during reading and writing)
List<surfRegionIdentifier> regionToc_;
List<surfZoneIdentifier> zoneToc_;
// Private member functions
@ -115,19 +115,19 @@ protected:
// Protected Member functions
//- Return non-const access to the region Ids
List<label>& storedRegionIds()
//- Return non-const access to the zone Ids
List<label>& storedZoneIds()
{
return regionIds_;
return zoneIds_;
}
//- Return non-const access to the region table-of-contents
List<surfRegionIdentifier>& storedRegionToc()
//- Return non-const access to the zone table-of-contents
List<surfZoneIdentifier>& storedZoneToc()
{
return regionToc_;
return zoneToc_;
}
//- Set new regions from faceMap
//- Set new zones from faceMap
virtual void remapFaces(const UList<label>& faceMap);
public:
@ -155,23 +155,23 @@ public:
UnsortedMeshedSurface();
//- Construct by transferring components
// (points, faces, region ids, region info).
// (points, faces, zone ids, zone info).
UnsortedMeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<List<label> >& regionIds,
const Xfer<surfRegionIdentifierList>&
const Xfer<List<label> >& zoneIds,
const Xfer<surfZoneIdentifierList>&
);
//- Construct by transferring points, faces.
// Use region information, or set single default region
// Use zone information, or set single default zone
UnsortedMeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const UList<label>& regionSizes = UList<label>::null(),
const UList<word>& regionNames = UList<word>::null()
const UList<label>& zoneSizes = UList<label>::null(),
const UList<word>& zoneNames = UList<word>::null()
);
//- Construct from a boundary mesh with local points/faces
@ -264,37 +264,37 @@ public:
return ParentType::size();
}
//- Reset size of face and region list
//- Reset size of face and zone list
void setSize(const label);
//- Return const access to the regions ids
const List<label>& regionIds() const
//- Return const access to the zone ids
const List<label>& zoneIds() const
{
return regionIds_;
return zoneIds_;
}
//- Return const access to the region table-of-contents
const List<surfRegionIdentifier>& regionToc() const
//- Return const access to the zone table-of-contents
const List<surfZoneIdentifier>& zoneToc() const
{
return regionToc_;
return zoneToc_;
}
//- Sort faces according to region.
// Returns a surfRegionList and sets faceMap to index within faces()
surfRegionList sortedRegions(labelList& faceMap) const;
//- Sort faces according to zone.
// Returns a surfZoneList and sets faceMap to index within faces()
surfZoneList sortedZones(labelList& faceMap) const;
//- Set regions to 0 and set a single region
//- Set zones to 0 and set a single zone
// Optionally with a specific name
void oneRegion(const word& name = word::null);
void oneZone(const word& name = word::null);
//- Set region ids and regions
void setRegions(const surfRegionList&);
//- Set zone ids and zones
void setZones(const surfZoneList&);
//- Set region ids and regions
void setRegions(const UList<label>& sizes, const UList<word>& names);
//- Set zone ids and zones
void setZones(const UList<label>& sizes, const UList<word>& names);
//- Set region ids and set regions with default names
void setRegions(const UList<label>& sizes);
//- Set zone ids and zones with default names
void setZones(const UList<label>& sizes);
// Edit
@ -317,12 +317,12 @@ public:
const labelHashSet& include
) const;
//- Transfer components (points, faces, region ids).
//- Transfer components (points, faces, zone ids).
virtual void reset
(
const Xfer<pointField>&,
const Xfer<List<Face> >&,
const Xfer<List<label> >& regionIds = Xfer<List<label> >::null()
const Xfer<List<label> >& zoneIds = Xfer<List<label> >::null()
);
//- Transfer the contents of the argument and annull the argument
@ -331,6 +331,9 @@ public:
//- Transfer the contents of the argument and annull the argument
void transfer(MeshedSurface<Face>&);
//- Transfer contents to the Xfer container
Xfer< UnsortedMeshedSurface<Face> > xfer();
// Read

View File

@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
const List<Face>& faceLst = this->faces();
labelList faceMap;
surfRegionList regionLst = sortedRegions(faceMap);
surfZoneList zoneLst = sortedZones(faceMap);
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os);
os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl
<< regionLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
<< "// zones:" << nl
<< zoneLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
regionLst[regionI].writeDict(os);
zoneLst[zoneI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl;
@ -74,12 +74,12 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
label faceI = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this region
const surfRegion& reg = regionLst[regionI];
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
os << faceLst[faceMap[faceI++]] << nl;
}

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "surfFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const word surfLabelField::typeName("surfLabelField");
template<>
const word surfScalarField::typeName("surfScalarField");
template<>
const word surfVectorField::typeName("surfVectorField");
template<>
const word surfSphericalTensorField::typeName("surfSphericalTensorField");
template<>
const word surfSymmTensorField::typeName("surfSymmTensorField");
template<>
const word surfTensorField::typeName("surfTensorField");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<DimensionedField<scalar, surfMesh> >
DimensionedField<scalar, surfMesh>::component
(
const direction
) const
{
return *this;
}
template<>
void DimensionedField<scalar, surfMesh>::replace
(
const direction,
const DimensionedField<scalar, surfMesh>& sf
)
{
*this == sf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfFields
Description
Fields for surfMesh
SourceFiles
surfFields.C
\*---------------------------------------------------------------------------*/
#ifndef surfFields_H
#define surfFields_H
#include "DimensionedField.H"
#include "surfGeoMesh.H"
#include "surfFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
tmp<DimensionedField<scalar, surfMesh> >
DimensionedField<scalar, surfMesh>::component
(
const direction
) const;
template<>
void DimensionedField<scalar, surfMesh>::replace
(
const direction,
const DimensionedField<scalar, surfMesh>& sf
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#ifndef surfFieldsFwd_H
#define surfFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class surfGeoMesh;
template<class Type, class GeoMesh>
class DimensionedField;
typedef DimensionedField<label, surfGeoMesh> surfLabelField;
typedef DimensionedField<scalar, surfGeoMesh> surfScalarField;
typedef DimensionedField<vector, surfGeoMesh> surfVectorField;
typedef DimensionedField<sphericalTensor, surfGeoMesh> surfSphericalTensorField;
typedef DimensionedField<symmTensor, surfGeoMesh> surfSymmTensorField;
typedef DimensionedField<tensor, surfGeoMesh> surfTensorField;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfGeoMesh
Description
The surfMesh GeoMesh (for holding fields).
Similar to a volGeoMesh needed to do the Finite Volume discretisation.
\*---------------------------------------------------------------------------*/
#ifndef surfGeoMesh_H
#define surfGeoMesh_H
#include "SurfGeoMesh.H"
#include "surfMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfGeoMesh Declaration
\*---------------------------------------------------------------------------*/
class surfGeoMesh
:
public SurfGeoMesh<surfMesh>
{
public:
// Constructors
//- Construct from surfMesh reference
explicit surfGeoMesh(const surfMesh& mesh)
:
SurfGeoMesh<surfMesh>(mesh)
{}
// Member Functions
//- Return size
static label size(const surfMesh& mesh)
{
return mesh.nFaces();
}
//- Return size
label size() const
{
return size(mesh_);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,446 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "surfMesh.H"
#include "Time.H"
#include "cellIOList.H"
#include "SubList.H"
#include "OSspecific.H"
#include "MeshedSurface.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfMesh, 0);
Foam::word Foam::surfMesh::defaultName = "default";
Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::surfMesh::oneZone()
{
word zoneName;
if (surfZones_.size())
{
zoneName = surfZones_[0].name();
}
if (zoneName.empty())
{
zoneName = "zone0";
}
// set single default zone
surfZones_.setSize(1);
surfZones_[0] = surfZone
(
zoneName,
nFaces(), // zone size
0, // zone start
0 // zone index
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfMesh::surfMesh(const IOobject& io)
:
surfaceRegistry(io.db(), io.name()),
surfMeshAllocator
(
IOobject
(
"points",
time().findInstance(meshDir(), "points"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
IOobject
(
"faces",
time().findInstance(meshDir(), "faces"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
MeshReference(ioFaces_, ioPoints_),
surfZones_
(
IOobject
(
"surfZones",
time().findInstance(meshDir(), "surfZones"),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
{}
Foam::surfMesh::surfMesh
(
const IOobject& io,
const Xfer<pointField>& pointLst,
const Xfer<faceList>& faceLst,
const bool syncPar
)
:
surfaceRegistry(io, io.name()),
surfMeshAllocator
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pointLst,
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
faceLst
),
MeshReference(ioFaces_, ioPoints_),
surfZones_
(
IOobject
(
"surfZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
)
)
{}
Foam::surfMesh::surfMesh
(
const IOobject& io,
const MeshedSurface<face>& surf,
const bool syncPar
)
:
surfaceRegistry(io, io.name()),
surfMeshAllocator
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.points(),
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.faces()
),
MeshReference(ioFaces_, ioPoints_),
surfZones_
(
IOobject
(
"surfZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.zones()
)
{}
Foam::surfMesh::surfMesh
(
const IOobject& io,
const Xfer< MeshedSurface<face> >& surf,
const bool syncPar
)
:
surfaceRegistry(io, io.name()),
surfMeshAllocator
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pointField(),
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
faceList()
),
MeshReference(ioFaces_, ioPoints_),
surfZones_
(
IOobject
(
"surfZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surfZoneList()
)
{
transfer(surf());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfMesh::~surfMesh()
{
// clearOut();
// resetMotion();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::resetPrimitives
(
const Xfer<pointField>& points,
const Xfer<faceList>& faces,
const Xfer<surfZoneList>& zones,
const bool validate
)
{
// Clear addressing.
MeshReference::clearGeom();
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (&points)
{
ioPoints_.transfer(points());
}
if (&faces)
{
ioFaces_.transfer(faces());
}
if (&zones)
{
surfZones_.transfer(zones());
}
if (validate)
{
checkZones();
}
}
void Foam::surfMesh::transfer
(
MeshedSurface<face>& surf
)
{
// Clear addressing.
MeshReference::clearGeom();
ioPoints_.transfer(surf.storedPoints());
ioFaces_.transfer(surf.storedFaces());
surfZones_.transfer(surf.storedZones());
}
void Foam::surfMesh::rename(const word& newName)
{
surfaceRegistry::rename(newName);
FatalErrorIn
(
"surfMesh::rename(const word&)\n"
)
<< "rename does not work correctly\n"
<< exit(FatalError);
}
Foam::fileName Foam::surfMesh::meshDir() const
{
return dbDir()/meshSubDir;
}
const Foam::fileName& Foam::surfMesh::pointsInstance() const
{
return ioPoints_.instance();
}
const Foam::fileName& Foam::surfMesh::facesInstance() const
{
return ioFaces_.instance();
}
Foam::label Foam::surfMesh::nPoints() const
{
return ioPoints_.size();
}
Foam::label Foam::surfMesh::nFaces() const
{
return ioFaces_.size();
}
const Foam::pointField& Foam::surfMesh::points() const
{
return ioPoints_;
}
const Foam::faceList& Foam::surfMesh::faces() const
{
return ioFaces_;
}
void Foam::surfMesh::checkZones()
{
// extra safety, ensure we have at some zones
// and they cover all the faces - fix start silently
if (surfZones_.size() <= 1)
{
oneZone();
}
else
{
label count = 0;
forAll(surfZones_, zoneI)
{
surfZones_[zoneI].start() = count;
count += surfZones_[zoneI].size();
}
if (count < nFaces())
{
WarningIn
(
"surfMesh::checkZones()\n"
)
<< "more faces " << nFaces() << " than zones " << count
<< " ... extending final zone"
<< endl;
surfZones_[surfZones_.size()-1].size() += count - nFaces();
}
else if (count > size())
{
FatalErrorIn
(
"surfMesh::checkZones()\n"
)
<< "more zones " << count << " than faces " << nFaces()
<< exit(FatalError);
}
}
}
// Add boundary patches. Constructor helper
void Foam::surfMesh::addZones
(
const surfZoneList& zones,
const bool validate
)
{
surfZones_.setSize(zones.size());
forAll(surfZones_, zoneI)
{
surfZones_[zoneI] = surfZone(zones[zoneI], zoneI);
}
if (validate)
{
checkZones();
}
}
// Remove all files and some subdirs (eg, sets)
void Foam::surfMesh::removeFiles(const fileName& instanceDir) const
{
fileName meshFilesPath = db().path()/instanceDir/meshSubDir;
rm(meshFilesPath/"points");
rm(meshFilesPath/"faces");
rm(meshFilesPath/"surfZones");
}
void Foam::surfMesh::removeFiles() const
{
removeFiles(instance());
}
// ************************************************************************* //

View File

@ -0,0 +1,334 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfMesh
Description
A surface mesh consisting of general polygon faces.
SourceFiles
surfMesh.C
surfMeshClear.C
surfMeshIO.C
\*---------------------------------------------------------------------------*/
#ifndef surfMesh_H
#define surfMesh_H
#include "surfaceRegistry.H"
#include "PrimitivePatch.H"
#include "pointField.H"
#include "faceList.H"
#include "pointIOField.H"
#include "faceIOList.H"
#include "labelIOList.H"
#include "surfZoneIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Face>
class MeshedSurface;
/*---------------------------------------------------------------------------*\
Class surfMeshAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A helper class for storing points and faces
class surfMeshAllocator
{
protected:
pointIOField ioPoints_;
faceIOList ioFaces_;
surfMeshAllocator(const IOobject& ioPoints, const IOobject& ioFaces)
:
ioPoints_(ioPoints),
ioFaces_(ioFaces)
{}
surfMeshAllocator
(
const IOobject& ioPoints,
const pointField& points,
const IOobject& ioFaces,
const faceList& faces
)
:
ioPoints_(ioPoints, points),
ioFaces_(ioFaces, faces)
{}
surfMeshAllocator
(
const IOobject& ioPoints,
const Xfer<pointField>& points,
const IOobject& ioFaces,
const Xfer<faceList>& faces
)
:
ioPoints_(ioPoints, points),
ioFaces_(ioFaces, faces)
{}
};
/*---------------------------------------------------------------------------*\
Class surfMesh Declaration
\*---------------------------------------------------------------------------*/
class surfMesh
:
public surfaceRegistry,
public surfMeshAllocator,
public PrimitivePatch<face, ::Foam::UList, const pointField&, point>
{
public:
// Public data types
//- Enumeration defining the state of the mesh after a read update.
// Used for post-processing applications, where the mesh
// needs to update based on the files written in time
// directores
enum readUpdateState
{
UNCHANGED,
POINTS_MOVED,
TOPO_CHANGE,
TOPO_PATCH_CHANGE
};
private:
// Private typedefs
typedef PrimitivePatch
<
face,
::Foam::UList,
const pointField&,
point
>
MeshReference;
// Permanent data
// Zoning information
//- Face zones
surfZoneIOList surfZones_;
// Private member functions
//- Set a single zone
void oneZone();
//- Disallow construct as copy
surfMesh(const surfMesh&);
//- Disallow default bitwise assignment
void operator=(const surfMesh&);
public:
// Public typedefs
typedef surfMesh Mesh;
//- Runtime type information
TypeName("surfMesh");
//- Return the default surface name
static word defaultName;
//- Return the mesh sub-directory name (usually "surfMesh")
static word meshSubDir;
//- Return the default zone name
static word defaultZoneName;
// Constructors
//- Construct from IOobject
explicit surfMesh(const IOobject& io);
//- Construct by transferring components (points, faces) without zones.
// surfZones are added using addZones() member function
surfMesh
(
const IOobject&,
const Xfer<pointField>&,
const Xfer<faceList>&,
const bool syncPar=true
);
//- Construct copy from MeshedSurface
surfMesh
(
const IOobject&,
const MeshedSurface<face>& surf,
const bool syncPar=true
);
//- Construct copy from MeshedSurface
surfMesh
(
const IOobject&,
const Xfer< MeshedSurface<face> >& surf,
const bool syncPar=true
);
// Destructor
virtual ~surfMesh();
// Member Functions
// Database
//- Return the local mesh directory (dbDir()/meshSubDir)
fileName meshDir() const;
//- Return the current instance directory for points
// Used in the consruction of gemometric mesh data dependent
// on points
const fileName& pointsInstance() const;
//- Return the current instance directory for faces
const fileName& facesInstance() const;
//- Set the instance for mesh files
void setInstance(const fileName&);
// Access
//- Return raw points
virtual label nPoints() const;
//- Return raw faces
virtual label nFaces() const;
//- Return number of faces
virtual label size() const
{
return nFaces();
}
//- Return raw points
virtual const pointField& points() const;
//- Return raw faces
virtual const faceList& faces() const;
//- Return surface zones
const surfZoneList& surfZones() const
{
return surfZones_;
}
//- Return non-const access to the zones
surfZoneList& surfZones()
{
return surfZones_;
}
//- Check the surface zone definitions
void checkZones();
//- Add surface zones patches
void addZones
(
const List<surfZone>&,
const bool validate = true
);
//- Update the mesh based on the mesh files saved in
// time directories
virtual readUpdateState readUpdate();
//- Update the mesh corresponding to given map
//- Remove surface zones
void removeZones();
//- Rename surface
virtual void rename(const word&);
//- Reset mesh primitive data.
void resetPrimitives
(
const Xfer<pointField>& points,
const Xfer<faceList>& faces,
const Xfer<surfZoneList>& zones,
const bool validate = true
);
void transfer(MeshedSurface<face>&);
// Storage management
//- Clear geometry
void clearGeom();
//- Clear addressing
void clearAddressing();
//- Clear all geometry and addressing unnecessary for CFD
void clearOut();
//- Clear primitive data (points, faces and cells)
void clearPrimitives();
//- Remove all files from mesh instance
void removeFiles(const fileName& instanceDir) const;
//- Remove all files from mesh instance()
void removeFiles() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "surfMesh.H"
#include "globalMeshData.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::surfMesh::removeZones()
{
if (debug)
{
Info<< "void surfMesh::removeZones(): "
<< "Removing surface zones."
<< endl;
}
// Remove the surface zones
surfZones_.clear();
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::clearGeom()
{
if (debug)
{
Info<< "void surfMesh::clearGeom() : "
<< "clearing geometric data"
<< endl;
}
MeshReference::clearGeom();
}
void Foam::surfMesh::clearAddressing()
{
if (debug)
{
Info<< "void surfMesh::clearAddressing() : "
<< "clearing topology"
<< endl;
}
MeshReference::clearPatchMeshAddr();
}
void Foam::surfMesh::clearOut()
{
clearGeom();
clearAddressing();
}
// ************************************************************************* //

View File

@ -0,0 +1,215 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "surfMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::setInstance(const fileName& inst)
{
if (debug)
{
Info<< "void surfMesh::setInstance(const fileName& inst) : "
<< "Resetting file instance to " << inst << endl;
}
ioPoints_.writeOpt() = IOobject::AUTO_WRITE;
ioPoints_.instance() = inst;
ioFaces_.writeOpt() = IOobject::AUTO_WRITE;
ioFaces_.instance() = inst;
surfZones_.writeOpt() = IOobject::AUTO_WRITE;
surfZones_.instance() = inst;
}
Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
{
if (debug)
{
Info<< "surfMesh::readUpdateState surfMesh::readUpdate() : "
<< "Updating mesh based on saved data." << endl;
}
// Find the point and cell instance
fileName pointsInst(time().findInstance(meshDir(), "points"));
fileName facesInst(time().findInstance(meshDir(), "faces"));
if (debug)
{
Info<< "Faces instance: old = " << facesInstance()
<< " new = " << facesInst << nl
<< "Points instance: old = " << pointsInstance()
<< " new = " << pointsInst << endl;
}
if (facesInst != facesInstance())
{
// Topological change
if (debug)
{
Info << "Topological change" << endl;
}
clearOut();
// Set instance to new instance. Note that points instance can differ
// from from faces instance.
setInstance(facesInst);
ioPoints_.instance() = pointsInst;
ioPoints_ = pointIOField
(
IOobject
(
"points",
pointsInst,
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
ioFaces_ = faceIOList
(
IOobject
(
"faces",
facesInst,
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
// synchronize the sizes
MeshReference newMeshRef(ioFaces_, ioPoints_);
MeshReference::operator=(newMeshRef);
// Reset the surface zones
surfZoneIOList newZones
(
IOobject
(
"surfZones",
facesInst,
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
// Check that zone types and names are unchanged
bool zonesChanged = false;
if (surfZones_.size() != newZones.size())
{
zonesChanged = true;
}
else
{
forAll (surfZones_, zoneI)
{
if (surfZones_[zoneI].name() != newZones[zoneI].name())
{
zonesChanged = true;
break;
}
}
}
if (zonesChanged)
{
WarningIn("surfMesh::readUpdateState surfMesh::readUpdate()")
<< "Number of zones has changed. This may have "
<< "unexpected consequences. Proceed with care." << endl;
surfZones_.transfer(newZones);
}
else
{
surfZones_.transfer(newZones);
}
if (zonesChanged)
{
return surfMesh::TOPO_PATCH_CHANGE;
}
else
{
return surfMesh::TOPO_CHANGE;
}
}
else if (pointsInst != pointsInstance())
{
// Points moved
if (debug)
{
Info << "Point motion" << endl;
}
clearGeom();
ioPoints_.instance() = pointsInst;
ioPoints_ = pointIOField
(
IOobject
(
"points",
pointsInst,
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
return surfMesh::POINTS_MOVED;
}
else
{
if (debug)
{
Info << "No change" << endl;
}
return surfMesh::UNCHANGED;
}
}
// ************************************************************************* //

View File

@ -26,28 +26,28 @@ Description
\*---------------------------------------------------------------------------*/
#include "surfRegion.H"
#include "surfZone.H"
#include "dictionary.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfRegion, 0);
defineTypeNameAndDebug(Foam::surfZone, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfRegion::surfRegion()
Foam::surfZone::surfZone()
:
surfRegionIdentifier(),
surfZoneIdentifier(),
size_(0),
start_(0)
{}
Foam::surfRegion::surfRegion
Foam::surfZone::surfZone
(
const word& name,
const label size,
@ -56,68 +56,68 @@ Foam::surfRegion::surfRegion
const word& geometricType
)
:
surfRegionIdentifier(name, index, geometricType),
surfZoneIdentifier(name, index, geometricType),
size_(size),
start_(start)
{}
Foam::surfRegion::surfRegion(Istream& is, const label index)
Foam::surfZone::surfZone(Istream& is, const label index)
:
surfRegionIdentifier(),
surfZoneIdentifier(),
size_(0),
start_(0)
{
word name(is);
dictionary dict(is);
operator=(surfRegion(name, dict, index));
operator=(surfZone(name, dict, index));
}
Foam::surfRegion::surfRegion
Foam::surfZone::surfZone
(
const word& name,
const dictionary& dict,
const label index
)
:
surfRegionIdentifier(name, dict, index),
surfZoneIdentifier(name, dict, index),
size_(readLabel(dict.lookup("nFaces"))),
start_(readLabel(dict.lookup("startFace")))
{}
Foam::surfRegion::surfRegion(const surfRegion& reg)
Foam::surfZone::surfZone(const surfZone& zone)
:
surfRegionIdentifier(reg, reg.index()),
size_(reg.size()),
start_(reg.start())
surfZoneIdentifier(zone, zone.index()),
size_(zone.size()),
start_(zone.start())
{}
Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
Foam::surfZone::surfZone(const surfZone& zone, const label index)
:
surfRegionIdentifier(reg, index),
size_(reg.size()),
start_(reg.start())
surfZoneIdentifier(zone, index),
size_(zone.size()),
start_(zone.start())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfRegion::write(Ostream& os) const
void Foam::surfZone::write(Ostream& os) const
{
writeDict(os);
}
void Foam::surfRegion::writeDict(Ostream& os) const
void Foam::surfZone::writeDict(Ostream& os) const
{
os << indent << name() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
surfRegionIdentifier::write(os);
surfZoneIdentifier::write(os);
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
@ -127,38 +127,38 @@ void Foam::surfRegion::writeDict(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
bool Foam::surfRegion::operator!=(const surfRegion& reg) const
bool Foam::surfZone::operator!=(const surfZone& rhs) const
{
return !(*this == reg);
return !(*this == rhs);
}
bool Foam::surfRegion::operator==(const surfRegion& reg) const
bool Foam::surfZone::operator==(const surfZone& rhs) const
{
return
(
(geometricType() == reg.geometricType())
&& (size() == reg.size())
&& (start() == reg.start())
(geometricType() == rhs.geometricType())
&& (size() == rhs.size())
&& (start() == rhs.start())
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfRegion& reg)
Foam::Istream& Foam::operator>>(Istream& is, surfZone& zone)
{
reg = surfRegion(is, 0);
zone = surfZone(is, 0);
is.check("Istream& operator>>(Istream&, surfRegion&)");
is.check("Istream& operator>>(Istream&, surfZone&)");
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone)
{
reg.write(os);
os.check("Ostream& operator<<(Ostream&, const surfRegion&");
zone.write(os);
os.check("Ostream& operator<<(Ostream&, const surfZone&");
return os;
}

View File

@ -23,24 +23,25 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfRegion
Foam::surfZone
Description
A region on a meshed surface.
Similar in concept to a faceZone on the surface.
A surface zone on a MeshedSurface.
Similar in concept to a faceZone, but the face list is contiguous.
SourceFiles
surfRegion.C
surfZone.C
\*---------------------------------------------------------------------------*/
#ifndef surfRegion_H
#define surfRegion_H
#ifndef surfZone_H
#define surfZone_H
#include "word.H"
#include "label.H"
#include "className.H"
#include "surfRegionIdentifier.H"
#include "surfZoneIdentifier.H"
#include "autoPtr.H"
#include "dictionary.H"
@ -51,18 +52,18 @@ namespace Foam
// Forward declaration of friend functions and operators
class surfRegion;
class surfZone;
Istream& operator>>(Istream&, surfRegion&);
Ostream& operator<<(Ostream&, const surfRegion&);
Istream& operator>>(Istream&, surfZone&);
Ostream& operator<<(Ostream&, const surfZone&);
/*---------------------------------------------------------------------------*\
Class surfRegion Declaration
Class surfZone Declaration
\*---------------------------------------------------------------------------*/
class surfRegion
class surfZone
:
public surfRegionIdentifier
public surfZoneIdentifier
{
// Private data
@ -75,16 +76,16 @@ class surfRegion
public:
//- Runtime type information
ClassName("surfRegion");
ClassName("surfZone");
// Constructors
//- Construct null
surfRegion();
surfZone();
//- Construct from components
surfRegion
surfZone
(
const word& name,
const label size,
@ -94,10 +95,10 @@ public:
);
//- Construct from Istream
surfRegion(Istream& is, const label index);
surfZone(Istream& is, const label index);
//- Construct from dictionary
surfRegion
surfZone
(
const word& name,
const dictionary& dict,
@ -105,48 +106,48 @@ public:
);
//- Construct as copy
surfRegion(const surfRegion&);
surfZone(const surfZone&);
//- Construct from another region, resetting the index
surfRegion(const surfRegion&, const label index);
//- Construct from another zone, resetting the index
surfZone(const surfZone&, const label index);
//- Return clone
autoPtr<surfRegion> clone() const
autoPtr<surfZone> clone() const
{
notImplemented("autoPtr<surfRegion> clone() const");
return autoPtr<surfRegion>(NULL);
notImplemented("autoPtr<surfZone> clone() const");
return autoPtr<surfZone>(NULL);
}
static autoPtr<surfRegion> New(Istream& is)
static autoPtr<surfZone> New(Istream& is)
{
word name(is);
dictionary dict(is);
return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
return autoPtr<surfZone>(new surfZone(name, dict, 0));
}
// Member Functions
//- Return start label of this region in the face list
//- Return start label of this zone in the face list
label start() const
{
return start_;
}
//- Return start label of this region in the face list
//- Return start label of this zone in the face list
label& start()
{
return start_;
}
//- Return size of this region in the face list
//- Return size of this zone in the face list
label size() const
{
return size_;
}
//- Return size of this region in the face list
//- Return size of this zone in the face list
label& size()
{
return size_;
@ -161,15 +162,15 @@ public:
// Member Operators
bool operator!=(const surfRegion&) const;
bool operator!=(const surfZone&) const;
//- compare.
bool operator==(const surfRegion&) const;
bool operator==(const surfZone&) const;
// IOstream Operators
friend Istream& operator>>(Istream&, surfRegion&);
friend Ostream& operator<<(Ostream&, const surfRegion&);
friend Istream& operator>>(Istream&, surfZone&);
friend Ostream& operator<<(Ostream&, const surfZone&);
};

View File

@ -24,71 +24,71 @@ License
\*---------------------------------------------------------------------------*/
#include "surfRegionIOList.H"
#include "surfZoneIOList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
defineTypeNameAndDebug(Foam::surfZoneIOList, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfRegionIOList::surfRegionIOList
Foam::surfZoneIOList::surfZoneIOList
(
const IOobject& io
)
:
surfRegionList(),
surfZoneList(),
regIOobject(io)
{
Foam::string functionName =
"surfRegionIOList::surfRegionIOList"
"surfZoneIOList::surfZoneIOList"
"(const IOobject& io)";
if (readOpt() == IOobject::MUST_READ)
{
surfRegionList& regions = *this;
surfZoneList& zones = *this;
// read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> dictEntries(is);
regions.setSize(dictEntries.size());
zones.setSize(dictEntries.size());
label faceI = 0;
forAll(regions, regionI)
forAll(zones, zoneI)
{
const dictionary& dict = dictEntries[regionI].dict();
const dictionary& dict = dictEntries[zoneI].dict();
label regionSize = readLabel(dict.lookup("nFaces"));
label zoneSize = readLabel(dict.lookup("nFaces"));
label startFaceI = readLabel(dict.lookup("startFace"));
regions[regionI] = surfRegion
zones[zoneI] = surfZone
(
dictEntries[regionI].keyword(),
regionSize,
dictEntries[zoneI].keyword(),
zoneSize,
startFaceI,
regionI
zoneI
);
word geoType;
if (dict.readIfPresent("geometricType", geoType))
{
regions[regionI].geometricType() = geoType;
zones[zoneI].geometricType() = geoType;
}
if (startFaceI != faceI)
{
FatalErrorIn(functionName)
<< "Regions are not ordered. Start of region " << regionI
<< " does not correspond to sum of preceding regions."
<< "surfZones are not ordered. Start of zone " << zoneI
<< " does not correspond to sum of preceding zones."
<< endl
<< "while reading " << io.objectPath()
<< exit(FatalError);
}
faceI += regionSize;
faceI += zoneSize;
}
// Check state of IOstream
@ -99,20 +99,20 @@ Foam::surfRegionIOList::surfRegionIOList
}
// Construct from IOObject
Foam::surfRegionIOList::surfRegionIOList
Foam::surfZoneIOList::surfZoneIOList
(
const IOobject& io,
const surfRegionList& regions
const surfZoneList& zones
)
:
surfRegionList(regions),
surfZoneList(zones),
regIOobject(io)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfRegionIOList::~surfRegionIOList()
Foam::surfZoneIOList::~surfZoneIOList()
{}
@ -120,7 +120,7 @@ Foam::surfRegionIOList::~surfRegionIOList()
// writeData member function required by regIOobject
bool Foam::surfRegionIOList::writeData(Ostream& os) const
bool Foam::surfZoneIOList::writeData(Ostream& os) const
{
os << *this;
return os.good();
@ -129,7 +129,7 @@ bool Foam::surfRegionIOList::writeData(Ostream& os) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIOList& L)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& L)
{
os << L.size() << nl << token::BEGIN_LIST;

View File

@ -23,20 +23,20 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfRegionIOList
Foam::surfZoneIOList
Description
IOobject for a surfRegionList
IOobject for a surfZoneList
SourceFiles
surfRegionIOList.C
surfZoneIOList.C
\*---------------------------------------------------------------------------*/
#ifndef surfRegionIOList_H
#define surfRegionIOList_H
#ifndef surfZoneIOList_H
#define surfZoneIOList_H
#include "surfRegionList.H"
#include "surfZoneList.H"
#include "regIOobject.H"
#include "faceList.H"
#include "className.H"
@ -49,12 +49,12 @@ namespace Foam
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class surfRegionIOList Declaration
Class surfZoneIOList Declaration
\*---------------------------------------------------------------------------*/
class surfRegionIOList
class surfZoneIOList
:
public surfRegionList,
public surfZoneList,
public regIOobject
{
// Private data
@ -63,29 +63,29 @@ class surfRegionIOList
// Private Member Functions
//- Disallow default bitwise copy construct
surfRegionIOList(const surfRegionIOList&);
surfZoneIOList(const surfZoneIOList&);
//- Disallow default bitwise assignment
void operator=(const surfRegionIOList&);
void operator=(const surfZoneIOList&);
public:
//- Runtime type information
TypeName("surfRegionIOList");
TypeName("surfZoneIOList");
// Constructors
//- Construct from IOobject
explicit surfRegionIOList(const IOobject&);
explicit surfZoneIOList(const IOobject&);
//- Construct from IOobject
surfRegionIOList(const IOobject&, const surfRegionList&);
surfZoneIOList(const IOobject&, const surfZoneList&);
// Destructor
~surfRegionIOList();
~surfZoneIOList();
// Member Functions
@ -102,7 +102,7 @@ public:
// IOstream Operators
friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
friend Ostream& operator<<(Ostream&, const surfZoneIOList&);
};

View File

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::surfRegionList
Foam::surfZoneList
Description
\*---------------------------------------------------------------------------*/
#ifndef surfRegionList_H
#define surfRegionList_H
#ifndef surfZoneList_H
#define surfZoneList_H
#include "surfRegion.H"
#include "surfZone.H"
#include "List.H"
#include "surfRegionIdentifierList.H"
#include "surfZoneIdentifierList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,7 +43,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfRegion> surfRegionList;
typedef List<surfZone> surfZoneList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,22 +24,22 @@ License
\*---------------------------------------------------------------------------*/
#include "surfRegionIdentifier.H"
#include "surfZoneIdentifier.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfRegionIdentifier::surfRegionIdentifier()
Foam::surfZoneIdentifier::surfZoneIdentifier()
:
name_(word::null),
boundaryIndex_(0),
index_(0),
geometricType_(word::null)
{}
Foam::surfRegionIdentifier::surfRegionIdentifier
Foam::surfZoneIdentifier::surfZoneIdentifier
(
const word& name,
const label index,
@ -47,12 +47,12 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
)
:
name_(name),
boundaryIndex_(index),
index_(index),
geometricType_(geometricType)
{}
Foam::surfRegionIdentifier::surfRegionIdentifier
Foam::surfZoneIdentifier::surfZoneIdentifier
(
const word& name,
const dictionary& dict,
@ -60,33 +60,33 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
)
:
name_(name),
boundaryIndex_(index)
index_(index)
{
dict.readIfPresent("geometricType", geometricType_);
}
Foam::surfRegionIdentifier::surfRegionIdentifier
Foam::surfZoneIdentifier::surfZoneIdentifier
(
const surfRegionIdentifier& p,
const surfZoneIdentifier& p,
const label index
)
:
name_(p.name()),
boundaryIndex_(index),
index_(index),
geometricType_(p.geometricType())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfRegionIdentifier::~surfRegionIdentifier()
Foam::surfZoneIdentifier::~surfZoneIdentifier()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfRegionIdentifier::write(Ostream& os) const
void Foam::surfZoneIdentifier::write(Ostream& os) const
{
if (geometricType_.size())
{
@ -98,18 +98,18 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// bool Foam::surfRegionIdentifier::operator!=
// bool Foam::surfZoneIdentifier::operator!=
// (
// const surfRegionIdentifier& p
// const surfZoneIdentifier& p
// ) const
// {
// return !(*this == p);
// }
//
//
// bool Foam::surfRegionIdentifier::operator==
// bool Foam::surfZoneIdentifier::operator==
// (
// const surfRegionIdentifier& p
// const surfZoneIdentifier& p
// ) const
// {
// return geometricType() == p.geometricType() && name() == p.name();
@ -118,7 +118,7 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
// Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& p)
// {
// is >> p.name_ >> p.geometricType_;
//
@ -126,12 +126,12 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
// }
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIdentifier& p)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& p)
{
p.write(os);
os.check
(
"Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
"Ostream& operator<<(Ostream&, const surfZoneIdentifier&)"
);
return os;
}

View File

@ -23,23 +23,21 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfRegionIdentifier
Foam::surfZoneIdentifier
Description
An identifier for a region on a meshed surface.
An identifier for a surface zone on a meshed surface.
Similar in concept to a faceZone on the surface, but can also have a
"geometricType" rather. Despite the similarity to a 'patch' for
volume meshes (with a "physicalType"), the region does not have any
patch information per se.
"geometricType" as well.
SourceFiles
surfRegionIdentifier.C
surfZoneIdentifier.C
\*---------------------------------------------------------------------------*/
#ifndef surfRegionIdentifier_H
#define surfRegionIdentifier_H
#ifndef surfZoneIdentifier_H
#define surfZoneIdentifier_H
#include "word.H"
#include "label.H"
@ -54,24 +52,24 @@ class dictionary;
// Forward declaration of friend functions and operators
class surfRegionIdentifier;
Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
class surfZoneIdentifier;
Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
/*---------------------------------------------------------------------------*\
Class surfRegionIdentifier Declaration
Class surfZoneIdentifier Declaration
\*---------------------------------------------------------------------------*/
class surfRegionIdentifier
class surfZoneIdentifier
{
// Private data
//- Name of region
//- Name of zone
word name_;
//- Index of region in surface mesh
label boundaryIndex_;
//- Index of zone in surface mesh
label index_;
//- Type name of region
//- Type name of zone
mutable word geometricType_;
public:
@ -79,10 +77,10 @@ public:
// Constructors
//- Construct null
surfRegionIdentifier();
surfZoneIdentifier();
//- Construct from components
surfRegionIdentifier
surfZoneIdentifier
(
const word& name,
const label index,
@ -91,24 +89,24 @@ public:
);
//- Construct from dictionary
surfRegionIdentifier
surfZoneIdentifier
(
const word& name,
const dictionary&,
const label index
);
//- Construct from another region identifier, resetting the index
surfRegionIdentifier
//- Construct from another zone identifier, resetting the index
surfZoneIdentifier
(
const surfRegionIdentifier&,
const surfZoneIdentifier&,
const label index
);
// Destructor
virtual ~surfRegionIdentifier();
virtual ~surfZoneIdentifier();
// Member Functions
@ -125,42 +123,42 @@ public:
return name_;
}
//- Return the geometric type of the region
//- Return the geometric type of the zone
const word& geometricType() const
{
return geometricType_;
}
//- Return the geometric type of the region for modification
//- Return the geometric type of the zone for modification
word& geometricType()
{
return geometricType_;
}
//- Return the index of this region in the surface mesh
//- Return the index of this zone in the surface mesh
label index() const
{
return boundaryIndex_;
return index_;
}
//- Write surfRegionIdentifier as a dictionary
//- Write surfZoneIdentifier as a dictionary
void write(Ostream&) const;
//- Write surfRegionIdentifier as a dictionary
//- Write surfZoneIdentifier as a dictionary
// void writeDict(Ostream&) const;
// Member Operators
// bool operator!=(const surfRegionIdentifier&) const;
// bool operator!=(const surfZoneIdentifier&) const;
//
// //- compare.
// bool operator==(const surfRegionIdentifier&) const;
// bool operator==(const surfZoneIdentifier&) const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
// friend Istream& operator>>(Istream&, surfRegionIdentifier&);
friend Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
// friend Istream& operator>>(Istream&, surfZoneIdentifier&);
};

View File

@ -23,16 +23,16 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::surfRegionIdentifierList
Foam::surfZoneIdentifierList
Description
\*---------------------------------------------------------------------------*/
#ifndef surfRegionIdentifierList_H
#define surfRegionIdentifierList_H
#ifndef surfZoneIdentifierList_H
#define surfZoneIdentifierList_H
#include "surfRegionIdentifier.H"
#include "surfZoneIdentifier.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -42,7 +42,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfRegionIdentifier> surfRegionIdentifierList;
typedef List<surfZoneIdentifier> surfZoneIdentifierList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
<< exit(FatalError);
}
// # of kids is the # of regions
// # of kids is the # of zones
args = cueToOrDie(is, "kids");
label nRegions = parse<int>(args);
label nZones = parse<int>(args);
// Start of vertices for object/region
// Start of vertices for object/zones
label vertexOffset = 0;
DynamicList<point> dynPoints;
DynamicList<Face> dynFaces;
List<word> names(nRegions);
List<label> sizes(nRegions, 0);
List<word> names(nZones);
List<label> sizes(nZones, 0);
for (label regionI = 0; regionI < nRegions; ++regionI)
for (label zoneI = 0; zoneI < nZones; ++zoneI)
{
names[regionI] = word("region") + Foam::name(regionI);
names[zoneI] = word("zone") + Foam::name(zoneI);
args = cueToOrDie(is, "OBJECT", "while reading " + names[regionI]);
args = cueToOrDie(is, "OBJECT", "while reading " + names[zoneI]);
// number of vertices for this region
label nRegionPoints = 0;
// number of vertices for this zone
label nZonePoints = 0;
vector location(pTraits<vector>::zero);
// tensor rotation(I);
// Read all info for current region
// Read all info for current zone
while (is.good())
{
// Read line and get first word. If end of file break since
// region should always end with 'kids' command ?not sure.
// zone should always end with 'kids' command ?not sure.
if (!readCmd(is, cmd, args))
{
FatalErrorIn
(
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
)
<< "Did not read up to \"kids 0\" while reading region "
<< regionI << " from file " << filename
<< "Did not read up to \"kids 0\" while reading zone "
<< zoneI << " from file " << filename
<< exit(FatalError);
}
@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
string str = parse<string>(args);
string::stripInvalid<word>(str);
names[regionI] = str;
names[zoneI] = str;
}
else if (cmd == "rot")
{
@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
)
<< "rot (rotation tensor) command not implemented"
<< "Line:" << cmd << ' ' << args << endl
<< "while reading region " << regionI << endl;
<< "while reading zone " << zoneI << endl;
}
else if (cmd == "loc")
{
@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
else if (cmd == "numvert")
{
// numvert %d
nRegionPoints = parse<int>(args);
nZonePoints = parse<int>(args);
for (label vertI = 0; vertI < nRegionPoints; ++vertI)
for (label vertI = 0; vertI < nZonePoints; ++vertI)
{
is.getLine(line);
IStringStream lineStream(line);
@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
{
static string errorMsg =
string(" while reading face ")
+ Foam::name(faceI) + " on region "
+ Foam::name(regionI)
+ Foam::name(faceI) + " on zone "
+ Foam::name(zoneI)
+ " from file " + filename;
cueToOrDie(is, "SURF", errorMsg);
@ -230,23 +230,23 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
label fp2 = (fp1 + 1) % f.size();
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
sizes[regionI]++;
sizes[zoneI]++;
}
}
else
{
dynFaces.append(Face(f));
sizes[regionI]++;
sizes[zoneI]++;
}
}
// Done the current region.
// Done the current zone.
// Increment the offset vertices are stored at
vertexOffset += nRegionPoints;
vertexOffset += nZonePoints;
}
else if (cmd == "kids")
{
// 'kids' denotes the end of the current region.
// 'kids' denotes the end of the current zone.
label nKids = parse<int>(args);
if (nKids != 0)
@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
)
<< "Can only read objects without kids."
<< " Encountered " << nKids << " kids when"
<< " reading region " << regionI
<< " reading zone " << zoneI
<< exit(FatalError);
}
// Done reading current region
// Done reading current zone
break;
}
}
@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
this->storedPoints().transfer(dynPoints);
this->storedFaces().transfer(dynFaces);
// add regions, culling empty ones
this->addRegions(sizes, names, true);
// add zones, culling empty ones
this->addZones(sizes, names, true);
this->stitchFaces(SMALL);
return true;
}
@ -287,16 +287,16 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, regionLst);
writeHeader(os, zoneLst);
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
os << "OBJECT poly" << nl
<< "name \"" << reg.name() << '"' << endl;
<< "name \"" << zone.name() << '"' << endl;
// Temporary PrimitivePatch to calculate compact points & faces
// use 'UList' to avoid allocations!
@ -322,7 +322,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
const Face& f = patch.localFaces()[localFaceI];
os << "SURF 0x20" << nl // polygon
<< "mat " << regionI << nl
<< "mat " << zoneI << nl
<< "refs " << f.size() << nl;
forAll(f, fp)
@ -344,22 +344,22 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
)
{
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
writeHeader(os, regionLst);
writeHeader(os, zoneLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
os << "OBJECT poly" << nl
<< "name \"" << reg.name() << '"' << endl;
<< "name \"" << zone.name() << '"' << endl;
// Create region with only region faces included for ease of addressing
// Create zone with only zone faces included for ease of addressing
labelHashSet include(surf.size());
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const label faceI = faceMap[faceIndex++];
include.insert(faceI);
@ -384,7 +384,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
const Face& f = subm.localFaces()[localFaceI];
os << "SURF 0x20" << nl // polygon
<< "mat " << regionI << nl
<< "mat " << zoneI << nl
<< "refs " << f.size() << nl;
forAll(f, fp)

View File

@ -31,8 +31,8 @@ Description
http://www.inivis.com/ac3d/man/ac3dfileformat.html
Note
The faces are already organized as regions.
The output is always sorted by regions.
The faces are already organized as zones.
The output is always sorted by zones.
SourceFiles
AC3DsurfaceFormat.C
@ -120,7 +120,7 @@ public:
}
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
// The output is always sorted by zones.
static void write
(
Ostream&,
@ -128,7 +128,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is always sorted by regions.
// The output is always sorted by zones.
static void write
(
const fileName& name,

View File

@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
(
Ostream& os,
const UList<surfRegion>& regionLst
const UList<surfZone>& zoneLst
)
{
// Write with regions as separate objects under "world" object.
// Write with zones as separate objects under "world" object.
// Header is taken over from sample file.
// Defines separate materials for all regions. Recycle colours.
// Defines separate materials for all zones. Recycle colours.
// Define 8 standard colours as r,g,b components
static scalar colourMap[] =
@ -139,12 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
// Write header. Define materials.
os << "AC3Db" << nl;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
label colourI = regionI % 8;
label colourI = zoneI % 8;
label colourCompI = 3 * colourI;
os << "MATERIAL \"" << regionLst[regionI].name() << "Mat\" rgb "
os << "MATERIAL \"" << zoneLst[zoneI].name() << "Mat\" rgb "
<< colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
<< ' ' << colourMap[colourCompI+2]
<< " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
@ -153,7 +153,7 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
}
os << "OBJECT world" << nl
<< "kids " << regionLst.size() << endl;
<< "kids " << zoneLst.size() << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -77,7 +77,7 @@ protected:
);
//- Write header with materials
static void writeHeader(Ostream&, const UList<surfRegion>&);
static void writeHeader(Ostream&, const UList<surfZone>&);
};

View File

@ -72,31 +72,31 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
List<Keyed<triFace> > facesRead(is);
List<Face> faceLst(facesRead.size());
List<label> regionIds(facesRead.size());
List<label> zoneIds(facesRead.size());
// disentangle faces/keys - already triangulated
forAll(facesRead, faceI)
{
// unfortunately cannot transfer to save memory
faceLst[faceI] = facesRead[faceI];
regionIds[faceI] = facesRead[faceI].key();
zoneIds[faceI] = facesRead[faceI].key();
}
this->storedFaces().transfer(faceLst);
this->storedRegionIds().transfer(regionIds);
this->storedZoneIds().transfer(zoneIds);
// change ftrPatch into surfRegionIdentifier
List<surfRegionIdentifier> newRegions(ftrPatches.size());
forAll(newRegions, regionI)
// change ftrPatch into surfZoneIdentifier
List<surfZoneIdentifier> newZones(ftrPatches.size());
forAll(newZones, zoneI)
{
newRegions[regionI] = surfRegionIdentifier
newZones[zoneI] = surfZoneIdentifier
(
ftrPatches[regionI].name(),
regionI
ftrPatches[zoneI].name(),
zoneI
);
}
this->storedRegionToc().transfer(newRegions);
this->storedZoneToc().transfer(newZones);
return true;
}

View File

@ -82,11 +82,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// write directly into the lists:
pointField& pointLst = this->storedPoints();
List<Face>& faceLst = this->storedFaces();
List<label>& regionIds = this->storedRegionIds();
List<label>& zoneIds = this->storedZoneIds();
pointLst.setSize(nPoints);
faceLst.setSize(nElems);
regionIds.setSize(nElems);
zoneIds.setSize(nElems);
// Read points
forAll(pointLst, pointI)
@ -118,11 +118,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// Read triangles. Convert references to edges into pointlabels
label maxRegion = 0;
label maxZone = 0;
forAll(faceLst, faceI)
{
label e0Label, e1Label, e2Label;
label regionI = 0;
label zoneI = 0;
line = this->getLineNoComment(is);
{
@ -130,17 +130,17 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
lineStream
>> e0Label >> e1Label >> e2Label;
// Optional region number: read first, then check state on stream
// Optional zone number: read first, then check state on stream
if (lineStream)
{
label num;
lineStream >> num;
if (!lineStream.bad())
{
regionI = num;
if (maxRegion < regionI)
zoneI = num;
if (maxZone < zoneI)
{
maxRegion = regionI;
maxZone = zoneI;
}
}
}
@ -202,21 +202,21 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
}
faceLst[faceI] = triFace(e0Far, common01, e1Far);
regionIds[faceI] = regionI;
zoneIds[faceI] = zoneI;
}
List<surfRegionIdentifier> newRegions(maxRegion+1);
forAll(newRegions, regionI)
List<surfZoneIdentifier> newZones(maxZone+1);
forAll(newZones, zoneI)
{
newRegions[regionI] = surfRegionIdentifier
newZones[zoneI] = surfZoneIdentifier
(
"region" + ::Foam::name(regionI),
regionI
"zone" + ::Foam::name(zoneI),
zoneI
);
}
this->storedRegionToc().transfer(newRegions);
this->storedZoneToc().transfer(newZones);
return true;
}
@ -230,7 +230,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
// check if output triangulation would be required
@ -260,14 +260,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
}
}
// Write header, print region names as comment
// Write header, print zone names as comment
os << "# GTS file" << nl
<< "# Regions:" << nl;
<< "# Zones:" << nl;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
os << "# " << regionI << " "
<< regionLst[regionI].name() << nl;
os << "# " << zoneI << " "
<< zoneLst[zoneI].name() << nl;
}
os << "#" << endl;
@ -300,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
const labelListList& faceEs = surf.faceEdges();
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const labelList& fEdges = faceEs[faceIndex++];
os << fEdges[0] + 1 << ' '
<< fEdges[1] + 1 << ' '
<< fEdges[2] + 1 << ' '
<< regionI << endl;
<< zoneI << endl;
}
}
}
@ -326,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<label>& regionIds = surf.regionIds();
const List<surfRegionIdentifier>& regionToc = surf.regionToc();
const List<label>& zoneIds = surf.zoneIds();
const List<surfZoneIdentifier>& zoneToc = surf.zoneToc();
// check if output triangulation would be required
// It is too annoying to triangulate on-the-fly
@ -356,14 +356,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
}
}
// Write header, print region names as comment
// Write header, print zone names as comment
os << "# GTS file" << nl
<< "# Regions:" << nl;
<< "# Zones:" << nl;
forAll(regionToc, regionI)
forAll(zoneToc, zoneI)
{
os << "# " << regionI << " "
<< regionToc[regionI].name() << nl;
os << "# " << zoneI << " "
<< zoneToc[zoneI].name() << nl;
}
os << "#" << endl;
@ -404,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
os << fEdges[0] + 1 << ' '
<< fEdges[1] + 1 << ' '
<< fEdges[2] + 1 << ' '
<< regionIds[faceI] << endl;
<< zoneIds[faceI] << endl;
}
}

View File

@ -27,7 +27,7 @@ Class
Description
Provide a means of reading/writing GTS format.
The output is never sorted by region.
The output is never sorted by zone.
SourceFiles
GTSsurfaceFormat.C

View File

@ -71,13 +71,13 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
DynamicList<label> pointId;
DynamicList<point> dynPoints;
DynamicList<Face> dynFaces;
DynamicList<label> dynRegions;
DynamicList<label> dynZones;
DynamicList<label> dynSizes;
Map<label> lookup;
// assume the types are not intermixed
bool sorted = true;
label regionI = 0;
label zoneI = 0;
// Name for face group
Map<word> nameLookup;
@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
// Ansa tags. Denoted by $ANSA_NAME.
// These will appear just before the first use of a type.
// We read them and store the PSHELL types which are used to name
// the regions.
// the zones.
label ansaId = -1;
word ansaType, ansaName;
@ -211,28 +211,28 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
fTri[1] = readLabel(IStringStream(line.substr(32,8))());
fTri[2] = readLabel(IStringStream(line.substr(40,8))());
// Convert groupID into regionId
// Convert groupID into zoneId
Map<label>::const_iterator fnd = lookup.find(groupId);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// pshell types are intermixed
sorted = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(groupId, regionI);
zoneI = dynSizes.size();
lookup.insert(groupId, zoneI);
dynSizes.append(0);
// Info<< "region" << regionI << " => group " << groupId <<endl;
// Info<< "zone" << zoneI << " => group " << groupId <<endl;
}
dynFaces.append(fTri);
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
else if (cmd == "CQUAD4")
{
@ -245,23 +245,23 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
fQuad[3] = readLabel(IStringStream(line.substr(48,8))());
// Convert groupID into regionId
// Convert groupID into zoneId
Map<label>::const_iterator fnd = lookup.find(groupId);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// pshell types are intermixed
sorted = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(groupId, regionI);
zoneI = dynSizes.size();
lookup.insert(groupId, zoneI);
dynSizes.append(0);
// Info<< "region" << regionI << " => group " << groupId <<endl;
// Info<< "zone" << zoneI << " => group " << groupId <<endl;
}
@ -269,15 +269,15 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
{
dynFaces.append(triFace(f[0], f[1], f[2]));
dynFaces.append(triFace(f[0], f[2], f[3]));
dynRegions.append(regionI);
dynRegions.append(regionI);
dynSizes[regionI] += 2;
dynZones.append(zoneI);
dynZones.append(zoneI);
dynSizes[zoneI] += 2;
}
else
{
dynFaces.append(Face(f));
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
}
else if (cmd == "GRID")
@ -322,7 +322,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
}
else if (cmd == "PSHELL")
{
// pshell type for region names with the Ansa extension
// pshell type for zone names with the Ansa extension
label groupId = readLabel(IStringStream(line.substr(8,8))());
if (groupId == ansaId && ansaType == "PSHELL")
@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
mapPointId.clear();
// create default region names, or from ANSA/Hypermesh information
// create default zone names, or from ANSA/Hypermesh information
List<word> names(dynSizes.size());
forAllConstIter(Map<label>, lookup, iter)
{
const label regionI = iter();
const label zoneI = iter();
const label groupI = iter.key();
Map<word>::const_iterator fnd = nameLookup.find(groupI);
if (fnd != nameLookup.end())
{
names[regionI] = fnd();
names[zoneI] = fnd();
}
else
{
names[regionI] = word("region") + ::Foam::name(regionI);
names[zoneI] = word("zone") + ::Foam::name(zoneI);
}
}
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
// add regions, culling empty ones
this->addRegions(dynSizes, names, true);
// add zones, culling empty ones
this->addZones(dynSizes, names, true);
return true;
}

View File

@ -29,7 +29,7 @@ Description
Nastran surface reader.
- Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
to obtain region names.
to obtain zone names.
- Handles Nastran short and long formats, but not free format.
- Properly handles the Nastran compact floating point notation: \n
@verbatim

View File

@ -70,15 +70,15 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
DynamicList<point> dynPoints;
DynamicList<Face> dynFaces;
DynamicList<label> dynRegions;
DynamicList<label> dynZones;
DynamicList<word> dynNames;
DynamicList<label> dynSizes;
HashTable<label> lookup;
// place faces without a group in region0
label regionI = 0;
lookup.insert("region0", regionI);
dynNames.append("region0");
// place faces without a group in zone0
label zoneI = 0;
lookup.insert("zone0", zoneI);
dynNames.append("zone0");
dynSizes.append(0);
while (is.good())
@ -111,17 +111,17 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
HashTable<label>::const_iterator fnd = lookup.find(name);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// group appeared out of order
sorted = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(name, regionI);
zoneI = dynSizes.size();
lookup.insert(name, zoneI);
dynNames.append(name);
dynSizes.append(0);
}
@ -185,15 +185,15 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
label fp2 = (fp1 + 1) % f.size();
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
}
else
{
dynFaces.append(Face(f));
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
}
}
@ -202,10 +202,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
// transfer to normal lists
this->storedPoints().transfer(dynPoints);
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
// add regions, culling empty ones
this->addRegions(dynSizes, dynNames, true);
// add zones, culling empty ones
this->addZones(dynSizes, dynNames, true);
return true;
}
@ -218,18 +218,18 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
)
{
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size(), regionLst);
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
os << "g " << reg.name() << endl;
os << "g " << zone.name() << endl;
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const Face& f = faceLst[faceIndex++];
@ -255,19 +255,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces();
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
writeHeader(os, surf.points(), faceLst.size(), regionLst);
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this region
const surfRegion& reg = regionLst[regionI];
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "g " << reg.name() << endl;
os << "g " << zone.name() << endl;
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];

View File

@ -116,7 +116,7 @@ public:
}
//- Write UnsortedMeshedSurface
// The output is sorted by regions
// The output is sorted by zones
static void write
(
Ostream&,
@ -124,7 +124,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
// The output is sorted by zones
static void write
(
const fileName& name,

View File

@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
Ostream& os,
const pointField& pointLst,
const label nFaces,
const UList<surfRegion>& regionLst
const UList<surfZone>& zoneLst
)
{
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
<< nl
<< "# points : " << pointLst.size() << nl
<< "# faces : " << nFaces << nl
<< "# region : " << regionLst.size() << nl;
<< "# zones : " << zoneLst.size() << nl;
// Print region names as comment
forAll(regionLst, regionI)
// Print zone names as comment
forAll(zoneLst, zoneI)
{
os << "# " << regionI << " " << regionLst[regionI].name()
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
os << "# " << zoneI << " " << zoneLst[zoneI].name()
<< " (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
}
os << nl

View File

@ -63,7 +63,7 @@ protected:
Ostream&,
const pointField&,
const label nFaces,
const UList<surfRegion>&
const UList<surfZone>&
);
};

View File

@ -101,7 +101,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
pointLst[pointI] = point(x, y, z);
}
// Read faces - ignore optional region information
// Read faces - ignore optional zone information
// use a DynamicList for possible on-the-fly triangulation
DynamicList<Face> dynFaces(nElems);
@ -145,8 +145,8 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
// transfer to normal lists
reset(pointLst.xfer(), dynFaces.xfer());
// no region information
this->oneRegion();
// no zone information
this->oneZone();
return true;
}
@ -161,16 +161,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces();
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
writeHeader(os, surf.points(), faceLst.size(), regionLst);
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
@ -180,10 +180,10 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
os << ' ' << f[fp];
}
// add optional region information
os << ' ' << regionI << endl;
// add optional zone information
os << ' ' << zoneI << endl;
}
os << "# </region>" << endl;
os << "# </zone>" << endl;
}
os << "# </faces>" << endl;
}
@ -197,16 +197,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
)
{
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size(), regionLst);
writeHeader(os, surf.points(), faceLst.size(), zoneLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
os << "# <zone name=\"" << zoneLst[zoneI].name() << "\">" << endl;
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
@ -216,10 +216,10 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
os << ' ' << f[fp];
}
// add optional region information
os << ' ' << regionI << endl;
// add optional zone information
os << ' ' << zoneI << endl;
}
os << "# </region>" << endl;
os << "# </zone>" << endl;
}
os << "# </faces>" << endl;
}

View File

@ -36,7 +36,7 @@ See Also
Note
When reading, the optional @a colorspec is ignored.
When writing, it is set to the region number (integer).
When writing, it is set to the zone number (integer).
SourceFiles
OFFsurfaceFormat.C
@ -122,7 +122,7 @@ public:
}
//- Write UnsortedMeshedSurface
// The output is sorted by region.
// The output is sorted by zone.
static void write
(
Ostream&,
@ -130,7 +130,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
// The output is sorted by zone.
static void write
(
const fileName& name,

View File

@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
Ostream& os,
const pointField& pointLst,
const label nFaces,
const UList<surfRegion>& regionLst
const UList<surfZone>& zoneLst
)
{
// Write header
@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
<< nl
<< "# points : " << pointLst.size() << nl
<< "# faces : " << nFaces << nl
<< "# regions: " << regionLst.size() << nl;
<< "# zones : " << zoneLst.size() << nl;
// Print region names as comment
forAll(regionLst, regionI)
// Print zone names as comment
forAll(zoneLst, zoneI)
{
os << "# " << regionI << " " << regionLst[regionI].name()
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
os << "# " << zoneI << " " << zoneLst[zoneI].name()
<< " (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
}
os << nl

View File

@ -63,7 +63,7 @@ protected:
Ostream&,
const pointField&,
const label nFaces,
const UList<surfRegion>&
const UList<surfZone>&
);
};

View File

@ -46,14 +46,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
)
{
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points(), faceLst.size());
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
@ -62,7 +62,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{
os << ' ' << f[fp];
}
os << ' ' << regionI << endl;
os << ' ' << zoneI << endl;
}
}
@ -82,12 +82,12 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
writeHeader(os, surf.points(), faceLst.size());
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
@ -96,7 +96,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{
os << ' ' << f[fp];
}
os << ' ' << regionI << endl;
os << ' ' << zoneI << endl;
}
}

View File

@ -109,7 +109,7 @@ public:
}
//- Write UnsortedMeshedSurface
// The output is sorted by region.
// The output is sorted by zone.
static void write
(
Ostream&,
@ -117,7 +117,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by region.
// The output is sorted by zone.
static void write
(
const fileName& name,

View File

@ -53,7 +53,7 @@ void Foam::fileFormats::SMESHsurfaceFormatCore::writeHeader
<< nl
<< "# <faces count=\"" << nFaces << "\">" << endl;
os << nFaces << " 1" << endl; // one attribute: region number
os << nFaces << " 1" << endl; // one attribute: zone number
}

View File

@ -122,14 +122,14 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
readHeader(is, "PROSTAR_CELL");
DynamicList<Face> dynFaces;
DynamicList<label> dynRegions;
DynamicList<label> dynZones;
DynamicList<word> dynNames;
DynamicList<label> dynSizes;
Map<label> lookup;
// assume the cellTableIds are not intermixed
bool sorted = true;
label regionI = 0;
label zoneI = 0;
label lineLabel, shapeId, nLabels, cellTableId, typeId;
DynamicList<label> vertexLabels(64);
@ -157,22 +157,22 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
if (typeId == starcdShellType_)
{
// Convert groupID into regionID
// Convert groupID into zoneID
Map<label>::const_iterator fnd = lookup.find(cellTableId);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// cellTableIds are intermixed
sorted = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(cellTableId, regionI);
dynNames.append(word("cellTable_") + ::Foam::name(regionI));
zoneI = dynSizes.size();
lookup.insert(cellTableId, zoneI);
dynNames.append(word("cellTable_") + ::Foam::name(zoneI));
dynSizes.append(0);
}
@ -195,24 +195,24 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
static_cast<UList<label>&>(triFaces[faceI])
)
);
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
}
else
{
dynFaces.append(Face(vertices));
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
}
}
mapPointId.clear();
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
// add regions, culling empty ones
this->addRegions(dynSizes, dynNames, true);
// add zones, culling empty ones
this->addZones(dynSizes, dynNames, true);
return true;
}
@ -231,17 +231,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
writeHeader(os, "CELL");
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const Face& f = faceLst[faceIndex++];
writeShell(os, f, faceIndex, regionI + 1);
writeShell(os, f, faceIndex, zoneI + 1);
}
}
@ -251,7 +251,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
OFstream(baseName + ".inp")(),
surf.points(),
surf.size(),
regionLst
zoneLst
);
}
@ -272,17 +272,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces();
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
const surfRegion& reg = regionLst[regionI];
const surfZone& zone = zoneLst[zoneI];
forAll(reg, localFaceI)
forAll(zone, localFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, f, faceIndex, regionI + 1);
writeShell(os, f, faceIndex, zoneI + 1);
}
}
@ -292,7 +292,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
OFstream(baseName + ".inp")(),
surf.points(),
surf.size(),
regionLst
zoneLst
);
}

View File

@ -124,7 +124,7 @@ public:
);
//- Write UnsortedMeshedSurface
// The output is sorted by regions
// The output is sorted by zones
static void write
(
const fileName&,

View File

@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
Ostream& os,
const pointField& pointLst,
const label nFaces,
const UList<surfRegion>& regionLst
const UList<surfZone>& zoneLst
)
{
word caseName = os.name().lessExt().name();
@ -176,11 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
<< "! case " << caseName << nl
<< "! ------------------------------" << nl;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
os << "ctable " << regionI + 1 << " shell" << nl
<< "ctname " << regionI + 1 << " "
<< regionLst[regionI].name() << nl;
os << "ctable " << zoneI + 1 << " shell" << nl
<< "ctname " << zoneI + 1 << " "
<< zoneLst[zoneI].name() << nl;
}
os << "! ------------------------------" << nl

View File

@ -70,7 +70,7 @@ protected:
Ostream&,
const pointField&,
const label nFaces,
const UList<surfRegion>&
const UList<surfZone>&
);
};

View File

@ -70,7 +70,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
const pointField& pointLst,
const Face& f,
const vector& norm,
const label regionI
const label zoneI
)
{
// simple triangulation about f[0].
@ -86,7 +86,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
p0,
pointLst[f[fp1]],
pointLst[f[fp2]],
regionI
zoneI
);
stlTri.write(os);
@ -104,22 +104,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
const vectorField& normLst = surf.faceNormals();
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this region
const surfRegion& reg = regionLst[regionI];
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << reg.name() << endl;
forAll(reg, localFaceI)
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
const label faceI = faceIndex++;
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << reg.name() << endl;
os << "endsolid " << zone.name() << endl;
}
}
@ -136,34 +136,34 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
if (surf.regionToc().size() == 1)
if (surf.zoneToc().size() == 1)
{
// a single region - we can skip sorting
os << "solid " << surf.regionToc()[0].name() << endl;
// a single zone - we can skip sorting
os << "solid " << surf.zoneToc()[0].name() << endl;
forAll(faceLst, faceI)
{
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << surf.regionToc()[0].name() << endl;
os << "endsolid " << surf.zoneToc()[0].name() << endl;
}
else
{
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
// Print all faces belonging to this region
const surfRegion& reg = regionLst[regionI];
// Print all faces belonging to this zone
const surfZone& zone = zoneLst[zoneI];
os << "solid " << reg.name() << endl;
forAll(reg, localFaceI)
os << "solid " << zone.name() << endl;
forAll(zone, localFaceI)
{
const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
}
os << "endsolid " << reg.name() << endl;
os << "endsolid " << zone.name() << endl;
}
}
}
@ -180,7 +180,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
unsigned int nTris = 0;
if (surf.isTri())
@ -200,9 +200,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], regionFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
writeShell
(
@ -210,7 +210,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
pointLst,
faceLst[faceIndex],
normLst[faceIndex],
regionI
zoneI
);
++faceIndex;
@ -229,7 +229,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<label>& regionIds = surf.regionIds();
const List<label>& zoneIds = surf.zoneIds();
const vectorField& normLst = surf.faceNormals();
unsigned int nTris = 0;
@ -258,7 +258,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
pointLst,
faceLst[faceI],
normLst[faceI],
regionIds[faceI]
zoneIds[faceI]
);
}
}
@ -292,13 +292,13 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// transfer points
this->storedPoints().transfer(reader.points());
// retrieve the original region information
// retrieve the original zone information
List<word> names(reader.names().xfer());
List<label> sizes(reader.sizes().xfer());
List<label> regionIds(reader.regionIds().xfer());
List<label> zoneIds(reader.zoneIds().xfer());
// generate the (sorted) faces
List<Face> faceLst(regionIds.size());
List<Face> faceLst(zoneIds.size());
if (reader.sorted())
{
@ -314,7 +314,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow
List<label> faceMap;
sortedOrder(regionIds, faceMap);
sortedOrder(zoneIds, faceMap);
// generate sorted faces
forAll(faceMap, faceI)
@ -323,18 +323,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
}
}
regionIds.clear();
zoneIds.clear();
// transfer:
this->storedFaces().transfer(faceLst);
if (names.size())
{
this->addRegions(sizes, names);
this->addZones(sizes, names);
}
else
{
this->addRegions(sizes);
this->addZones(sizes);
}
this->stitchFaces(SMALL);

View File

@ -29,7 +29,7 @@ Description
Provide a means of reading/writing STL files (ASCII and binary).
Note
For efficiency, the regions are sorted before creating the faces.
For efficiency, the zones are sorted before creating the faces.
The class is thus derived from MeshedSurface.
SourceFiles
@ -79,7 +79,7 @@ class STLsurfaceFormat
const pointField&,
const Face&,
const vector&,
const label regionI
const label zoneI
);
@ -142,7 +142,7 @@ public:
const MeshedSurface<Face>&
);
//- Write UnsortedMeshedSurface (as ASCII) sorted by region
//- Write UnsortedMeshedSurface (as ASCII) sorted by zone
static void write
(
Ostream&,
@ -150,7 +150,7 @@ public:
);
//- Write UnsortedMeshedSurface
// ASCII output is sorted by region; binary output is unsorted
// ASCII output is sorted by zone; binary output is unsorted
static void write
(
const fileName&,

View File

@ -63,9 +63,8 @@ int yyFlexLexer::yywrap()
//- A lexer for parsing STL ASCII files.
// Returns DynamicList(s) of points and facets (regionIds).
// Since the facets appear within a solid/endsolid grouping,
// they are always within a region
// Returns DynamicList(s) of points and facets (zoneIds).
// The facets are within a solid/endsolid grouping
class STLASCIILexer
:
public yyFlexLexer
@ -73,7 +72,7 @@ class STLASCIILexer
// Private data
bool sorted_;
label groupID_; // current region
label groupID_; // current solid group
label lineNo_;
word startError_;
@ -110,20 +109,20 @@ public:
return points_;
}
//- A list of facet IDs (region IDs)
//- A list of facet IDs (group IDs)
// corresponds to the number of triangles
DynamicList<label>& facets()
{
return facets_;
}
//- region names
//- Names
DynamicList<word>& names()
{
return names_;
}
//- region sizes
//- Sizes
DynamicList<label>& sizes()
{
return sizes_;
@ -417,7 +416,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
// transfer to normal lists
points_.transfer(lexer.points());
regionIds_.transfer(lexer.facets());
zoneIds_.transfer(lexer.facets());
names_.transfer(lexer.names());
sizes_.transfer(lexer.sizes());

View File

@ -139,18 +139,18 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
#ifdef DEBUG_STLBINARY
Info<< "# " << nTris << " facets" << endl;
label prevRegion = -1;
label prevZone = -1;
#endif
points_.setSize(3*nTris);
regionIds_.setSize(nTris);
zoneIds_.setSize(nTris);
Map<label> lookup;
DynamicList<label> dynSizes;
label ptI = 0;
label regionI = -1;
forAll(regionIds_, faceI)
label zoneI = -1;
forAll(zoneIds_, faceI)
{
// Read an STL triangle
STLtriangle stlTri(is);
@ -160,39 +160,39 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
points_[ptI++] = stlTri.b();
points_[ptI++] = stlTri.c();
// interprete colour as a region
const label stlRegion = stlTri.region();
// interprete stl attribute as a zone
const label origId = stlTri.attrib();
Map<label>::const_iterator fnd = lookup.find(stlRegion);
Map<label>::const_iterator fnd = lookup.find(origId);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// group appeared out of order
sorted_ = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(stlRegion, regionI);
zoneI = dynSizes.size();
lookup.insert(origId, zoneI);
dynSizes.append(0);
}
regionIds_[faceI] = regionI;
dynSizes[regionI]++;
zoneIds_[faceI] = zoneI;
dynSizes[zoneI]++;
#ifdef DEBUG_STLBINARY
if (prevRegion != regionI)
if (prevZone != zoneI)
{
if (prevRegion != -1)
if (prevZone != -1)
{
Info<< "endsolid region" << prevRegion << nl;
Info<< "endsolid zone" << prevZone << nl;
}
prevRegion = regionI;
prevZone = zoneI;
Info<< "solid region" << prevRegion << nl;
Info<< "solid zone" << prevZone << nl;
}
Info<< " facet normal " << stlTri.normal() << nl
@ -221,7 +221,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
:
sorted_(true),
points_(0),
regionIds_(0),
zoneIds_(0),
names_(0),
sizes_(0)
{

View File

@ -63,8 +63,8 @@ class STLsurfaceFormatCore
//- The points supporting the facets
pointField points_;
//- The regions associated with the faces
List<label> regionIds_;
//- The zones associated with the faces
List<label> zoneIds_;
//- The solid names, in the order of their first appearance
List<word> names_;
@ -123,7 +123,7 @@ public:
{
sorted_ = true;
points_.clear();
regionIds_.clear();
zoneIds_.clear();
names_.clear();
sizes_.clear();
}
@ -134,10 +134,10 @@ public:
return points_;
}
//- Return full access to the regionIds
List<label>& regionIds()
//- Return full access to the zoneIds
List<label>& zoneIds()
{
return regionIds_;
return zoneIds_;
}
//- The list of solid names in the order of their first appearance

View File

@ -46,18 +46,19 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class STLtriangle Declaration
Class STLtriangle Declaration
\*---------------------------------------------------------------------------*/
class STLtriangle
{
// Private data
typedef unsigned short STLregion;
//- Attribute is 16-bit
typedef unsigned short STLattrib;
STLpoint normal_, a_, b_, c_;
STLregion region_;
STLattrib attrib_;
public:
@ -73,7 +74,7 @@ public:
const STLpoint& a,
const STLpoint& b,
const STLpoint& c,
unsigned short region
unsigned short attrib
);
//- Construct from istream (read binary)
@ -88,7 +89,7 @@ public:
inline const STLpoint& a() const;
inline const STLpoint& b() const;
inline const STLpoint& c() const;
inline unsigned short region() const;
inline unsigned short attrib() const;
// Read

View File

@ -38,14 +38,14 @@ inline Foam::STLtriangle::STLtriangle
const STLpoint& a,
const STLpoint& b,
const STLpoint& c,
unsigned short region
unsigned short attrib
)
:
normal_(normal),
a_(a),
b_(b),
c_(c),
region_(region)
attrib_(attrib)
{}
@ -77,23 +77,23 @@ inline const Foam::STLpoint& Foam::STLtriangle::c() const
return c_;
}
inline unsigned short Foam::STLtriangle::region() const
inline unsigned short Foam::STLtriangle::attrib() const
{
return region_;
return attrib_;
}
inline void Foam::STLtriangle::read(istream& is)
{
is.read(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
is.read(reinterpret_cast<char*>(&region_), sizeof(STLregion));
is.read(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
}
inline void Foam::STLtriangle::write(ostream& os)
{
os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
os.write(reinterpret_cast<char*>(&region_), sizeof(STLregion));
os.write(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
@ -104,7 +104,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const STLtriangle& t)
<< t.a_ << token::SPACE
<< t.b_ << token::SPACE
<< t.c_ << token::SPACE
<< t.region_;
<< t.attrib_;
return os;
}

View File

@ -165,89 +165,89 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
}
// Returns region info.
// Sets faceMap to the indexing according to region numbers.
// Region numbers start at 0.
Foam::surfRegionList
Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
// Returns zone info.
// Sets faceMap to the indexing according to zone numbers.
// Zone numbers start at 0.
Foam::surfZoneList
Foam::fileFormats::surfaceFormatsCore::sortedZonesById
(
const UList<label>& regionIds,
const Map<word>& regionNames,
const UList<label>& zoneIds,
const Map<word>& zoneNames,
labelList& faceMap
)
{
// determine sort order according to region numbers
// determine sort order according to zone numbers
// std::sort() really seems to mix up the order.
// and std::stable_sort() might take too long / too much memory
// Assuming that we have relatively fewer regions compared to the
// Assuming that we have relatively fewer zones compared to the
// number of items, just do it ourselves
// step 1: get region sizes and store (regionId => regionI)
// step 1: get zone sizes and store (origId => zoneI)
Map<label> lookup;
forAll(regionIds, faceI)
forAll(zoneIds, faceI)
{
const label regId = regionIds[faceI];
const label origId = zoneIds[faceI];
Map<label>::iterator fnd = lookup.find(regId);
Map<label>::iterator fnd = lookup.find(origId);
if (fnd != lookup.end())
{
fnd()++;
}
else
{
lookup.insert(regId, 1);
lookup.insert(origId, 1);
}
}
// step 2: assign start/size (and name) to the newRegions
// re-use the lookup to map (regionId => regionI)
surfRegionList regionLst(lookup.size());
// step 2: assign start/size (and name) to the newZones
// re-use the lookup to map (zoneId => zoneI)
surfZoneList zoneLst(lookup.size());
label start = 0;
label regionI = 0;
label zoneI = 0;
forAllIter(Map<label>, lookup, iter)
{
label regId = iter.key();
label origId = iter.key();
word name;
Map<word>::const_iterator fnd = regionNames.find(regId);
if (fnd != regionNames.end())
Map<word>::const_iterator fnd = zoneNames.find(origId);
if (fnd != zoneNames.end())
{
name = fnd();
}
else
{
name = word("region") + ::Foam::name(regionI);
name = word("zone") + ::Foam::name(zoneI);
}
regionLst[regionI] = surfRegion
zoneLst[zoneI] = surfZone
(
name,
0, // initialize with zero size
start,
regionI
zoneI
);
// increment the start for the next region
// and save the (regionId => regionI) mapping
// increment the start for the next zone
// and save the (zoneId => zoneI) mapping
start += iter();
iter() = regionI++;
iter() = zoneI++;
}
// step 3: build the re-ordering
faceMap.setSize(regionIds.size());
faceMap.setSize(zoneIds.size());
forAll(regionIds, faceI)
forAll(zoneIds, faceI)
{
label regionI = lookup[regionIds[faceI]];
label zoneI = lookup[zoneIds[faceI]];
faceMap[faceI] =
regionLst[regionI].start() + regionLst[regionI].size()++;
zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
}
// with reordered faces registered in faceMap
return regionLst;
return zoneLst;
}

View File

@ -39,8 +39,8 @@ SourceFiles
#include "Map.H"
#include "HashSet.H"
#include "labelList.H"
#include "surfRegionList.H"
#include "surfRegionIdentifierList.H"
#include "surfZoneList.H"
#include "surfZoneIdentifierList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -92,12 +92,12 @@ public:
//- Name of UnsortedMeshedSurface directory to use.
static fileName findMeshName(const Time&);
//- Determine the sort order from the region ids.
// Returns region list and sets faceMap to indices within faceLst
static surfRegionList sortedRegionsById
//- Determine the sort order from the zone ids.
// Returns zone list and sets faceMap to indices within faceLst
static surfZoneList sortedZonesById
(
const UList<label>& regionIds,
const Map<word>& regionNames,
const UList<label>& zoneIds,
const Map<word>& zoneNames,
labelList& faceMap
);

View File

@ -37,7 +37,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
Ostream& os,
const pointField& pointLst,
const Face& f,
const label regionI
const label zoneI
)
{
// simple triangulation about f[0].
@ -53,8 +53,8 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
os << p0.x() << ' ' << p0.y() << ' ' << p0.z() << ' '
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
// region as colour
<< "0x" << hex << regionI << dec << endl;
// zone as colour
<< "0x" << hex << zoneI << dec << endl;
}
}
@ -87,12 +87,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
// transfer points
this->storedPoints().transfer(reader.points());
// retrieve the original region information
// retrieve the original zone information
List<label> sizes(reader.sizes().xfer());
List<label> regionIds(reader.regionIds().xfer());
List<label> zoneIds(reader.zoneIds().xfer());
// generate the (sorted) faces
List<Face> faceLst(regionIds.size());
List<Face> faceLst(zoneIds.size());
if (reader.sorted())
{
@ -108,7 +108,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
// unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow
List<label> faceMap;
sortedOrder(regionIds, faceMap);
sortedOrder(zoneIds, faceMap);
// generate sorted faces
forAll(faceMap, faceI)
@ -117,12 +117,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
}
}
regionIds.clear();
zoneIds.clear();
// transfer:
this->storedFaces().transfer(faceLst);
this->addRegions(sizes);
this->addZones(sizes);
this->stitchFaces(SMALL);
return true;
}
@ -137,15 +137,15 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
{
const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
writeShell(os, pointLst, f, regionI);
writeShell(os, pointLst, f, zoneI);
}
}
}
@ -162,8 +162,8 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces();
bool doSort = false;
// a single region needs no sorting
if (surf.regionToc().size() == 1)
// a single zone needs no sorting
if (surf.zoneToc().size() == 1)
{
doSort = false;
}
@ -171,25 +171,25 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
if (doSort)
{
labelList faceMap;
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
List<surfZone> zoneLst = surf.sortedZones(faceMap);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, pointLst, f, regionI);
writeShell(os, pointLst, f, zoneI);
}
}
}
else
{
const List<label>& regionIds = surf.regionIds();
const List<label>& zoneIds = surf.zoneIds();
forAll(faceLst, faceI)
{
writeShell(os, pointLst, faceLst[faceI], regionIds[faceI]);
writeShell(os, pointLst, faceLst[faceI], zoneIds[faceI]);
}
}
}

View File

@ -29,7 +29,7 @@ Description
Provide a means of reading/writing .tri format.
Note
For efficiency, the regions are sorted before creating the faces.
For efficiency, the zones are sorted before creating the faces.
The class is thus derived from MeshedSurface.
SourceFiles
@ -69,7 +69,7 @@ class TRIsurfaceFormat
Ostream&,
const pointField&,
const Face&,
const label regionI
const label zoneI
);
//- Disallow default bitwise copy construct
@ -123,7 +123,7 @@ public:
}
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions
// By default, the output is not sorted by zones
static void write
(
Ostream&,
@ -131,7 +131,7 @@ public:
);
//- Write UnsortedMeshedSurface
// By default, the output is not sorted by regions
// By default, the output is not sorted by zones
static void write
(
const fileName& name,

View File

@ -43,7 +43,7 @@ Foam::fileFormats::TRIsurfaceFormatCore::TRIsurfaceFormatCore
:
sorted_(true),
points_(0),
regionIds_(0),
zoneIds_(0),
sizes_(0)
{
read(filename);
@ -79,14 +79,14 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
// uses similar structure as STL, just some points
// the rest of the reader resembles the STL binary reader
DynamicList<point> dynPoints;
DynamicList<label> dynRegions;
DynamicList<label> dynZones;
DynamicList<label> dynSizes;
HashTable<label> lookup;
// place faces without a group in region0
label regionI = 0;
dynSizes.append(regionI);
lookup.insert("regionI", regionI);
// place faces without a group in zone0
label zoneI = 0;
dynSizes.append(zoneI);
lookup.insert("zoneI", zoneI);
while (is.good())
{
@ -130,56 +130,56 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
)
);
// Region/colour in .tri file starts with 0x. Skip.
// zone/colour in .tri file starts with 0x. Skip.
// ie, instead of having 0xFF, skip 0 and leave xFF to
// get read as a word and name it "regionFF"
// get read as a word and name it "zoneFF"
char zero;
lineStream >> zero;
word rawName(lineStream);
word name("region" + rawName(1, rawName.size()-1));
word name("zone" + rawName(1, rawName.size()-1));
HashTable<label>::const_iterator fnd = lookup.find(name);
if (fnd != lookup.end())
{
if (regionI != fnd())
if (zoneI != fnd())
{
// group appeared out of order
sorted_ = false;
}
regionI = fnd();
zoneI = fnd();
}
else
{
regionI = dynSizes.size();
lookup.insert(name, regionI);
zoneI = dynSizes.size();
lookup.insert(name, zoneI);
dynSizes.append(0);
}
dynRegions.append(regionI);
dynSizes[regionI]++;
dynZones.append(zoneI);
dynSizes[zoneI]++;
}
// skip empty groups
label nRegion = 0;
forAll(dynSizes, regionI)
label nZone = 0;
forAll(dynSizes, zoneI)
{
if (dynSizes[regionI])
if (dynSizes[zoneI])
{
if (nRegion != regionI)
if (nZone != zoneI)
{
dynSizes[nRegion] = dynSizes[regionI];
dynSizes[nZone] = dynSizes[zoneI];
}
nRegion++;
nZone++;
}
}
// truncate addressed size
dynSizes.setCapacity(nRegion);
dynSizes.setCapacity(nZone);
// transfer to normal lists
points_.transfer(dynPoints);
regionIds_.transfer(dynRegions);
zoneIds_.transfer(dynZones);
sizes_.transfer(dynSizes);
return true;

View File

@ -64,8 +64,8 @@ class TRIsurfaceFormatCore
//- The points supporting the facets
pointField points_;
//- The regions associated with the faces
List<label> regionIds_;
//- The zones associated with the faces
List<label> zoneIds_;
//- The solid count, in the order of their first appearance
List<label> sizes_;
@ -104,7 +104,7 @@ public:
{
sorted_ = true;
points_.clear();
regionIds_.clear();
zoneIds_.clear();
sizes_.clear();
}
@ -114,13 +114,13 @@ public:
return points_;
}
//- Return full access to the regions
List<label>& regionIds()
//- Return full access to the zones
List<label>& zoneIds()
{
return regionIds_;
return zoneIds_;
}
//- The list of region sizes in the order of their first appearance
//- The list of zone sizes in the order of their first appearance
List<label>& sizes()
{
return sizes_;

View File

@ -66,15 +66,15 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
)
{
const List<Face>& faceLst = surf.faces();
const List<surfRegion>& regionLst = surf.regions();
const List<surfZone>& zoneLst = surf.zones();
writeHeader(os, surf.points());
writeHeaderPolygons(os, faceLst);
label faceIndex = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
const Face& f = faceLst[faceIndex++];
@ -87,7 +87,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
}
}
writeTail(os, regionLst);
writeTail(os, zoneLst);
}
@ -115,7 +115,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
os << ' ' << nl;
}
writeTail(os, surf.regionIds());
writeTail(os, surf.zoneIds());
}

View File

@ -27,7 +27,7 @@ Class
Description
Provide a means of writing VTK legacy format.
The output is never sorted by region.
The output is never sorted by zone.
SourceFiles
VTKsurfaceFormat.C

View File

@ -58,25 +58,25 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
(
Ostream& os,
const UList<surfRegion>& regionLst
const UList<surfZone>& zoneLst
)
{
label nFaces = 0;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
nFaces += regionLst[regionI].size();
nFaces += zoneLst[zoneI].size();
}
// Print region numbers
// Print zone numbers
os << nl
<< "CELL_DATA " << nFaces << nl
<< "FIELD attributes 1" << nl
<< "region 1 " << nFaces << " float" << nl;
<< "zone 1 " << nFaces << " float" << nl;
forAll(regionLst, regionI)
forAll(zoneLst, zoneI)
{
forAll(regionLst[regionI], localFaceI)
forAll(zoneLst[zoneI], localFaceI)
{
if (localFaceI)
{
@ -89,7 +89,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
os << nl;
}
}
os << regionI + 1;
os << zoneI + 1;
}
os << nl;
}
@ -99,17 +99,16 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
(
Ostream& os,
const UList<label>& regionIds
const UList<label>& zoneIds
)
{
// Print region numbers
// Print zone numbers
os << nl
<< "CELL_DATA " << regionIds.size() << nl
<< "CELL_DATA " << zoneIds.size() << nl
<< "FIELD attributes 1" << nl
<< "region 1 " << regionIds.size() << " float" << nl;
<< "zone 1 " << zoneIds.size() << " float" << nl;
forAll(regionIds, faceI)
forAll(zoneIds, faceI)
{
if (faceI)
{
@ -122,7 +121,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
os << nl;
}
}
os << regionIds[faceI] + 1;
os << zoneIds[faceI] + 1;
}
os << nl;
}

View File

@ -64,11 +64,11 @@ protected:
const pointField&
);
//- Write trailing information with region information
static void writeTail(Ostream&, const UList<surfRegion>&);
//- Write trailing information with zone information
static void writeTail(Ostream&, const UList<surfZone>&);
//- Write trailing information with region Ids
static void writeTail(Ostream&, const UList<label>& regionIds);
//- Write trailing information with zone Ids
static void writeTail(Ostream&, const UList<label>& zoneIds);
};

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "surfaceRegistry.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfaceRegistry, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceRegistry::surfaceRegistry(const IOobject& io, const word& name)
:
objectRegistry
(
IOobject
(
name,
( io.instance().size() ? io.instance() : "constant" ),
"surfaces",
io.db(),
io.readOpt(),
io.writeOpt(),
io.registerObject()
)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceRegistry::~surfaceRegistry()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::surfaceRegistry
Description
Wraps the normal objectRegistry with a local instance for %surfaces.
SourceFiles
surfaceRegistry.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceRegistry_H
#define surfaceRegistry_H
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfaceRegistry Declaration
\*---------------------------------------------------------------------------*/
class surfaceRegistry
:
public objectRegistry
{
// Private Member Functions
//- Disallow default bitwise copy construct
surfaceRegistry(const surfaceRegistry&);
//- Disallow default bitwise assignment
void operator=(const surfaceRegistry&);
public:
//- Runtime type information
TypeName("surfaceRegistry");
// Constructors
//- Construct for the given objectRegistry and named instance
explicit surfaceRegistry(const IOobject&, const word& name="default");
// Destructor
virtual ~surfaceRegistry();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //