Loading...
Searching...
No Matches
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"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
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);
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,
76 )
77 ),
78 mesh_(mesh)
79{}
80
81
83(
84 const polyMesh& mesh,
85 const IOdictionary& dict,
86 const word& type
87)
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_
144 }
145
146 return autoPtr<motionSolver>(ctorPtr(mesh, solverDict));
147}
148
149
151{
152 IOdictionary solverDict
153 (
154 IOobject
155 (
156 "dynamicMeshDict",
157 mesh.time().constant(),
158 mesh,
162 );
163
164 return New(mesh, solverDict);
165}
166
169:
170 mesh_(mesh)
171{}
172
173
174Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::iNew::operator()
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
194 );
195}
196
197
198// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
199
204}
205
208{
211
212
214{}
215
216
218(
219 IOstreamOption,
220 const bool writeOnProc
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...
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
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:60
static FOAM_NO_DANGLING_REFERENCE const twoDPointCorrector & New(const polyMesh &mesh, Args &&... args)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
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:133
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:560
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T using any compatibility names if needed. FatalIOError if not found,...
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
iNew(const polyMesh &mesh)
Virtual base class for mesh motion solver.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write state using stream options.
virtual void updateMesh(const mapPolyMesh &)=0
Update local data for topology changes.
static IOobject stealRegistration(const IOdictionary &dict)
De-register object if registered and assign to current.
const polyMesh & mesh() const
Return reference to mesh.
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
motionSolver(const polyMesh &mesh)
Construct from polyMesh.
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
virtual autoPtr< motionSolver > clone() const
Clone function.
virtual bool read()
Read dynamicMeshDict dictionary.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
bool checkOut()
Remove object from registry, and remove all file watches.
virtual bool read()
Read object.
A class for managing temporary objects.
Definition tmp.H:75
void correctPoints(pointField &p) const
Correct motion points.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
const auto & io
Different types of constants.
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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 POSIX.C:801
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict