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-2024 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 "polyMesh.H"
28 #include "dictionaryEntry.H"
29 #include "twoDPointCorrector.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const word& name,
45  const polyMesh& mesh,
46  const word& type
47 )
48 :
49  name_(name),
50  mesh_(mesh)
51 {}
52 
53 
55 {
57  return autoPtr<motionSolver>(nullptr);
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
62 
64 (
65  const word& name,
66  const polyMesh& mesh,
67  const dictionary& solverDict
68 )
69 {
70  const word solverTypeName = solverDict.lookup<word>("motionSolver");
71 
72  Info<< "Selecting motion solver: " << solverTypeName << endl;
73 
74  libs.open
75  (
76  solverDict,
77  "motionSolverLibs",
78  dictionaryConstructorTablePtr_
79  );
80 
81  if (!dictionaryConstructorTablePtr_)
82  {
83  FatalIOErrorInFunction(solverDict)
84  << "solver table is empty"
85  << exit(FatalIOError);
86  }
87 
88  dictionaryConstructorTable::iterator cstrIter =
89  dictionaryConstructorTablePtr_->find(solverTypeName);
90 
91  if (cstrIter == dictionaryConstructorTablePtr_->end())
92  {
93  FatalIOErrorInFunction(solverDict)
94  << "Unknown solver type "
95  << solverTypeName << nl << nl
96  << "Valid solver types are:" << endl
97  << dictionaryConstructorTablePtr_->sortedToc()
98  << exit(FatalIOError);
99  }
100 
101  return autoPtr<motionSolver>
102  (
103  cstrIter()
104  (
105  name,
106  mesh,
107  solverDict.optionalSubDict(solverTypeName + "Coeffs")
108  )
109  );
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
114 
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 {
123  solve();
124  return curPoints();
125 }
126 
127 
129 {
131 }
132 
133 
135 {
136  return true;
137 }
138 
139 
140 // ************************************************************************* //
static twoDPointCorrector & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:740
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:927
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
Virtual base class for mesh motion solver.
Definition: motionSolver.H:57
virtual ~motionSolver()
Destructor.
Definition: motionSolver.C:115
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:121
motionSolver(const word &name, const polyMesh &mesh, const word &type)
Construct from polyMesh and dictionary and type.
Definition: motionSolver.C:43
virtual void twoDCorrectPoints(pointField &) const
Correct point field for reduced-dimensionality cases.
Definition: motionSolver.C:128
static autoPtr< motionSolver > New(const word &name, const polyMesh &, const dictionary &)
Select constructed from polyMesh and dictionary.
Definition: motionSolver.C:64
virtual bool write() const
Optionally write motion state information for restart.
Definition: motionSolver.C:134
virtual autoPtr< motionSolver > clone() const
Clone function.
Definition: motionSolver.C:54
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for managing temporary objects.
Definition: tmp.H:55
void correctPoints(pointField &p) const
Correct motion points.
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dlLibraryTable libs
Table of loaded dynamic libraries.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
defineTypeNameAndDebug(combustionModel, 0)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
static const char nl
Definition: Ostream.H:267
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
volScalarField & p