mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
145
src/dynamicMesh/motionSolver/motionSolver.C
Normal file
145
src/dynamicMesh/motionSolver/motionSolver.C
Normal file
@ -0,0 +1,145 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "motionSolver.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "dlLibraryTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(motionSolver, 0);
|
||||
defineRunTimeSelectionTable(motionSolver, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::motionSolver::motionSolver(const polyMesh& mesh)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dynamicMeshDict",
|
||||
mesh.time().constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
mesh_(mesh),
|
||||
twoDPointCorrector_(mesh)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
|
||||
{
|
||||
IOdictionary solverDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dynamicMeshDict",
|
||||
mesh.time().constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
Istream& msData = solverDict.lookup("solver");
|
||||
|
||||
word solverTypeName(msData);
|
||||
|
||||
Info << "Selecting motion solver: " << solverTypeName << endl;
|
||||
|
||||
dlLibraryTable::open
|
||||
(
|
||||
solverDict,
|
||||
"motionSolverLibs",
|
||||
dictionaryConstructorTablePtr_
|
||||
);
|
||||
|
||||
if (!dictionaryConstructorTablePtr_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"motionSolver::New(const polyMesh& mesh)"
|
||||
) << "solver table is empty"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(solverTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"motionSolver::New(const polyMesh& mesh)"
|
||||
) << "Unknown solver type " << solverTypeName
|
||||
<< endl << endl
|
||||
<< "Valid solver types are: " << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<motionSolver>(cstrIter()(mesh, msData));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::motionSolver::~motionSolver()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::motionSolver::newPoints()
|
||||
{
|
||||
solve();
|
||||
return curPoints();
|
||||
}
|
||||
|
||||
|
||||
void Foam::motionSolver::twoDCorrectPoints(pointField& p) const
|
||||
{
|
||||
twoDPointCorrector_.correctPoints(p);
|
||||
}
|
||||
|
||||
|
||||
void Foam::motionSolver::updateMesh()
|
||||
{
|
||||
twoDPointCorrector_.updateMesh();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
137
src/dynamicMesh/motionSolver/motionSolver.H
Normal file
137
src/dynamicMesh/motionSolver/motionSolver.H
Normal file
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::motionSolver
|
||||
|
||||
Description
|
||||
Virtual base class for mesh motion solver.
|
||||
|
||||
SourceFiles
|
||||
motionSolver.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef motionSolver_H
|
||||
#define motionSolver_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "pointField.H"
|
||||
#include "twoDPointCorrector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward class declarations
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class motionSolver Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class motionSolver
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- 2-D motion corrector pointer
|
||||
twoDPointCorrector twoDPointCorrector_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("motionSolver");
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
motionSolver,
|
||||
dictionary,
|
||||
(const polyMesh& mesh, Istream& msData),
|
||||
(mesh, msData)
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from polyMesh
|
||||
static autoPtr<motionSolver> New(const polyMesh& mesh);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from polyMesh
|
||||
motionSolver(const polyMesh& mesh);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~motionSolver();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return reference to mesh
|
||||
const polyMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
//- Provide new points for motion. Solves for motion
|
||||
virtual tmp<pointField> newPoints();
|
||||
|
||||
//- Provide current points for motion. Uses current motion field
|
||||
virtual tmp<pointField> curPoints() const = 0;
|
||||
|
||||
virtual void twoDCorrectPoints(pointField&) const;
|
||||
|
||||
//- Solve for motion
|
||||
virtual void solve() = 0;
|
||||
|
||||
//- Update topology
|
||||
virtual void updateMesh();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user