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

newPointPatchField.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 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00028 
00029 template<class Type>
00030 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
00031 (
00032     const word& patchFieldType,
00033     const pointPatch& p,
00034     const DimensionedField<Type, pointMesh>& iF
00035 )
00036 {
00037     if (debug)
00038     {
00039         Info<< "PointPatchField<Type>::"
00040                "New(const word&, const pointPatch&, const Field<Type>&) : "
00041                "constructing pointPatchField<Type>"
00042             << endl;
00043     }
00044 
00045     typename pointPatchConstructorTable::iterator cstrIter =
00046         pointPatchConstructorTablePtr_->find(patchFieldType);
00047 
00048     if (cstrIter == pointPatchConstructorTablePtr_->end())
00049     {
00050         FatalErrorIn
00051         (
00052             "PointPatchField<Type>::New"
00053             "(const word&, const pointPatch&, const Field<Type>&)"
00054         )   << "Unknown patchTypefield type "
00055             << patchFieldType
00056             << endl << endl
00057             << "Valid patchField types are :" << endl
00058             << pointPatchConstructorTablePtr_->toc()
00059             << exit(FatalError);
00060     }
00061 
00062     typename pointPatchConstructorTable::iterator patchTypeCstrIter =
00063         pointPatchConstructorTablePtr_->find(p.type());
00064 
00065     if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end())
00066     {
00067         return autoPtr<pointPatchField<Type> >(patchTypeCstrIter()(p, iF));
00068     }
00069     else
00070     {
00071         return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF));
00072     }
00073 }
00074 
00075 
00076 template<class Type>
00077 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
00078 (
00079     const pointPatch& p,
00080     const DimensionedField<Type, pointMesh>& iF,
00081     const dictionary& dict
00082 )
00083 {
00084     if (debug)
00085     {
00086         Info<< "PointPatchField<Type>::"
00087                "New(const pointPatch&, const Field<Type>&, const dictionary&)"
00088                " : constructing pointPatchField<Type>"
00089             << endl;
00090     }
00091 
00092     word patchFieldType(dict.lookup("type"));
00093 
00094     typename dictionaryConstructorTable::iterator cstrIter
00095         = dictionaryConstructorTablePtr_->find(patchFieldType);
00096 
00097     if (cstrIter == dictionaryConstructorTablePtr_->end())
00098     {
00099         if (!disallowGenericPointPatchField)
00100         {
00101             cstrIter = dictionaryConstructorTablePtr_->find("generic");
00102         }
00103 
00104         if (cstrIter == dictionaryConstructorTablePtr_->end())
00105         {
00106             FatalIOErrorIn
00107             (
00108                 "PointPatchField<Type>::"
00109                 "New(const pointPatch&, const Field<Type>&, const dictionary&)",
00110                 dict
00111             )   << "Unknown patchField type " << patchFieldType
00112                 << " for patch type " << p.type() << endl << endl
00113                 << "Valid patchField types are :" << endl
00114                 << dictionaryConstructorTablePtr_->toc()
00115                 << exit(FatalIOError);
00116         }
00117     }
00118 
00119     if
00120     (
00121        !dict.found("patchType")
00122      || word(dict.lookup("patchType")) != p.type()
00123     )
00124     {
00125         typename dictionaryConstructorTable::iterator patchTypeCstrIter
00126             = dictionaryConstructorTablePtr_->find(p.type());
00127 
00128         if
00129         (
00130             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
00131          && patchTypeCstrIter() != cstrIter()
00132         )
00133         {
00134             FatalIOErrorIn
00135             (
00136                 "PointPatchField<Type>const pointPatch&, "
00137                 "const Field<Type>&, const dictionary&)",
00138                 dict
00139             )   << "inconsistent patch and patchField types for \n"
00140                 << "    patch type " << p.type()
00141                 << " and patchField type " << patchFieldType
00142                 << exit(FatalIOError);
00143         }
00144     }
00145 
00146     return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF, dict));
00147 }
00148 
00149 
00150 // Return a pointer to a new patch created on freestore from
00151 // a given pointPatchField<Type> mapped onto a new patch
00152 template<class Type>
00153 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
00154 (
00155     const pointPatchField<Type>& ptf,
00156     const pointPatch& p,
00157     const DimensionedField<Type, pointMesh>& iF,
00158     const pointPatchFieldMapper& pfMapper
00159 )
00160 {
00161     if (debug)
00162     {
00163         Info<< "PointPatchField<Type>::"
00164                "New(const pointPatchField<Type>&,"
00165                " const pointPatch&, const Field<Type>&, "
00166                "const pointPatchFieldMapper&) : "
00167                "constructing pointPatchField<Type>"
00168             << endl;
00169     }
00170 
00171     typename patchMapperConstructorTable::iterator cstrIter =
00172         patchMapperConstructorTablePtr_->find(ptf.type());
00173 
00174     if (cstrIter == patchMapperConstructorTablePtr_->end())
00175     {
00176         FatalErrorIn
00177         (
00178             "PointPatchField<Type>::"
00179             "New(const pointPatchField<Type>&, "
00180             "const pointPatch&, const Field<Type>&, "
00181             "const pointPatchFieldMapper&)"
00182         )   << "unknown patchTypefield type "
00183             << ptf.type() << endl << endl
00184             << "Valid patchField types are :" << endl
00185             << patchMapperConstructorTablePtr_->toc()
00186             << exit(FatalError);
00187     }
00188 
00189     return autoPtr<pointPatchField<Type> >(cstrIter()(ptf, p, iF, pfMapper));
00190 }
00191 
00192 
00193 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd