FIX: Update foamPackSource for new SF upload scheme
[freefoam.git] / src / dynamicMesh / motionSolver / motionSolver.C
blobb5a74224e5f31345b26d98cda3d72cc495f36c67
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "motionSolver.H"
27 #include <OpenFOAM/Time.H>
28 #include <OpenFOAM/polyMesh.H>
29 #include <OpenFOAM/dlLibraryTable.H>
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(motionSolver, 0);
36     defineRunTimeSelectionTable(motionSolver, dictionary);
39 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
41 Foam::motionSolver::motionSolver(const polyMesh& mesh)
43     IOdictionary
44     (
45         IOobject
46         (
47             "dynamicMeshDict",
48             mesh.time().constant(),
49             mesh,
50             IOobject::MUST_READ,
51             IOobject::NO_WRITE
52         )
53     ),
54     mesh_(mesh),
55     twoDPointCorrector_(mesh)
59 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
61 Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
63     IOdictionary solverDict
64     (
65         IOobject
66         (
67             "dynamicMeshDict",
68             mesh.time().constant(),
69             mesh,
70             IOobject::MUST_READ,
71             IOobject::NO_WRITE,
72             false
73         )
74     );
76     Istream& msData = solverDict.lookup("solver");
78     word solverTypeName(msData);
80     Info << "Selecting motion solver: " << solverTypeName << endl;
82     dlLibraryTable::open
83     (
84         solverDict,
85         "motionSolverLibs",
86         dictionaryConstructorTablePtr_
87     );
89     if (!dictionaryConstructorTablePtr_)
90     {
91         FatalErrorIn
92         (
93             "motionSolver::New(const polyMesh& mesh)"
94         )   << "solver table is empty"
95             << exit(FatalError);
96     }
98     dictionaryConstructorTable::iterator cstrIter =
99         dictionaryConstructorTablePtr_->find(solverTypeName);
101     if (cstrIter == dictionaryConstructorTablePtr_->end())
102     {
103         FatalErrorIn
104         (
105             "motionSolver::New(const polyMesh& mesh)"
106         )   << "Unknown solver type " << solverTypeName
107             << endl << endl
108             << "Valid solver types are: " << endl
109             << dictionaryConstructorTablePtr_->sortedToc()
110             << exit(FatalError);
111     }
113     return autoPtr<motionSolver>(cstrIter()(mesh, msData));
117 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
119 Foam::motionSolver::~motionSolver()
123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
125 Foam::tmp<Foam::pointField> Foam::motionSolver::newPoints()
127     solve();
128     return curPoints();
132 void Foam::motionSolver::twoDCorrectPoints(pointField& p) const
134     twoDPointCorrector_.correctPoints(p);
138 void Foam::motionSolver::updateMesh(const mapPolyMesh& mpm)
140     twoDPointCorrector_.updateMesh();
144 // ************************ vim: set sw=4 sts=4 et: ************************ //