FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00027 
00028 template<class Type>
00029 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00030 (
00031     const word& patchFieldType,
00032     const fvPatch& p,
00033     const DimensionedField<Type, volMesh>& iF
00034 )
00035 {
00036     if (debug)
00037     {
00038         Info<< "fvPatchField<Type>::New(const word&, const fvPatch&, "
00039                "const DimensionedField<Type, volMesh>&) : patchFieldType="
00040             << patchFieldType
00041             << endl;
00042     }
00043 
00044     typename patchConstructorTable::iterator cstrIter =
00045         patchConstructorTablePtr_->find(patchFieldType);
00046 
00047     if (cstrIter == patchConstructorTablePtr_->end())
00048     {
00049         FatalErrorIn
00050         (
00051             "fvPatchField<Type>::New(const word&, const fvPatch&, "
00052             "const DimensionedField<Type, volMesh>&)"
00053         )   << "Unknown patchTypefield type " << patchFieldType
00054             << endl << endl
00055             << "Valid patchField types are :" << endl
00056             << patchConstructorTablePtr_->sortedToc()
00057             << exit(FatalError);
00058     }
00059 
00060     typename patchConstructorTable::iterator patchTypeCstrIter =
00061         patchConstructorTablePtr_->find(p.type());
00062 
00063     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
00064     {
00065         return patchTypeCstrIter()(p, iF);
00066     }
00067     else
00068     {
00069         return cstrIter()(p, iF);
00070     }
00071 }
00072 
00073 
00074 template<class Type>
00075 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00076 (
00077     const fvPatch& p,
00078     const DimensionedField<Type, volMesh>& iF,
00079     const dictionary& dict
00080 )
00081 {
00082     word patchFieldType(dict.lookup("type"));
00083 
00084     if (debug)
00085     {
00086         Info<< "fvPatchField<Type>::New(const fvPatch&, "
00087                "const DimensionedField<Type, volMesh>&, "
00088                "const dictionary&) : patchFieldType="  << patchFieldType
00089             << endl;
00090     }
00091 
00092     typename dictionaryConstructorTable::iterator cstrIter
00093         = dictionaryConstructorTablePtr_->find(patchFieldType);
00094 
00095     if (cstrIter == dictionaryConstructorTablePtr_->end())
00096     {
00097         if (!disallowGenericFvPatchField)
00098         {
00099             cstrIter = dictionaryConstructorTablePtr_->find("generic");
00100         }
00101 
00102         if (cstrIter == dictionaryConstructorTablePtr_->end())
00103         {
00104             FatalIOErrorIn
00105             (
00106                 "fvPatchField<Type>::New(const fvPatch&, "
00107                 "const DimensionedField<Type, volMesh>&, "
00108                 "const dictionary&)",
00109                 dict
00110             )   << "Unknown patchField type " << patchFieldType
00111                 << " for patch type " << p.type() << endl << endl
00112                 << "Valid patchField types are :" << endl
00113                 << dictionaryConstructorTablePtr_->sortedToc()
00114                 << exit(FatalIOError);
00115         }
00116     }
00117 
00118     if
00119     (
00120        !dict.found("patchType")
00121      || word(dict.lookup("patchType")) != p.type()
00122     )
00123     {
00124         typename dictionaryConstructorTable::iterator patchTypeCstrIter
00125             = dictionaryConstructorTablePtr_->find(p.type());
00126 
00127         if
00128         (
00129             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
00130          && patchTypeCstrIter() != cstrIter()
00131         )
00132         {
00133             FatalIOErrorIn
00134             (
00135                 "fvPatchField<Type>::New(const fvPatch&, "
00136                 "const DimensionedField<Type, volMesh>&, "
00137                 "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 cstrIter()(p, iF, dict);
00147 }
00148 
00149 
00150 template<class Type>
00151 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
00152 (
00153     const fvPatchField<Type>& ptf,
00154     const fvPatch& p,
00155     const DimensionedField<Type, volMesh>& iF,
00156     const fvPatchFieldMapper& pfMapper
00157 )
00158 {
00159     if (debug)
00160     {
00161         Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
00162                "const fvPatch&, const DimensionedField<Type, volMesh>&, "
00163                "const fvPatchFieldMapper&) : "
00164                "constructing fvPatchField<Type>"
00165             << endl;
00166     }
00167 
00168     typename patchMapperConstructorTable::iterator cstrIter =
00169         patchMapperConstructorTablePtr_->find(ptf.type());
00170 
00171     if (cstrIter == patchMapperConstructorTablePtr_->end())
00172     {
00173         FatalErrorIn
00174         (
00175             "fvPatchField<Type>::New(const fvPatchField<Type>&, "
00176             "const fvPatch&, const DimensionedField<Type, volMesh>&, "
00177             "const fvPatchFieldMapper&)"
00178         )   << "unknown patchTypefield type " << ptf.type() << endl << endl
00179             << "Valid patchField types are :" << endl
00180             << patchMapperConstructorTablePtr_->sortedToc()
00181             << exit(FatalError);
00182     }
00183 
00184     return cstrIter()(ptf, p, iF, pfMapper);
00185 }
00186 
00187 
00188 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines