Loading...
Searching...
No Matches
deformedGeom.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 deformedGeom
28
29Group
30 grpMeshManipulationUtilities
31
32Description
33 Deforms a polyMesh using a displacement field U and a scaling factor
34 supplied as an argument.
35
36\*---------------------------------------------------------------------------*/
37
38#include "argList.H"
39#include "fvMesh.H"
40#include "pointFields.H"
42
43using namespace Foam;
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47int main(int argc, char *argv[])
48{
50 (
51 "Deforms a polyMesh using a displacement field U and a scaling factor"
52 " supplied as an argument"
53 );
54
55 argList::addArgument("factor", "The deformation scaling factor");
56
57 #include "setRootCase.H"
58
59 const scalar scaleFactor = args.get<scalar>(1);
60
61 #include "createTime.H"
62 #include "createNamedMesh.H"
63
65
66 // Get times list
67 instantList Times = runTime.times();
68
69 pointField zeroPoints(mesh.points());
70
71 // skip "constant" time
72 for (label timeI = 1; timeI < Times.size(); ++timeI)
73 {
74 runTime.setTime(Times[timeI], timeI);
75
76 Info<< "Time = " << runTime.timeName() << endl;
77
78 IOobject Uheader
79 (
80 "U",
81 runTime.timeName(),
82 mesh,
84 );
85
86 // Check U exists
87 if (Uheader.typeHeaderOk<volVectorField>(true))
88 {
89 Info<< " Reading U" << endl;
90 volVectorField U(Uheader, mesh);
91
92 pointField newPoints
93 (
94 zeroPoints
95 + scaleFactor*pInterp.interpolate(U)().primitiveField()
96 );
97
98 mesh.polyMesh::movePoints(newPoints);
99 mesh.write();
100 }
101 else
102 {
103 Info<< " No U" << endl;
104 }
105
106 Info<< endl;
107 }
108
109 Info<< "End\n" << endl;
110
111 return 0;
112}
113
114
115// ************************************************************************* //
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition argList.C:366
static void addNote(const string &note)
Add extra notes for the usage information.
Definition argList.C:477
Interpolate from cell centres to points (vertices) using inverse distance weighting.
U
Definition pEqn.H:72
dynamicFvMesh & mesh
engineTime & runTime
Required Classes.
autoPtr< volPointInterpolation > pInterp
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Definition instantList.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
vectorField pointField
pointField is a vectorField.
Foam::argList args(argc, argv)