mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -1,3 +0,0 @@
|
|||||||
surfaceCoordinateSystemTransform.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
|
||||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
|
||||||
|
|
||||||
EXE_LIBS = -lmeshTools -lsurfMesh
|
|
||||||
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/triSurface/lnInclude \
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = -lsurfMesh
|
EXE_LIBS = -lmeshTools -lsurfMesh
|
||||||
|
|||||||
@ -26,25 +26,30 @@ Application
|
|||||||
surfaceMeshConvert
|
surfaceMeshConvert
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Converts from one surface mesh format to another
|
|
||||||
|
Convert between surface formats with optional scaling or
|
||||||
|
transformations (rotate/translate) on a coordinateSystem.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
- surfaceMeshConvert inputFile outputFile [OPTION]
|
- surfaceMeshConvert inputFile outputFile [OPTION]
|
||||||
|
|
||||||
@param -clean \n
|
@param -clean \n
|
||||||
Perform some surface checking/cleanup on the input surface
|
Perform some surface checking/cleanup on the input surface.
|
||||||
|
|
||||||
@param -orient \n
|
@param -scaleIn \<scale\> \n
|
||||||
Check face orientation on the input surface
|
Specify a scaling factor when reading files.
|
||||||
|
|
||||||
@param -scale \<scale\> \n
|
@param -scaleOut \<scale\> \n
|
||||||
Specify a scaling factor for writing the files
|
Specify a scaling factor when writing files.
|
||||||
|
|
||||||
@param -triSurface \n
|
@param -dict \<dictionary\> \n
|
||||||
Use triSurface library for input/output
|
Specify an alternative dictionary for constant/coordinateSystems.
|
||||||
|
|
||||||
@param -keyed \n
|
@param -from \<coordinateSystem\> \n
|
||||||
Use keyedSurface for input/output
|
Specify a coordinate System when reading files.
|
||||||
|
|
||||||
|
@param -to \<coordinateSystem\> \n
|
||||||
|
Specify a coordinate System when writing files.
|
||||||
|
|
||||||
Note
|
Note
|
||||||
The filename extensions are used to determine the file format type.
|
The filename extensions are used to determine the file format type.
|
||||||
@ -54,12 +59,9 @@ Note
|
|||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "timeSelector.H"
|
#include "timeSelector.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "polyMesh.H"
|
|
||||||
#include "triSurface.H"
|
|
||||||
#include "PackedBoolList.H"
|
|
||||||
|
|
||||||
#include "MeshedSurfaces.H"
|
#include "MeshedSurfaces.H"
|
||||||
#include "UnsortedMeshedSurfaces.H"
|
#include "coordinateSystems.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -71,24 +73,21 @@ int main(int argc, char *argv[])
|
|||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
argList::validArgs.append("inputFile");
|
argList::validArgs.append("inputFile");
|
||||||
argList::validArgs.append("outputFile");
|
argList::validArgs.append("outputFile");
|
||||||
argList::validOptions.insert("clean", "");
|
argList::validOptions.insert("clean", "scale");
|
||||||
argList::validOptions.insert("orient", "");
|
argList::validOptions.insert("scaleIn", "scale");
|
||||||
argList::validOptions.insert("scale", "scale");
|
argList::validOptions.insert("scaleOut", "scale");
|
||||||
argList::validOptions.insert("triSurface", "");
|
argList::validOptions.insert("dict", "coordinateSystemsDict");
|
||||||
argList::validOptions.insert("unsorted", "");
|
argList::validOptions.insert("from", "sourceCoordinateSystem");
|
||||||
argList::validOptions.insert("triFace", "");
|
argList::validOptions.insert("to", "targetCoordinateSystem");
|
||||||
# include "setRootCase.H"
|
|
||||||
const stringList& params = args.additionalArgs();
|
|
||||||
|
|
||||||
scalar scaleFactor = 0;
|
argList args(argc, argv);
|
||||||
if (args.options().found("scale"))
|
Time runTime(args.rootPath(), args.caseName());
|
||||||
{
|
const stringList& params = args.additionalArgs();
|
||||||
IStringStream(args.options()["scale"])() >> scaleFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName importName(params[0]);
|
fileName importName(params[0]);
|
||||||
fileName exportName(params[1]);
|
fileName exportName(params[1]);
|
||||||
|
|
||||||
|
// disable inplace editing
|
||||||
if (importName == exportName)
|
if (importName == exportName)
|
||||||
{
|
{
|
||||||
FatalErrorIn(args.executable())
|
FatalErrorIn(args.executable())
|
||||||
@ -96,165 +95,157 @@ int main(int argc, char *argv[])
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check that reading/writing is supported
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!meshedSurface::canRead(importName, true)
|
!MeshedSurface<face>::canRead(importName, true)
|
||||||
|| !meshedSurface::canWriteType(exportName.ext(), true)
|
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return 1;
|
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;
|
if (args.options().found("dict"))
|
||||||
surf.writeStats(Info);
|
|
||||||
Info<< endl;
|
|
||||||
|
|
||||||
if (args.options().found("orient"))
|
|
||||||
{
|
{
|
||||||
Info<< "Checking surface orientation" << endl;
|
fileName dictPath(args.options()["dict"]);
|
||||||
PatchTools::checkOrientation(surf, true);
|
|
||||||
Info<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
csDictIoPtr.set
|
||||||
{
|
(
|
||||||
Info<< "Cleaning up surface" << endl;
|
new IOobject
|
||||||
surf.cleanup(true);
|
(
|
||||||
surf.writeStats(Info);
|
( dictPath.isDir() ? dictPath/coordinateSystems::typeName : dictPath ),
|
||||||
Info<< endl;
|
runTime,
|
||||||
}
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
Info<< "writing " << exportName;
|
false
|
||||||
if (scaleFactor <= 0)
|
)
|
||||||
{
|
);
|
||||||
Info<< " without scaling" << endl;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " with scaling " << scaleFactor << endl;
|
csDictIoPtr.set
|
||||||
surf.scalePoints(scaleFactor);
|
(
|
||||||
surf.writeStats(Info);
|
new IOobject
|
||||||
Info<< endl;
|
(
|
||||||
|
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);
|
IStringStream(args.options()["scaleIn"])() >> scaleIn;
|
||||||
|
|
||||||
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
|
if (args.options().found("scaleOut"))
|
||||||
else if (args.options().found("triFace"))
|
|
||||||
{
|
{
|
||||||
MeshedSurface<triFace> surf(importName);
|
IStringStream(args.options()["scaleOut"])() >> scaleOut;
|
||||||
|
|
||||||
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);
|
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"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
Info<< "Cleaning up surface" << endl;
|
|
||||||
surf.cleanup(true);
|
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;
|
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);
|
surf.write(exportName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
surfaceMeshConvertTesting.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = -lsurfMesh
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -84,7 +84,7 @@ protected:
|
|||||||
return static_cast<List<Face> &>(*this);
|
return static_cast<List<Face> &>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set new regions from faceMap
|
//- Set new zones from faceMap
|
||||||
virtual void remapFaces(const UList<label>& faceMap);
|
virtual void remapFaces(const UList<label>& faceMap);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
surfRegion/surfRegion/surfRegion.C
|
surfZone/surfZone/surfZone.C
|
||||||
surfRegion/surfRegion/surfRegionIOList.C
|
surfZone/surfZone/surfZoneIOList.C
|
||||||
surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
|
surfZone/surfZoneIdentifier/surfZoneIdentifier.C
|
||||||
|
|
||||||
MeshedSurface/MeshedSurfaces.C
|
MeshedSurface/MeshedSurfaces.C
|
||||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||||
|
|
||||||
|
surfaceRegistry/surfaceRegistry.C
|
||||||
|
surfFields/surfFields.C
|
||||||
|
surfMesh/surfMesh.C
|
||||||
|
surfMesh/surfMeshClear.C
|
||||||
|
surfMesh/surfMeshIO.C
|
||||||
|
|
||||||
surfaceFormats = surfaceFormats
|
surfaceFormats = surfaceFormats
|
||||||
$(surfaceFormats)/surfaceFormatsCore.C
|
$(surfaceFormats)/surfaceFormatsCore.C
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ License
|
|||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "polyBoundaryMesh.H"
|
#include "polyBoundaryMesh.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
// #include "surfMesh.H"
|
#include "surfMesh.H"
|
||||||
#include "primitivePatch.H"
|
#include "primitivePatch.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
@ -166,11 +166,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
(
|
(
|
||||||
const Xfer<pointField>& pointLst,
|
const Xfer<pointField>& pointLst,
|
||||||
const Xfer<List<Face> >& faceLst,
|
const Xfer<List<Face> >& faceLst,
|
||||||
const Xfer<surfRegionList>& regionLst
|
const Xfer<surfZoneList>& zoneLst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
ParentType(pointLst, faceLst),
|
ParentType(pointLst, faceLst),
|
||||||
regions_(regionLst)
|
zones_(zoneLst)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -179,26 +179,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
(
|
(
|
||||||
const Xfer<pointField>& pointLst,
|
const Xfer<pointField>& pointLst,
|
||||||
const Xfer<List<Face> >& faceLst,
|
const Xfer<List<Face> >& faceLst,
|
||||||
const UList<label>& regionSizes,
|
const UList<label>& zoneSizes,
|
||||||
const UList<word>& regionNames
|
const UList<word>& zoneNames
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
ParentType(pointLst, faceLst)
|
ParentType(pointLst, faceLst)
|
||||||
{
|
{
|
||||||
if (®ionSizes)
|
if (&zoneSizes)
|
||||||
{
|
{
|
||||||
if (®ionNames)
|
if (&zoneNames)
|
||||||
{
|
{
|
||||||
addRegions(regionSizes, regionNames);
|
addZones(zoneSizes, zoneNames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addRegions(regionSizes);
|
addZones(zoneSizes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oneRegion();
|
oneZone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,15 +238,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// create region list
|
// create zone list
|
||||||
surfRegionList newRegions(bPatches.size());
|
surfZoneList newZones(bPatches.size());
|
||||||
|
|
||||||
label startFaceI = 0;
|
label startFaceI = 0;
|
||||||
forAll(bPatches, patchI)
|
forAll(bPatches, patchI)
|
||||||
{
|
{
|
||||||
const polyPatch& p = bPatches[patchI];
|
const polyPatch& p = bPatches[patchI];
|
||||||
|
|
||||||
newRegions[patchI] = surfRegion
|
newZones[patchI] = surfZone
|
||||||
(
|
(
|
||||||
p.name(),
|
p.name(),
|
||||||
p.size(),
|
p.size(),
|
||||||
@ -262,7 +262,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
(
|
(
|
||||||
xferCopy(bPoints),
|
xferCopy(bPoints),
|
||||||
xferCopy(bFaces),
|
xferCopy(bFaces),
|
||||||
xferMove(newRegions)
|
xferMove(newZones)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
origFaces.clear();
|
origFaces.clear();
|
||||||
|
|
||||||
this->storedFaces().transfer(newFaces);
|
this->storedFaces().transfer(newFaces);
|
||||||
regions_.transfer(surf.regions_);
|
zones_.transfer(surf.zones_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -294,39 +294,46 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
template<class Face>
|
||||||
// in preparation
|
|
||||||
Foam::MeshedSurface<Face>::MeshedSurface
|
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
|
// must triangulate?
|
||||||
List<surfRegion> newRegions(sPatches.size());
|
if (this->isTri())
|
||||||
|
|
||||||
label startFaceI = 0;
|
|
||||||
forAll(sPatches, patchI)
|
|
||||||
{
|
{
|
||||||
const surfPatch& p = sPatches[patchI];
|
surf.triangulate();
|
||||||
|
this->storedPoints().transfer(surf.storedPoints());
|
||||||
|
|
||||||
newRegions[patchI] = surfRegion
|
// transcribe from face -> triFace
|
||||||
(
|
List<face>& origFaces = surf.storedFaces();
|
||||||
p.name(),
|
List<triFace> newFaces(origFaces.size());
|
||||||
p.size(),
|
forAll(origFaces, faceI)
|
||||||
startFaceI,
|
{
|
||||||
patchI
|
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>
|
template<class Face>
|
||||||
@ -336,8 +343,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
surfZoneList zoneLst = surf.sortedZones(faceMap);
|
||||||
regions_.transfer(regionLst);
|
zones_.transfer(zoneLst);
|
||||||
|
|
||||||
const List<Face>& origFaces = surf.faces();
|
const List<Face>& origFaces = surf.faces();
|
||||||
List<Face> newFaces(origFaces.size());
|
List<Face> newFaces(origFaces.size());
|
||||||
@ -388,7 +395,7 @@ template<class Face>
|
|||||||
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
|
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
|
||||||
:
|
:
|
||||||
ParentType(surf),
|
ParentType(surf),
|
||||||
regions_(surf.regions_)
|
zones_(surf.zones_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -420,70 +427,70 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
|
|||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::MeshedSurface<Face>::oneRegion(const word& name)
|
void Foam::MeshedSurface<Face>::oneZone(const word& name)
|
||||||
{
|
{
|
||||||
word regionName(name);
|
word zoneName(name);
|
||||||
if (regionName.empty())
|
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
|
// set single default zone
|
||||||
regions_.setSize(1);
|
zones_.setSize(1);
|
||||||
regions_[0] = surfRegion
|
zones_[0] = surfZone
|
||||||
(
|
(
|
||||||
regionName,
|
zoneName,
|
||||||
size(), // region size
|
size(), // zone size
|
||||||
0, // region start
|
0, // zone start
|
||||||
0 // region index
|
0 // zone index
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
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
|
// and they cover all the faces - fix start silently
|
||||||
if (regions_.size() <= 1)
|
if (zones_.size() <= 1)
|
||||||
{
|
{
|
||||||
oneRegion();
|
oneZone();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label count = 0;
|
label count = 0;
|
||||||
forAll(regions_, regionI)
|
forAll(zones_, zoneI)
|
||||||
{
|
{
|
||||||
regions_[regionI].start() = count;
|
zones_[zoneI].start() = count;
|
||||||
count += regions_[regionI].size();
|
count += zones_[zoneI].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < size())
|
if (count < size())
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"MeshedSurface::checkRegions()\n"
|
"MeshedSurface::checkZones()\n"
|
||||||
)
|
)
|
||||||
<< "more face " << size() << " than regions " << count
|
<< "more faces " << size() << " than zones " << count
|
||||||
<< " ... extending final region"
|
<< " ... extending final zone"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
regions_[regions_.size()-1].size() += count - size();
|
zones_[zones_.size()-1].size() += count - size();
|
||||||
}
|
}
|
||||||
else if (count > size())
|
else if (count > size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"MeshedSurface::checkRegions()\n"
|
"MeshedSurface::checkZones()\n"
|
||||||
)
|
)
|
||||||
<< "more regions " << count << " than faces " << size()
|
<< "more zones " << count << " than faces " << size()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,12 +501,12 @@ template<class Face>
|
|||||||
void Foam::MeshedSurface<Face>::sortFacesAndStore
|
void Foam::MeshedSurface<Face>::sortFacesAndStore
|
||||||
(
|
(
|
||||||
const Xfer<List<Face> >& unsortedFaces,
|
const Xfer<List<Face> >& unsortedFaces,
|
||||||
const Xfer<List<label> >& regionIds,
|
const Xfer<List<label> >& zoneIds,
|
||||||
const bool sorted
|
const bool sorted
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
List<Face> oldFaces(unsortedFaces);
|
List<Face> oldFaces(unsortedFaces);
|
||||||
List<label> regions(regionIds);
|
List<label> zones(zoneIds);
|
||||||
|
|
||||||
if (sorted)
|
if (sorted)
|
||||||
{
|
{
|
||||||
@ -511,8 +518,8 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
|
|||||||
// unsorted - determine the sorted order:
|
// unsorted - determine the sorted order:
|
||||||
// avoid SortableList since we discard the main list anyhow
|
// avoid SortableList since we discard the main list anyhow
|
||||||
List<label> faceMap;
|
List<label> faceMap;
|
||||||
sortedOrder(regions, faceMap);
|
sortedOrder(zones, faceMap);
|
||||||
regions.clear();
|
zones.clear();
|
||||||
|
|
||||||
// sorted faces
|
// sorted faces
|
||||||
List<Face> newFaces(faceMap.size());
|
List<Face> newFaces(faceMap.size());
|
||||||
@ -524,7 +531,7 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
|
|||||||
this->storedFaces().transfer(newFaces);
|
this->storedFaces().transfer(newFaces);
|
||||||
|
|
||||||
}
|
}
|
||||||
regions.clear();
|
zones.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -534,29 +541,29 @@ void Foam::MeshedSurface<Face>::remapFaces
|
|||||||
const UList<label>& faceMap
|
const UList<label>& faceMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// recalculate the region start/size
|
// recalculate the zone start/size
|
||||||
if (&faceMap && faceMap.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
|
// optimized for single zone case
|
||||||
regions_[0].size() = faceMap.size();
|
zones_[0].size() = faceMap.size();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
label origEndI = 0;
|
label origEndI = 0;
|
||||||
forAll(regions_, regionI)
|
forAll(zones_, zoneI)
|
||||||
{
|
{
|
||||||
surfRegion& reg = regions_[regionI];
|
surfZone& zone = zones_[zoneI];
|
||||||
|
|
||||||
// adjust region start
|
// adjust zone start
|
||||||
reg.start() = newFaceI;
|
zone.start() = newFaceI;
|
||||||
origEndI += reg.size();
|
origEndI += zone.size();
|
||||||
|
|
||||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||||
{
|
{
|
||||||
@ -570,8 +577,8 @@ void Foam::MeshedSurface<Face>::remapFaces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust region size
|
// adjust zone size
|
||||||
reg.size() = newFaceI - reg.start();
|
zone.size() = newFaceI - zone.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -586,7 +593,7 @@ template<class Face>
|
|||||||
void Foam::MeshedSurface<Face>::clear()
|
void Foam::MeshedSurface<Face>::clear()
|
||||||
{
|
{
|
||||||
ParentType::clear();
|
ParentType::clear();
|
||||||
regions_.clear();
|
zones_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -614,11 +621,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
|||||||
oldToNew[pointMap[pointI]] = pointI;
|
oldToNew[pointMap[pointI]] = pointI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create/copy a new region list, each region with zero size
|
// create/copy a new zones list, each zone with zero size
|
||||||
surfRegionList newRegions(regions_);
|
surfZoneList newZones(zones_);
|
||||||
forAll(newRegions, regionI)
|
forAll(newZones, zoneI)
|
||||||
{
|
{
|
||||||
newRegions[regionI].size() = 0;
|
newZones[zoneI].size() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renumber face node labels
|
// Renumber face node labels
|
||||||
@ -637,18 +644,18 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
|||||||
}
|
}
|
||||||
oldToNew.clear();
|
oldToNew.clear();
|
||||||
|
|
||||||
// recalculate the region start/size
|
// recalculate the zones start/size
|
||||||
label newFaceI = 0;
|
label newFaceI = 0;
|
||||||
label origEndI = 0;
|
label origEndI = 0;
|
||||||
|
|
||||||
// adjust region sizes
|
// adjust zone sizes
|
||||||
forAll(newRegions, regionI)
|
forAll(newZones, zoneI)
|
||||||
{
|
{
|
||||||
surfRegion& reg = newRegions[regionI];
|
surfZone& zone = newZones[zoneI];
|
||||||
|
|
||||||
// adjust region start
|
// adjust zone start
|
||||||
reg.start() = newFaceI;
|
zone.start() = newFaceI;
|
||||||
origEndI += reg.size();
|
origEndI += zone.size();
|
||||||
|
|
||||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||||
{
|
{
|
||||||
@ -662,8 +669,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust region size
|
// adjust zone size
|
||||||
reg.size() = newFaceI - reg.start();
|
zone.size() = newFaceI - zone.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -672,7 +679,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
|||||||
(
|
(
|
||||||
xferMove(newPoints),
|
xferMove(newPoints),
|
||||||
xferMove(newFaces),
|
xferMove(newFaces),
|
||||||
xferMove(newRegions)
|
xferMove(newZones)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,29 +697,29 @@ Foam::MeshedSurface<Face>::subsetMesh
|
|||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::MeshedSurface<Face>::addRegions
|
void Foam::MeshedSurface<Face>::addZones
|
||||||
(
|
(
|
||||||
const UList<surfRegion>& regions,
|
const UList<surfZone>& zones,
|
||||||
const bool cullEmpty
|
const bool cullEmpty
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nRegion = 0;
|
label nZone = 0;
|
||||||
|
|
||||||
regions_.setSize(regions.size());
|
zones_.setSize(zones.size());
|
||||||
forAll(regions_, regionI)
|
forAll(zones_, zoneI)
|
||||||
{
|
{
|
||||||
if (regions[regionI].size() || !cullEmpty)
|
if (zones[zoneI].size() || !cullEmpty)
|
||||||
{
|
{
|
||||||
regions_[nRegion] = surfRegion(regions[regionI], nRegion);
|
zones_[nZone] = surfZone(zones[zoneI], nZone);
|
||||||
nRegion++;
|
nZone++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regions_.setSize(nRegion);
|
zones_.setSize(nZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::MeshedSurface<Face>::addRegions
|
void Foam::MeshedSurface<Face>::addZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes,
|
const UList<label>& sizes,
|
||||||
const UList<word>& names,
|
const UList<word>& names,
|
||||||
@ -720,55 +727,55 @@ void Foam::MeshedSurface<Face>::addRegions
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
label start = 0;
|
label start = 0;
|
||||||
label nRegion = 0;
|
label nZone = 0;
|
||||||
|
|
||||||
regions_.setSize(sizes.size());
|
zones_.setSize(sizes.size());
|
||||||
forAll(regions_, regionI)
|
forAll(zones_, zoneI)
|
||||||
{
|
{
|
||||||
if (sizes[regionI] || !cullEmpty)
|
if (sizes[zoneI] || !cullEmpty)
|
||||||
{
|
{
|
||||||
regions_[nRegion] = surfRegion
|
zones_[nZone] = surfZone
|
||||||
(
|
(
|
||||||
names[regionI],
|
names[zoneI],
|
||||||
sizes[regionI],
|
sizes[zoneI],
|
||||||
start,
|
start,
|
||||||
nRegion
|
nZone
|
||||||
);
|
);
|
||||||
start += sizes[regionI];
|
start += sizes[zoneI];
|
||||||
nRegion++;
|
nZone++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regions_.setSize(nRegion);
|
zones_.setSize(nZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::MeshedSurface<Face>::addRegions
|
void Foam::MeshedSurface<Face>::addZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes,
|
const UList<label>& sizes,
|
||||||
const bool cullEmpty
|
const bool cullEmpty
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label start = 0;
|
label start = 0;
|
||||||
label nRegion = 0;
|
label nZone = 0;
|
||||||
|
|
||||||
regions_.setSize(sizes.size());
|
zones_.setSize(sizes.size());
|
||||||
forAll(regions_, regionI)
|
forAll(zones_, zoneI)
|
||||||
{
|
{
|
||||||
if (sizes[regionI] || !cullEmpty)
|
if (sizes[zoneI] || !cullEmpty)
|
||||||
{
|
{
|
||||||
regions_[nRegion] = surfRegion
|
zones_[nZone] = surfZone
|
||||||
(
|
(
|
||||||
word("region") + ::Foam::name(nRegion),
|
word("zone") + ::Foam::name(nZone),
|
||||||
sizes[regionI],
|
sizes[zoneI],
|
||||||
start,
|
start,
|
||||||
nRegion
|
nZone
|
||||||
);
|
);
|
||||||
start += sizes[regionI];
|
start += sizes[zoneI];
|
||||||
nRegion++;
|
nZone++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regions_.setSize(nRegion);
|
zones_.setSize(nZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -779,7 +786,7 @@ void Foam::MeshedSurface<Face>::transfer
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||||
regions_.transfer(surf.regions_);
|
zones_.transfer(surf.zones_);
|
||||||
|
|
||||||
surf.clear();
|
surf.clear();
|
||||||
}
|
}
|
||||||
@ -794,7 +801,7 @@ void Foam::MeshedSurface<Face>::transfer
|
|||||||
clear();
|
clear();
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
surfZoneList zoneLst = surf.sortedZones(faceMap);
|
||||||
List<Face>& oldFaces = surf.storedFaces();
|
List<Face>& oldFaces = surf.storedFaces();
|
||||||
|
|
||||||
List<Face> newFaces(faceMap.size());
|
List<Face> newFaces(faceMap.size());
|
||||||
@ -805,12 +812,20 @@ void Foam::MeshedSurface<Face>::transfer
|
|||||||
faceMap.clear();
|
faceMap.clear();
|
||||||
|
|
||||||
reset(xferMove(surf.storedPoints()), xferMove(newFaces));
|
reset(xferMove(surf.storedPoints()), xferMove(newFaces));
|
||||||
regions_.transfer(regionLst);
|
zones_.transfer(zoneLst);
|
||||||
|
|
||||||
surf.clear();
|
surf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::Xfer< Foam::MeshedSurface<Face> >
|
||||||
|
Foam::MeshedSurface<Face>::xfer()
|
||||||
|
{
|
||||||
|
return xferMove(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read from file, determine format from extension
|
// Read from file, determine format from extension
|
||||||
template<class Face>
|
template<class Face>
|
||||||
bool Foam::MeshedSurface<Face>::read(const fileName& name)
|
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->storedPoints() = surf.points();
|
||||||
this->storedFaces() = surf.faces();
|
this->storedFaces() = surf.faces();
|
||||||
regions_ = surf.regions_;
|
zones_ = surf.zones_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -26,13 +26,13 @@ Class
|
|||||||
Foam::MeshedSurface
|
Foam::MeshedSurface
|
||||||
|
|
||||||
Description
|
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
|
with a similarily named surfaceMesh, which actually refers to
|
||||||
the cell faces of a volume mesh.
|
the cell faces of a volume mesh.
|
||||||
|
|
||||||
The MeshedSurface is intended to surfaces from a variety of sources.
|
The MeshedSurface is intended for surfaces from a variety of sources.
|
||||||
- A set of points and faces without any region information.
|
- A set of points and faces without any surface zone information.
|
||||||
- A set of points and faces with randomly sorted region information.
|
- A set of points and faces with randomly ordered zone information.
|
||||||
This could arise, for example, from reading external file formats
|
This could arise, for example, from reading external file formats
|
||||||
such as STL, etc.
|
such as STL, etc.
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ SourceFiles
|
|||||||
#define MeshedSurface_H
|
#define MeshedSurface_H
|
||||||
|
|
||||||
#include "BasicMeshedSurface.H"
|
#include "BasicMeshedSurface.H"
|
||||||
#include "surfRegionList.H"
|
#include "surfZoneList.H"
|
||||||
#include "surfaceFormatsCore.H"
|
#include "surfaceFormatsCore.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
#include "memberFunctionSelectionTables.H"
|
#include "memberFunctionSelectionTables.H"
|
||||||
@ -59,6 +59,7 @@ namespace Foam
|
|||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class Time;
|
class Time;
|
||||||
|
class surfMesh;
|
||||||
template<class Face> class MeshedSurface;
|
template<class Face> class MeshedSurface;
|
||||||
template<class Face> class UnsortedMeshedSurface;
|
template<class Face> class UnsortedMeshedSurface;
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ class MeshedSurface
|
|||||||
public fileFormats::surfaceFormatsCore
|
public fileFormats::surfaceFormatsCore
|
||||||
{
|
{
|
||||||
friend class UnsortedMeshedSurface<Face>;
|
friend class UnsortedMeshedSurface<Face>;
|
||||||
|
friend class surfMesh;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -88,9 +90,9 @@ private:
|
|||||||
|
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- Region information
|
//- Zone information
|
||||||
// (face ordering nFaces/startFace only used during reading/writing)
|
// (face ordering nFaces/startFace only used during reading/writing)
|
||||||
List<surfRegion> regions_;
|
List<surfZone> zones_;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
|
|
||||||
@ -101,18 +103,24 @@ protected:
|
|||||||
|
|
||||||
// Protected Member functions
|
// Protected Member functions
|
||||||
|
|
||||||
//- basic sanity check on regions
|
//- basic sanity check on zones
|
||||||
void checkRegions();
|
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
|
void sortFacesAndStore
|
||||||
(
|
(
|
||||||
const Xfer<List<Face> >& unsortedFaces,
|
const Xfer<List<Face> >& unsortedFaces,
|
||||||
const Xfer<List<label> >& regionIds,
|
const Xfer<List<label> >& zoneIds,
|
||||||
const bool sorted
|
const bool sorted
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Set new regions from faceMap
|
//- Set new zones from faceMap
|
||||||
virtual void remapFaces(const UList<label>& faceMap);
|
virtual void remapFaces(const UList<label>& faceMap);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -139,22 +147,22 @@ public:
|
|||||||
//- Construct null
|
//- Construct null
|
||||||
MeshedSurface();
|
MeshedSurface();
|
||||||
|
|
||||||
//- Construct by transferring components (points, faces, regions).
|
//- Construct by transferring components (points, faces, zones).
|
||||||
MeshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const Xfer<pointField>&,
|
const Xfer<pointField>&,
|
||||||
const Xfer<List<Face> >&,
|
const Xfer<List<Face> >&,
|
||||||
const Xfer<surfRegionList>&
|
const Xfer<surfZoneList>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces.
|
//- Construct by transferring points, faces.
|
||||||
// Use region information, or set single default region.
|
// Use zone information, or set single default zone.
|
||||||
MeshedSurface
|
MeshedSurface
|
||||||
(
|
(
|
||||||
const Xfer<pointField>&,
|
const Xfer<pointField>&,
|
||||||
const Xfer<List<Face> >&,
|
const Xfer<List<Face> >&,
|
||||||
const UList<label>& regionSizes = UList<label>::null(),
|
const UList<label>& zoneSizes = UList<label>::null(),
|
||||||
const UList<word>& regionNames = UList<word>::null()
|
const UList<word>& zoneNames = UList<word>::null()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from a boundary mesh with local points/faces
|
//- Construct from a boundary mesh with local points/faces
|
||||||
@ -250,31 +258,31 @@ public:
|
|||||||
return ParentType::size();
|
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
|
//- set a single zone, optionally with a specific name
|
||||||
void oneRegion(const word& name = word::null);
|
void oneZone(const word& name = word::null);
|
||||||
|
|
||||||
//- Add regions
|
//- Add zones
|
||||||
void addRegions
|
void addZones
|
||||||
(
|
(
|
||||||
const UList<surfRegion>&,
|
const UList<surfZone>&,
|
||||||
const bool cullEmpty=false
|
const bool cullEmpty=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Add regions
|
//- Add zones
|
||||||
void addRegions
|
void addZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes,
|
const UList<label>& sizes,
|
||||||
const UList<word>& names,
|
const UList<word>& names,
|
||||||
const bool cullEmpty=false
|
const bool cullEmpty=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Add regions
|
//- Add zones
|
||||||
void addRegions
|
void addZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes,
|
const UList<label>& sizes,
|
||||||
const bool cullEmpty=false
|
const bool cullEmpty=false
|
||||||
@ -306,6 +314,8 @@ public:
|
|||||||
//- Transfer the contents of the argument and annull the argument
|
//- Transfer the contents of the argument and annull the argument
|
||||||
void transfer(UnsortedMeshedSurface<Face>&);
|
void transfer(UnsortedMeshedSurface<Face>&);
|
||||||
|
|
||||||
|
//- Transfer contents to the Xfer container
|
||||||
|
Xfer< MeshedSurface<Face> > xfer();
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|
||||||
|
|||||||
@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
List<surfRegion> regionLst(is);
|
List<surfZone> newZones(is);
|
||||||
|
|
||||||
// copy and set the indices
|
// copy and set the indices
|
||||||
regions_.setSize(regionLst.size());
|
zones_.setSize(newZones.size());
|
||||||
forAll(regionLst, regionI)
|
forAll(newZones, zoneI)
|
||||||
{
|
{
|
||||||
regions_[regionI] = surfRegion
|
zones_[zoneI] = surfZone
|
||||||
(
|
(
|
||||||
regionLst[regionI],
|
newZones[zoneI],
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
|||||||
Xfer<pointField>::null(),
|
Xfer<pointField>::null(),
|
||||||
faceLst.xfer()
|
faceLst.xfer()
|
||||||
);
|
);
|
||||||
surf.addRegions(regions_);
|
surf.addZones(zones_);
|
||||||
|
|
||||||
// this will break if the triangulation needed points
|
// this will break if the triangulation needed points
|
||||||
surf.triangulate();
|
surf.triangulate();
|
||||||
regions_ = surf.regions();
|
zones_ = surf.zones();
|
||||||
|
|
||||||
// transcribe from face -> triFace (Face)
|
// transcribe from face -> triFace (Face)
|
||||||
const List<face>& origFaces = surf.faces();
|
const List<face>& origFaces = surf.faces();
|
||||||
@ -101,12 +101,12 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
|
|||||||
IOobject::writeBanner(os);
|
IOobject::writeBanner(os);
|
||||||
os << "// OpenFOAM Surface Format" << nl
|
os << "// OpenFOAM Surface Format" << nl
|
||||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||||
<< "// regions:" << nl
|
<< "// zones:" << nl
|
||||||
<< regions_.size() << nl << token::BEGIN_LIST << incrIndent << 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;
|
os << decrIndent << token::END_LIST << nl;
|
||||||
|
|
||||||
|
|||||||
105
src/surfMesh/SurfGeoMesh/SurfGeoMesh.H
Normal file
105
src/surfMesh/SurfGeoMesh/SurfGeoMesh.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -163,13 +163,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
|||||||
(
|
(
|
||||||
const Xfer<pointField>& pointLst,
|
const Xfer<pointField>& pointLst,
|
||||||
const Xfer<List<Face> >& faceLst,
|
const Xfer<List<Face> >& faceLst,
|
||||||
const Xfer<List<label> >& regionIds,
|
const Xfer<List<label> >& zoneIds,
|
||||||
const Xfer<surfRegionIdentifierList>& regionTofc
|
const Xfer<surfZoneIdentifierList>& zoneTofc
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
ParentType(pointLst, faceLst),
|
ParentType(pointLst, faceLst),
|
||||||
regionIds_(regionIds),
|
zoneIds_(zoneIds),
|
||||||
regionToc_(regionTofc)
|
zoneToc_(zoneTofc)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -178,26 +178,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
|||||||
(
|
(
|
||||||
const Xfer<pointField>& pointLst,
|
const Xfer<pointField>& pointLst,
|
||||||
const Xfer<List<Face> >& faceLst,
|
const Xfer<List<Face> >& faceLst,
|
||||||
const UList<label>& regionSizes,
|
const UList<label>& zoneSizes,
|
||||||
const UList<word>& regionNames
|
const UList<word>& zoneNames
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
ParentType(pointLst, faceLst)
|
ParentType(pointLst, faceLst)
|
||||||
{
|
{
|
||||||
if (®ionSizes)
|
if (&zoneSizes)
|
||||||
{
|
{
|
||||||
if (®ionNames)
|
if (&zoneNames)
|
||||||
{
|
{
|
||||||
setRegions(regionSizes, regionNames);
|
setZones(zoneSizes, zoneNames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setRegions(regionSizes);
|
setZones(zoneSizes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oneRegion();
|
oneZone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
|||||||
:
|
:
|
||||||
ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
|
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())),
|
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
|
||||||
regionIds_(surf.regionIds_),
|
zoneIds_(surf.zoneIds_),
|
||||||
regionToc_(surf.regionToc_)
|
zoneToc_(surf.zoneToc_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -302,99 +302,99 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
|||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
|
void Foam::UnsortedMeshedSurface<Face>::oneZone(const word& name)
|
||||||
{
|
{
|
||||||
regionIds_.setSize(size());
|
zoneIds_.setSize(size());
|
||||||
regionIds_ = 0;
|
zoneIds_ = 0;
|
||||||
|
|
||||||
word regionName(name);
|
word zoneName(name);
|
||||||
if (regionName.empty())
|
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
|
// set single default zone
|
||||||
regionToc_.setSize(1);
|
zoneToc_.setSize(1);
|
||||||
regionToc_[0] = surfRegionIdentifier(regionName, 0);
|
zoneToc_[0] = surfZoneIdentifier(zoneName, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
void Foam::UnsortedMeshedSurface<Face>::setZones
|
||||||
(
|
(
|
||||||
const surfRegionList& regionLst
|
const surfZoneList& zoneLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
regionIds_.setSize(size());
|
zoneIds_.setSize(size());
|
||||||
regionToc_.setSize(regionLst.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
|
// assign sub-zone Ids
|
||||||
SubList<label> subRegion(regionIds_, reg.size(), reg.start());
|
SubList<label> subZone(zoneIds_, zone.size(), zone.start());
|
||||||
subRegion = regionI;
|
subZone = zoneI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
void Foam::UnsortedMeshedSurface<Face>::setZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes,
|
const UList<label>& sizes,
|
||||||
const UList<word>& names
|
const UList<word>& names
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
regionIds_.setSize(size());
|
zoneIds_.setSize(size());
|
||||||
regionToc_.setSize(sizes.size());
|
zoneToc_.setSize(sizes.size());
|
||||||
|
|
||||||
label start = 0;
|
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
|
// assign sub-zone Ids
|
||||||
SubList<label> subRegion(regionIds_, sizes[regionI], start);
|
SubList<label> subZone(zoneIds_, sizes[zoneI], start);
|
||||||
subRegion = regionI;
|
subZone = zoneI;
|
||||||
|
|
||||||
start += sizes[regionI];
|
start += sizes[zoneI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
void Foam::UnsortedMeshedSurface<Face>::setZones
|
||||||
(
|
(
|
||||||
const UList<label>& sizes
|
const UList<label>& sizes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
regionIds_.setSize(size());
|
zoneIds_.setSize(size());
|
||||||
regionToc_.setSize(sizes.size());
|
zoneToc_.setSize(sizes.size());
|
||||||
|
|
||||||
label start = 0;
|
label start = 0;
|
||||||
forAll(regionToc_, regionI)
|
forAll(zoneToc_, zoneI)
|
||||||
{
|
{
|
||||||
regionToc_[regionI] = surfRegionIdentifier
|
zoneToc_[zoneI] = surfZoneIdentifier
|
||||||
(
|
(
|
||||||
word("region") + ::Foam::name(regionI),
|
word("zone") + ::Foam::name(zoneI),
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
// assign sub-region Ids
|
// assign sub-zone Ids
|
||||||
SubList<label> subRegion(regionIds_, sizes[regionI], start);
|
SubList<label> subZone(zoneIds_, sizes[zoneI], start);
|
||||||
subRegion = regionI;
|
subZone = zoneI;
|
||||||
|
|
||||||
start += sizes[regionI];
|
start += sizes[zoneI];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,27 +405,27 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
|
|||||||
const UList<label>& faceMap
|
const UList<label>& faceMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// re-assign the region Ids
|
// re-assign the zone Ids
|
||||||
if (&faceMap && faceMap.size())
|
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
|
// optimized for single-zone case
|
||||||
regionIds_ = 0;
|
zoneIds_ = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<label> newRegions(faceMap.size());
|
List<label> newZones(faceMap.size());
|
||||||
|
|
||||||
forAll(faceMap, faceI)
|
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)
|
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
|
||||||
{
|
{
|
||||||
ParentType::setSize(s);
|
ParentType::setSize(s);
|
||||||
// if regions extend: set with last regionId
|
// if zones extend: set with last zoneId
|
||||||
regionIds_.setSize(s, regionToc_.size() - 1);
|
zoneIds_.setSize(s, zoneToc_.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -446,25 +446,25 @@ template<class Face>
|
|||||||
void Foam::UnsortedMeshedSurface<Face>::clear()
|
void Foam::UnsortedMeshedSurface<Face>::clear()
|
||||||
{
|
{
|
||||||
ParentType::clear();
|
ParentType::clear();
|
||||||
regionIds_.clear();
|
zoneIds_.clear();
|
||||||
regionToc_.clear();
|
zoneToc_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Face>
|
template<class Face>
|
||||||
Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
|
||||||
(
|
(
|
||||||
labelList& faceMap
|
labelList& faceMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// supply some region names
|
// supply some zone names
|
||||||
Map<word> regionNames;
|
Map<word> zoneNames;
|
||||||
forAll(regionToc_, regionI)
|
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
|
// Renumber face node labels and compact
|
||||||
List<Face> newFaces(faceMap.size());
|
List<Face> newFaces(faceMap.size());
|
||||||
List<label> newRegions(faceMap.size());
|
List<label> newZones(faceMap.size());
|
||||||
|
|
||||||
forAll(faceMap, faceI)
|
forAll(faceMap, faceI)
|
||||||
{
|
{
|
||||||
@ -507,7 +507,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
|||||||
f[fp] = oldToNew[f[fp]];
|
f[fp] = oldToNew[f[fp]];
|
||||||
}
|
}
|
||||||
|
|
||||||
newRegions[faceI] = regionIds_[origFaceI];
|
newZones[faceI] = zoneIds_[origFaceI];
|
||||||
}
|
}
|
||||||
oldToNew.clear();
|
oldToNew.clear();
|
||||||
|
|
||||||
@ -516,8 +516,8 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
|||||||
(
|
(
|
||||||
xferMove(newPoints),
|
xferMove(newPoints),
|
||||||
xferMove(newFaces),
|
xferMove(newFaces),
|
||||||
xferMove(newRegions),
|
xferMove(newZones),
|
||||||
xferCopy(regionToc_)
|
xferCopy(zoneToc_)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,14 +538,14 @@ void Foam::UnsortedMeshedSurface<Face>::reset
|
|||||||
(
|
(
|
||||||
const Xfer<pointField>& pointLst,
|
const Xfer<pointField>& pointLst,
|
||||||
const Xfer<List<Face> >& faceLst,
|
const Xfer<List<Face> >& faceLst,
|
||||||
const Xfer<List<label> >& regionIds
|
const Xfer<List<label> >& zoneIds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ParentType::reset(pointLst, faceLst);
|
ParentType::reset(pointLst, faceLst);
|
||||||
|
|
||||||
if (®ionIds)
|
if (&zoneIds)
|
||||||
{
|
{
|
||||||
regionIds_.transfer(regionIds());
|
zoneIds_.transfer(zoneIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,9 +560,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
|||||||
(
|
(
|
||||||
xferMove(surf.storedPoints()),
|
xferMove(surf.storedPoints()),
|
||||||
xferMove(surf.storedFaces()),
|
xferMove(surf.storedFaces()),
|
||||||
xferMove(surf.regionIds_)
|
xferMove(surf.zoneIds_)
|
||||||
);
|
);
|
||||||
regionToc_.transfer(surf.regionToc_);
|
zoneToc_.transfer(surf.zoneToc_);
|
||||||
|
|
||||||
surf.clear();
|
surf.clear();
|
||||||
}
|
}
|
||||||
@ -575,11 +575,20 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||||
setRegions(surf.regions());
|
setZones(surf.zones());
|
||||||
surf.clear();
|
surf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Face>
|
||||||
|
Foam::Xfer< Foam::UnsortedMeshedSurface<Face> >
|
||||||
|
Foam::UnsortedMeshedSurface<Face>::xfer()
|
||||||
|
{
|
||||||
|
return xferMove(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Read from file, determine format from extension
|
// Read from file, determine format from extension
|
||||||
template<class Face>
|
template<class Face>
|
||||||
bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& name)
|
bool Foam::UnsortedMeshedSurface<Face>::read(const fileName& name)
|
||||||
@ -638,8 +647,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
|
|||||||
|
|
||||||
this->storedPoints() = surf.points();
|
this->storedPoints() = surf.points();
|
||||||
this->storedFaces() = surf.faces();
|
this->storedFaces() = surf.faces();
|
||||||
regionIds_ = surf.regionIds_;
|
zoneIds_ = surf.zoneIds_;
|
||||||
regionToc_ = surf.regionToc_;
|
zoneToc_ = surf.zoneToc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -26,18 +26,18 @@ Class
|
|||||||
Foam::UnsortedMeshedSurface
|
Foam::UnsortedMeshedSurface
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A surface geometry mesh, in which the region information is conveyed by
|
A surface geometry mesh, in which the surface zone information is
|
||||||
the 'regionId' associated with each face.
|
conveyed by the 'zoneId' associated with each face.
|
||||||
|
|
||||||
This form of surface description is particularly useful for reading in
|
This form of surface description is particularly useful for reading in
|
||||||
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
|
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
|
||||||
can also be particularly useful for situations in which the surface
|
can also be particularly useful for situations in which the surface
|
||||||
many be adjusted in an arbitrary manner without worrying about needed
|
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
|
See Also
|
||||||
The Foam::MeshedSurface - which is organized as a surface mesh, but
|
The Foam::MeshedSurface - which is organized as a surface mesh, but
|
||||||
with independent region information.
|
with independent zone information.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
UnsortedMeshedSurface.C
|
UnsortedMeshedSurface.C
|
||||||
@ -48,8 +48,8 @@ SourceFiles
|
|||||||
#define UnsortedMeshedSurface_H
|
#define UnsortedMeshedSurface_H
|
||||||
|
|
||||||
#include "BasicMeshedSurface.H"
|
#include "BasicMeshedSurface.H"
|
||||||
#include "surfRegionIdentifierList.H"
|
#include "surfZoneIdentifierList.H"
|
||||||
#include "surfRegionList.H"
|
#include "surfZoneList.H"
|
||||||
#include "surfaceFormatsCore.H"
|
#include "surfaceFormatsCore.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
#include "memberFunctionSelectionTables.H"
|
#include "memberFunctionSelectionTables.H"
|
||||||
@ -93,12 +93,12 @@ private:
|
|||||||
|
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- The region Ids associated with the faces
|
//- The zone Id associated with each face
|
||||||
labelList regionIds_;
|
labelList zoneIds_;
|
||||||
|
|
||||||
//- Region information (face ordering nFaces/startFace only used
|
//- Zone information (face ordering nFaces/startFace only used
|
||||||
// during reading and writing)
|
// during reading and writing)
|
||||||
List<surfRegionIdentifier> regionToc_;
|
List<surfZoneIdentifier> zoneToc_;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
|
|
||||||
@ -115,19 +115,19 @@ protected:
|
|||||||
|
|
||||||
// Protected Member functions
|
// Protected Member functions
|
||||||
|
|
||||||
//- Return non-const access to the region Ids
|
//- Return non-const access to the zone Ids
|
||||||
List<label>& storedRegionIds()
|
List<label>& storedZoneIds()
|
||||||
{
|
{
|
||||||
return regionIds_;
|
return zoneIds_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return non-const access to the region table-of-contents
|
//- Return non-const access to the zone table-of-contents
|
||||||
List<surfRegionIdentifier>& storedRegionToc()
|
List<surfZoneIdentifier>& storedZoneToc()
|
||||||
{
|
{
|
||||||
return regionToc_;
|
return zoneToc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Set new regions from faceMap
|
//- Set new zones from faceMap
|
||||||
virtual void remapFaces(const UList<label>& faceMap);
|
virtual void remapFaces(const UList<label>& faceMap);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -155,23 +155,23 @@ public:
|
|||||||
UnsortedMeshedSurface();
|
UnsortedMeshedSurface();
|
||||||
|
|
||||||
//- Construct by transferring components
|
//- Construct by transferring components
|
||||||
// (points, faces, region ids, region info).
|
// (points, faces, zone ids, zone info).
|
||||||
UnsortedMeshedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const Xfer<pointField>&,
|
const Xfer<pointField>&,
|
||||||
const Xfer<List<Face> >&,
|
const Xfer<List<Face> >&,
|
||||||
const Xfer<List<label> >& regionIds,
|
const Xfer<List<label> >& zoneIds,
|
||||||
const Xfer<surfRegionIdentifierList>&
|
const Xfer<surfZoneIdentifierList>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by transferring points, faces.
|
//- Construct by transferring points, faces.
|
||||||
// Use region information, or set single default region
|
// Use zone information, or set single default zone
|
||||||
UnsortedMeshedSurface
|
UnsortedMeshedSurface
|
||||||
(
|
(
|
||||||
const Xfer<pointField>&,
|
const Xfer<pointField>&,
|
||||||
const Xfer<List<Face> >&,
|
const Xfer<List<Face> >&,
|
||||||
const UList<label>& regionSizes = UList<label>::null(),
|
const UList<label>& zoneSizes = UList<label>::null(),
|
||||||
const UList<word>& regionNames = UList<word>::null()
|
const UList<word>& zoneNames = UList<word>::null()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from a boundary mesh with local points/faces
|
//- Construct from a boundary mesh with local points/faces
|
||||||
@ -264,37 +264,37 @@ public:
|
|||||||
return ParentType::size();
|
return ParentType::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Reset size of face and region list
|
//- Reset size of face and zone list
|
||||||
void setSize(const label);
|
void setSize(const label);
|
||||||
|
|
||||||
//- Return const access to the regions ids
|
//- Return const access to the zone ids
|
||||||
const List<label>& regionIds() const
|
const List<label>& zoneIds() const
|
||||||
{
|
{
|
||||||
return regionIds_;
|
return zoneIds_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return const access to the region table-of-contents
|
//- Return const access to the zone table-of-contents
|
||||||
const List<surfRegionIdentifier>& regionToc() const
|
const List<surfZoneIdentifier>& zoneToc() const
|
||||||
{
|
{
|
||||||
return regionToc_;
|
return zoneToc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Sort faces according to region.
|
//- Sort faces according to zone.
|
||||||
// Returns a surfRegionList and sets faceMap to index within faces()
|
// Returns a surfZoneList and sets faceMap to index within faces()
|
||||||
surfRegionList sortedRegions(labelList& faceMap) const;
|
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
|
// Optionally with a specific name
|
||||||
void oneRegion(const word& name = word::null);
|
void oneZone(const word& name = word::null);
|
||||||
|
|
||||||
//- Set region ids and regions
|
//- Set zone ids and zones
|
||||||
void setRegions(const surfRegionList&);
|
void setZones(const surfZoneList&);
|
||||||
|
|
||||||
//- Set region ids and regions
|
//- Set zone ids and zones
|
||||||
void setRegions(const UList<label>& sizes, const UList<word>& names);
|
void setZones(const UList<label>& sizes, const UList<word>& names);
|
||||||
|
|
||||||
//- Set region ids and set regions with default names
|
//- Set zone ids and zones with default names
|
||||||
void setRegions(const UList<label>& sizes);
|
void setZones(const UList<label>& sizes);
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
@ -317,12 +317,12 @@ public:
|
|||||||
const labelHashSet& include
|
const labelHashSet& include
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Transfer components (points, faces, region ids).
|
//- Transfer components (points, faces, zone ids).
|
||||||
virtual void reset
|
virtual void reset
|
||||||
(
|
(
|
||||||
const Xfer<pointField>&,
|
const Xfer<pointField>&,
|
||||||
const Xfer<List<Face> >&,
|
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
|
//- 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
|
//- Transfer the contents of the argument and annull the argument
|
||||||
void transfer(MeshedSurface<Face>&);
|
void transfer(MeshedSurface<Face>&);
|
||||||
|
|
||||||
|
//- Transfer contents to the Xfer container
|
||||||
|
Xfer< UnsortedMeshedSurface<Face> > xfer();
|
||||||
|
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|
||||||
|
|||||||
@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
|||||||
const List<Face>& faceLst = this->faces();
|
const List<Face>& faceLst = this->faces();
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
surfRegionList regionLst = sortedRegions(faceMap);
|
surfZoneList zoneLst = sortedZones(faceMap);
|
||||||
|
|
||||||
// just emit some information until we get a nice IOobject
|
// just emit some information until we get a nice IOobject
|
||||||
IOobject::writeBanner(os);
|
IOobject::writeBanner(os);
|
||||||
os << "// OpenFOAM Surface Format" << nl
|
os << "// OpenFOAM Surface Format" << nl
|
||||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
|
||||||
<< "// regions:" << nl
|
<< "// zones:" << nl
|
||||||
<< regionLst.size() << nl << token::BEGIN_LIST << incrIndent << 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;
|
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;
|
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
|
||||||
|
|
||||||
label faceI = 0;
|
label faceI = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
// Print all faces belonging to this region
|
// Print all faces belonging to this zone
|
||||||
const surfRegion& reg = regionLst[regionI];
|
const surfZone& zone = zoneLst[zoneI];
|
||||||
|
|
||||||
forAll(reg, localFaceI)
|
forAll(zone, localFaceI)
|
||||||
{
|
{
|
||||||
os << faceLst[faceMap[faceI++]] << nl;
|
os << faceLst[faceMap[faceI++]] << nl;
|
||||||
}
|
}
|
||||||
|
|||||||
82
src/surfMesh/surfFields/surfFields.C
Normal file
82
src/surfMesh/surfFields/surfFields.C
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
73
src/surfMesh/surfFields/surfFields.H
Normal file
73
src/surfMesh/surfFields/surfFields.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
59
src/surfMesh/surfFields/surfFieldsFwd.H
Normal file
59
src/surfMesh/surfFields/surfFieldsFwd.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
90
src/surfMesh/surfFields/surfGeoMesh.H
Normal file
90
src/surfMesh/surfFields/surfGeoMesh.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
446
src/surfMesh/surfMesh/surfMesh.C
Normal file
446
src/surfMesh/surfMesh/surfMesh.C
Normal 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
334
src/surfMesh/surfMesh/surfMesh.H
Normal file
334
src/surfMesh/surfMesh/surfMesh.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
84
src/surfMesh/surfMesh/surfMeshClear.C
Normal file
84
src/surfMesh/surfMesh/surfMeshClear.C
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
215
src/surfMesh/surfMesh/surfMeshIO.C
Normal file
215
src/surfMesh/surfMesh/surfMeshIO.C
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -26,28 +26,28 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "surfRegion.H"
|
#include "surfZone.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeNameAndDebug(Foam::surfRegion, 0);
|
defineTypeNameAndDebug(Foam::surfZone, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion()
|
Foam::surfZone::surfZone()
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(),
|
surfZoneIdentifier(),
|
||||||
size_(0),
|
size_(0),
|
||||||
start_(0)
|
start_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion
|
Foam::surfZone::surfZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const label size,
|
const label size,
|
||||||
@ -56,68 +56,68 @@ Foam::surfRegion::surfRegion
|
|||||||
const word& geometricType
|
const word& geometricType
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(name, index, geometricType),
|
surfZoneIdentifier(name, index, geometricType),
|
||||||
size_(size),
|
size_(size),
|
||||||
start_(start)
|
start_(start)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion(Istream& is, const label index)
|
Foam::surfZone::surfZone(Istream& is, const label index)
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(),
|
surfZoneIdentifier(),
|
||||||
size_(0),
|
size_(0),
|
||||||
start_(0)
|
start_(0)
|
||||||
{
|
{
|
||||||
word name(is);
|
word name(is);
|
||||||
dictionary dict(is);
|
dictionary dict(is);
|
||||||
|
|
||||||
operator=(surfRegion(name, dict, index));
|
operator=(surfZone(name, dict, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion
|
Foam::surfZone::surfZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const label index
|
const label index
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(name, dict, index),
|
surfZoneIdentifier(name, dict, index),
|
||||||
size_(readLabel(dict.lookup("nFaces"))),
|
size_(readLabel(dict.lookup("nFaces"))),
|
||||||
start_(readLabel(dict.lookup("startFace")))
|
start_(readLabel(dict.lookup("startFace")))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion(const surfRegion& reg)
|
Foam::surfZone::surfZone(const surfZone& zone)
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(reg, reg.index()),
|
surfZoneIdentifier(zone, zone.index()),
|
||||||
size_(reg.size()),
|
size_(zone.size()),
|
||||||
start_(reg.start())
|
start_(zone.start())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
|
Foam::surfZone::surfZone(const surfZone& zone, const label index)
|
||||||
:
|
:
|
||||||
surfRegionIdentifier(reg, index),
|
surfZoneIdentifier(zone, index),
|
||||||
size_(reg.size()),
|
size_(zone.size()),
|
||||||
start_(reg.start())
|
start_(zone.start())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::surfRegion::write(Ostream& os) const
|
void Foam::surfZone::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
writeDict(os);
|
writeDict(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::surfRegion::writeDict(Ostream& os) const
|
void Foam::surfZone::writeDict(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << indent << name() << nl
|
os << indent << name() << nl
|
||||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||||
|
|
||||||
surfRegionIdentifier::write(os);
|
surfZoneIdentifier::write(os);
|
||||||
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
|
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("startFace") << start() << 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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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
|
return
|
||||||
(
|
(
|
||||||
(geometricType() == reg.geometricType())
|
(geometricType() == rhs.geometricType())
|
||||||
&& (size() == reg.size())
|
&& (size() == rhs.size())
|
||||||
&& (start() == reg.start())
|
&& (start() == rhs.start())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone)
|
||||||
{
|
{
|
||||||
reg.write(os);
|
zone.write(os);
|
||||||
os.check("Ostream& operator<<(Ostream&, const surfRegion&");
|
os.check("Ostream& operator<<(Ostream&, const surfZone&");
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,24 +23,25 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::surfRegion
|
Foam::surfZone
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A region on a meshed surface.
|
A surface zone on a MeshedSurface.
|
||||||
Similar in concept to a faceZone on the surface.
|
|
||||||
|
Similar in concept to a faceZone, but the face list is contiguous.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
surfRegion.C
|
surfZone.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef surfRegion_H
|
#ifndef surfZone_H
|
||||||
#define surfRegion_H
|
#define surfZone_H
|
||||||
|
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "className.H"
|
#include "className.H"
|
||||||
#include "surfRegionIdentifier.H"
|
#include "surfZoneIdentifier.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
@ -51,18 +52,18 @@ namespace Foam
|
|||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class surfRegion;
|
class surfZone;
|
||||||
|
|
||||||
Istream& operator>>(Istream&, surfRegion&);
|
Istream& operator>>(Istream&, surfZone&);
|
||||||
Ostream& operator<<(Ostream&, const surfRegion&);
|
Ostream& operator<<(Ostream&, const surfZone&);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class surfRegion Declaration
|
Class surfZone Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class surfRegion
|
class surfZone
|
||||||
:
|
:
|
||||||
public surfRegionIdentifier
|
public surfZoneIdentifier
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -75,16 +76,16 @@ class surfRegion
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
ClassName("surfRegion");
|
ClassName("surfZone");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
surfRegion();
|
surfZone();
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
surfRegion
|
surfZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const label size,
|
const label size,
|
||||||
@ -94,10 +95,10 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
surfRegion(Istream& is, const label index);
|
surfZone(Istream& is, const label index);
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
surfRegion
|
surfZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
@ -105,48 +106,48 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
surfRegion(const surfRegion&);
|
surfZone(const surfZone&);
|
||||||
|
|
||||||
//- Construct from another region, resetting the index
|
//- Construct from another zone, resetting the index
|
||||||
surfRegion(const surfRegion&, const label index);
|
surfZone(const surfZone&, const label index);
|
||||||
|
|
||||||
//- Return clone
|
//- Return clone
|
||||||
autoPtr<surfRegion> clone() const
|
autoPtr<surfZone> clone() const
|
||||||
{
|
{
|
||||||
notImplemented("autoPtr<surfRegion> clone() const");
|
notImplemented("autoPtr<surfZone> clone() const");
|
||||||
return autoPtr<surfRegion>(NULL);
|
return autoPtr<surfZone>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static autoPtr<surfRegion> New(Istream& is)
|
static autoPtr<surfZone> New(Istream& is)
|
||||||
{
|
{
|
||||||
word name(is);
|
word name(is);
|
||||||
dictionary dict(is);
|
dictionary dict(is);
|
||||||
|
|
||||||
return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
|
return autoPtr<surfZone>(new surfZone(name, dict, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// 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
|
label start() const
|
||||||
{
|
{
|
||||||
return start_;
|
return start_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return start label of this region in the face list
|
//- Return start label of this zone in the face list
|
||||||
label& start()
|
label& start()
|
||||||
{
|
{
|
||||||
return start_;
|
return start_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return size of this region in the face list
|
//- Return size of this zone in the face list
|
||||||
label size() const
|
label size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return size of this region in the face list
|
//- Return size of this zone in the face list
|
||||||
label& size()
|
label& size()
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
@ -161,15 +162,15 @@ public:
|
|||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
bool operator!=(const surfRegion&) const;
|
bool operator!=(const surfZone&) const;
|
||||||
|
|
||||||
//- compare.
|
//- compare.
|
||||||
bool operator==(const surfRegion&) const;
|
bool operator==(const surfZone&) const;
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
friend Istream& operator>>(Istream&, surfRegion&);
|
friend Istream& operator>>(Istream&, surfZone&);
|
||||||
friend Ostream& operator<<(Ostream&, const surfRegion&);
|
friend Ostream& operator<<(Ostream&, const surfZone&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -24,71 +24,71 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "surfRegionIOList.H"
|
#include "surfZoneIOList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
|
defineTypeNameAndDebug(Foam::surfZoneIOList, 0);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::surfRegionIOList::surfRegionIOList
|
Foam::surfZoneIOList::surfZoneIOList
|
||||||
(
|
(
|
||||||
const IOobject& io
|
const IOobject& io
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
surfRegionList(),
|
surfZoneList(),
|
||||||
regIOobject(io)
|
regIOobject(io)
|
||||||
{
|
{
|
||||||
Foam::string functionName =
|
Foam::string functionName =
|
||||||
"surfRegionIOList::surfRegionIOList"
|
"surfZoneIOList::surfZoneIOList"
|
||||||
"(const IOobject& io)";
|
"(const IOobject& io)";
|
||||||
|
|
||||||
|
|
||||||
if (readOpt() == IOobject::MUST_READ)
|
if (readOpt() == IOobject::MUST_READ)
|
||||||
{
|
{
|
||||||
surfRegionList& regions = *this;
|
surfZoneList& zones = *this;
|
||||||
|
|
||||||
// read polyPatchList
|
// read polyPatchList
|
||||||
Istream& is = readStream(typeName);
|
Istream& is = readStream(typeName);
|
||||||
|
|
||||||
PtrList<entry> dictEntries(is);
|
PtrList<entry> dictEntries(is);
|
||||||
regions.setSize(dictEntries.size());
|
zones.setSize(dictEntries.size());
|
||||||
|
|
||||||
label faceI = 0;
|
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"));
|
label startFaceI = readLabel(dict.lookup("startFace"));
|
||||||
|
|
||||||
regions[regionI] = surfRegion
|
zones[zoneI] = surfZone
|
||||||
(
|
(
|
||||||
dictEntries[regionI].keyword(),
|
dictEntries[zoneI].keyword(),
|
||||||
regionSize,
|
zoneSize,
|
||||||
startFaceI,
|
startFaceI,
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
word geoType;
|
word geoType;
|
||||||
if (dict.readIfPresent("geometricType", geoType))
|
if (dict.readIfPresent("geometricType", geoType))
|
||||||
{
|
{
|
||||||
regions[regionI].geometricType() = geoType;
|
zones[zoneI].geometricType() = geoType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startFaceI != faceI)
|
if (startFaceI != faceI)
|
||||||
{
|
{
|
||||||
FatalErrorIn(functionName)
|
FatalErrorIn(functionName)
|
||||||
<< "Regions are not ordered. Start of region " << regionI
|
<< "surfZones are not ordered. Start of zone " << zoneI
|
||||||
<< " does not correspond to sum of preceding regions."
|
<< " does not correspond to sum of preceding zones."
|
||||||
<< endl
|
<< endl
|
||||||
<< "while reading " << io.objectPath()
|
<< "while reading " << io.objectPath()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
faceI += regionSize;
|
faceI += zoneSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check state of IOstream
|
// Check state of IOstream
|
||||||
@ -99,20 +99,20 @@ Foam::surfRegionIOList::surfRegionIOList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct from IOObject
|
// Construct from IOObject
|
||||||
Foam::surfRegionIOList::surfRegionIOList
|
Foam::surfZoneIOList::surfZoneIOList
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const surfRegionList& regions
|
const surfZoneList& zones
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
surfRegionList(regions),
|
surfZoneList(zones),
|
||||||
regIOobject(io)
|
regIOobject(io)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::surfRegionIOList::~surfRegionIOList()
|
Foam::surfZoneIOList::~surfZoneIOList()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ Foam::surfRegionIOList::~surfRegionIOList()
|
|||||||
|
|
||||||
|
|
||||||
// writeData member function required by regIOobject
|
// writeData member function required by regIOobject
|
||||||
bool Foam::surfRegionIOList::writeData(Ostream& os) const
|
bool Foam::surfZoneIOList::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << *this;
|
os << *this;
|
||||||
return os.good();
|
return os.good();
|
||||||
@ -129,7 +129,7 @@ bool Foam::surfRegionIOList::writeData(Ostream& os) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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;
|
os << L.size() << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
@ -23,20 +23,20 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::surfRegionIOList
|
Foam::surfZoneIOList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
IOobject for a surfRegionList
|
IOobject for a surfZoneList
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
surfRegionIOList.C
|
surfZoneIOList.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef surfRegionIOList_H
|
#ifndef surfZoneIOList_H
|
||||||
#define surfRegionIOList_H
|
#define surfZoneIOList_H
|
||||||
|
|
||||||
#include "surfRegionList.H"
|
#include "surfZoneList.H"
|
||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
#include "className.H"
|
#include "className.H"
|
||||||
@ -49,12 +49,12 @@ namespace Foam
|
|||||||
// Forward declaration of classes
|
// Forward declaration of classes
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class surfRegionIOList Declaration
|
Class surfZoneIOList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class surfRegionIOList
|
class surfZoneIOList
|
||||||
:
|
:
|
||||||
public surfRegionList,
|
public surfZoneList,
|
||||||
public regIOobject
|
public regIOobject
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
@ -63,29 +63,29 @@ class surfRegionIOList
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
surfRegionIOList(const surfRegionIOList&);
|
surfZoneIOList(const surfZoneIOList&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const surfRegionIOList&);
|
void operator=(const surfZoneIOList&);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("surfRegionIOList");
|
TypeName("surfZoneIOList");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
explicit surfRegionIOList(const IOobject&);
|
explicit surfZoneIOList(const IOobject&);
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
surfRegionIOList(const IOobject&, const surfRegionList&);
|
surfZoneIOList(const IOobject&, const surfZoneList&);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
~surfRegionIOList();
|
~surfZoneIOList();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
|
friend Ostream& operator<<(Ostream&, const surfZoneIOList&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -23,18 +23,18 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Typedef
|
Typedef
|
||||||
Foam::surfRegionList
|
Foam::surfZoneList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef surfRegionList_H
|
#ifndef surfZoneList_H
|
||||||
#define surfRegionList_H
|
#define surfZoneList_H
|
||||||
|
|
||||||
#include "surfRegion.H"
|
#include "surfZone.H"
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "surfRegionIdentifierList.H"
|
#include "surfZoneIdentifierList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
typedef List<surfRegion> surfRegionList;
|
typedef List<surfZone> surfZoneList;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -24,22 +24,22 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "surfRegionIdentifier.H"
|
#include "surfZoneIdentifier.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::surfRegionIdentifier::surfRegionIdentifier()
|
Foam::surfZoneIdentifier::surfZoneIdentifier()
|
||||||
:
|
:
|
||||||
name_(word::null),
|
name_(word::null),
|
||||||
boundaryIndex_(0),
|
index_(0),
|
||||||
geometricType_(word::null)
|
geometricType_(word::null)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
Foam::surfZoneIdentifier::surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const label index,
|
const label index,
|
||||||
@ -47,12 +47,12 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
name_(name),
|
name_(name),
|
||||||
boundaryIndex_(index),
|
index_(index),
|
||||||
geometricType_(geometricType)
|
geometricType_(geometricType)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
Foam::surfZoneIdentifier::surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
@ -60,33 +60,33 @@ Foam::surfRegionIdentifier::surfRegionIdentifier
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
name_(name),
|
name_(name),
|
||||||
boundaryIndex_(index)
|
index_(index)
|
||||||
{
|
{
|
||||||
dict.readIfPresent("geometricType", geometricType_);
|
dict.readIfPresent("geometricType", geometricType_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
Foam::surfZoneIdentifier::surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const surfRegionIdentifier& p,
|
const surfZoneIdentifier& p,
|
||||||
const label index
|
const label index
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
name_(p.name()),
|
name_(p.name()),
|
||||||
boundaryIndex_(index),
|
index_(index),
|
||||||
geometricType_(p.geometricType())
|
geometricType_(p.geometricType())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::surfRegionIdentifier::~surfRegionIdentifier()
|
Foam::surfZoneIdentifier::~surfZoneIdentifier()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
void Foam::surfRegionIdentifier::write(Ostream& os) const
|
void Foam::surfZoneIdentifier::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
if (geometricType_.size())
|
if (geometricType_.size())
|
||||||
{
|
{
|
||||||
@ -98,18 +98,18 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// bool Foam::surfRegionIdentifier::operator!=
|
// bool Foam::surfZoneIdentifier::operator!=
|
||||||
// (
|
// (
|
||||||
// const surfRegionIdentifier& p
|
// const surfZoneIdentifier& p
|
||||||
// ) const
|
// ) const
|
||||||
// {
|
// {
|
||||||
// return !(*this == p);
|
// return !(*this == p);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// bool Foam::surfRegionIdentifier::operator==
|
// bool Foam::surfZoneIdentifier::operator==
|
||||||
// (
|
// (
|
||||||
// const surfRegionIdentifier& p
|
// const surfZoneIdentifier& p
|
||||||
// ) const
|
// ) const
|
||||||
// {
|
// {
|
||||||
// return geometricType() == p.geometricType() && name() == p.name();
|
// return geometricType() == p.geometricType() && name() == p.name();
|
||||||
@ -118,7 +118,7 @@ void Foam::surfRegionIdentifier::write(Ostream& os) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
|
// Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& p)
|
||||||
// {
|
// {
|
||||||
// is >> p.name_ >> p.geometricType_;
|
// 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);
|
p.write(os);
|
||||||
os.check
|
os.check
|
||||||
(
|
(
|
||||||
"Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
|
"Ostream& operator<<(Ostream&, const surfZoneIdentifier&)"
|
||||||
);
|
);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -23,23 +23,21 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::surfRegionIdentifier
|
Foam::surfZoneIdentifier
|
||||||
|
|
||||||
Description
|
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
|
Similar in concept to a faceZone on the surface, but can also have a
|
||||||
"geometricType" rather. Despite the similarity to a 'patch' for
|
"geometricType" as well.
|
||||||
volume meshes (with a "physicalType"), the region does not have any
|
|
||||||
patch information per se.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
surfRegionIdentifier.C
|
surfZoneIdentifier.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef surfRegionIdentifier_H
|
#ifndef surfZoneIdentifier_H
|
||||||
#define surfRegionIdentifier_H
|
#define surfZoneIdentifier_H
|
||||||
|
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
@ -54,24 +52,24 @@ class dictionary;
|
|||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class surfRegionIdentifier;
|
class surfZoneIdentifier;
|
||||||
Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class surfRegionIdentifier Declaration
|
Class surfZoneIdentifier Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class surfRegionIdentifier
|
class surfZoneIdentifier
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Name of region
|
//- Name of zone
|
||||||
word name_;
|
word name_;
|
||||||
|
|
||||||
//- Index of region in surface mesh
|
//- Index of zone in surface mesh
|
||||||
label boundaryIndex_;
|
label index_;
|
||||||
|
|
||||||
//- Type name of region
|
//- Type name of zone
|
||||||
mutable word geometricType_;
|
mutable word geometricType_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -79,10 +77,10 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
surfRegionIdentifier();
|
surfZoneIdentifier();
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
surfRegionIdentifier
|
surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const label index,
|
const label index,
|
||||||
@ -91,24 +89,24 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
surfRegionIdentifier
|
surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary&,
|
const dictionary&,
|
||||||
const label index
|
const label index
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from another region identifier, resetting the index
|
//- Construct from another zone identifier, resetting the index
|
||||||
surfRegionIdentifier
|
surfZoneIdentifier
|
||||||
(
|
(
|
||||||
const surfRegionIdentifier&,
|
const surfZoneIdentifier&,
|
||||||
const label index
|
const label index
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
virtual ~surfRegionIdentifier();
|
virtual ~surfZoneIdentifier();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -125,42 +123,42 @@ public:
|
|||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the geometric type of the region
|
//- Return the geometric type of the zone
|
||||||
const word& geometricType() const
|
const word& geometricType() const
|
||||||
{
|
{
|
||||||
return geometricType_;
|
return geometricType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the geometric type of the region for modification
|
//- Return the geometric type of the zone for modification
|
||||||
word& geometricType()
|
word& geometricType()
|
||||||
{
|
{
|
||||||
return 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
|
label index() const
|
||||||
{
|
{
|
||||||
return boundaryIndex_;
|
return index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write surfRegionIdentifier as a dictionary
|
//- Write surfZoneIdentifier as a dictionary
|
||||||
void write(Ostream&) const;
|
void write(Ostream&) const;
|
||||||
|
|
||||||
//- Write surfRegionIdentifier as a dictionary
|
//- Write surfZoneIdentifier as a dictionary
|
||||||
// void writeDict(Ostream&) const;
|
// void writeDict(Ostream&) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
// bool operator!=(const surfRegionIdentifier&) const;
|
// bool operator!=(const surfZoneIdentifier&) const;
|
||||||
//
|
//
|
||||||
// //- compare.
|
// //- compare.
|
||||||
// bool operator==(const surfRegionIdentifier&) const;
|
// bool operator==(const surfZoneIdentifier&) const;
|
||||||
|
|
||||||
// Ostream Operator
|
// Ostream Operator
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
friend Ostream& operator<<(Ostream&, const surfZoneIdentifier&);
|
||||||
// friend Istream& operator>>(Istream&, surfRegionIdentifier&);
|
// friend Istream& operator>>(Istream&, surfZoneIdentifier&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -23,16 +23,16 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Typedef
|
Typedef
|
||||||
Foam::surfRegionIdentifierList
|
Foam::surfZoneIdentifierList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef surfRegionIdentifierList_H
|
#ifndef surfZoneIdentifierList_H
|
||||||
#define surfRegionIdentifierList_H
|
#define surfZoneIdentifierList_H
|
||||||
|
|
||||||
#include "surfRegionIdentifier.H"
|
#include "surfZoneIdentifier.H"
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -42,7 +42,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
typedef List<surfRegionIdentifier> surfRegionIdentifierList;
|
typedef List<surfZoneIdentifier> surfZoneIdentifierList;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// # of kids is the # of regions
|
// # of kids is the # of zones
|
||||||
args = cueToOrDie(is, "kids");
|
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;
|
label vertexOffset = 0;
|
||||||
|
|
||||||
DynamicList<point> dynPoints;
|
DynamicList<point> dynPoints;
|
||||||
DynamicList<Face> dynFaces;
|
DynamicList<Face> dynFaces;
|
||||||
List<word> names(nRegions);
|
List<word> names(nZones);
|
||||||
List<label> sizes(nRegions, 0);
|
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
|
// number of vertices for this zone
|
||||||
label nRegionPoints = 0;
|
label nZonePoints = 0;
|
||||||
vector location(pTraits<vector>::zero);
|
vector location(pTraits<vector>::zero);
|
||||||
// tensor rotation(I);
|
// tensor rotation(I);
|
||||||
|
|
||||||
// Read all info for current region
|
// Read all info for current zone
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
// Read line and get first word. If end of file break since
|
// 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))
|
if (!readCmd(is, cmd, args))
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||||
)
|
)
|
||||||
<< "Did not read up to \"kids 0\" while reading region "
|
<< "Did not read up to \"kids 0\" while reading zone "
|
||||||
<< regionI << " from file " << filename
|
<< zoneI << " from file " << filename
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
string str = parse<string>(args);
|
string str = parse<string>(args);
|
||||||
string::stripInvalid<word>(str);
|
string::stripInvalid<word>(str);
|
||||||
|
|
||||||
names[regionI] = str;
|
names[zoneI] = str;
|
||||||
}
|
}
|
||||||
else if (cmd == "rot")
|
else if (cmd == "rot")
|
||||||
{
|
{
|
||||||
@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
)
|
)
|
||||||
<< "rot (rotation tensor) command not implemented"
|
<< "rot (rotation tensor) command not implemented"
|
||||||
<< "Line:" << cmd << ' ' << args << endl
|
<< "Line:" << cmd << ' ' << args << endl
|
||||||
<< "while reading region " << regionI << endl;
|
<< "while reading zone " << zoneI << endl;
|
||||||
}
|
}
|
||||||
else if (cmd == "loc")
|
else if (cmd == "loc")
|
||||||
{
|
{
|
||||||
@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
else if (cmd == "numvert")
|
else if (cmd == "numvert")
|
||||||
{
|
{
|
||||||
// numvert %d
|
// 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);
|
is.getLine(line);
|
||||||
IStringStream lineStream(line);
|
IStringStream lineStream(line);
|
||||||
@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
{
|
{
|
||||||
static string errorMsg =
|
static string errorMsg =
|
||||||
string(" while reading face ")
|
string(" while reading face ")
|
||||||
+ Foam::name(faceI) + " on region "
|
+ Foam::name(faceI) + " on zone "
|
||||||
+ Foam::name(regionI)
|
+ Foam::name(zoneI)
|
||||||
+ " from file " + filename;
|
+ " from file " + filename;
|
||||||
|
|
||||||
cueToOrDie(is, "SURF", errorMsg);
|
cueToOrDie(is, "SURF", errorMsg);
|
||||||
@ -230,23 +230,23 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = (fp1 + 1) % f.size();
|
||||||
|
|
||||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||||
sizes[regionI]++;
|
sizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynFaces.append(Face(f));
|
dynFaces.append(Face(f));
|
||||||
sizes[regionI]++;
|
sizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done the current region.
|
// Done the current zone.
|
||||||
// Increment the offset vertices are stored at
|
// Increment the offset vertices are stored at
|
||||||
vertexOffset += nRegionPoints;
|
vertexOffset += nZonePoints;
|
||||||
}
|
}
|
||||||
else if (cmd == "kids")
|
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);
|
label nKids = parse<int>(args);
|
||||||
|
|
||||||
if (nKids != 0)
|
if (nKids != 0)
|
||||||
@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
)
|
)
|
||||||
<< "Can only read objects without kids."
|
<< "Can only read objects without kids."
|
||||||
<< " Encountered " << nKids << " kids when"
|
<< " Encountered " << nKids << " kids when"
|
||||||
<< " reading region " << regionI
|
<< " reading zone " << zoneI
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done reading current region
|
// Done reading current zone
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
this->storedPoints().transfer(dynPoints);
|
this->storedPoints().transfer(dynPoints);
|
||||||
this->storedFaces().transfer(dynFaces);
|
this->storedFaces().transfer(dynFaces);
|
||||||
|
|
||||||
// add regions, culling empty ones
|
// add zones, culling empty ones
|
||||||
this->addRegions(sizes, names, true);
|
this->addZones(sizes, names, true);
|
||||||
this->stitchFaces(SMALL);
|
this->stitchFaces(SMALL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -287,16 +287,16 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<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
|
os << "OBJECT poly" << nl
|
||||||
<< "name \"" << reg.name() << '"' << endl;
|
<< "name \"" << zone.name() << '"' << endl;
|
||||||
|
|
||||||
// Temporary PrimitivePatch to calculate compact points & faces
|
// Temporary PrimitivePatch to calculate compact points & faces
|
||||||
// use 'UList' to avoid allocations!
|
// use 'UList' to avoid allocations!
|
||||||
@ -322,7 +322,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
|||||||
const Face& f = patch.localFaces()[localFaceI];
|
const Face& f = patch.localFaces()[localFaceI];
|
||||||
|
|
||||||
os << "SURF 0x20" << nl // polygon
|
os << "SURF 0x20" << nl // polygon
|
||||||
<< "mat " << regionI << nl
|
<< "mat " << zoneI << nl
|
||||||
<< "refs " << f.size() << nl;
|
<< "refs " << f.size() << nl;
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
@ -344,22 +344,22 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||||
|
|
||||||
writeHeader(os, regionLst);
|
writeHeader(os, zoneLst);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
const surfRegion& reg = regionLst[regionI];
|
const surfZone& zone = zoneLst[zoneI];
|
||||||
|
|
||||||
os << "OBJECT poly" << nl
|
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());
|
labelHashSet include(surf.size());
|
||||||
|
|
||||||
forAll(reg, localFaceI)
|
forAll(zone, localFaceI)
|
||||||
{
|
{
|
||||||
const label faceI = faceMap[faceIndex++];
|
const label faceI = faceMap[faceIndex++];
|
||||||
include.insert(faceI);
|
include.insert(faceI);
|
||||||
@ -384,7 +384,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
|||||||
const Face& f = subm.localFaces()[localFaceI];
|
const Face& f = subm.localFaces()[localFaceI];
|
||||||
|
|
||||||
os << "SURF 0x20" << nl // polygon
|
os << "SURF 0x20" << nl // polygon
|
||||||
<< "mat " << regionI << nl
|
<< "mat " << zoneI << nl
|
||||||
<< "refs " << f.size() << nl;
|
<< "refs " << f.size() << nl;
|
||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
|
|||||||
@ -31,8 +31,8 @@ Description
|
|||||||
http://www.inivis.com/ac3d/man/ac3dfileformat.html
|
http://www.inivis.com/ac3d/man/ac3dfileformat.html
|
||||||
|
|
||||||
Note
|
Note
|
||||||
The faces are already organized as regions.
|
The faces are already organized as zones.
|
||||||
The output is always sorted by regions.
|
The output is always sorted by zones.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
AC3DsurfaceFormat.C
|
AC3DsurfaceFormat.C
|
||||||
@ -120,7 +120,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is always sorted by regions.
|
// The output is always sorted by zones.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -128,7 +128,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is always sorted by regions.
|
// The output is always sorted by zones.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
|
|||||||
@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
|
|||||||
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||||
(
|
(
|
||||||
Ostream& os,
|
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.
|
// 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
|
// Define 8 standard colours as r,g,b components
|
||||||
static scalar colourMap[] =
|
static scalar colourMap[] =
|
||||||
@ -139,12 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
|||||||
// Write header. Define materials.
|
// Write header. Define materials.
|
||||||
os << "AC3Db" << nl;
|
os << "AC3Db" << nl;
|
||||||
|
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
label colourI = regionI % 8;
|
label colourI = zoneI % 8;
|
||||||
label colourCompI = 3 * colourI;
|
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] << ' ' << colourMap[colourCompI+1]
|
||||||
<< ' ' << colourMap[colourCompI+2]
|
<< ' ' << colourMap[colourCompI+2]
|
||||||
<< " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
|
<< " 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
|
os << "OBJECT world" << nl
|
||||||
<< "kids " << regionLst.size() << endl;
|
<< "kids " << zoneLst.size() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -77,7 +77,7 @@ protected:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write header with materials
|
//- Write header with materials
|
||||||
static void writeHeader(Ostream&, const UList<surfRegion>&);
|
static void writeHeader(Ostream&, const UList<surfZone>&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -72,31 +72,31 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
|||||||
List<Keyed<triFace> > facesRead(is);
|
List<Keyed<triFace> > facesRead(is);
|
||||||
|
|
||||||
List<Face> faceLst(facesRead.size());
|
List<Face> faceLst(facesRead.size());
|
||||||
List<label> regionIds(facesRead.size());
|
List<label> zoneIds(facesRead.size());
|
||||||
|
|
||||||
// disentangle faces/keys - already triangulated
|
// disentangle faces/keys - already triangulated
|
||||||
forAll(facesRead, faceI)
|
forAll(facesRead, faceI)
|
||||||
{
|
{
|
||||||
// unfortunately cannot transfer to save memory
|
// unfortunately cannot transfer to save memory
|
||||||
faceLst[faceI] = facesRead[faceI];
|
faceLst[faceI] = facesRead[faceI];
|
||||||
regionIds[faceI] = facesRead[faceI].key();
|
zoneIds[faceI] = facesRead[faceI].key();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->storedFaces().transfer(faceLst);
|
this->storedFaces().transfer(faceLst);
|
||||||
this->storedRegionIds().transfer(regionIds);
|
this->storedZoneIds().transfer(zoneIds);
|
||||||
|
|
||||||
// change ftrPatch into surfRegionIdentifier
|
// change ftrPatch into surfZoneIdentifier
|
||||||
List<surfRegionIdentifier> newRegions(ftrPatches.size());
|
List<surfZoneIdentifier> newZones(ftrPatches.size());
|
||||||
forAll(newRegions, regionI)
|
forAll(newZones, zoneI)
|
||||||
{
|
{
|
||||||
newRegions[regionI] = surfRegionIdentifier
|
newZones[zoneI] = surfZoneIdentifier
|
||||||
(
|
(
|
||||||
ftrPatches[regionI].name(),
|
ftrPatches[zoneI].name(),
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->storedRegionToc().transfer(newRegions);
|
this->storedZoneToc().transfer(newZones);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,11 +82,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
|||||||
// write directly into the lists:
|
// write directly into the lists:
|
||||||
pointField& pointLst = this->storedPoints();
|
pointField& pointLst = this->storedPoints();
|
||||||
List<Face>& faceLst = this->storedFaces();
|
List<Face>& faceLst = this->storedFaces();
|
||||||
List<label>& regionIds = this->storedRegionIds();
|
List<label>& zoneIds = this->storedZoneIds();
|
||||||
|
|
||||||
pointLst.setSize(nPoints);
|
pointLst.setSize(nPoints);
|
||||||
faceLst.setSize(nElems);
|
faceLst.setSize(nElems);
|
||||||
regionIds.setSize(nElems);
|
zoneIds.setSize(nElems);
|
||||||
|
|
||||||
// Read points
|
// Read points
|
||||||
forAll(pointLst, pointI)
|
forAll(pointLst, pointI)
|
||||||
@ -118,11 +118,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
|||||||
|
|
||||||
|
|
||||||
// Read triangles. Convert references to edges into pointlabels
|
// Read triangles. Convert references to edges into pointlabels
|
||||||
label maxRegion = 0;
|
label maxZone = 0;
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
label e0Label, e1Label, e2Label;
|
label e0Label, e1Label, e2Label;
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
|
|
||||||
line = this->getLineNoComment(is);
|
line = this->getLineNoComment(is);
|
||||||
{
|
{
|
||||||
@ -130,17 +130,17 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
|||||||
lineStream
|
lineStream
|
||||||
>> e0Label >> e1Label >> e2Label;
|
>> 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)
|
if (lineStream)
|
||||||
{
|
{
|
||||||
label num;
|
label num;
|
||||||
lineStream >> num;
|
lineStream >> num;
|
||||||
if (!lineStream.bad())
|
if (!lineStream.bad())
|
||||||
{
|
{
|
||||||
regionI = num;
|
zoneI = num;
|
||||||
if (maxRegion < regionI)
|
if (maxZone < zoneI)
|
||||||
{
|
{
|
||||||
maxRegion = regionI;
|
maxZone = zoneI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,21 +202,21 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
faceLst[faceI] = triFace(e0Far, common01, e1Far);
|
faceLst[faceI] = triFace(e0Far, common01, e1Far);
|
||||||
regionIds[faceI] = regionI;
|
zoneIds[faceI] = zoneI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<surfRegionIdentifier> newRegions(maxRegion+1);
|
List<surfZoneIdentifier> newZones(maxZone+1);
|
||||||
forAll(newRegions, regionI)
|
forAll(newZones, zoneI)
|
||||||
{
|
{
|
||||||
newRegions[regionI] = surfRegionIdentifier
|
newZones[zoneI] = surfZoneIdentifier
|
||||||
(
|
(
|
||||||
"region" + ::Foam::name(regionI),
|
"zone" + ::Foam::name(zoneI),
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->storedRegionToc().transfer(newRegions);
|
this->storedZoneToc().transfer(newZones);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
|
|
||||||
// check if output triangulation would be required
|
// 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
|
os << "# GTS file" << nl
|
||||||
<< "# Regions:" << nl;
|
<< "# Zones:" << nl;
|
||||||
|
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
os << "# " << regionI << " "
|
os << "# " << zoneI << " "
|
||||||
<< regionLst[regionI].name() << nl;
|
<< zoneLst[zoneI].name() << nl;
|
||||||
}
|
}
|
||||||
os << "#" << endl;
|
os << "#" << endl;
|
||||||
|
|
||||||
@ -300,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
|||||||
const labelListList& faceEs = surf.faceEdges();
|
const labelListList& faceEs = surf.faceEdges();
|
||||||
|
|
||||||
label faceIndex = 0;
|
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++];
|
const labelList& fEdges = faceEs[faceIndex++];
|
||||||
|
|
||||||
os << fEdges[0] + 1 << ' '
|
os << fEdges[0] + 1 << ' '
|
||||||
<< fEdges[1] + 1 << ' '
|
<< fEdges[1] + 1 << ' '
|
||||||
<< fEdges[2] + 1 << ' '
|
<< fEdges[2] + 1 << ' '
|
||||||
<< regionI << endl;
|
<< zoneI << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<label>& regionIds = surf.regionIds();
|
const List<label>& zoneIds = surf.zoneIds();
|
||||||
const List<surfRegionIdentifier>& regionToc = surf.regionToc();
|
const List<surfZoneIdentifier>& zoneToc = surf.zoneToc();
|
||||||
|
|
||||||
// check if output triangulation would be required
|
// check if output triangulation would be required
|
||||||
// It is too annoying to triangulate on-the-fly
|
// 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
|
os << "# GTS file" << nl
|
||||||
<< "# Regions:" << nl;
|
<< "# Zones:" << nl;
|
||||||
|
|
||||||
forAll(regionToc, regionI)
|
forAll(zoneToc, zoneI)
|
||||||
{
|
{
|
||||||
os << "# " << regionI << " "
|
os << "# " << zoneI << " "
|
||||||
<< regionToc[regionI].name() << nl;
|
<< zoneToc[zoneI].name() << nl;
|
||||||
}
|
}
|
||||||
os << "#" << endl;
|
os << "#" << endl;
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
|||||||
os << fEdges[0] + 1 << ' '
|
os << fEdges[0] + 1 << ' '
|
||||||
<< fEdges[1] + 1 << ' '
|
<< fEdges[1] + 1 << ' '
|
||||||
<< fEdges[2] + 1 << ' '
|
<< fEdges[2] + 1 << ' '
|
||||||
<< regionIds[faceI] << endl;
|
<< zoneIds[faceI] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of reading/writing GTS format.
|
Provide a means of reading/writing GTS format.
|
||||||
The output is never sorted by region.
|
The output is never sorted by zone.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
GTSsurfaceFormat.C
|
GTSsurfaceFormat.C
|
||||||
|
|||||||
@ -71,13 +71,13 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
DynamicList<label> pointId;
|
DynamicList<label> pointId;
|
||||||
DynamicList<point> dynPoints;
|
DynamicList<point> dynPoints;
|
||||||
DynamicList<Face> dynFaces;
|
DynamicList<Face> dynFaces;
|
||||||
DynamicList<label> dynRegions;
|
DynamicList<label> dynZones;
|
||||||
DynamicList<label> dynSizes;
|
DynamicList<label> dynSizes;
|
||||||
Map<label> lookup;
|
Map<label> lookup;
|
||||||
|
|
||||||
// assume the types are not intermixed
|
// assume the types are not intermixed
|
||||||
bool sorted = true;
|
bool sorted = true;
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
|
|
||||||
// Name for face group
|
// Name for face group
|
||||||
Map<word> nameLookup;
|
Map<word> nameLookup;
|
||||||
@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
// Ansa tags. Denoted by $ANSA_NAME.
|
// Ansa tags. Denoted by $ANSA_NAME.
|
||||||
// These will appear just before the first use of a type.
|
// These will appear just before the first use of a type.
|
||||||
// We read them and store the PSHELL types which are used to name
|
// We read them and store the PSHELL types which are used to name
|
||||||
// the regions.
|
// the zones.
|
||||||
label ansaId = -1;
|
label ansaId = -1;
|
||||||
word ansaType, ansaName;
|
word ansaType, ansaName;
|
||||||
|
|
||||||
@ -211,28 +211,28 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
fTri[1] = readLabel(IStringStream(line.substr(32,8))());
|
fTri[1] = readLabel(IStringStream(line.substr(32,8))());
|
||||||
fTri[2] = readLabel(IStringStream(line.substr(40,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);
|
Map<label>::const_iterator fnd = lookup.find(groupId);
|
||||||
if (fnd != lookup.end())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// pshell types are intermixed
|
// pshell types are intermixed
|
||||||
sorted = false;
|
sorted = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(groupId, regionI);
|
lookup.insert(groupId, zoneI);
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
// Info<< "region" << regionI << " => group " << groupId <<endl;
|
// Info<< "zone" << zoneI << " => group " << groupId <<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynFaces.append(fTri);
|
dynFaces.append(fTri);
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
else if (cmd == "CQUAD4")
|
else if (cmd == "CQUAD4")
|
||||||
{
|
{
|
||||||
@ -245,23 +245,23 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
|
fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
|
||||||
fQuad[3] = readLabel(IStringStream(line.substr(48,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);
|
Map<label>::const_iterator fnd = lookup.find(groupId);
|
||||||
if (fnd != lookup.end())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// pshell types are intermixed
|
// pshell types are intermixed
|
||||||
sorted = false;
|
sorted = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(groupId, regionI);
|
lookup.insert(groupId, zoneI);
|
||||||
dynSizes.append(0);
|
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[1], f[2]));
|
||||||
dynFaces.append(triFace(f[0], f[2], f[3]));
|
dynFaces.append(triFace(f[0], f[2], f[3]));
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI] += 2;
|
dynSizes[zoneI] += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynFaces.append(Face(f));
|
dynFaces.append(Face(f));
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd == "GRID")
|
else if (cmd == "GRID")
|
||||||
@ -322,7 +322,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
}
|
}
|
||||||
else if (cmd == "PSHELL")
|
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))());
|
label groupId = readLabel(IStringStream(line.substr(8,8))());
|
||||||
|
|
||||||
if (groupId == ansaId && ansaType == "PSHELL")
|
if (groupId == ansaId && ansaType == "PSHELL")
|
||||||
@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
|||||||
mapPointId.clear();
|
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());
|
List<word> names(dynSizes.size());
|
||||||
forAllConstIter(Map<label>, lookup, iter)
|
forAllConstIter(Map<label>, lookup, iter)
|
||||||
{
|
{
|
||||||
const label regionI = iter();
|
const label zoneI = iter();
|
||||||
const label groupI = iter.key();
|
const label groupI = iter.key();
|
||||||
|
|
||||||
Map<word>::const_iterator fnd = nameLookup.find(groupI);
|
Map<word>::const_iterator fnd = nameLookup.find(groupI);
|
||||||
if (fnd != nameLookup.end())
|
if (fnd != nameLookup.end())
|
||||||
{
|
{
|
||||||
names[regionI] = fnd();
|
names[zoneI] = fnd();
|
||||||
}
|
}
|
||||||
else
|
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
|
// add zones, culling empty ones
|
||||||
this->addRegions(dynSizes, names, true);
|
this->addZones(dynSizes, names, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
Nastran surface reader.
|
Nastran surface reader.
|
||||||
|
|
||||||
- Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
|
- 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.
|
- Handles Nastran short and long formats, but not free format.
|
||||||
- Properly handles the Nastran compact floating point notation: \n
|
- Properly handles the Nastran compact floating point notation: \n
|
||||||
@verbatim
|
@verbatim
|
||||||
|
|||||||
@ -70,15 +70,15 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
|||||||
|
|
||||||
DynamicList<point> dynPoints;
|
DynamicList<point> dynPoints;
|
||||||
DynamicList<Face> dynFaces;
|
DynamicList<Face> dynFaces;
|
||||||
DynamicList<label> dynRegions;
|
DynamicList<label> dynZones;
|
||||||
DynamicList<word> dynNames;
|
DynamicList<word> dynNames;
|
||||||
DynamicList<label> dynSizes;
|
DynamicList<label> dynSizes;
|
||||||
HashTable<label> lookup;
|
HashTable<label> lookup;
|
||||||
|
|
||||||
// place faces without a group in region0
|
// place faces without a group in zone0
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
lookup.insert("region0", regionI);
|
lookup.insert("zone0", zoneI);
|
||||||
dynNames.append("region0");
|
dynNames.append("zone0");
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
|
|
||||||
while (is.good())
|
while (is.good())
|
||||||
@ -111,17 +111,17 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
|||||||
HashTable<label>::const_iterator fnd = lookup.find(name);
|
HashTable<label>::const_iterator fnd = lookup.find(name);
|
||||||
if (fnd != lookup.end())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// group appeared out of order
|
// group appeared out of order
|
||||||
sorted = false;
|
sorted = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(name, regionI);
|
lookup.insert(name, zoneI);
|
||||||
dynNames.append(name);
|
dynNames.append(name);
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
}
|
}
|
||||||
@ -185,15 +185,15 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
|||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = (fp1 + 1) % f.size();
|
||||||
|
|
||||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynFaces.append(Face(f));
|
dynFaces.append(Face(f));
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,10 +202,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
|||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
this->storedPoints().transfer(dynPoints);
|
this->storedPoints().transfer(dynPoints);
|
||||||
|
|
||||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
|
||||||
|
|
||||||
// add regions, culling empty ones
|
// add zones, culling empty ones
|
||||||
this->addRegions(dynSizes, dynNames, true);
|
this->addZones(dynSizes, dynNames, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,18 +218,18 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<Face>& faceLst = surf.faces();
|
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;
|
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++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
|
|
||||||
@ -255,19 +255,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
|||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
labelList faceMap;
|
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;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
// Print all faces belonging to this region
|
// Print all faces belonging to this zone
|
||||||
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[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by regions
|
// The output is sorted by zones
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -124,7 +124,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by regions
|
// The output is sorted by zones
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
|
|||||||
@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
|||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>& regionLst
|
const UList<surfZone>& zoneLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||||
@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
|||||||
<< nl
|
<< nl
|
||||||
<< "# points : " << pointLst.size() << nl
|
<< "# points : " << pointLst.size() << nl
|
||||||
<< "# faces : " << nFaces << nl
|
<< "# faces : " << nFaces << nl
|
||||||
<< "# region : " << regionLst.size() << nl;
|
<< "# zones : " << zoneLst.size() << nl;
|
||||||
|
|
||||||
// Print region names as comment
|
// Print zone names as comment
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
os << "# " << zoneI << " " << zoneLst[zoneI].name()
|
||||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
<< " (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << nl
|
os << nl
|
||||||
|
|||||||
@ -63,7 +63,7 @@ protected:
|
|||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>&
|
const UList<surfZone>&
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -101,7 +101,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
|||||||
pointLst[pointI] = point(x, y, z);
|
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
|
// use a DynamicList for possible on-the-fly triangulation
|
||||||
DynamicList<Face> dynFaces(nElems);
|
DynamicList<Face> dynFaces(nElems);
|
||||||
|
|
||||||
@ -145,8 +145,8 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
|||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
reset(pointLst.xfer(), dynFaces.xfer());
|
reset(pointLst.xfer(), dynFaces.xfer());
|
||||||
|
|
||||||
// no region information
|
// no zone information
|
||||||
this->oneRegion();
|
this->oneZone();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,16 +161,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
|||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
labelList faceMap;
|
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;
|
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++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
@ -180,10 +180,10 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
|||||||
os << ' ' << f[fp];
|
os << ' ' << f[fp];
|
||||||
}
|
}
|
||||||
|
|
||||||
// add optional region information
|
// add optional zone information
|
||||||
os << ' ' << regionI << endl;
|
os << ' ' << zoneI << endl;
|
||||||
}
|
}
|
||||||
os << "# </region>" << endl;
|
os << "# </zone>" << endl;
|
||||||
}
|
}
|
||||||
os << "# </faces>" << endl;
|
os << "# </faces>" << endl;
|
||||||
}
|
}
|
||||||
@ -197,16 +197,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<Face>& faceLst = surf.faces();
|
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;
|
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++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
|
|
||||||
@ -216,10 +216,10 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
|||||||
os << ' ' << f[fp];
|
os << ' ' << f[fp];
|
||||||
}
|
}
|
||||||
|
|
||||||
// add optional region information
|
// add optional zone information
|
||||||
os << ' ' << regionI << endl;
|
os << ' ' << zoneI << endl;
|
||||||
}
|
}
|
||||||
os << "# </region>" << endl;
|
os << "# </zone>" << endl;
|
||||||
}
|
}
|
||||||
os << "# </faces>" << endl;
|
os << "# </faces>" << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ See Also
|
|||||||
|
|
||||||
Note
|
Note
|
||||||
When reading, the optional @a colorspec is ignored.
|
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
|
SourceFiles
|
||||||
OFFsurfaceFormat.C
|
OFFsurfaceFormat.C
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by region.
|
// The output is sorted by zone.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by region.
|
// The output is sorted by zone.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
|||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>& regionLst
|
const UList<surfZone>& zoneLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Write header
|
// Write header
|
||||||
@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
|||||||
<< nl
|
<< nl
|
||||||
<< "# points : " << pointLst.size() << nl
|
<< "# points : " << pointLst.size() << nl
|
||||||
<< "# faces : " << nFaces << nl
|
<< "# faces : " << nFaces << nl
|
||||||
<< "# regions: " << regionLst.size() << nl;
|
<< "# zones : " << zoneLst.size() << nl;
|
||||||
|
|
||||||
// Print region names as comment
|
// Print zone names as comment
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
os << "# " << zoneI << " " << zoneLst[zoneI].name()
|
||||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
<< " (nFaces: " << zoneLst[zoneI].size() << ")" << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << nl
|
os << nl
|
||||||
|
|||||||
@ -63,7 +63,7 @@ protected:
|
|||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>&
|
const UList<surfZone>&
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -46,14 +46,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
writeHeader(os, surf.points(), faceLst.size());
|
writeHeader(os, surf.points(), faceLst.size());
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], localFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
const Face& f = faceLst[faceIndex++];
|
const Face& f = faceLst[faceIndex++];
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
os << ' ' << f[fp];
|
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());
|
writeHeader(os, surf.points(), faceLst.size());
|
||||||
|
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], localFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
os << ' ' << f[fp];
|
os << ' ' << f[fp];
|
||||||
}
|
}
|
||||||
os << ' ' << regionI << endl;
|
os << ' ' << zoneI << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by region.
|
// The output is sorted by zone.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by region.
|
// The output is sorted by zone.
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void Foam::fileFormats::SMESHsurfaceFormatCore::writeHeader
|
|||||||
<< nl
|
<< nl
|
||||||
<< "# <faces count=\"" << nFaces << "\">" << endl;
|
<< "# <faces count=\"" << nFaces << "\">" << endl;
|
||||||
|
|
||||||
os << nFaces << " 1" << endl; // one attribute: region number
|
os << nFaces << " 1" << endl; // one attribute: zone number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -122,14 +122,14 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
readHeader(is, "PROSTAR_CELL");
|
readHeader(is, "PROSTAR_CELL");
|
||||||
|
|
||||||
DynamicList<Face> dynFaces;
|
DynamicList<Face> dynFaces;
|
||||||
DynamicList<label> dynRegions;
|
DynamicList<label> dynZones;
|
||||||
DynamicList<word> dynNames;
|
DynamicList<word> dynNames;
|
||||||
DynamicList<label> dynSizes;
|
DynamicList<label> dynSizes;
|
||||||
Map<label> lookup;
|
Map<label> lookup;
|
||||||
|
|
||||||
// assume the cellTableIds are not intermixed
|
// assume the cellTableIds are not intermixed
|
||||||
bool sorted = true;
|
bool sorted = true;
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
|
|
||||||
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
label lineLabel, shapeId, nLabels, cellTableId, typeId;
|
||||||
DynamicList<label> vertexLabels(64);
|
DynamicList<label> vertexLabels(64);
|
||||||
@ -157,22 +157,22 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
|
|
||||||
if (typeId == starcdShellType_)
|
if (typeId == starcdShellType_)
|
||||||
{
|
{
|
||||||
// Convert groupID into regionID
|
// Convert groupID into zoneID
|
||||||
Map<label>::const_iterator fnd = lookup.find(cellTableId);
|
Map<label>::const_iterator fnd = lookup.find(cellTableId);
|
||||||
if (fnd != lookup.end())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// cellTableIds are intermixed
|
// cellTableIds are intermixed
|
||||||
sorted = false;
|
sorted = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(cellTableId, regionI);
|
lookup.insert(cellTableId, zoneI);
|
||||||
dynNames.append(word("cellTable_") + ::Foam::name(regionI));
|
dynNames.append(word("cellTable_") + ::Foam::name(zoneI));
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,24 +195,24 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
static_cast<UList<label>&>(triFaces[faceI])
|
static_cast<UList<label>&>(triFaces[faceI])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynFaces.append(Face(vertices));
|
dynFaces.append(Face(vertices));
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mapPointId.clear();
|
mapPointId.clear();
|
||||||
|
|
||||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
sortFacesAndStore(dynFaces.xfer(), dynZones.xfer(), sorted);
|
||||||
|
|
||||||
// add regions, culling empty ones
|
// add zones, culling empty ones
|
||||||
this->addRegions(dynSizes, dynNames, true);
|
this->addZones(dynSizes, dynNames, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,17 +231,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
|||||||
writeHeader(os, "CELL");
|
writeHeader(os, "CELL");
|
||||||
|
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
label faceIndex = 0;
|
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++];
|
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")(),
|
OFstream(baseName + ".inp")(),
|
||||||
surf.points(),
|
surf.points(),
|
||||||
surf.size(),
|
surf.size(),
|
||||||
regionLst
|
zoneLst
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,17 +272,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
|||||||
|
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||||
|
|
||||||
label faceIndex = 0;
|
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++]];
|
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")(),
|
OFstream(baseName + ".inp")(),
|
||||||
surf.points(),
|
surf.points(),
|
||||||
surf.size(),
|
surf.size(),
|
||||||
regionLst
|
zoneLst
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// The output is sorted by regions
|
// The output is sorted by zones
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
|||||||
@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
|||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>& regionLst
|
const UList<surfZone>& zoneLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
word caseName = os.name().lessExt().name();
|
word caseName = os.name().lessExt().name();
|
||||||
@ -176,11 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
|||||||
<< "! case " << caseName << nl
|
<< "! case " << caseName << nl
|
||||||
<< "! ------------------------------" << nl;
|
<< "! ------------------------------" << nl;
|
||||||
|
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
os << "ctable " << regionI + 1 << " shell" << nl
|
os << "ctable " << zoneI + 1 << " shell" << nl
|
||||||
<< "ctname " << regionI + 1 << " "
|
<< "ctname " << zoneI + 1 << " "
|
||||||
<< regionLst[regionI].name() << nl;
|
<< zoneLst[zoneI].name() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "! ------------------------------" << nl
|
os << "! ------------------------------" << nl
|
||||||
|
|||||||
@ -70,7 +70,7 @@ protected:
|
|||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const UList<surfRegion>&
|
const UList<surfZone>&
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -70,7 +70,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
|||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const Face& f,
|
const Face& f,
|
||||||
const vector& norm,
|
const vector& norm,
|
||||||
const label regionI
|
const label zoneI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// simple triangulation about f[0].
|
// simple triangulation about f[0].
|
||||||
@ -86,7 +86,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
|||||||
p0,
|
p0,
|
||||||
pointLst[f[fp1]],
|
pointLst[f[fp1]],
|
||||||
pointLst[f[fp2]],
|
pointLst[f[fp2]],
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
stlTri.write(os);
|
stlTri.write(os);
|
||||||
@ -104,22 +104,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
const vectorField& normLst = surf.faceNormals();
|
const vectorField& normLst = surf.faceNormals();
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
// Print all faces belonging to this region
|
// Print all faces belonging to this zone
|
||||||
const surfRegion& reg = regionLst[regionI];
|
const surfZone& zone = zoneLst[zoneI];
|
||||||
|
|
||||||
os << "solid " << reg.name() << endl;
|
os << "solid " << zone.name() << endl;
|
||||||
forAll(reg, localFaceI)
|
forAll(zone, localFaceI)
|
||||||
{
|
{
|
||||||
const label faceI = faceIndex++;
|
const label faceI = faceIndex++;
|
||||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
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 List<Face>& faceLst = surf.faces();
|
||||||
const vectorField& normLst = surf.faceNormals();
|
const vectorField& normLst = surf.faceNormals();
|
||||||
|
|
||||||
if (surf.regionToc().size() == 1)
|
if (surf.zoneToc().size() == 1)
|
||||||
{
|
{
|
||||||
// a single region - we can skip sorting
|
// a single zone - we can skip sorting
|
||||||
os << "solid " << surf.regionToc()[0].name() << endl;
|
os << "solid " << surf.zoneToc()[0].name() << endl;
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||||
}
|
}
|
||||||
os << "endsolid " << surf.regionToc()[0].name() << endl;
|
os << "endsolid " << surf.zoneToc()[0].name() << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
// Print all faces belonging to this region
|
// Print all faces belonging to this zone
|
||||||
const surfRegion& reg = regionLst[regionI];
|
const surfZone& zone = zoneLst[zoneI];
|
||||||
|
|
||||||
os << "solid " << reg.name() << endl;
|
os << "solid " << zone.name() << endl;
|
||||||
forAll(reg, localFaceI)
|
forAll(zone, localFaceI)
|
||||||
{
|
{
|
||||||
const label faceI = faceMap[faceIndex++];
|
const label faceI = faceMap[faceIndex++];
|
||||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
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 pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const vectorField& normLst = surf.faceNormals();
|
const vectorField& normLst = surf.faceNormals();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
unsigned int nTris = 0;
|
unsigned int nTris = 0;
|
||||||
if (surf.isTri())
|
if (surf.isTri())
|
||||||
@ -200,9 +200,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
|||||||
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], regionFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
writeShell
|
writeShell
|
||||||
(
|
(
|
||||||
@ -210,7 +210,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
|||||||
pointLst,
|
pointLst,
|
||||||
faceLst[faceIndex],
|
faceLst[faceIndex],
|
||||||
normLst[faceIndex],
|
normLst[faceIndex],
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
++faceIndex;
|
++faceIndex;
|
||||||
@ -229,7 +229,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<label>& regionIds = surf.regionIds();
|
const List<label>& zoneIds = surf.zoneIds();
|
||||||
const vectorField& normLst = surf.faceNormals();
|
const vectorField& normLst = surf.faceNormals();
|
||||||
|
|
||||||
unsigned int nTris = 0;
|
unsigned int nTris = 0;
|
||||||
@ -258,7 +258,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
|||||||
pointLst,
|
pointLst,
|
||||||
faceLst[faceI],
|
faceLst[faceI],
|
||||||
normLst[faceI],
|
normLst[faceI],
|
||||||
regionIds[faceI]
|
zoneIds[faceI]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,13 +292,13 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
|||||||
// transfer points
|
// transfer points
|
||||||
this->storedPoints().transfer(reader.points());
|
this->storedPoints().transfer(reader.points());
|
||||||
|
|
||||||
// retrieve the original region information
|
// retrieve the original zone information
|
||||||
List<word> names(reader.names().xfer());
|
List<word> names(reader.names().xfer());
|
||||||
List<label> sizes(reader.sizes().xfer());
|
List<label> sizes(reader.sizes().xfer());
|
||||||
List<label> regionIds(reader.regionIds().xfer());
|
List<label> zoneIds(reader.zoneIds().xfer());
|
||||||
|
|
||||||
// generate the (sorted) faces
|
// generate the (sorted) faces
|
||||||
List<Face> faceLst(regionIds.size());
|
List<Face> faceLst(zoneIds.size());
|
||||||
|
|
||||||
if (reader.sorted())
|
if (reader.sorted())
|
||||||
{
|
{
|
||||||
@ -314,7 +314,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
|||||||
// unsorted - determine the sorted order:
|
// unsorted - determine the sorted order:
|
||||||
// avoid SortableList since we discard the main list anyhow
|
// avoid SortableList since we discard the main list anyhow
|
||||||
List<label> faceMap;
|
List<label> faceMap;
|
||||||
sortedOrder(regionIds, faceMap);
|
sortedOrder(zoneIds, faceMap);
|
||||||
|
|
||||||
// generate sorted faces
|
// generate sorted faces
|
||||||
forAll(faceMap, faceI)
|
forAll(faceMap, faceI)
|
||||||
@ -323,18 +323,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
|||||||
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regionIds.clear();
|
zoneIds.clear();
|
||||||
|
|
||||||
// transfer:
|
// transfer:
|
||||||
this->storedFaces().transfer(faceLst);
|
this->storedFaces().transfer(faceLst);
|
||||||
|
|
||||||
if (names.size())
|
if (names.size())
|
||||||
{
|
{
|
||||||
this->addRegions(sizes, names);
|
this->addZones(sizes, names);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->addRegions(sizes);
|
this->addZones(sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->stitchFaces(SMALL);
|
this->stitchFaces(SMALL);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
Provide a means of reading/writing STL files (ASCII and binary).
|
Provide a means of reading/writing STL files (ASCII and binary).
|
||||||
|
|
||||||
Note
|
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.
|
The class is thus derived from MeshedSurface.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -79,7 +79,7 @@ class STLsurfaceFormat
|
|||||||
const pointField&,
|
const pointField&,
|
||||||
const Face&,
|
const Face&,
|
||||||
const vector&,
|
const vector&,
|
||||||
const label regionI
|
const label zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
const MeshedSurface<Face>&
|
const MeshedSurface<Face>&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface (as ASCII) sorted by region
|
//- Write UnsortedMeshedSurface (as ASCII) sorted by zone
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- 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
|
static void write
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
|||||||
@ -63,9 +63,8 @@ int yyFlexLexer::yywrap()
|
|||||||
|
|
||||||
|
|
||||||
//- A lexer for parsing STL ASCII files.
|
//- A lexer for parsing STL ASCII files.
|
||||||
// Returns DynamicList(s) of points and facets (regionIds).
|
// Returns DynamicList(s) of points and facets (zoneIds).
|
||||||
// Since the facets appear within a solid/endsolid grouping,
|
// The facets are within a solid/endsolid grouping
|
||||||
// they are always within a region
|
|
||||||
class STLASCIILexer
|
class STLASCIILexer
|
||||||
:
|
:
|
||||||
public yyFlexLexer
|
public yyFlexLexer
|
||||||
@ -73,7 +72,7 @@ class STLASCIILexer
|
|||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
bool sorted_;
|
bool sorted_;
|
||||||
label groupID_; // current region
|
label groupID_; // current solid group
|
||||||
label lineNo_;
|
label lineNo_;
|
||||||
word startError_;
|
word startError_;
|
||||||
|
|
||||||
@ -110,20 +109,20 @@ public:
|
|||||||
return points_;
|
return points_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- A list of facet IDs (region IDs)
|
//- A list of facet IDs (group IDs)
|
||||||
// corresponds to the number of triangles
|
// corresponds to the number of triangles
|
||||||
DynamicList<label>& facets()
|
DynamicList<label>& facets()
|
||||||
{
|
{
|
||||||
return facets_;
|
return facets_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- region names
|
//- Names
|
||||||
DynamicList<word>& names()
|
DynamicList<word>& names()
|
||||||
{
|
{
|
||||||
return names_;
|
return names_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- region sizes
|
//- Sizes
|
||||||
DynamicList<label>& sizes()
|
DynamicList<label>& sizes()
|
||||||
{
|
{
|
||||||
return sizes_;
|
return sizes_;
|
||||||
@ -417,7 +416,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
|||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points_.transfer(lexer.points());
|
points_.transfer(lexer.points());
|
||||||
regionIds_.transfer(lexer.facets());
|
zoneIds_.transfer(lexer.facets());
|
||||||
names_.transfer(lexer.names());
|
names_.transfer(lexer.names());
|
||||||
sizes_.transfer(lexer.sizes());
|
sizes_.transfer(lexer.sizes());
|
||||||
|
|
||||||
|
|||||||
@ -139,18 +139,18 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
|||||||
|
|
||||||
#ifdef DEBUG_STLBINARY
|
#ifdef DEBUG_STLBINARY
|
||||||
Info<< "# " << nTris << " facets" << endl;
|
Info<< "# " << nTris << " facets" << endl;
|
||||||
label prevRegion = -1;
|
label prevZone = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
points_.setSize(3*nTris);
|
points_.setSize(3*nTris);
|
||||||
regionIds_.setSize(nTris);
|
zoneIds_.setSize(nTris);
|
||||||
|
|
||||||
Map<label> lookup;
|
Map<label> lookup;
|
||||||
DynamicList<label> dynSizes;
|
DynamicList<label> dynSizes;
|
||||||
|
|
||||||
label ptI = 0;
|
label ptI = 0;
|
||||||
label regionI = -1;
|
label zoneI = -1;
|
||||||
forAll(regionIds_, faceI)
|
forAll(zoneIds_, faceI)
|
||||||
{
|
{
|
||||||
// Read an STL triangle
|
// Read an STL triangle
|
||||||
STLtriangle stlTri(is);
|
STLtriangle stlTri(is);
|
||||||
@ -160,39 +160,39 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
|||||||
points_[ptI++] = stlTri.b();
|
points_[ptI++] = stlTri.b();
|
||||||
points_[ptI++] = stlTri.c();
|
points_[ptI++] = stlTri.c();
|
||||||
|
|
||||||
// interprete colour as a region
|
// interprete stl attribute as a zone
|
||||||
const label stlRegion = stlTri.region();
|
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 (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// group appeared out of order
|
// group appeared out of order
|
||||||
sorted_ = false;
|
sorted_ = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(stlRegion, regionI);
|
lookup.insert(origId, zoneI);
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
regionIds_[faceI] = regionI;
|
zoneIds_[faceI] = zoneI;
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
|
|
||||||
#ifdef DEBUG_STLBINARY
|
#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
|
Info<< " facet normal " << stlTri.normal() << nl
|
||||||
@ -221,7 +221,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
|
|||||||
:
|
:
|
||||||
sorted_(true),
|
sorted_(true),
|
||||||
points_(0),
|
points_(0),
|
||||||
regionIds_(0),
|
zoneIds_(0),
|
||||||
names_(0),
|
names_(0),
|
||||||
sizes_(0)
|
sizes_(0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,8 +63,8 @@ class STLsurfaceFormatCore
|
|||||||
//- The points supporting the facets
|
//- The points supporting the facets
|
||||||
pointField points_;
|
pointField points_;
|
||||||
|
|
||||||
//- The regions associated with the faces
|
//- The zones associated with the faces
|
||||||
List<label> regionIds_;
|
List<label> zoneIds_;
|
||||||
|
|
||||||
//- The solid names, in the order of their first appearance
|
//- The solid names, in the order of their first appearance
|
||||||
List<word> names_;
|
List<word> names_;
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
{
|
{
|
||||||
sorted_ = true;
|
sorted_ = true;
|
||||||
points_.clear();
|
points_.clear();
|
||||||
regionIds_.clear();
|
zoneIds_.clear();
|
||||||
names_.clear();
|
names_.clear();
|
||||||
sizes_.clear();
|
sizes_.clear();
|
||||||
}
|
}
|
||||||
@ -134,10 +134,10 @@ public:
|
|||||||
return points_;
|
return points_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return full access to the regionIds
|
//- Return full access to the zoneIds
|
||||||
List<label>& regionIds()
|
List<label>& zoneIds()
|
||||||
{
|
{
|
||||||
return regionIds_;
|
return zoneIds_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- The list of solid names in the order of their first appearance
|
//- The list of solid names in the order of their first appearance
|
||||||
|
|||||||
@ -46,18 +46,19 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class STLtriangle Declaration
|
Class STLtriangle Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class STLtriangle
|
class STLtriangle
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
typedef unsigned short STLregion;
|
//- Attribute is 16-bit
|
||||||
|
typedef unsigned short STLattrib;
|
||||||
|
|
||||||
STLpoint normal_, a_, b_, c_;
|
STLpoint normal_, a_, b_, c_;
|
||||||
|
|
||||||
STLregion region_;
|
STLattrib attrib_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ public:
|
|||||||
const STLpoint& a,
|
const STLpoint& a,
|
||||||
const STLpoint& b,
|
const STLpoint& b,
|
||||||
const STLpoint& c,
|
const STLpoint& c,
|
||||||
unsigned short region
|
unsigned short attrib
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from istream (read binary)
|
//- Construct from istream (read binary)
|
||||||
@ -88,7 +89,7 @@ public:
|
|||||||
inline const STLpoint& a() const;
|
inline const STLpoint& a() const;
|
||||||
inline const STLpoint& b() const;
|
inline const STLpoint& b() const;
|
||||||
inline const STLpoint& c() const;
|
inline const STLpoint& c() const;
|
||||||
inline unsigned short region() const;
|
inline unsigned short attrib() const;
|
||||||
|
|
||||||
// Read
|
// Read
|
||||||
|
|
||||||
|
|||||||
@ -38,14 +38,14 @@ inline Foam::STLtriangle::STLtriangle
|
|||||||
const STLpoint& a,
|
const STLpoint& a,
|
||||||
const STLpoint& b,
|
const STLpoint& b,
|
||||||
const STLpoint& c,
|
const STLpoint& c,
|
||||||
unsigned short region
|
unsigned short attrib
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
normal_(normal),
|
normal_(normal),
|
||||||
a_(a),
|
a_(a),
|
||||||
b_(b),
|
b_(b),
|
||||||
c_(c),
|
c_(c),
|
||||||
region_(region)
|
attrib_(attrib)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -77,23 +77,23 @@ inline const Foam::STLpoint& Foam::STLtriangle::c() const
|
|||||||
return c_;
|
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)
|
inline void Foam::STLtriangle::read(istream& is)
|
||||||
{
|
{
|
||||||
is.read(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
|
is.read(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
|
||||||
is.read(reinterpret_cast<char*>(®ion_), sizeof(STLregion));
|
is.read(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::STLtriangle::write(ostream& os)
|
inline void Foam::STLtriangle::write(ostream& os)
|
||||||
{
|
{
|
||||||
os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
|
os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
|
||||||
os.write(reinterpret_cast<char*>(®ion_), sizeof(STLregion));
|
os.write(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
@ -104,7 +104,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const STLtriangle& t)
|
|||||||
<< t.a_ << token::SPACE
|
<< t.a_ << token::SPACE
|
||||||
<< t.b_ << token::SPACE
|
<< t.b_ << token::SPACE
|
||||||
<< t.c_ << token::SPACE
|
<< t.c_ << token::SPACE
|
||||||
<< t.region_;
|
<< t.attrib_;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,89 +165,89 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns region info.
|
// Returns zone info.
|
||||||
// Sets faceMap to the indexing according to region numbers.
|
// Sets faceMap to the indexing according to zone numbers.
|
||||||
// Region numbers start at 0.
|
// Zone numbers start at 0.
|
||||||
Foam::surfRegionList
|
Foam::surfZoneList
|
||||||
Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
|
Foam::fileFormats::surfaceFormatsCore::sortedZonesById
|
||||||
(
|
(
|
||||||
const UList<label>& regionIds,
|
const UList<label>& zoneIds,
|
||||||
const Map<word>& regionNames,
|
const Map<word>& zoneNames,
|
||||||
labelList& faceMap
|
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.
|
// std::sort() really seems to mix up the order.
|
||||||
// and std::stable_sort() might take too long / too much memory
|
// 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
|
// 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;
|
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())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
fnd()++;
|
fnd()++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lookup.insert(regId, 1);
|
lookup.insert(origId, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 2: assign start/size (and name) to the newRegions
|
// step 2: assign start/size (and name) to the newZones
|
||||||
// re-use the lookup to map (regionId => regionI)
|
// re-use the lookup to map (zoneId => zoneI)
|
||||||
surfRegionList regionLst(lookup.size());
|
surfZoneList zoneLst(lookup.size());
|
||||||
label start = 0;
|
label start = 0;
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
forAllIter(Map<label>, lookup, iter)
|
forAllIter(Map<label>, lookup, iter)
|
||||||
{
|
{
|
||||||
label regId = iter.key();
|
label origId = iter.key();
|
||||||
|
|
||||||
word name;
|
word name;
|
||||||
Map<word>::const_iterator fnd = regionNames.find(regId);
|
Map<word>::const_iterator fnd = zoneNames.find(origId);
|
||||||
if (fnd != regionNames.end())
|
if (fnd != zoneNames.end())
|
||||||
{
|
{
|
||||||
name = fnd();
|
name = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = word("region") + ::Foam::name(regionI);
|
name = word("zone") + ::Foam::name(zoneI);
|
||||||
}
|
}
|
||||||
|
|
||||||
regionLst[regionI] = surfRegion
|
zoneLst[zoneI] = surfZone
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
0, // initialize with zero size
|
0, // initialize with zero size
|
||||||
start,
|
start,
|
||||||
regionI
|
zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
// increment the start for the next region
|
// increment the start for the next zone
|
||||||
// and save the (regionId => regionI) mapping
|
// and save the (zoneId => zoneI) mapping
|
||||||
start += iter();
|
start += iter();
|
||||||
iter() = regionI++;
|
iter() = zoneI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// step 3: build the re-ordering
|
// 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] =
|
faceMap[faceI] =
|
||||||
regionLst[regionI].start() + regionLst[regionI].size()++;
|
zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// with reordered faces registered in faceMap
|
// with reordered faces registered in faceMap
|
||||||
return regionLst;
|
return zoneLst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
#include "Map.H"
|
#include "Map.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "surfRegionList.H"
|
#include "surfZoneList.H"
|
||||||
#include "surfRegionIdentifierList.H"
|
#include "surfZoneIdentifierList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -92,12 +92,12 @@ public:
|
|||||||
//- Name of UnsortedMeshedSurface directory to use.
|
//- Name of UnsortedMeshedSurface directory to use.
|
||||||
static fileName findMeshName(const Time&);
|
static fileName findMeshName(const Time&);
|
||||||
|
|
||||||
//- Determine the sort order from the region ids.
|
//- Determine the sort order from the zone ids.
|
||||||
// Returns region list and sets faceMap to indices within faceLst
|
// Returns zone list and sets faceMap to indices within faceLst
|
||||||
static surfRegionList sortedRegionsById
|
static surfZoneList sortedZonesById
|
||||||
(
|
(
|
||||||
const UList<label>& regionIds,
|
const UList<label>& zoneIds,
|
||||||
const Map<word>& regionNames,
|
const Map<word>& zoneNames,
|
||||||
labelList& faceMap
|
labelList& faceMap
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
|||||||
Ostream& os,
|
Ostream& os,
|
||||||
const pointField& pointLst,
|
const pointField& pointLst,
|
||||||
const Face& f,
|
const Face& f,
|
||||||
const label regionI
|
const label zoneI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// simple triangulation about f[0].
|
// simple triangulation about f[0].
|
||||||
@ -53,8 +53,8 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
|||||||
os << p0.x() << ' ' << p0.y() << ' ' << p0.z() << ' '
|
os << p0.x() << ' ' << p0.y() << ' ' << p0.z() << ' '
|
||||||
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
|
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
|
||||||
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
|
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
|
||||||
// region as colour
|
// zone as colour
|
||||||
<< "0x" << hex << regionI << dec << endl;
|
<< "0x" << hex << zoneI << dec << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +87,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
|||||||
// transfer points
|
// transfer points
|
||||||
this->storedPoints().transfer(reader.points());
|
this->storedPoints().transfer(reader.points());
|
||||||
|
|
||||||
// retrieve the original region information
|
// retrieve the original zone information
|
||||||
List<label> sizes(reader.sizes().xfer());
|
List<label> sizes(reader.sizes().xfer());
|
||||||
List<label> regionIds(reader.regionIds().xfer());
|
List<label> zoneIds(reader.zoneIds().xfer());
|
||||||
|
|
||||||
// generate the (sorted) faces
|
// generate the (sorted) faces
|
||||||
List<Face> faceLst(regionIds.size());
|
List<Face> faceLst(zoneIds.size());
|
||||||
|
|
||||||
if (reader.sorted())
|
if (reader.sorted())
|
||||||
{
|
{
|
||||||
@ -108,7 +108,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
|||||||
// unsorted - determine the sorted order:
|
// unsorted - determine the sorted order:
|
||||||
// avoid SortableList since we discard the main list anyhow
|
// avoid SortableList since we discard the main list anyhow
|
||||||
List<label> faceMap;
|
List<label> faceMap;
|
||||||
sortedOrder(regionIds, faceMap);
|
sortedOrder(zoneIds, faceMap);
|
||||||
|
|
||||||
// generate sorted faces
|
// generate sorted faces
|
||||||
forAll(faceMap, faceI)
|
forAll(faceMap, faceI)
|
||||||
@ -117,12 +117,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
|
|||||||
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regionIds.clear();
|
zoneIds.clear();
|
||||||
|
|
||||||
// transfer:
|
// transfer:
|
||||||
this->storedFaces().transfer(faceLst);
|
this->storedFaces().transfer(faceLst);
|
||||||
|
|
||||||
this->addRegions(sizes);
|
this->addZones(sizes);
|
||||||
this->stitchFaces(SMALL);
|
this->stitchFaces(SMALL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -137,15 +137,15 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
|||||||
{
|
{
|
||||||
const pointField& pointLst = surf.points();
|
const pointField& pointLst = surf.points();
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], localFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
const Face& f = faceLst[faceIndex++];
|
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();
|
const List<Face>& faceLst = surf.faces();
|
||||||
|
|
||||||
bool doSort = false;
|
bool doSort = false;
|
||||||
// a single region needs no sorting
|
// a single zone needs no sorting
|
||||||
if (surf.regionToc().size() == 1)
|
if (surf.zoneToc().size() == 1)
|
||||||
{
|
{
|
||||||
doSort = false;
|
doSort = false;
|
||||||
}
|
}
|
||||||
@ -171,25 +171,25 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
|
|||||||
if (doSort)
|
if (doSort)
|
||||||
{
|
{
|
||||||
labelList faceMap;
|
labelList faceMap;
|
||||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], localFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||||
writeShell(os, pointLst, f, regionI);
|
writeShell(os, pointLst, f, zoneI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const List<label>& regionIds = surf.regionIds();
|
const List<label>& zoneIds = surf.zoneIds();
|
||||||
|
|
||||||
forAll(faceLst, faceI)
|
forAll(faceLst, faceI)
|
||||||
{
|
{
|
||||||
writeShell(os, pointLst, faceLst[faceI], regionIds[faceI]);
|
writeShell(os, pointLst, faceLst[faceI], zoneIds[faceI]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
Provide a means of reading/writing .tri format.
|
Provide a means of reading/writing .tri format.
|
||||||
|
|
||||||
Note
|
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.
|
The class is thus derived from MeshedSurface.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -69,7 +69,7 @@ class TRIsurfaceFormat
|
|||||||
Ostream&,
|
Ostream&,
|
||||||
const pointField&,
|
const pointField&,
|
||||||
const Face&,
|
const Face&,
|
||||||
const label regionI
|
const label zoneI
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// By default, the output is not sorted by regions
|
// By default, the output is not sorted by zones
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write UnsortedMeshedSurface
|
//- Write UnsortedMeshedSurface
|
||||||
// By default, the output is not sorted by regions
|
// By default, the output is not sorted by zones
|
||||||
static void write
|
static void write
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
|
|||||||
@ -43,7 +43,7 @@ Foam::fileFormats::TRIsurfaceFormatCore::TRIsurfaceFormatCore
|
|||||||
:
|
:
|
||||||
sorted_(true),
|
sorted_(true),
|
||||||
points_(0),
|
points_(0),
|
||||||
regionIds_(0),
|
zoneIds_(0),
|
||||||
sizes_(0)
|
sizes_(0)
|
||||||
{
|
{
|
||||||
read(filename);
|
read(filename);
|
||||||
@ -79,14 +79,14 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read
|
|||||||
// uses similar structure as STL, just some points
|
// uses similar structure as STL, just some points
|
||||||
// the rest of the reader resembles the STL binary reader
|
// the rest of the reader resembles the STL binary reader
|
||||||
DynamicList<point> dynPoints;
|
DynamicList<point> dynPoints;
|
||||||
DynamicList<label> dynRegions;
|
DynamicList<label> dynZones;
|
||||||
DynamicList<label> dynSizes;
|
DynamicList<label> dynSizes;
|
||||||
HashTable<label> lookup;
|
HashTable<label> lookup;
|
||||||
|
|
||||||
// place faces without a group in region0
|
// place faces without a group in zone0
|
||||||
label regionI = 0;
|
label zoneI = 0;
|
||||||
dynSizes.append(regionI);
|
dynSizes.append(zoneI);
|
||||||
lookup.insert("regionI", regionI);
|
lookup.insert("zoneI", zoneI);
|
||||||
|
|
||||||
while (is.good())
|
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
|
// 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;
|
char zero;
|
||||||
lineStream >> zero;
|
lineStream >> zero;
|
||||||
|
|
||||||
word rawName(lineStream);
|
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);
|
HashTable<label>::const_iterator fnd = lookup.find(name);
|
||||||
if (fnd != lookup.end())
|
if (fnd != lookup.end())
|
||||||
{
|
{
|
||||||
if (regionI != fnd())
|
if (zoneI != fnd())
|
||||||
{
|
{
|
||||||
// group appeared out of order
|
// group appeared out of order
|
||||||
sorted_ = false;
|
sorted_ = false;
|
||||||
}
|
}
|
||||||
regionI = fnd();
|
zoneI = fnd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(name, regionI);
|
lookup.insert(name, zoneI);
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynRegions.append(regionI);
|
dynZones.append(zoneI);
|
||||||
dynSizes[regionI]++;
|
dynSizes[zoneI]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip empty groups
|
// skip empty groups
|
||||||
label nRegion = 0;
|
label nZone = 0;
|
||||||
forAll(dynSizes, regionI)
|
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
|
// truncate addressed size
|
||||||
dynSizes.setCapacity(nRegion);
|
dynSizes.setCapacity(nZone);
|
||||||
|
|
||||||
// transfer to normal lists
|
// transfer to normal lists
|
||||||
points_.transfer(dynPoints);
|
points_.transfer(dynPoints);
|
||||||
regionIds_.transfer(dynRegions);
|
zoneIds_.transfer(dynZones);
|
||||||
sizes_.transfer(dynSizes);
|
sizes_.transfer(dynSizes);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -64,8 +64,8 @@ class TRIsurfaceFormatCore
|
|||||||
//- The points supporting the facets
|
//- The points supporting the facets
|
||||||
pointField points_;
|
pointField points_;
|
||||||
|
|
||||||
//- The regions associated with the faces
|
//- The zones associated with the faces
|
||||||
List<label> regionIds_;
|
List<label> zoneIds_;
|
||||||
|
|
||||||
//- The solid count, in the order of their first appearance
|
//- The solid count, in the order of their first appearance
|
||||||
List<label> sizes_;
|
List<label> sizes_;
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
{
|
{
|
||||||
sorted_ = true;
|
sorted_ = true;
|
||||||
points_.clear();
|
points_.clear();
|
||||||
regionIds_.clear();
|
zoneIds_.clear();
|
||||||
sizes_.clear();
|
sizes_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,13 +114,13 @@ public:
|
|||||||
return points_;
|
return points_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return full access to the regions
|
//- Return full access to the zones
|
||||||
List<label>& regionIds()
|
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()
|
List<label>& sizes()
|
||||||
{
|
{
|
||||||
return sizes_;
|
return sizes_;
|
||||||
|
|||||||
@ -66,15 +66,15 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const List<Face>& faceLst = surf.faces();
|
const List<Face>& faceLst = surf.faces();
|
||||||
const List<surfRegion>& regionLst = surf.regions();
|
const List<surfZone>& zoneLst = surf.zones();
|
||||||
|
|
||||||
writeHeader(os, surf.points());
|
writeHeader(os, surf.points());
|
||||||
writeHeaderPolygons(os, faceLst);
|
writeHeaderPolygons(os, faceLst);
|
||||||
|
|
||||||
label faceIndex = 0;
|
label faceIndex = 0;
|
||||||
forAll(regionLst, regionI)
|
forAll(zoneLst, zoneI)
|
||||||
{
|
{
|
||||||
forAll(regionLst[regionI], localFaceI)
|
forAll(zoneLst[zoneI], localFaceI)
|
||||||
{
|
{
|
||||||
const Face& f = faceLst[faceIndex++];
|
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;
|
os << ' ' << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTail(os, surf.regionIds());
|
writeTail(os, surf.zoneIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
Provide a means of writing VTK legacy format.
|
Provide a means of writing VTK legacy format.
|
||||||
The output is never sorted by region.
|
The output is never sorted by zone.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
VTKsurfaceFormat.C
|
VTKsurfaceFormat.C
|
||||||
|
|||||||
@ -58,25 +58,25 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
|
|||||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const UList<surfRegion>& regionLst
|
const UList<surfZone>& zoneLst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nFaces = 0;
|
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
|
os << nl
|
||||||
<< "CELL_DATA " << nFaces << nl
|
<< "CELL_DATA " << nFaces << nl
|
||||||
<< "FIELD attributes 1" << 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)
|
if (localFaceI)
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
|||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << regionI + 1;
|
os << zoneI + 1;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
@ -99,17 +99,16 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
|||||||
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const UList<label>& regionIds
|
const UList<label>& zoneIds
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Print region numbers
|
// Print zone numbers
|
||||||
os << nl
|
os << nl
|
||||||
<< "CELL_DATA " << regionIds.size() << nl
|
<< "CELL_DATA " << zoneIds.size() << nl
|
||||||
<< "FIELD attributes 1" << nl
|
<< "FIELD attributes 1" << nl
|
||||||
<< "region 1 " << regionIds.size() << " float" << nl;
|
<< "zone 1 " << zoneIds.size() << " float" << nl;
|
||||||
|
|
||||||
|
forAll(zoneIds, faceI)
|
||||||
forAll(regionIds, faceI)
|
|
||||||
{
|
{
|
||||||
if (faceI)
|
if (faceI)
|
||||||
{
|
{
|
||||||
@ -122,7 +121,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeTail
|
|||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << regionIds[faceI] + 1;
|
os << zoneIds[faceI] + 1;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,11 +64,11 @@ protected:
|
|||||||
const pointField&
|
const pointField&
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write trailing information with region information
|
//- Write trailing information with zone information
|
||||||
static void writeTail(Ostream&, const UList<surfRegion>&);
|
static void writeTail(Ostream&, const UList<surfZone>&);
|
||||||
|
|
||||||
//- Write trailing information with region Ids
|
//- Write trailing information with zone Ids
|
||||||
static void writeTail(Ostream&, const UList<label>& regionIds);
|
static void writeTail(Ostream&, const UList<label>& zoneIds);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
62
src/surfMesh/surfaceRegistry/surfaceRegistry.C
Normal file
62
src/surfMesh/surfaceRegistry/surfaceRegistry.C
Normal 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 * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
91
src/surfMesh/surfaceRegistry/surfaceRegistry.H
Normal file
91
src/surfMesh/surfaceRegistry/surfaceRegistry.H
Normal 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user