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

valuePointPatchField.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 #include "valuePointPatchField.H"
00028 #include "pointPatchFieldMapper.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 void valuePointPatchField<Type>::checkFieldSize() const
00039 {
00040     if (size() != this->patch().size())
00041     {
00042         FatalErrorIn
00043         (
00044             "void valuePointPatchField<Type>::checkField() const"
00045         )   << "field does not correspond to patch. " << endl
00046             << "Field size: " << size() << " patch size: "
00047             << this->patch().size()
00048             << abort(FatalError);
00049     }
00050 }
00051 
00052 
00053 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
00054 
00055 template<class Type>
00056 valuePointPatchField<Type>::valuePointPatchField
00057 (
00058     const pointPatch& p,
00059     const DimensionedField<Type, pointMesh>& iF
00060 )
00061 :
00062     pointPatchField<Type>(p, iF),
00063     Field<Type>(p.size())
00064 {}
00065 
00066 
00067 template<class Type>
00068 valuePointPatchField<Type>::valuePointPatchField
00069 (
00070     const pointPatch& p,
00071     const DimensionedField<Type, pointMesh>& iF,
00072     const dictionary& dict,
00073     const bool valueRequired
00074 )
00075 :
00076     pointPatchField<Type>(p, iF, dict),
00077     Field<Type>(p.size())
00078 {
00079     if (dict.found("value"))
00080     {
00081         Field<Type>::operator=
00082         (
00083             Field<Type>("value", dict, p.size())
00084         );
00085     }
00086     else if (!valueRequired)
00087     {
00088         Field<Type>::operator=(pTraits<Type>::zero);
00089     }
00090     else
00091     {
00092         FatalIOErrorIn
00093         (
00094             "pointPatchField<Type>::pointPatchField"
00095             "("
00096             "const fvPatch& p,"
00097             "const DimensionedField<Type, pointMesh>& iF,"
00098             "const dictionary& dict,"
00099             "const bool valueRequired"
00100             ")",
00101             dict
00102         )   << "Essential entry 'value' missing"
00103             << exit(FatalIOError);
00104     }
00105 }
00106 
00107 
00108 template<class Type>
00109 valuePointPatchField<Type>::valuePointPatchField
00110 (
00111     const valuePointPatchField<Type>& ptf,
00112     const pointPatch& p,
00113     const DimensionedField<Type, pointMesh>& iF,
00114     const pointPatchFieldMapper& mapper
00115 )
00116 :
00117     pointPatchField<Type>(p, iF),
00118     Field<Type>(ptf, mapper)
00119 {}
00120 
00121 
00122 template<class Type>
00123 valuePointPatchField<Type>::valuePointPatchField
00124 (
00125     const valuePointPatchField<Type>& ptf,
00126     const DimensionedField<Type, pointMesh>& iF
00127 )
00128 :
00129     pointPatchField<Type>(ptf, iF),
00130     Field<Type>(ptf)
00131 {}
00132 
00133 
00134 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00135 
00136 template<class Type>
00137 void valuePointPatchField<Type>::autoMap
00138 (
00139     const pointPatchFieldMapper& m
00140 )
00141 {
00142     Field<Type>::autoMap(m);
00143 }
00144 
00145 
00146 template<class Type>
00147 void valuePointPatchField<Type>::rmap
00148 (
00149     const pointPatchField<Type>& ptf,
00150     const labelList& addr
00151 )
00152 {
00153     Field<Type>::rmap
00154     (
00155         refCast<const valuePointPatchField<Type> >
00156         (
00157             ptf
00158         ),
00159         addr
00160     );
00161 }
00162 
00163 
00164 template<class Type>
00165 void valuePointPatchField<Type>::updateCoeffs()
00166 {
00167     if (this->updated())
00168     {
00169         return;
00170     }
00171 
00172     // Get internal field to insert values into
00173     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
00174 
00175     setInInternalField(iF, *this);
00176 
00177     pointPatchField<Type>::updateCoeffs();
00178 }
00179 
00180 
00181 template<class Type>
00182 void valuePointPatchField<Type>::evaluate(const Pstream::commsTypes)
00183 {
00184     // Get internal field to insert values into
00185     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
00186 
00187     setInInternalField(iF, *this);
00188 
00189     pointPatchField<Type>::evaluate();
00190 }
00191 
00192 
00193 template<class Type>
00194 void valuePointPatchField<Type>::write(Ostream& os) const
00195 {
00196     pointPatchField<Type>::write(os);
00197     this->writeEntry("value", os);
00198 }
00199 
00200 
00201 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00202 
00203 template<class Type>
00204 void valuePointPatchField<Type>::operator=
00205 (
00206     const valuePointPatchField<Type>& ptf
00207 )
00208 {
00209     Field<Type>::operator=(ptf);
00210 }
00211 
00212 
00213 template<class Type>
00214 void valuePointPatchField<Type>::operator=
00215 (
00216     const pointPatchField<Type>& ptf
00217 )
00218 {
00219     Field<Type>::operator=(ptf.patchInternalField());
00220 }
00221 
00222 
00223 template<class Type>
00224 void valuePointPatchField<Type>::operator=
00225 (
00226     const Field<Type>& tf
00227 )
00228 {
00229     Field<Type>::operator=(tf);
00230 }
00231 
00232 
00233 template<class Type>
00234 void valuePointPatchField<Type>::operator=
00235 (
00236     const Type& t
00237 )
00238 {
00239     Field<Type>::operator=(t);
00240 }
00241 
00242 
00243 // Force an assignment
00244 template<class Type>
00245 void valuePointPatchField<Type>::operator==
00246 (
00247     const valuePointPatchField<Type>& ptf
00248 )
00249 {
00250     Field<Type>::operator=(ptf);
00251 }
00252 
00253 
00254 template<class Type>
00255 void valuePointPatchField<Type>::operator==
00256 (
00257     const pointPatchField<Type>& ptf
00258 )
00259 {
00260     Field<Type>::operator=(ptf.patchInternalField());
00261 }
00262 
00263 
00264 template<class Type>
00265 void valuePointPatchField<Type>::operator==
00266 (
00267     const Field<Type>& tf
00268 )
00269 {
00270     Field<Type>::operator=(tf);
00271 }
00272 
00273 
00274 template<class Type>
00275 void valuePointPatchField<Type>::operator==
00276 (
00277     const Type& t
00278 )
00279 {
00280     Field<Type>::operator=(t);
00281 }
00282 
00283 
00284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00285 
00286 } // End namespace Foam
00287 
00288 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd