Commit 9a722b9a authored by Mark Olesen's avatar Mark Olesen

STYLE: use Foam::name() instead of helper methods

parent f9ede693
......@@ -240,8 +240,6 @@ $(tetCreatorOctree)/tetCreatorOctreeTetsFromSplitFaces.C
$(faceDecomposition)/faceDecomposition.C
$(faceDecomposition)/decomposeFaces.C
$(helperFunctions)/helperFunctionsStringConversion.C
$(sortEdgesIntoChains)/sortEdgesIntoChains.C
$(surfaceMorpherCells)/surfaceMorpherCells.C
......
......@@ -519,7 +519,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
Info<< "Adding layer subset " << layerI
<< " for patch " << patchI << endl;
usedPatch[patchI] = true;
subsetId = mesh_.addFaceSubset("layer_"+help::scalarToText(layerI));
subsetId = mesh_.addFaceSubset("layer_" + Foam::name(layerI));
++layerI;
forAll(treatPatchesWithPatch_[patchI], i)
......
......@@ -396,10 +396,9 @@ void detectBoundaryLayers::analyseLayers()
polyMeshGen& pmg = const_cast<polyMeshGen&>(mesh);
forAll(layerSubsetId, i)
{
layerSubsetId[i] = pmg.addCellSubset("bndLayer"+help::scalarToText(i));
layerSubsetId[i] = pmg.addCellSubset("bndLayer" + Foam::name(i));
}
forAll(layerAtBndFace_, bfI)
{
if (layerAtBndFace_[bfI] < 0)
......
......@@ -496,7 +496,7 @@ void VRWGraphSMPModifier::reverseAddressing
# endif
label minRow(INT_MAX), maxRow(-1);
List<List<LongList<labelPair>> > dataForOtherThreads(nThreads);
List<List<LongList<labelPair>>> dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
......
......@@ -89,7 +89,7 @@ void createFIRESelections(polyMeshGen& mesh)
forAll(procBoundaries, patchI)
{
word sName = "InterFacesToProc";
sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
sName += Foam::name(procBoundaries[patchI].neiProcNo());
const label sID = mesh.addFaceSubset(sName);
label faceI = procBoundaries[patchI].patchStart();
......@@ -141,7 +141,7 @@ void createFIRESelections(polyMeshGen& mesh)
forAll(procBoundaries, patchI)
{
word sName = "InterSurfaceEdgesToProc";
sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
sName += Foam::name(procBoundaries[patchI].neiProcNo());
const label subsetID = mesh.addPointSubset(sName);
label faceI = procBoundaries[patchI].patchStart();
......
......@@ -38,7 +38,6 @@ SourceFiles
#include "helperFunctionsGeometryQueries.H"
#include "helperFunctionsTopologyManipulation.H"
#include "helperFunctionsStringConversion.H"
#include "helperFunctionsPar.H"
#include "helperFunctionsFrontalMarking.H"
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "helperFunctionsStringConversion.H"
#include <sstream>
//#define DEBUG_pMesh
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
namespace help
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
scalar textToScalar(const word& w)
{
std::stringstream ss;
ss << w;
double s;
ss >> s;
return s;
}
label textToLabel(const word& w)
{
return label(textToScalar(w));
}
word scalarToText(const scalar s)
{
std::ostringstream ss;
ss << s;
return ss.str();
}
word labelToText(const label l)
{
std::ostringstream ss;
ss << l;
return ss.str();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
} // End namespace help
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
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 3 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, see <http://www.gnu.org/licenses/>.
InNamespace
Foam::help
Description
String conversion functions
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef helperFunctionsStringConversion_H
#define helperFunctionsStringConversion_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "word.H"
#include "label.H"
#include "scalar.H"
namespace Foam
{
/*---------------------------------------------------------------------------*\
Namespace help functions Declaration
\*---------------------------------------------------------------------------*/
namespace help
{
//- convert the text to scalar
scalar textToScalar(const word& w);
//- convert the text to label
label textToLabel(const word& w);
//- convert the scalar value into text
word scalarToText(const scalar s);
//- convert the integer value into text
word labelToText(const label l);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace help
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -763,7 +763,7 @@ void partTetMesh::createPolyMesh(polyMeshGen& pmg) const
forAll(internalOrdering, i)
{
const word name = "smoothPoints_" + help::scalarToText(i);
const word name = "smoothPoints_" + Foam::name(i);
const label orderID = pmg.addPointSubset(name);
forAllRow(internalOrdering, i, nI)
......@@ -774,7 +774,7 @@ void partTetMesh::createPolyMesh(polyMeshGen& pmg) const
forAll(boundaryOrdering, i)
{
const word name = "boundaryPoints_" + help::scalarToText(i);
const word name = "boundaryPoints_" + Foam::name(i);
const label orderID = pmg.addPointSubset(name);
forAllRow(boundaryOrdering, i, nI)
......
......@@ -92,7 +92,7 @@ void polyMeshGenCells::calculateOwnersAndNeighbours() const
label nInternalFaces(0);
List<List<LongList<labelPair>> > dataForOtherThreads(nThreads);
List<List<LongList<labelPair>>> dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads) reduction(+ : nInternalFaces)
......
......@@ -176,7 +176,7 @@ void polyMeshGenModifier::addBufferCells()
forAll(procBoundaries, patchI)
{
word subsetName = "processor_";
subsetName += help::scalarToText(procBoundaries[patchI].neiProcNo());
subsetName += Foam::name(procBoundaries[patchI].neiProcNo());
const label subsetID = mesh_.addCellSubset(subsetName);
labelList receivedCells;
......
......@@ -390,9 +390,9 @@ label meshOctreeModifier::markAdditionalLayers
markAdditionalLayersOfFaceNeighbours(markedBoxes, layerI);
# ifdef DEBUGSearch
for (label i = 1; i<(layerI + 1); ++i)
for (label i=1; i <(layerI+1); ++i)
{
const fileName fName("leaves_"+help::labelToText(i)+".vtk");
const fileName fName("leaves_"+Foam::name(i)+".vtk");
writeLeaves(fName, octree_, markedBoxes, i);
}
......
......@@ -785,7 +785,7 @@ void boundaryLayerOptimisation::optimiseHairNormalsAtTheBoundary()
{
writeHairEdges
(
"bndHairVectors_"+help::scalarToText(nIter)+".vtk",
"bndHairVectors_" + Foam::Name(nIter) + ".vtk",
(BOUNDARY | ATEDGE),
hairVecs
);
......@@ -1128,7 +1128,7 @@ void boundaryLayerOptimisation::optimiseHairNormalsInside()
{
writeHairEdges
(
"insideHairVectors_"+help::scalarToText(nIter)+".vtk",
"insideHairVectors_" + Foam::name(nIter) + ".vtk",
INSIDE,
hairVecs
);
......
......@@ -81,7 +81,7 @@ void meshSurfaceOptimizer::calculateTrianglesAndAddressing() const
sMod.patchesAccess()[0].geometricType() = "patch";
fileName sName("bndPointSimplex_");
sName += help::scalarToText(bpI);
sName += Foam::name(bpI);
sName += ".stl";
surf.writeSurface(sName);
}
......
......@@ -171,7 +171,7 @@ inline bool meshSurfaceOptimizer::transformIntoPlane
sMod.patchesAccess()[0].geometricType() = "patch";
fileName sName("bndSimplex_");
sName += help::scalarToText(bpI);
sName += Foam::name(bpI);
sName += ".stl";
surf.writeSurface(sName);
# endif
......
......@@ -434,7 +434,7 @@ void meshSurfaceOptimizer::exchangeData
const VRWGraph& bpAtProcs = surfaceEngine_.bpAtProcs();
const DynList<label>& neiProcs = surfaceEngine_.bpNeiProcs();
std::map<label, LongList<parTriFace> > shareData;
std::map<label, LongList<parTriFace>> shareData;
forAll(neiProcs, procI)
{
const label neiProc = neiProcs[procI];
......
......@@ -173,8 +173,10 @@ void createFundamentalSheetsJFS::createSheetsAtFeatureEdges()
# ifdef DEBUGSheets
labelList patchSheetId(boundaries.size());
forAll(patchSheetId, patchI)
{
patchSheetId[patchI] =
mesh_.addCellSubset("sheetPatch_"+help::labelToText(patchI));
mesh_.addCellSubset("sheetPatch_" + Foam::name(patchI));
}
forAll(patchCell, cellI)
{
......
......@@ -1659,7 +1659,7 @@ bool edgeExtractor::checkFacePatchesTopology()
const triSurf* surfPtr = surfaceWithPatches();
surfPtr->writeSurface
(
"surfaceTopologyIter_"+help::scalarToText(nIter)+".stl"
"surfaceTopologyIter_" + Foam::name(nIter) + ".stl"
);
delete surfPtr;
}
......@@ -2097,7 +2097,7 @@ bool edgeExtractor::checkFacePatchesGeometry()
const triSurf* surfPtr = surfaceWithPatches();
surfPtr->writeSurface
(
"surfaceIter_"+help::scalarToText(iter)+".stl"
"surfaceIter_" + Foam::name(iter) + ".stl"
);
delete surfPtr;
}
......@@ -2432,7 +2432,7 @@ void edgeExtractor::extractEdges()
# ifdef DEBUGEdgeExtractor
Info<< "Changes due to face patches" << endl;
fileName sName("checkFacePatches"+help::scalarToText(nIter)+".stl");
fileName sName("checkFacePatches" + Foam::name(nIter) + ".stl");
sPtr = surfaceWithPatches();
sPtr->writeSurface(sName);
deleteDemandDrivenData(sPtr);
......
......@@ -1247,8 +1247,8 @@ bool edgeExtractor::checkCorners()
surfPtr = surfaceWithPatches(bpI);
surfPtr->writeSurface
(
"corner_"+help::scalarToText(bpI)+
"_iter_"+help::scalarToText(nIteration)+".fms"
"corner_" + Foam::name(bpI)
+ "_iter_" + Foam::name(nIteration) +".fms"
);
deleteDemandDrivenData(surfPtr);
Info<< "Best candidate " << bestPoint << endl;
......@@ -1802,7 +1802,7 @@ bool edgeExtractor::checkCorners()
surfPtr = surfaceWithPatches();
surfPtr->writeSurface
(
"checkCornersAfterIteration_"+help::scalarToText(nIteration)+".fms"
"checkCornersAfterIteration_" + Foam::name(nIteration) + ".fms"
);
deleteDemandDrivenData(surfPtr);
# endif
......
......@@ -261,7 +261,7 @@ label checkSurfaceManifolds
labelList groupIds(nManifolds);
forAll(groupIds, i)
{
const word sName = subsetPrefix + help::scalarToText(i);
const word sName = subsetPrefix + Foam::name(i);
label setId = surf.facetSubsetIndex(sName);
if (setId >= 0)
surf.removeFacetSubset(setId);
......@@ -499,7 +499,7 @@ label checkOrientation(triSurf& surf, const word subsetPrefix)
labelList groupIds(nGroups);
forAll(groupIds, i)
{
const word sName = subsetPrefix + help::scalarToText(i);
const word sName = subsetPrefix + Foam::name(i);
label setId = surf.facetSubsetIndex(sName);
if (setId >= 0)
surf.removeFacetSubset(setId);
......@@ -629,7 +629,7 @@ label checkDisconnectedParts(triSurf& surf, const word subsetPrefix)
labelList groupIds(nGroups);
forAll(groupIds, i)
{
const word sName = subsetPrefix + help::scalarToText(i);
const word sName = subsetPrefix + Foam::name(i);
label setId = surf.facetSubsetIndex(sName);
if (setId >= 0)
surf.removeFacetSubset(setId);
......@@ -858,8 +858,8 @@ label checkSelfIntersections
const label sId =
const_cast<triSurf&>(surf).addFacetSubset
(
"noCommonIntersect_"+help::scalarToText(tI)+
"_"+help::scalarToText(triJ)
"noCommonIntersect_" + Foam::name(tI)
+ "_" + Foam::name(triJ)
);
const_cast<triSurf&>(surf).addFacetToSubset(sId, tI);
const_cast<triSurf&>(surf).addFacetToSubset(sId, triJ);
......@@ -994,8 +994,8 @@ label checkOverlaps
const label sId =
const_cast<triSurf&>(surf).addFacetSubset
(
"noCommonOverlap_"+help::scalarToText(tI)+
"_"+help::scalarToText(triJ)
"noCommonOverlap_" + Foam::name(tI)
+ "_" + Foam::name(triJ)
);
const_cast<triSurf&>(surf).addFacetToSubset(sId, tI);
const_cast<triSurf&>(surf).addFacetToSubset(sId, triJ);
......@@ -1011,8 +1011,8 @@ label checkOverlaps
newSurf.appendTriangle(labelledTri(0, i + 1, i + 2, 0));
newSurf.writeSurface
(
"overlap_"+help::scalarToText(tI)+
"_"+help::scalarToText(triJ)+".fms"
"overlap_" + Foam::name(tI)
+ "_" + Foam::name) + ".fms"
);
# endif
}
......
......@@ -427,9 +427,9 @@ void triSurfaceCurvatureEstimator::calculateSurfaceCurvatures()
OFstream file
(
"point_" +
help::scalarToText(pointI) +
Foam::name(pointI) +
"_region_" +
help::scalarToText(regionI) +
Foam::name(regionI) +
"_triangles.vtk"
);
writeSurfaceToVTK(file, surface_, rTriangles, labels);
......
......@@ -104,7 +104,7 @@ const triSurf* triSurfacePatchManipulator::surfaceWithPatches
{
forAll(newPatches, patchI)
{
newPatches[patchI].name() = prefix + help::scalarToText(patchI);
newPatches[patchI].name() = prefix + Foam::name(patchI);
newPatches[patchI].geometricType() = "patch";
newPatches[patchI].index() = patchI;
}
......@@ -119,7 +119,7 @@ const triSurf* triSurfacePatchManipulator::surfaceWithPatches
surf_[facetsInPatch(patchI, fpI)].region();
newPatches[patchI].name() =
surf_.patches()[origPatchI].name() + '_' +
help::scalarToText(patchI);
Foam::name(patchI);
newPatches[patchI].geometricType() =
surf_.patches()[origPatchI].geometricType();
newPatches[patchI].index() = patchI;
......
......@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
if (args.options().found("nLoops"))
{
nLoops = readLabel(IStringStream(args.options()["nLoops"])());
nLoops = readLabel(args["nLoops"]);
}
else
{
......@@ -65,8 +65,7 @@ int main(int argc, char *argv[])
if (args.options().found("nIterations"))
{
nIterations =
readLabel(IStringStream(args.options()["nIterations"])());
nIterations = readLabel(args["nIterations"]);
}
else
{
......@@ -75,8 +74,7 @@ int main(int argc, char *argv[])
if (args.options().found("nSurfaceIterations"))
{
nSurfaceIterations =
readLabel(IStringStream(args.options()["nSurfaceIterations"])());
nSurfaceIterations = readLabel(args["nSurfaceIterations"]);
}
else
{
......@@ -85,8 +83,7 @@ int main(int argc, char *argv[])
if (args.options().found("qualityThreshold"))
{
qualityThreshold =
readScalar(IStringStream(args.options()["qualityThreshold"])());
qualityThreshold = readScalar(args["qualityThreshold"]);
}
else
{
......
......@@ -31,6 +31,7 @@ Description
#include "helperFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
......@@ -41,7 +42,7 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
const scalar scalingFactor(help::textToScalar(args.args()[1]));
const scalar scalingFactor(readScalar(args[1]));
Info<< "Scaling mesh vertices by a factor " << scalingFactor << endl;
......@@ -58,10 +59,12 @@ int main(int argc, char *argv[])
# pragma omp parallel for schedule(dynamic, 100)
# endif
forAll(pts, pointI)
{
pts[pointI] *= scalingFactor;
}
// write the mesh back on disk
Info<< "Writting scaled mesh" << endl;
//- write the mesh back on disk
Info<< "Writing scaled mesh" << endl;
pmg.write();
Info<< "End\n" << endl;
......
......@@ -31,9 +31,10 @@ Description
#include "fileName.H"
#include "triSurf.H"
#include "triSurfModifier.H"
#include "helperFunctions.H"
#include <sstream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
......@@ -46,9 +47,9 @@ int main(int argc, char *argv[])
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]));
const fileName inFileName(args[1]);
const fileName outFileName(args[2]);
const scalar scalingFactor(readScalar(args[3]));
// read the surface mesh
triSurf surface(inFileName);
......
......@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
scalar tol(45.0);
if (args.options().found("angle"))
{
const scalar ang = readScalar(IStringStream(args.options()["angle"])());
const scalar ang = readScalar(args["angle"]);
tol = ang;
}
else
......
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