FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "motionSolver.H"
00027 #include <OpenFOAM/Time.H>
00028 #include <OpenFOAM/polyMesh.H>
00029 #include <OpenFOAM/dlLibraryTable.H>
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(motionSolver, 0);
00036     defineRunTimeSelectionTable(motionSolver, dictionary);
00037 }
00038 
00039 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00040 
00041 Foam::motionSolver::motionSolver(const polyMesh& mesh)
00042 :
00043     IOdictionary
00044     (
00045         IOobject
00046         (
00047             "dynamicMeshDict",
00048             mesh.time().constant(),
00049             mesh,
00050             IOobject::MUST_READ,
00051             IOobject::NO_WRITE
00052         )
00053     ),
00054     mesh_(mesh),
00055     twoDPointCorrector_(mesh)
00056 {}
00057 
00058 
00059 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00060 
00061 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
00062 {
00063     IOdictionary solverDict
00064     (
00065         IOobject
00066         (
00067             "dynamicMeshDict",
00068             mesh.time().constant(),
00069             mesh,
00070             IOobject::MUST_READ,
00071             IOobject::NO_WRITE,
00072             false
00073         )
00074     );
00075 
00076     Istream& msData = solverDict.lookup("solver");
00077 
00078     word solverTypeName(msData);
00079 
00080     Info << "Selecting motion solver: " << solverTypeName << endl;
00081 
00082     dlLibraryTable::open
00083     (
00084         solverDict,
00085         "motionSolverLibs",
00086         dictionaryConstructorTablePtr_
00087     );
00088 
00089     if (!dictionaryConstructorTablePtr_)
00090     {
00091         FatalErrorIn
00092         (
00093             "motionSolver::New(const polyMesh& mesh)"
00094         )   << "solver table is empty"
00095             << exit(FatalError);
00096     }
00097 
00098     dictionaryConstructorTable::iterator cstrIter =
00099         dictionaryConstructorTablePtr_->find(solverTypeName);
00100 
00101     if (cstrIter == dictionaryConstructorTablePtr_->end())
00102     {
00103         FatalErrorIn
00104         (
00105             "motionSolver::New(const polyMesh& mesh)"
00106         )   << "Unknown solver type " << solverTypeName
00107             << endl << endl
00108             << "Valid solver types are: " << endl
00109             << dictionaryConstructorTablePtr_->sortedToc()
00110             << exit(FatalError);
00111     }
00112 
00113     return autoPtr<motionSolver>(cstrIter()(mesh, msData));
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00118 
00119 Foam::motionSolver::~motionSolver()
00120 {}
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00124 
00125 Foam::tmp<Foam::pointField> Foam::motionSolver::newPoints()
00126 {
00127     solve();
00128     return curPoints();
00129 }
00130 
00131 
00132 void Foam::motionSolver::twoDCorrectPoints(pointField& p) const
00133 {
00134     twoDPointCorrector_.correctPoints(p);
00135 }
00136 
00137 
00138 void Foam::motionSolver::updateMesh(const mapPolyMesh& mpm)
00139 {
00140     twoDPointCorrector_.updateMesh();
00141 }
00142 
00143 
00144 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines