scaleMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  Scales the mesh into other units.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "argList.H"
30 #include "polyMeshGen.H"
31 #include "helperFunctions.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // Main program:
35 using namespace Foam;
36 
37 int main(int argc, char *argv[])
38 {
39  argList::validArgs.append("scalingFactor");
40 
41 # include "setRootCase.H"
42 # include "createTime.H"
43 
44  const scalar scalingFactor(help::textToScalar(args.args()[1]));
45 
46  Info << "Scaling mesh vertices by a factor " << scalingFactor << endl;
47 
48  //- read the mesh from disk
49  polyMeshGen pmg(runTime);
50 
51  Info << "Reading mesh" << endl;
52  pmg.read();
53 
54  //- scale the points
55  pointFieldPMG& pts = pmg.points();
56 
57  # ifdef USE_OMP
58  # pragma omp parallel for schedule(dynamic, 100)
59  # endif
60  forAll(pts, pointI)
61  pts[pointI] *= scalingFactor;
62 
63  //- write the mesh back on disk
64  Info << "Writting scaled mesh" << endl;
65  pmg.write();
66 
67  Info << "End\n" << endl;
68 
69  return 0;
70 }
71 
72 
73 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:143
Foam::help::textToScalar
scalar textToScalar(const word &w)
convert the text to scalar
Definition: helperFunctionsStringConversion.C:45
Foam::argList::args
const stringList & args() const
Return arguments.
Definition: argListI.H:66
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyMeshGenPoints::points
const pointFieldPMG & points() const
access to points
Definition: polyMeshGenPointsI.H:44
Foam::polyMeshGen::read
void read()
Definition: polyMeshGen.C:121
Foam::Info
messageStream Info
polyMeshGen.H
argList.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
setRootCase.H
helperFunctions.H
Foam::polyMeshGen::write
void write() const
Definition: polyMeshGen.C:126
createTime.H
main
int main(int argc, char *argv[])
Definition: scaleMesh.C:37
args
Foam::argList args(argc, argv)
Foam::pointFieldPMG
Definition: pointFieldPMG.H:50