deformedGeom.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-2024 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  deformedGeom
26 
27 Description
28  Deforms a polyMesh using a displacement field U and a scaling factor
29  supplied as an argument.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "argList.H"
34 #include "fvMesh.H"
35 #include "pointFields.H"
36 #include "IStringStream.H"
37 #include "volPointInterpolation.H"
38 
39 using namespace Foam;
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
45  #include "addMeshOption.H"
46  #include "addRegionOption.H"
47  argList::validArgs.append("scaling factor");
48 
49  #include "setRootCase.H"
50 
51  const scalar scaleFactor = args.argRead<scalar>(1);
52 
53  #include "createTime.H"
55 
57 
58  // Get times list
59  instantList Times = runTime.times();
60 
61  pointField zeroPoints(mesh.points());
62 
63  // skip "constant" time
64  for (label timeI = 1; timeI < Times.size(); ++timeI)
65  {
66  runTime.setTime(Times[timeI], timeI);
67 
68  Info<< "Time = " << runTime.userTimeName() << endl;
69 
71  (
72  "U",
73  runTime.name(),
74  mesh,
76  );
77 
78  // Check U exists
79  if (Uheader.headerOk())
80  {
81  Info<< " Reading U" << endl;
82  volVectorField U(Uheader, mesh);
83 
84  pointField newPoints
85  (
86  zeroPoints
87  + scaleFactor*pInterp.interpolate(U)().primitiveField()
88  );
89 
90  mesh.setPoints(newPoints);
91  mesh.write();
92  }
93  else
94  {
95  Info<< " No U" << endl;
96  }
97 
98  Info<< endl;
99  }
100 
101  Info<< "End\n" << endl;
102 
103  return 0;
104 }
105 
106 
107 // ************************************************************************* //
static volPointInterpolation & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
T argRead(const label index) const
Read a value from the argument at index.
Definition: argListI.H:234
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1785
virtual void setPoints(const pointField &)
Reset the points.
Definition: fvMesh.C:1228
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:530
Interpolate from cell centres to points (vertices) using inverse distance weighting.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
int main(int argc, char *argv[])
Definition: financialFoam.C:44
U
Definition: pEqn.H:72
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
Foam::argList args(argc, argv)