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-2021 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("motionSolvers"))
68  {
69  return autoPtr<motionSolver>(new motionSolverList(mesh, solverDict));
70  }
71  else
72  {
73  const word solverTypeName = solverDict.lookup<word>("motionSolver");
74 
75  Info<< "Selecting motion solver: " << solverTypeName << endl;
76 
77  libs.open
78  (
79  solverDict,
80  "motionSolverLibs",
81  dictionaryConstructorTablePtr_
82  );
83 
84  if (!dictionaryConstructorTablePtr_)
85  {
87  << "solver table is empty"
88  << exit(FatalError);
89  }
90 
91  dictionaryConstructorTable::iterator cstrIter =
92  dictionaryConstructorTablePtr_->find(solverTypeName);
93 
94  if (cstrIter == dictionaryConstructorTablePtr_->end())
95  {
97  << "Unknown solver type "
98  << solverTypeName << nl << nl
99  << "Valid solver types are:" << endl
100  << dictionaryConstructorTablePtr_->sortedToc()
101  << exit(FatalError);
102  }
103 
104  return autoPtr<motionSolver>(cstrIter()(mesh, solverDict));
105  }
106 }
107 
108 
110 :
111  mesh_(mesh)
112 {}
113 
114 
115 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::iNew::operator()
116 (
117  Istream& is
118 ) const
119 {
121 
122  return motionSolver::New(mesh_, dict);
123 }
124 
125 
126 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
127 
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 {
136  solve();
137  return curPoints();
138 }
139 
140 
142 {
144 }
145 
146 
148 {}
149 
150 
152 {
153  return true;
154 }
155 
156 
157 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
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:134
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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:151
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
void correctPoints(pointField &p) const
Correct motion points.
virtual void updateMesh(const mapPolyMesh &)=0
Update local data for topology changes.
Definition: motionSolver.C:147
dynamicFvMesh & mesh
iNew(const polyMesh &mesh)
Definition: motionSolver.C:109
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1040
A class for handling words, derived from string.
Definition: word.H:59
virtual ~motionSolver()
Destructor.
Definition: motionSolver.C:128
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
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:370
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:141
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844