mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added surfaceMeshImport, surfaceMeshExport
This commit is contained in:
@ -102,8 +102,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if
|
||||
(
|
||||
!meshedSurface::canRead(importName, true)
|
||||
|| !meshedSurface::canWriteType(exportName.ext(), true)
|
||||
!MeshedSurface<face>::canRead(importName, true)
|
||||
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
surfaceMeshExport.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceMeshExport
|
||||
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = -lmeshTools -lsurfMesh
|
||||
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
surfaceMeshExport
|
||||
|
||||
Description
|
||||
Export from surfMesh to various third-party surface formats with
|
||||
optional scaling or transformations (rotate/translate) on a
|
||||
coordinateSystem.
|
||||
|
||||
Usage
|
||||
- surfaceMeshExport outputFile [OPTION]
|
||||
|
||||
@param -clean \n
|
||||
Perform some surface checking/cleanup on the input surface.
|
||||
|
||||
@param -name \<name\> \n
|
||||
Specify an alternative surface name when writing.
|
||||
|
||||
@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 constant/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("outputFile");
|
||||
argList::validOptions.insert("name", "name");
|
||||
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 exportName(params[0]);
|
||||
word importName("default");
|
||||
|
||||
// check that writing is supported
|
||||
if (!MeshedSurface<face>::canWriteType(exportName.ext(), true))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.options().found("name"))
|
||||
{
|
||||
importName = args.options()["name"];
|
||||
}
|
||||
|
||||
|
||||
// get the coordinate transformations
|
||||
autoPtr<coordinateSystem> fromCsys;
|
||||
autoPtr<coordinateSystem> toCsys;
|
||||
|
||||
if (args.options().found("from") || args.options().found("to"))
|
||||
{
|
||||
autoPtr<IOobject> ioPtr;
|
||||
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
ioPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
(
|
||||
dictPath.isDir()
|
||||
? dictPath/coordinateSystems::typeName
|
||||
: dictPath
|
||||
),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ioPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
coordinateSystems::typeName,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!ioPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open coordinateSystems file\n "
|
||||
<< ioPtr->objectPath() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
coordinateSystems csLst(ioPtr());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
surfMesh smesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
importName,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "read surfMesh:\n " << smesh.objectPath() << endl;
|
||||
|
||||
|
||||
// Simply copy for now, but really should have a separate write method
|
||||
|
||||
MeshedSurface<face> surf(smesh);
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
surf.cleanup(true);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
Info<< "writing " << exportName << endl;
|
||||
surf.write(exportName);
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,3 @@
|
||||
surfaceMeshImport.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/surfaceMeshImport
|
||||
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||
|
||||
EXE_LIBS = -lmeshTools -lsurfMesh
|
||||
@ -0,0 +1,271 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
surfaceMeshImport
|
||||
|
||||
Description
|
||||
Import from various third-party surface formats into surfMesh
|
||||
with optional scaling or transformations (rotate/translate)
|
||||
on a coordinateSystem.
|
||||
|
||||
Usage
|
||||
- surfaceMeshImport inputFile [OPTION]
|
||||
|
||||
@param -clean \n
|
||||
Perform some surface checking/cleanup on the input surface.
|
||||
|
||||
@param -name \<name\> \n
|
||||
Specify an alternative surface name when writing.
|
||||
|
||||
@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 constant/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::validOptions.insert("name", "name");
|
||||
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]);
|
||||
word exportName("default");
|
||||
|
||||
// check that reading is supported
|
||||
if (!MeshedSurface<face>::canRead(importName, true))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.options().found("name"))
|
||||
{
|
||||
exportName = args.options()["name"];
|
||||
}
|
||||
|
||||
|
||||
// get the coordinate transformations
|
||||
autoPtr<coordinateSystem> fromCsys;
|
||||
autoPtr<coordinateSystem> toCsys;
|
||||
|
||||
if (args.options().found("from") || args.options().found("to"))
|
||||
{
|
||||
autoPtr<IOobject> ioPtr;
|
||||
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
ioPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
(
|
||||
dictPath.isDir()
|
||||
? dictPath/coordinateSystems::typeName
|
||||
: dictPath
|
||||
),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ioPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
coordinateSystems::typeName,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!ioPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open coordinateSystems file\n "
|
||||
<< ioPtr->objectPath() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
coordinateSystems csLst(ioPtr());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
MeshedSurface<face> surf(importName);
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
surf.cleanup(true);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
surfMesh smesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
exportName,
|
||||
runTime.constant(),
|
||||
runTime
|
||||
),
|
||||
surf.xfer()
|
||||
);
|
||||
|
||||
|
||||
Info<< "writing surfMesh:\n " << smesh.objectPath() << endl;
|
||||
smesh.write();
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -532,10 +532,35 @@ void Foam::BasicMeshedSurface<Face>::remapFaces(const UList<label>&)
|
||||
template<class Face>
|
||||
void Foam::BasicMeshedSurface<Face>::writeStats(Ostream& os) const
|
||||
{
|
||||
os << "points : " << this->points().size() << nl
|
||||
<< (this->isTri() ? "triangles : " : "faces : ")
|
||||
<< this->size() << nl
|
||||
<< "boundingBox : " << boundBox(this->points()) << endl;
|
||||
os << "points : " << this->points().size() << nl;
|
||||
if (this->isTri())
|
||||
{
|
||||
os << "triangles : " << this->size() << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
label nTri = 0;
|
||||
label nQuad = 0;
|
||||
forAll(*this, i)
|
||||
{
|
||||
const label n = this->operator[](i).size();
|
||||
|
||||
if (n == 3)
|
||||
{
|
||||
nTri++;
|
||||
}
|
||||
else if (n == 4)
|
||||
{
|
||||
nQuad++;
|
||||
}
|
||||
}
|
||||
|
||||
os << "faces : " << this->size()
|
||||
<< " (tri:" << nTri << " quad:" << nQuad
|
||||
<< " poly:" << (this->size() - nTri - nQuad ) << ")" << nl;
|
||||
}
|
||||
|
||||
os << "boundingBox : " << boundBox(this->points()) << endl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,6 +2,7 @@ surfZone/surfZone/surfZone.C
|
||||
surfZone/surfZone/surfZoneIOList.C
|
||||
surfZone/surfZoneIdentifier/surfZoneIdentifier.C
|
||||
|
||||
MeshedSurface/MeshedSurfaceCore.C
|
||||
MeshedSurface/MeshedSurfaces.C
|
||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
|
||||
@ -225,13 +225,13 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
mesh.points()
|
||||
);
|
||||
|
||||
// use global/local points
|
||||
// use global/local points:
|
||||
const pointField& bPoints =
|
||||
(
|
||||
useGlobalPoints ? mesh.points() : allBoundary.localPoints()
|
||||
);
|
||||
|
||||
// global or local face addressing
|
||||
// global/local face addressing:
|
||||
const List<Face>& bFaces =
|
||||
(
|
||||
useGlobalPoints ? allBoundary : allBoundary.localFaces()
|
||||
@ -242,22 +242,29 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
surfZoneList newZones(bPatches.size());
|
||||
|
||||
label startFaceI = 0;
|
||||
label nZone = 0;
|
||||
forAll(bPatches, patchI)
|
||||
{
|
||||
const polyPatch& p = bPatches[patchI];
|
||||
|
||||
newZones[patchI] = surfZone
|
||||
if (p.size())
|
||||
{
|
||||
newZones[nZone] = surfZone
|
||||
(
|
||||
p.name(),
|
||||
p.size(),
|
||||
startFaceI,
|
||||
patchI
|
||||
nZone
|
||||
);
|
||||
|
||||
nZone++;
|
||||
startFaceI += p.size();
|
||||
}
|
||||
}
|
||||
|
||||
// must create with the same face type as the polyBoundaryMesh
|
||||
newZones.setSize(nZone);
|
||||
|
||||
// same face type as the polyBoundaryMesh
|
||||
MeshedSurface<face> surf
|
||||
(
|
||||
xferCopy(bPoints),
|
||||
@ -265,42 +272,14 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
xferMove(newZones)
|
||||
);
|
||||
|
||||
|
||||
// must triangulate?
|
||||
if (this->isTri())
|
||||
{
|
||||
surf.triangulate();
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
|
||||
// transcribe from face -> triFace
|
||||
List<face>& origFaces = surf.storedFaces();
|
||||
List<triFace> newFaces(origFaces.size());
|
||||
forAll(origFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = Face
|
||||
(
|
||||
static_cast<const UList<label>&>(origFaces[faceI])
|
||||
);
|
||||
}
|
||||
origFaces.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
zones_.transfer(surf.zones_);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->transfer(surf);
|
||||
}
|
||||
this->transcribe(surf);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const surfMesh& mesh
|
||||
)
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const surfMesh& mesh)
|
||||
{
|
||||
// must create with the same face type as surfMesh
|
||||
// same face type as surfMesh
|
||||
MeshedSurface<face> surf
|
||||
(
|
||||
xferCopy(mesh.points()),
|
||||
@ -308,31 +287,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
xferCopy(mesh.surfZones())
|
||||
);
|
||||
|
||||
// must triangulate?
|
||||
if (this->isTri())
|
||||
{
|
||||
surf.triangulate();
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
|
||||
// transcribe from face -> triFace
|
||||
List<face>& origFaces = surf.storedFaces();
|
||||
List<triFace> newFaces(origFaces.size());
|
||||
forAll(origFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = Face
|
||||
(
|
||||
static_cast<const UList<label>&>(origFaces[faceI])
|
||||
);
|
||||
}
|
||||
origFaces.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
zones_.transfer(surf.zones_);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->transfer(surf);
|
||||
}
|
||||
this->transcribe(surf);
|
||||
}
|
||||
|
||||
|
||||
@ -426,6 +381,9 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::oneZone(const word& name)
|
||||
{
|
||||
@ -447,7 +405,7 @@ void Foam::MeshedSurface<Face>::oneZone(const word& name)
|
||||
zones_[0] = surfZone
|
||||
(
|
||||
zoneName,
|
||||
size(), // zone size
|
||||
this->size(), // zone size
|
||||
0, // zone start
|
||||
0 // zone index
|
||||
);
|
||||
@ -584,8 +542,6 @@ void Foam::MeshedSurface<Face>::remapFaces
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class polyBoundaryMesh;
|
||||
class surfMesh;
|
||||
|
||||
template<class Face>
|
||||
Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
|
||||
Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MeshedSurface Declaration
|
||||
@ -79,7 +79,14 @@ class MeshedSurface
|
||||
public BasicMeshedSurface<Face>,
|
||||
public fileFormats::surfaceFormatsCore
|
||||
{
|
||||
friend class UnsortedMeshedSurface<Face>;
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class MeshedSurface;
|
||||
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class UnsortedMeshedSurface;
|
||||
|
||||
friend class surfMesh;
|
||||
|
||||
private:
|
||||
@ -99,6 +106,9 @@ private:
|
||||
//- Read OpenFOAM Surface format
|
||||
bool read(Istream&);
|
||||
|
||||
//- Transfer points/zones and transcribe face -> triFace
|
||||
void transcribe(MeshedSurface<face>&);
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
89
src/surfMesh/MeshedSurface/MeshedSurfaceCore.C
Normal file
89
src/surfMesh/MeshedSurface/MeshedSurfaceCore.C
Normal file
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
#include "ListOps.H"
|
||||
#include "polyBoundaryMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "surfMesh.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// specialization: from face -> triFace
|
||||
template<>
|
||||
void Foam::MeshedSurface<triFace>::transcribe(MeshedSurface<face>& surf)
|
||||
{
|
||||
// first triangulate
|
||||
surf.triangulate();
|
||||
this->storedPoints().transfer(surf.storedPoints());
|
||||
zones_.transfer(surf.zones_);
|
||||
|
||||
// transcribe from face -> triFace
|
||||
List<face>& origFaces = surf.storedFaces();
|
||||
List<triFace> newFaces(origFaces.size());
|
||||
forAll(origFaces, faceI)
|
||||
{
|
||||
newFaces[faceI] = triFace
|
||||
(
|
||||
static_cast<const UList<label>&>(origFaces[faceI])
|
||||
);
|
||||
}
|
||||
surf.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
}
|
||||
|
||||
|
||||
// specialization: from face -> face
|
||||
template<>
|
||||
void Foam::MeshedSurface<face>::transcribe(MeshedSurface<face>& surf)
|
||||
{
|
||||
this->transfer(surf);
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -299,6 +299,8 @@ Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
|
||||
@ -83,6 +83,14 @@ class UnsortedMeshedSurface
|
||||
public BasicMeshedSurface<Face>,
|
||||
public fileFormats::surfaceFormatsCore
|
||||
{
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class MeshedSurface;
|
||||
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class UnsortedMeshedSurface;
|
||||
|
||||
friend class MeshedSurface<Face>;
|
||||
|
||||
private:
|
||||
|
||||
@ -35,7 +35,6 @@ Description
|
||||
defineTypeNameAndDebug(Foam::surfZone, 0);
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfZone::surfZone()
|
||||
@ -137,9 +136,9 @@ bool Foam::surfZone::operator==(const surfZone& rhs) const
|
||||
{
|
||||
return
|
||||
(
|
||||
(geometricType() == rhs.geometricType())
|
||||
&& (size() == rhs.size())
|
||||
&& (start() == rhs.start())
|
||||
size() == rhs.size()
|
||||
&& start() == rhs.start()
|
||||
&& geometricType() == rhs.geometricType()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,6 @@ Foam::surfZoneIOList::surfZoneIOList
|
||||
{
|
||||
surfZoneList& zones = *this;
|
||||
|
||||
// read polyPatchList
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
PtrList<entry> dictEntries(is);
|
||||
@ -82,9 +81,8 @@ Foam::surfZoneIOList::surfZoneIOList
|
||||
{
|
||||
FatalErrorIn(functionName)
|
||||
<< "surfZones are not ordered. Start of zone " << zoneI
|
||||
<< " does not correspond to sum of preceding zones."
|
||||
<< endl
|
||||
<< "while reading " << io.objectPath()
|
||||
<< " does not correspond to sum of preceding zones." << nl
|
||||
<< "while reading " << io.objectPath() << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -98,7 +96,7 @@ Foam::surfZoneIOList::surfZoneIOList
|
||||
}
|
||||
}
|
||||
|
||||
// Construct from IOObject
|
||||
|
||||
Foam::surfZoneIOList::surfZoneIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
@ -110,6 +108,17 @@ Foam::surfZoneIOList::surfZoneIOList
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfZoneIOList::surfZoneIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
const Xfer<surfZoneList>& zones
|
||||
)
|
||||
:
|
||||
surfZoneList(zones),
|
||||
regIOobject(io)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfZoneIOList::~surfZoneIOList()
|
||||
@ -131,14 +140,14 @@ bool Foam::surfZoneIOList::writeData(Ostream& os) const
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& L)
|
||||
{
|
||||
os << L.size() << nl << token::BEGIN_LIST;
|
||||
os << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
|
||||
|
||||
forAll(L, i)
|
||||
{
|
||||
L[i].writeDict(os);
|
||||
}
|
||||
|
||||
os << token::END_LIST;
|
||||
os << decrIndent << token::END_LIST;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class surfZoneIOList
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfZoneIOList");
|
||||
TypeName("surfZoneList");
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -80,9 +80,12 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit surfZoneIOList(const IOobject&);
|
||||
|
||||
//- Construct from IOobject
|
||||
//- Construct from IOobject and surfZoneList
|
||||
surfZoneIOList(const IOobject&, const surfZoneList&);
|
||||
|
||||
//- Construct from IOobject and surfZoneList
|
||||
surfZoneIOList(const IOobject&, const Xfer<surfZoneList>&);
|
||||
|
||||
// Destructor
|
||||
|
||||
~surfZoneIOList();
|
||||
|
||||
Reference in New Issue
Block a user