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 | Copyright (C) 2011-2015 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 "motionSolver.H"
27 #include "Time.H"
28 #include "polyMesh.H"
29 #include "dlLibraryTable.H"
30 #include "twoDPointCorrector.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(motionSolver, 0);
37  defineRunTimeSelectionTable(motionSolver, dictionary);
38 }
39 
40 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
41 
43 (
44  const IOdictionary& dict
45 )
46 {
47  IOobject io(dict);
48  if (dict.registerObject())
49  {
50  // De-register if necessary
51  const_cast<IOdictionary&>(dict).checkOut();
52 
53  io.registerObject() = true;
54  }
55 
56  return io;
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 :
65  (
66  IOobject
67  (
68  "dynamicMeshDict",
69  mesh.time().constant(),
70  mesh,
71  IOobject::MUST_READ_IF_MODIFIED,
72  IOobject::AUTO_WRITE
73  )
74  ),
75  mesh_(mesh)
76 {}
77 
78 
80 (
81  const polyMesh& mesh,
82  const IOdictionary& dict,
83  const word& type
84 )
85 :
86  IOdictionary(stealRegistration(dict), dict),
87  mesh_(mesh),
88  coeffDict_(dict.subDict(type + "Coeffs"))
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
93 
95 (
96  const polyMesh& mesh,
97  const IOdictionary& solverDict
98 )
99 {
100  const word solverTypeName(solverDict.lookup("solver"));
101 
102  Info<< "Selecting motion solver: " << solverTypeName << endl;
103 
104  const_cast<Time&>(mesh.time()).libs().open
105  (
106  solverDict,
107  "motionSolverLibs",
108  dictionaryConstructorTablePtr_
109  );
110 
111  if (!dictionaryConstructorTablePtr_)
112  {
114  << "solver table is empty"
115  << exit(FatalError);
116  }
117 
118  dictionaryConstructorTable::iterator cstrIter =
119  dictionaryConstructorTablePtr_->find(solverTypeName);
120 
121  if (cstrIter == dictionaryConstructorTablePtr_->end())
122  {
124  << "Unknown solver type "
125  << solverTypeName << nl << nl
126  << "Valid solver types are:" << endl
127  << dictionaryConstructorTablePtr_->sortedToc()
128  << exit(FatalError);
129  }
130 
131  return autoPtr<motionSolver>(cstrIter()(mesh, solverDict));
132 }
133 
134 
136 {
137  IOdictionary solverDict
138  (
139  IOobject
140  (
141  "dynamicMeshDict",
142  mesh.time().constant(),
143  mesh,
146  )
147  );
148 
149  return New(mesh, solverDict);
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 
156 {}
157 
158 
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160 
162 {
163  solve();
164  return curPoints();
165 }
166 
167 
169 {
171 }
172 
173 
175 {}
176 
177 
179 (
183 ) const
184 {
185  return true;
186 }
187 
188 
190 {
191  if (regIOobject::read())
192  {
193  coeffDict_ = subDict(type() + "Coeffs");
194 
195  return true;
196  }
197  else
198  {
199  return false;
200  }
201 }
202 
203 
204 // ************************************************************************* //
Foam::motionSolver::New
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
Definition: motionSolver.C:135
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
motionSolver.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::regIOobject::read
virtual bool read()
Read object.
Definition: regIOobjectRead.C:171
Foam::motionSolver::twoDCorrectPoints
virtual void twoDCorrectPoints(pointField &) const
Definition: motionSolver.C:168
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::motionSolver::motionSolver
motionSolver(const polyMesh &mesh)
Construct from polyMesh.
Definition: motionSolver.C:62
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::MeshObject< polyMesh, UpdateableMeshObject, twoDPointCorrector >::New
static const twoDPointCorrector & New(const polyMesh &mesh)
Definition: MeshObject.C:44
constant
Constant dispersed-phase particle diameter model.
Foam::IOstream::versionNumber
Version number type.
Definition: IOstream.H:96
Foam::IOobject::MUST_READ_IF_MODIFIED
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:109
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::IOobject::registerObject
bool & registerObject()
Register object created from this IOobject with registry if true.
Definition: IOobject.H:303
Foam::motionSolver::read
virtual bool read()
Read dynamicMeshDict dictionary.
Definition: motionSolver.C:189
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::autoPtr< Foam::motionSolver >
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Foam::motionSolver::newPoints
virtual tmp< pointField > newPoints()
Provide new points for motion. Solves for motion.
Definition: motionSolver.C:161
Foam::motionSolver::stealRegistration
static IOobject stealRegistration(const IOdictionary &dict)
De-register object if registered and assign to current.
Definition: motionSolver.C:43
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePaths.H:130
dlLibraryTable.H
Foam::motionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)=0
Update local data for topology changes.
Definition: motionSolver.C:174
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
twoDPointCorrector.H
Foam::twoDPointCorrector::correctPoints
void correctPoints(pointField &p) const
Correct motion points.
Definition: twoDPointCorrector.C:270
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::motionSolver::~motionSolver
virtual ~motionSolver()
Destructor.
Definition: motionSolver.C:155
Foam::motionSolver::writeObject
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write state using given format, version and compression.
Definition: motionSolver.C:179
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86