moveMesh.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-2015 OpenFOAM Foundation
9  Copyright (C) 2020-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  moveMesh
29 
30 Group
31  grpMeshManipulationUtilities
32 
33 Description
34  A solver utility for moving meshes.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "Time.H"
40 #include "fvMesh.H"
41 #include "motionSolver.H"
42 
43 using namespace Foam;
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 int main(int argc, char *argv[])
48 {
50  (
51  "A solver utility for moving meshes"
52  );
53 
55  (
56  "deltaT",
57  "time",
58  "Override deltaT (eg, for accelerated motion)"
59  );
60 
62  (
63  "endTime",
64  "time",
65  "Override endTime (eg, for shorter tests)"
66  );
67 
68  #include "setRootCase.H"
69  #include "createTime.H"
70  #include "createNamedMesh.H"
71 
72  scalar timeVal = 0;
73  if (args.readIfPresent("deltaT", timeVal))
74  {
75  runTime.setDeltaT(timeVal);
76  }
77 
78  if (args.readIfPresent("endTime", timeVal))
79  {
80  runTime.stopAt(Time::stopAtControls::saEndTime);
81  runTime.setEndTime(timeVal);
82  }
83 
85 
86  while (runTime.loop())
87  {
88  Info<< "Time = " << runTime.timeName() << endl;
89 
90  mesh.movePoints(motionPtr->newPoints());
91 
92  runTime.write();
93 
95  }
96 
97  Info<< "End\n" << endl;
98 
99  return 0;
100 }
101 
102 
103 // ************************************************************************* //
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:193
virtual stopAtControls stopAt() const
Return the stop control information.
Definition: Time.C:768
virtual void setEndTime(const dimensionedScalar &endTime)
Reset end time.
Definition: Time.C:952
virtual bool loop()
Return true if run should continue and if so increment time.
Definition: Time.C:856
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: fvMesh.C:929
Required Classes.
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
Definition: motionSolver.C:143
dynamicFvMesh & mesh
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition: Time.C:714
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:607
virtual void setDeltaT(const dimensionedScalar &deltaT, const bool adjust=true)
Reset time step, normally also calling adjustDeltaT()
Definition: Time.C:965
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
Foam::argList args(argc, argv)
Namespace for OpenFOAM.