All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
moveMesh.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  moveMesh
26 
27 Description
28  Mesh motion and topological mesh change utility.
29 
30  Executes the mover, topoChanger and distributor specified in the
31  dynamicMeshDict in a time-loop.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #include "argList.H"
36 #include "Time.H"
37 #include "fvMesh.H"
38 #include "pimpleControl.H"
39 #include "vtkSurfaceWriter.H"
40 #include "cyclicAMIPolyPatch.H"
41 #include "PatchTools.H"
42 #include "checkGeometry.H"
43 
44 using namespace Foam;
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
50  #include "addRegionOption.H"
52  (
53  "checkAMI",
54  "check AMI weights"
55  );
56 
57  #include "setRootCase.H"
58  #include "createTime.H"
59 
61 
62  if (args.optionReadIfPresent("region", regionName))
63  {
65  << "Create mesh " << regionName << " for time = "
66  << runTime.timeName() << Foam::nl << Foam::endl;
67  }
68  else
69  {
70  regionName = Foam::fvMesh::defaultRegion;
72  << "Create mesh for time = "
73  << runTime.timeName() << Foam::nl << Foam::endl;
74  }
75 
77  (
79  (
80  regionName,
81  runTime.timeName(),
82  runTime,
84  )
85  );
86 
87  const bool checkAMI = args.optionFound("checkAMI");
88 
89  if (checkAMI)
90  {
91  Info<< "Writing VTK files with weights of AMI patches." << nl << endl;
92  }
93 
95 
97  (
98  pimple.dict().lookupOrDefault<Switch>("moveMeshOuterCorrectors", false)
99  );
100 
101  while (runTime.run())
102  {
103  // Update the mesh for topology change, mesh to mesh mapping
104  mesh.update();
105 
106  runTime++;
107 
108  Info<< "Time = " << runTime.userTimeName() << endl;
109 
110  while (pimple.loop())
111  {
112  if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
113  {
114  // Move the mesh
115  mesh.move();
116  }
117  }
118 
119  mesh.checkMesh(true);
120 
121  if (checkAMI)
122  {
124  }
125 
126  runTime.write();
127 
128  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
129  << " ClockTime = " << runTime.elapsedClockTime() << " s"
130  << nl << endl;
131  }
132 
133  Info<< "End\n" << endl;
134 
135  return 0;
136 }
137 
138 
139 // ************************************************************************* //
bool update()
Update the mesh for topology change, mesh to mesh mapping.
Definition: fvMesh.C:584
Foam::word regionName
pimpleNoLoopControl & pimple
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:325
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
fvMesh & mesh
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:204
A class for handling words, derived from string.
Definition: word.H:59
virtual const dictionary & dict() const
Return the solution dictionary.
virtual bool checkMesh(const bool report=false) const
Check mesh for correctness. Returns false for no error.
bool move()
Move the mesh.
Definition: fvMesh.C:625
static const char nl
Definition: Ostream.H:260
moveMeshOuterCorrectors
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Pimple control class. Provides time-loop control methods which exit the simulation once convergence c...
Definition: pimpleControl.H:74
void writeAMIWeightsSums(const polyMesh &)
Write out the weights-sums on all the AMI patches.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
bool loop(Time &time)
Time loop loop.
Definition: pisoControl.C:107
messageStream Info
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:118
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Namespace for OpenFOAM.