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

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