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

newFvPatchField.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 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00028 
00029 template<class Type>
00030 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00031 (
00032     const word& patchFieldType,
00033     const fvPatch& p,
00034     const DimensionedField<Type, volMesh>& iF
00035 )
00036 {
00037     if (debug)
00038     {
00039         Info<< "fvPatchField<Type>::New(const word&, const fvPatch&, "
00040                "const DimensionedField<Type, volMesh>&) : patchFieldType="
00041             << patchFieldType
00042             << endl;
00043     }
00044 
00045     typename patchConstructorTable::iterator cstrIter =
00046         patchConstructorTablePtr_->find(patchFieldType);
00047 
00048     if (cstrIter == patchConstructorTablePtr_->end())
00049     {
00050         FatalErrorIn
00051         (
00052             "fvPatchField<Type>::New(const word&, const fvPatch&, "
00053             "const DimensionedField<Type, volMesh>&)"
00054         )   << "Unknown patchTypefield type " << patchFieldType
00055             << endl << endl
00056             << "Valid patchField types are :" << endl
00057             << patchConstructorTablePtr_->toc()
00058             << exit(FatalError);
00059     }
00060 
00061     typename patchConstructorTable::iterator patchTypeCstrIter =
00062         patchConstructorTablePtr_->find(p.type());
00063 
00064     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
00065     {
00066         return patchTypeCstrIter()(p, iF);
00067     }
00068     else
00069     {
00070         return cstrIter()(p, iF);
00071     }
00072 }
00073 
00074 
00075 template<class Type>
00076 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00077 (
00078     const fvPatch& p,
00079     const DimensionedField<Type, volMesh>& iF,
00080     const dictionary& dict
00081 )
00082 {
00083     word patchFieldType(dict.lookup("type"));
00084 
00085     if (debug)
00086     {
00087         Info<< "fvPatchField<Type>::New(const fvPatch&, "
00088                "const DimensionedField<Type, volMesh>&, "
00089                "const dictionary&) : patchFieldType="  << patchFieldType
00090             << endl;
00091     }
00092 
00093     typename dictionaryConstructorTable::iterator cstrIter
00094         = dictionaryConstructorTablePtr_->find(patchFieldType);
00095 
00096     if (cstrIter == dictionaryConstructorTablePtr_->end())
00097     {
00098         if (!disallowGenericFvPatchField)
00099         {
00100             cstrIter = dictionaryConstructorTablePtr_->find("generic");
00101         }
00102 
00103         if (cstrIter == dictionaryConstructorTablePtr_->end())
00104         {
00105             FatalIOErrorIn
00106             (
00107                 "fvPatchField<Type>::New(const fvPatch&, "
00108                 "const DimensionedField<Type, volMesh>&, "
00109                 "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                 "fvPatchField<Type>::New(const fvPatch&, "
00137                 "const DimensionedField<Type, volMesh>&, "
00138                 "const dictionary&)",
00139                 dict
00140             )   << "inconsistent patch and patchField types for \n"
00141                    "    patch type " << p.type()
00142                 << " and patchField type " << patchFieldType
00143                 << exit(FatalIOError);
00144         }
00145     }
00146 
00147     return cstrIter()(p, iF, dict);
00148 }
00149 
00150 
00151 template<class Type>
00152 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00153 (
00154     const fvPatchField<Type>& ptf,
00155     const fvPatch& p,
00156     const DimensionedField<Type, volMesh>& iF,
00157     const fvPatchFieldMapper& pfMapper
00158 )
00159 {
00160     if (debug)
00161     {
00162         Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
00163                "const fvPatch&, const DimensionedField<Type, volMesh>&, "
00164                "const fvPatchFieldMapper&) : "
00165                "constructing fvPatchField<Type>"
00166             << endl;
00167     }
00168 
00169     typename patchMapperConstructorTable::iterator cstrIter =
00170         patchMapperConstructorTablePtr_->find(ptf.type());
00171 
00172     if (cstrIter == patchMapperConstructorTablePtr_->end())
00173     {
00174         FatalErrorIn
00175         (
00176             "fvPatchField<Type>::New(const fvPatchField<Type>&, "
00177             "const fvPatch&, const DimensionedField<Type, volMesh>&, "
00178             "const fvPatchFieldMapper&)"
00179         )   << "unknown patchTypefield type " << ptf.type() << endl << endl
00180             << "Valid patchField types are :" << endl
00181             << patchMapperConstructorTablePtr_->toc()
00182             << exit(FatalError);
00183     }
00184 
00185     return cstrIter()(ptf, p, iF, pfMapper);
00186 }
00187 
00188 
00189 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd