Commit 10755bf0 authored by Franjo's avatar Franjo

Utility for unit conversion of surface meshes

parent 8058b73b
......@@ -22,7 +22,7 @@ License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Reads the specified surface and writes it in the fms format.
Scales surface vertices by a precribed factor.
\*---------------------------------------------------------------------------*/
......@@ -32,10 +32,6 @@ Description
#include "triSurf.H"
#include "triSurfModifier.H"
#include "helperFunctions.H"
#include "demandDrivenData.H"
#include "coordinateModifier.H"
#include "checkMeshDict.H"
#include "surfaceMeshGeometryModification.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -43,79 +39,31 @@ using namespace Foam;
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
checkMeshDict cmd(meshDict);
fileName surfaceFile = meshDict.lookup("surfaceFile");
if( Pstream::parRun() )
surfaceFile = ".."/surfaceFile;
triSurf surface(runTime.path()/surfaceFile);
surfaceMeshGeometryModification gMod(surface, meshDict);
//- modify points
const triSurf* modSurfPtr = gMod.modifyGeometry();
Info << "Writting modified surface" << endl;
modSurfPtr->writeSurface("modifiedSurf.stl");
# ifdef DEBUGScaling
//- apply backward modification
Info << "Here" << endl;
coordinateModifier cMod(meshDict.subDict("anisotropicSources"));
Info << "Starting modifications" << endl;
forAll(surface.points(), i)
{
Info << "\nOrig point " << i << " coordinates " << surface.points()[i]
<< " modified point " << modSurfPtr->points()[i] << endl;
const point p = cMod.backwardModifiedPoint(modSurfPtr->points()[i]);
if( mag(p - surface.points()[i]) > 1e-14 )
{
Warning << "Point " << i << " is different "
<< p
<< " from original " << surface.points()[i]
<< " modified point "
<< cMod.modifiedPoint(surface.points()[i]) << endl;
::exit(0);
}
}
Info << "Backscaling Ok" << endl;
::exit(0);
argList::noParallel();
argList::validArgs.clear();
argList::validArgs.append("input surface file");
argList::validArgs.append("output surface file");
argList::validArgs.append("scalingFactor");
argList args(argc, argv);
const fileName inFileName(args.args()[1]);
const fileName outFileName(args.args()[2]);
const scalar scalingFactor(help::textToScalar(args.args()[3]));
//- read the surface mesh
triSurf surface(inFileName);
triSurfModifier sMod(surface);
pointField& pts = sMod.pointsAccess();
//- scales the vertices
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 100)
# endif
forAll(pts, pointI)
pts[pointI] *= scalingFactor;
surfaceMeshGeometryModification bgMod(*modSurfPtr, meshDict);
const triSurf* backModSurfPtr = bgMod.revertGeometryModification();
Info << "Writting backward transformed surface" << endl;
backModSurfPtr->writeSurface("backwardModifiedSurf.stl");
# ifdef DEBUGScaling
forAll(backModSurfPtr->points(), pI)
if( mag(backModSurfPtr->points()[pI] - surface.points()[pI]) > 1e-14 )
Warning << "Point " << pI << " is different "
<< backModSurfPtr->points()[pI]
<< " from original " << surface.points()[pI] << endl;
# endif
deleteDemandDrivenData(modSurfPtr);
deleteDemandDrivenData(backModSurfPtr);
//- write the mesh back on disk
surface.writeSurface(outFileName);
Info << "End\n" << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment