mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Add foamToSurface to dev repository.
- Extracts the boundary faces of a polyMesh to a meshedSurface and writes in various possible formats.
This commit is contained in:
@ -0,0 +1,3 @@
|
|||||||
|
foamToSurface.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/foamToSurface
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lsurfMesh
|
||||||
@ -0,0 +1,129 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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
|
||||||
|
foamToSurface
|
||||||
|
|
||||||
|
Description
|
||||||
|
Reads an OpenFOAM mesh and writes the boundaries in a surface format.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
- foamToSurface [OPTION] \n
|
||||||
|
Reads an OpenFOAM mesh and writes the boundaries in a surface format.
|
||||||
|
|
||||||
|
@param -scale \<factor\>\n
|
||||||
|
Specify an alternative geometry scaling factor.
|
||||||
|
Eg, use @b 1000 to scale @em [m] to @em [mm].
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "timeSelector.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "MeshedSurfaces.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noParallel();
|
||||||
|
argList::validArgs.append("outputFile.ext");
|
||||||
|
timeSelector::addOptions();
|
||||||
|
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"scale",
|
||||||
|
"scale",
|
||||||
|
"specify geometry scaling factor"
|
||||||
|
);
|
||||||
|
|
||||||
|
# include "setRootCase.H"
|
||||||
|
|
||||||
|
const stringList& params = args.additionalArgs();
|
||||||
|
|
||||||
|
scalar scaleFactor = 0;
|
||||||
|
args.optionReadIfPresent<scalar>("scale", scaleFactor);
|
||||||
|
|
||||||
|
fileName exportName(params[0]);
|
||||||
|
|
||||||
|
fileName exportBase = exportName.lessExt();
|
||||||
|
word exportExt = exportName.ext();
|
||||||
|
|
||||||
|
if (!meshedSurface::canWriteType(exportExt, true))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# include "createTime.H"
|
||||||
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||||
|
# include "createPolyMesh.H"
|
||||||
|
|
||||||
|
forAll(timeDirs, timeI)
|
||||||
|
{
|
||||||
|
runTime.setTime(timeDirs[timeI], timeI);
|
||||||
|
# include "getTimeIndex.H"
|
||||||
|
|
||||||
|
polyMesh::readUpdateState state = mesh.readUpdate();
|
||||||
|
|
||||||
|
if (timeI == 0 || state != polyMesh::UNCHANGED)
|
||||||
|
{
|
||||||
|
if (state == polyMesh::UNCHANGED)
|
||||||
|
{
|
||||||
|
exportName = exportBase + "." + exportExt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exportName =
|
||||||
|
exportBase + '_' + runTime.timeName() + "." + exportExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
meshedSurface surf(mesh.boundaryMesh());
|
||||||
|
surf.scalePoints(scaleFactor);
|
||||||
|
|
||||||
|
Info<< "writing " << exportName;
|
||||||
|
if (scaleFactor <= 0)
|
||||||
|
{
|
||||||
|
Info<< " without scaling" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
|
}
|
||||||
|
surf.write(exportName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
// Read time index from */uniform/time, but treat 0 and constant specially
|
||||||
|
|
||||||
|
word timeName = "0";
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
runTime.timeName() != "constant"
|
||||||
|
&& runTime.timeName() != "0"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobject io
|
||||||
|
(
|
||||||
|
"time",
|
||||||
|
runTime.timeName(),
|
||||||
|
"uniform",
|
||||||
|
runTime,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
if (io.headerOk())
|
||||||
|
{
|
||||||
|
IOdictionary timeObject
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"time",
|
||||||
|
runTime.timeName(),
|
||||||
|
"uniform",
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
label index;
|
||||||
|
timeObject.lookup("index") >> index;
|
||||||
|
timeName = Foam::name(index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeName = runTime.timeName();
|
||||||
|
// Info<< "skip ... missing entry " << io.objectPath() << endl;
|
||||||
|
// continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl;
|
||||||
|
|
||||||
Reference in New Issue
Block a user