Commit 3e3f1e36 authored by Franjo's avatar Franjo

Merge branch 'enhancement-surfaceMeshUnits-63' into development

parents 8058b73b c3675b6b
backScaleMesh.C
EXE = $(FOAM_USER_APPBIN)/backScaleMesh
scaleMesh.C
EXE = $(FOAM_USER_APPBIN)/scaleMesh
......@@ -22,13 +22,13 @@ 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 the mesh into other units.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "polyMeshGen.H"
#include "coordinateModifier.H"
#include "helperFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -36,37 +36,32 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::validArgs.append("scalingFactor");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
const scalar scalingFactor(help::textToScalar(args.args()[1]));
Info << "Scaling mesh vertices by a factor " << scalingFactor << endl;
//- read the mesh from disk
polyMeshGen pmg(runTime);
Info << "Reading mesh" << endl;
pmg.read();
//- scale the points
pointFieldPMG& pts = pmg.points();
if( !meshDict.found("anisotropicSources") )
FatalError << "Cannot backward scale mesh. anisotropicSources"
<< " does not exist in meshDict" << exit(FatalError);
coordinateModifier cMod(meshDict.subDict("anisotropicSources"));
//- apply backward transformation
forAll(pts, i)
pts[i] = cMod.backwardModifiedPoint(pts[i]);
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 100)
# endif
forAll(pts, pointI)
pts[pointI] *= scalingFactor;
Info << "Writting mesh with backward transformed points" << endl;
//- write the mesh back on disk
Info << "Writting scaled mesh" << endl;
pmg.write();
Info << "End\n" << endl;
......
......@@ -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