dynamicMotionSolverListFvMesh.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) 2016 OpenFOAM Foundation
9  Copyright (C) 2019-2021 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 \*---------------------------------------------------------------------------*/
28 
31 #include "motionSolver.H"
32 #include "pointMesh.H"
33 #include "volFields.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(dynamicMotionSolverListFvMesh, 0);
41  (
42  dynamicFvMesh,
43  dynamicMotionSolverListFvMesh,
44  IOobject
45  );
47  (
48  dynamicFvMesh,
49  dynamicMotionSolverListFvMesh,
50  doInit
51  );
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
57 Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh
58 (
59  const IOobject& io,
60  const bool doInit
61 )
62 :
63  dynamicFvMesh(io, doInit),
64  motionSolvers_()
65 {
66  if (doInit)
67  {
68  init(false); // do not initialise lower levels
69  }
70 }
71 
72 
74 {
75  if (doInit)
76  {
77  dynamicFvMesh::init(doInit);
78  }
79 
80  IOobject ioDict
81  (
82  "dynamicMeshDict",
83  time().constant(),
84  *this,
87  false
88  );
89 
90  IOdictionary dict(ioDict);
91 
92  label i = 0;
93  if (dict.found("solvers"))
94  {
95  const dictionary& solvertDict = dict.subDict("solvers");
96 
97  motionSolvers_.setSize(solvertDict.size());
98 
99  for (const entry& dEntry : solvertDict)
100  {
101  if (dEntry.isDict())
102  {
103  IOobject io(ioDict);
106  io.rename(dEntry.dict().dictName());
107 
108  IOdictionary IOsolverDict
109  (
110  io,
111  dEntry.dict()
112  );
113 
114  motionSolvers_.set
115  (
116  i++,
117  motionSolver::New(*this, IOsolverDict)
118  );
119  }
120  }
121  motionSolvers_.setSize(i);
122  }
123  else
124  {
125  motionSolvers_.setSize(1);
126  motionSolvers_.set(i++, motionSolver::New(*this));
127  }
128 
129  // Assume something changed
130  return true;
131 }
132 
133 
134 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135 
137 {}
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
143 {
144  if (motionSolvers_.size())
145  {
146  // Accumulated displacement
147  pointField disp(motionSolvers_[0].newPoints() - fvMesh::points());
148 
149  for (label i = 1; i < motionSolvers_.size(); i++)
150  {
151  disp += motionSolvers_[i].newPoints() - fvMesh::points();
152  }
153 
154  fvMesh::movePoints(points() + disp);
155 
156  volVectorField* Uptr = getObjectPtr<volVectorField>("U");
157 
158  if (Uptr)
159  {
161  }
162  }
163 
164  return true;
165 }
166 
167 
168 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::motionSolver::New
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
Definition: motionSolver.C:150
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
motionSolver.H
Foam::dynamicFvMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: dynamicFvMesh.C:90
Foam::dynamicFvMesh
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:78
Foam::IOobject::writeOpt
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
Foam::dynamicMotionSolverListFvMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: dynamicMotionSolverListFvMesh.C:73
dynamicMotionSolverListFvMesh.H
Foam::Field< vector >
init
mesh init(true)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::surfaceInterpolation::movePoints
virtual bool movePoints()
Do what is necessary if the mesh has moved.
Definition: surfaceInterpolation.C:151
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobject::rename
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:506
Foam::IOobject::readOpt
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::dynamicMotionSolverListFvMesh::update
virtual bool update()
Dummy update function which does not change the mesh.
Definition: dynamicMotionSolverListFvMesh.C:142
Foam::dynamicMotionSolverListFvMesh::~dynamicMotionSolverListFvMesh
~dynamicMotionSolverListFvMesh()
Destructor.
Definition: dynamicMotionSolverListFvMesh.C:136
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
constant
constant condensation/saturation model.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
pointMesh.H
Foam::IOobject::MUST_READ
Definition: IOobject.H:185