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

newDynamicFvMesh.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 "dynamicFvMesh.H"
00028 #include "Time.H"
00029 #include "dlLibraryTable.H"
00030 
00031 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00032 
00033 Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
00034 {
00035     // Enclose the creation of the dynamicMesh to ensure it is
00036     // deleted before the dynamicFvMesh is created otherwise the dictionary
00037     // is entered in the database twice
00038     IOdictionary dynamicMeshDict
00039     (
00040         IOobject
00041         (
00042             "dynamicMeshDict",
00043             io.time().constant(),
00044             io.db(),
00045             IOobject::MUST_READ,
00046             IOobject::NO_WRITE,
00047             false
00048         )
00049     );
00050     
00051     word dynamicFvMeshTypeName(dynamicMeshDict.lookup("dynamicFvMesh"));
00052 
00053     Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;
00054 
00055     dlLibraryTable::open
00056     (
00057         dynamicMeshDict,
00058         "dynamicFvMeshLibs",
00059         IOobjectConstructorTablePtr_
00060     );
00061 
00062     if (!IOobjectConstructorTablePtr_)
00063     {
00064         FatalErrorIn
00065         (
00066             "dynamicFvMesh::New(const IOobject&)"
00067         )   << "dynamicFvMesh table is empty"
00068             << exit(FatalError);
00069     }
00070 
00071     IOobjectConstructorTable::iterator cstrIter =
00072         IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);
00073 
00074     if (cstrIter == IOobjectConstructorTablePtr_->end())
00075     {
00076         FatalErrorIn
00077         (
00078             "dynamicFvMesh::New(const IOobject&)"
00079         )   << "Unknown dynamicFvMesh type " << dynamicFvMeshTypeName
00080             << endl << endl
00081             << "Valid dynamicFvMesh types are :" << endl
00082             << IOobjectConstructorTablePtr_->toc()
00083             << exit(FatalError);
00084     }
00085 
00086     return autoPtr<dynamicFvMesh>(cstrIter()(io));
00087 }
00088 
00089 
00090 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd