flattenMesh.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Application
27 flattenMesh
28
29Group
30 grpMeshManipulationUtilities
31
32Description
33 Flattens the front and back planes of a 2D cartesian mesh.
34
35\*---------------------------------------------------------------------------*/
36
37#include "argList.H"
38#include "Time.H"
39#include "polyMesh.H"
40#include "emptyPolyPatch.H"
41#include "twoDPointCorrector.H"
42
43using namespace Foam;
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47int main(int argc, char *argv[])
48{
49 argList::addNote
50 (
51 "Flattens the front and back planes of a 2D cartesian mesh"
52 );
53
54 #include "setRootCase.H"
55 #include "createTime.H"
56 #include "createPolyMesh.H"
57
59 (
61 (
62 "points",
63 runTime.findInstance(polyMesh::meshSubDir, "points"),
64 polyMesh::meshSubDir,
65 runTime,
66 IOobject::MUST_READ,
67 IOobject::NO_WRITE,
68 false
69 )
70 );
71
72 boundBox bb(points);
73
74 Info<< "bounding box: min = " << bb.min()
75 << " max = " << bb.max() << " metres."
76 << endl;
77
78
80
81 twoDPointCorrector twoDCorr(mesh);
82
83 direction planeNormalCmpt = twoDCorr.normalDir();
84
85 scalar midCmptVal = midPoint[planeNormalCmpt];
86 scalar minCmptVal = bb.min()[planeNormalCmpt];
87 scalar maxCmptVal = bb.max()[planeNormalCmpt];
88
89 forAll(points, pointi)
90 {
91 if (points[pointi][planeNormalCmpt] < midCmptVal)
92 {
93 points[pointi][planeNormalCmpt] = minCmptVal;
94 }
95 else
96 {
97 points[pointi][planeNormalCmpt] = maxCmptVal;
98 }
99 }
100
101 twoDCorr.correctPoints(points);
102
103 // Set the precision of the points data to 10
104 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
105
106 Info<< "Writing points into directory " << points.path() << nl << endl;
107 points.write();
108
109 Info<< nl << "End" << nl << endl;
110
111 return 0;
112}
113
114
115// ************************************************************************* //
Y[inertIndex] max(0.0)
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
Mid-point interpolation (weighting factors = 0.5) scheme class.
Definition: midPoint.H:58
Class applies a two-dimensional correction to mesh motion point field.
dynamicFvMesh & mesh
engineTime & runTime
Required Variables.
const pointField & points
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
uint8_t direction
Definition: direction.H:56
Type gAverage(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333