motionSolver.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-2020 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 \*---------------------------------------------------------------------------*/
25 
26 #include "motionSolverList.H"
27 #include "twoDPointCorrector.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(motionSolver, 0);
34  defineRunTimeSelectionTable(motionSolver, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const polyMesh& mesh,
43  const dictionary& dict,
44  const word& type
45 )
46 :
47  mesh_(mesh),
48  coeffDict_(dict.optionalSubDict(type + "Coeffs"))
49 {}
50 
51 
53 {
55  return autoPtr<motionSolver>(nullptr);
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
60 
62 (
63  const polyMesh& mesh,
64  const dictionary& solverDict
65 )
66 {
67  if (solverDict.found("solvers"))
68  {
69  return autoPtr<motionSolver>(new motionSolverList(mesh, solverDict));
70  }
71  else
72  {
73  const word solverTypeName
74  (
75  solverDict.found("motionSolver")
76  ? solverDict.lookup("motionSolver")
77  : solverDict.lookup("solver")
78  );
79 
80  Info<< "Selecting motion solver: " << solverTypeName << endl;
81 
82  libs.open
83  (
84  solverDict,
85  "motionSolverLibs",
86  dictionaryConstructorTablePtr_
87  );
88 
89  if (!dictionaryConstructorTablePtr_)
90  {
92  << "solver table is empty"
93  << exit(FatalError);
94  }
95 
96  dictionaryConstructorTable::iterator cstrIter =
97  dictionaryConstructorTablePtr_->find(solverTypeName);
98 
99  if (cstrIter == dictionaryConstructorTablePtr_->end())
100  {
102  << "Unknown solver type "
103  << solverTypeName << nl << nl
104  << "Valid solver types are:" << endl
105  << dictionaryConstructorTablePtr_->sortedToc()
106  << exit(FatalError);
107  }
108 
109  return autoPtr<motionSolver>(cstrIter()(mesh, solverDict));
110  }
111 }
112 
113 
115 :
116  mesh_(mesh)
117 {}
118 
119 
120 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::iNew::operator()
121 (
122  Istream& is
123 ) const
124 {
126 
127  return motionSolver::New(mesh_, dict);
128 }
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
140 {
141  solve();
142  return curPoints();
143 }
144 
145 
147 {
149 }
150 
151 
153 {}
154 
155 
157 {
158  return true;
159 }
160 
161 
162 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:139
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static const dictionary null
Null dictionary.
Definition: dictionary.H:241
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual bool write() const
Optionally write motion state information for restart.
Definition: motionSolver.C:156
static autoPtr< motionSolver > New(const polyMesh &, const dictionary &)
Select constructed from polyMesh and dictionary.
Definition: motionSolver.C:62
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
Motion of the mesh specified as a list of motion solvers.
dlLibraryTable libs
Table of loaded dynamic libraries.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static const twoDPointCorrector & New(const polyMesh &mesh)
Definition: MeshObject.C:44
void correctPoints(pointField &p) const
Correct motion points.
virtual void updateMesh(const mapPolyMesh &)=0
Update local data for topology changes.
Definition: motionSolver.C:152
dynamicFvMesh & mesh
iNew(const polyMesh &mesh)
Definition: motionSolver.C:114
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1001
A class for handling words, derived from string.
Definition: word.H:59
virtual ~motionSolver()
Destructor.
Definition: motionSolver.C:133
virtual void solve()=0
Solve for motion.
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
virtual tmp< pointField > curPoints() const =0
Provide current points for motion. Uses current motion field.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
virtual autoPtr< motionSolver > clone() const
Clone function.
Definition: motionSolver.C:52
motionSolver(const polyMesh &mesh, const dictionary &, const word &type)
Construct from polyMesh and dictionary and type.
Definition: motionSolver.C:41
virtual void twoDCorrectPoints(pointField &) const
Definition: motionSolver.C:146
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812