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

newFvsPatchField.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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00027 
00028 namespace Foam
00029 {
00030 
00031 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
00032 
00033 template<class Type>
00034 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
00035 (
00036     const word& patchFieldType,
00037     const fvPatch& p,
00038     const DimensionedField<Type, surfaceMesh>& iF
00039 )
00040 {
00041     if (debug)
00042     {
00043         Info<< "fvsPatchField<Type>::New(const word&, const fvPatch&, "
00044                "const Field<Type>&) : "
00045                "constructing fvsPatchField<Type>"
00046             << endl;
00047     }
00048 
00049     typename patchConstructorTable::iterator cstrIter =
00050         patchConstructorTablePtr_->find(patchFieldType);
00051 
00052     if (cstrIter == patchConstructorTablePtr_->end())
00053     {
00054         FatalErrorIn
00055         (
00056             "fvsPatchField<Type>::New(const word&, const fvPatch&, "
00057             "const Field<Type>&)"
00058         )   << "Unknown patchTypefield type " << patchFieldType
00059             << endl << endl
00060             << "Valid patchField types are :" << endl
00061             << patchConstructorTablePtr_->sortedToc()
00062             << exit(FatalError);
00063     }
00064 
00065     typename patchConstructorTable::iterator patchTypeCstrIter =
00066         patchConstructorTablePtr_->find(p.type());
00067 
00068     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
00069     {
00070         return patchTypeCstrIter()(p, iF);
00071     }
00072     else
00073     {
00074         return cstrIter()(p, iF);
00075     }
00076 }
00077 
00078 
00079 template<class Type>
00080 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
00081 (
00082     const fvPatch& p,
00083     const DimensionedField<Type, surfaceMesh>& iF,
00084     const dictionary& dict
00085 )
00086 {
00087     if (debug)
00088     {
00089         Info<< "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
00090                "const dictionary&) : "
00091                "constructing fvsPatchField<Type>"
00092             << endl;
00093     }
00094 
00095     word patchFieldType(dict.lookup("type"));
00096 
00097     typename dictionaryConstructorTable::iterator cstrIter
00098         = dictionaryConstructorTablePtr_->find(patchFieldType);
00099 
00100     if (cstrIter == dictionaryConstructorTablePtr_->end())
00101     {
00102         if (!disallowDefaultFvsPatchField)
00103         {
00104             cstrIter = dictionaryConstructorTablePtr_->find("default");
00105         }
00106 
00107         if (cstrIter == dictionaryConstructorTablePtr_->end())
00108         {
00109             FatalIOErrorIn
00110             (
00111                 "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
00112                 "const dictionary&)",
00113                 dict
00114             )   << "Unknown patchField type " << patchFieldType
00115                 << " for patch type " << p.type() << endl << endl
00116                 << "Valid patchField types are :" << endl
00117                 << dictionaryConstructorTablePtr_->sortedToc()
00118                 << exit(FatalIOError);
00119         }
00120     }
00121 
00122     if 
00123     (
00124         !dict.found("patchType")
00125      || word(dict.lookup("patchType")) != p.type()
00126     )
00127     {
00128         typename dictionaryConstructorTable::iterator patchTypeCstrIter
00129             = dictionaryConstructorTablePtr_->find(p.type());
00130 
00131         if
00132         (
00133             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
00134          && patchTypeCstrIter() != cstrIter()
00135         )
00136         {
00137             FatalIOErrorIn
00138             (
00139                 "fvsPatchField<Type>const fvPatch&, const Field<Type>&, "
00140                 "const dictionary&)",
00141                 dict
00142             )   << "inconsistent patch and patchField types for \n"
00143                    "    patch type " << p.type()
00144                 << " and patchField type " << patchFieldType
00145                 << exit(FatalIOError);
00146         }
00147     }
00148 
00149     return cstrIter()(p, iF, dict);
00150 }
00151 
00152 
00153 // Return a pointer to a new patch created on freestore from
00154 // a given fvsPatchField<Type> mapped onto a new patch
00155 template<class Type>
00156 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
00157 (
00158     const fvsPatchField<Type>& ptf,
00159     const fvPatch& p,
00160     const DimensionedField<Type, surfaceMesh>& iF,
00161     const fvPatchFieldMapper& pfMapper
00162 )
00163 {
00164     if (debug)
00165     {
00166         Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
00167                " const fvPatch&, const Field<Type>&, "
00168                "const fvPatchFieldMapper&) : "
00169                "constructing fvsPatchField<Type>"
00170             << endl;
00171     }
00172 
00173     typename patchMapperConstructorTable::iterator cstrIter =
00174         patchMapperConstructorTablePtr_->find(ptf.type());
00175 
00176     if (cstrIter == patchMapperConstructorTablePtr_->end())
00177     {
00178         FatalErrorIn
00179         (
00180             "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
00181             "const fvPatch&, const Field<Type>&, "
00182             "const fvPatchFieldMapper&)"
00183         )   << "unknown patchTypefield type " << ptf.type() << endl << endl
00184             << "Valid patchField types are :" << endl
00185             << patchMapperConstructorTablePtr_->sortedToc()
00186             << exit(FatalError);
00187     }
00188 
00189     typename patchMapperConstructorTable::iterator
00190         patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
00191 
00192     if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
00193     {
00194         return patchTypeCstrIter()(ptf, p, iF, pfMapper);
00195     }
00196     else
00197     {
00198         return cstrIter()(ptf, p, iF, pfMapper);
00199     }
00200 }
00201 
00202 
00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00204 
00205 } // End namespace Foam
00206 
00207 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines