OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

motionSolver.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "motionSolver.H"
00028 #include "Time.H"
00029 #include "polyMesh.H"
00030 #include "dlLibraryTable.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036     defineTypeNameAndDebug(motionSolver, 0);
00037     defineRunTimeSelectionTable(motionSolver, dictionary);
00038 }
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::motionSolver::motionSolver(const polyMesh& mesh)
00043 :
00044     IOdictionary
00045     (
00046         IOobject
00047         (
00048             "dynamicMeshDict",
00049             mesh.time().constant(),
00050             mesh,
00051             IOobject::MUST_READ,
00052             IOobject::NO_WRITE
00053         )
00054     ),
00055     mesh_(mesh),
00056     twoDPointCorrector_(mesh)
00057 {}
00058 
00059 
00060 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00061 
00062 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
00063 {
00064     IOdictionary solverDict
00065     (
00066         IOobject
00067         (
00068             "dynamicMeshDict",
00069             mesh.time().constant(),
00070             mesh,
00071             IOobject::MUST_READ,
00072             IOobject::NO_WRITE,
00073             false
00074         )
00075     );
00076 
00077     Istream& msData = solverDict.lookup("solver");
00078 
00079     word solverTypeName(msData);
00080 
00081     Info << "Selecting motion solver: " << solverTypeName << endl;
00082 
00083     dlLibraryTable::open
00084     (
00085         solverDict,
00086         "motionSolverLibs",
00087         dictionaryConstructorTablePtr_
00088     );
00089 
00090     if (!dictionaryConstructorTablePtr_)
00091     {
00092         FatalErrorIn
00093         (
00094             "motionSolver::New(const polyMesh& mesh)"
00095         )   << "solver table is empty"
00096             << exit(FatalError);
00097     }
00098 
00099     dictionaryConstructorTable::iterator cstrIter =
00100         dictionaryConstructorTablePtr_->find(solverTypeName);
00101 
00102     if (cstrIter == dictionaryConstructorTablePtr_->end())
00103     {
00104         FatalErrorIn
00105         (
00106             "motionSolver::New(const polyMesh& mesh)"
00107         )   << "Unknown solver type " << solverTypeName
00108             << endl << endl
00109             << "Valid solver types are: " << endl
00110             << dictionaryConstructorTablePtr_->toc()
00111             << exit(FatalError);
00112     }
00113 
00114     return autoPtr<motionSolver>(cstrIter()(mesh, msData));
00115 }
00116 
00117 
00118 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00119 
00120 Foam::motionSolver::~motionSolver()
00121 {}
00122 
00123 
00124 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00125 
00126 Foam::tmp<Foam::pointField> Foam::motionSolver::newPoints()
00127 {
00128     solve();
00129     return curPoints();
00130 }
00131 
00132 
00133 void Foam::motionSolver::twoDCorrectPoints(pointField& p) const
00134 {
00135     twoDPointCorrector_.correctPoints(p);
00136 }
00137 
00138 
00139 void Foam::motionSolver::updateMesh(const mapPolyMesh& mpm)
00140 {
00141     twoDPointCorrector_.updateMesh();
00142 }
00143 
00144 
00145 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd