motionSolver.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-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
29#include "motionSolver.H"
30#include "Time.H"
31#include "polyMesh.H"
32#include "dictionaryEntry.H"
33#include "dlLibraryTable.H"
34#include "twoDPointCorrector.H"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
42}
43
44// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
45
47(
48 const IOdictionary& dict
49)
50{
52 if (dict.registerObject())
53 {
54 // De-register if necessary
55 const_cast<IOdictionary&>(dict).checkOut();
56 }
57 io.registerObject(true);
58
59 return io;
60}
61
62
63// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64
66:
68 (
70 (
71 "dynamicMeshDict",
72 mesh.time().constant(),
73 mesh,
74 IOobject::MUST_READ_IF_MODIFIED,
75 IOobject::AUTO_WRITE
76 )
77 ),
78 mesh_(mesh)
79{}
80
81
83(
84 const polyMesh& mesh,
85 const IOdictionary& dict,
86 const word& type
87)
88:
89 IOdictionary(stealRegistration(dict), dict),
90 mesh_(mesh),
91 coeffDict_(dict.optionalSubDict(type + "Coeffs"))
92{}
93
94
96{
98 return nullptr;
99}
100
101
102// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
103
105(
106 const polyMesh& mesh,
107 const IOdictionary& solverDict
108)
109{
110 // The change from "solver" to "motionSolver" has not been
111 // applied consistently. Accept both without complaint.
112 const word solverName
113 (
114 solverDict.getCompat<word>("motionSolver", {{"solver", -1612}})
115 );
116
117 Info<< "Selecting motion solver: " << solverName << nl;
118
119 mesh.time().libs().open
120 (
121 solverDict,
122 "motionSolverLibs",
123 dictionaryConstructorTablePtr_
124 );
125
126 if (!dictionaryConstructorTablePtr_)
127 {
129 << "solver table is empty"
130 << exit(FatalError);
131 }
132
133 auto* ctorPtr = dictionaryConstructorTable(solverName);
134
135 if (!ctorPtr)
136 {
138 (
139 solverDict,
140 "solver",
141 solverName,
142 *dictionaryConstructorTablePtr_
143 ) << exit(FatalIOError);
144 }
145
146 return autoPtr<motionSolver>(ctorPtr(mesh, solverDict));
147}
148
149
151{
152 IOdictionary solverDict
153 (
155 (
156 "dynamicMeshDict",
157 mesh.time().constant(),
158 mesh,
161 )
162 );
163
164 return New(mesh, solverDict);
165}
166
167
169:
170 mesh_(mesh)
171{}
172
173
175(
176 Istream& is
177) const
178{
179 dictionaryEntry dictEntry(dictionary::null, is);
180
181 return motionSolver::New
182 (
183 mesh_,
185 (
187 (
188 dictEntry.name() + ":meshSolver",
189 mesh_.time().constant(),
190 mesh_
191 ),
192 dictEntry
193 )
194 );
195}
196
197
198// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
199
201{
202 solve();
203 return curPoints();
204}
205
206
208{
209 twoDPointCorrector::New(mesh_).correctPoints(p);
210}
211
212
214{}
215
216
218(
220 const bool valid
221) const
222{
223 return true;
224}
225
226
228{
229 if (regIOobject::read())
230 {
231 coeffDict_ = optionalSubDict(type() + "Coeffs");
232
233 return true;
234 }
235
236 return false;
237}
238
239
240// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool registerObject() const noexcept
Should object created with this IOobject be registered?
Definition: IOobjectI.H:107
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
The IOstreamOption is a simple container for options an IOstream can normally have.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: Time.H:510
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A keyword and a list of tokens is a 'dictionaryEntry'.
virtual const fileName & name() const
Return the scoped dictionary name (eg, dictA.dictB.dictC)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:577
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
bool open(bool verbose=true)
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
void updateMesh()
Update for new mesh topology.
Class used for the construction of PtrLists of motionSolvers.
Definition: motionSolver.H:108
Virtual base class for mesh motion solver.
Definition: motionSolver.H:61
static IOobject stealRegistration(const IOdictionary &dict)
De-register object if registered and assign to current.
Definition: motionSolver.C:47
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:200
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write state using stream options.
Definition: motionSolver.C:218
virtual tmp< pointField > curPoints() const =0
Provide current points for motion. Uses current motion field.
virtual void solve()=0
Solve for motion.
virtual void twoDCorrectPoints(pointField &) const
Definition: motionSolver.C:207
virtual autoPtr< motionSolver > clone() const
Clone function.
Definition: motionSolver.C:95
virtual bool read()
Read dynamicMeshDict dictionary.
Definition: motionSolver.C:227
const Time & time() const noexcept
Return time registry.
constant condensation/saturation model.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
bool checkOut()
Remove all file watches and remove object from registry.
Definition: regIOobject.C:224
virtual bool read()
Read object.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
IOerror FatalIOError
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict