flattenMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  flattenMesh
26 
27 Description
28  Flattens the front and back planes of a 2D cartesian mesh.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "argList.H"
33 #include "Time.H"
34 #include "polyMesh.H"
35 #include "emptyPolyPatch.H"
36 #include "twoDPointCorrector.H"
37 
38 using namespace Foam;
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 int main(int argc, char *argv[])
43 {
44  #include "setRootCase.H"
45  #include "createTime.H"
46  #include "createPolyMesh.H"
47 
49  (
50  IOobject
51  (
52  "points",
53  runTime.findInstance(polyMesh::meshSubDir, "points"),
55  runTime,
58  false
59  )
60  );
61 
62  boundBox bb(points);
63 
64  Info<< "bounding box: min = " << bb.min()
65  << " max = " << bb.max() << " meters."
66  << endl;
67 
68 
70 
71  const twoDPointCorrector& twoDCorr
72  (
74  );
75 
76  direction planeNormalCmpt = twoDCorr.normalDir();
77 
78  scalar midCmptVal = midPoint[planeNormalCmpt];
79  scalar minCmptVal = bb.min()[planeNormalCmpt];
80  scalar maxCmptVal = bb.max()[planeNormalCmpt];
81 
82  forAll(points, pointi)
83  {
84  if (points[pointi][planeNormalCmpt] < midCmptVal)
85  {
86  points[pointi][planeNormalCmpt] = minCmptVal;
87  }
88  else
89  {
90  points[pointi][planeNormalCmpt] = maxCmptVal;
91  }
92  }
93 
94  twoDCorr.correctPoints(points);
95 
96  // Set the precision of the points data to 10
98 
99  Info<< "Writing points into directory " << points.path() << nl << endl;
100  points.write();
101 
102  Info<< "End\n" << endl;
103 
104  return 0;
105 }
106 
107 
108 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:458
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
Mid-point interpolation (weighting factors = 0.5) scheme class.
Definition: midPoint.H:53
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:271
Class applies a two-dimensional correction to mesh motion point field.
int main(int argc, char *argv[])
Definition: financialFoam.C:44
const pointField & points
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Type gAverage(const FieldField< Field, Type > &f)
static const char nl
Definition: Ostream.H:260
uint8_t direction
Definition: direction.H:45