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

fvsPatchField.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 "IOobject.H"
00028 #include "dictionary.H"
00029 #include "fvMesh.H"
00030 #include "fvPatchFieldMapper.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 template<class Type>
00040 fvsPatchField<Type>::fvsPatchField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<Type, surfaceMesh>& iF
00044 )
00045 :
00046     Field<Type>(p.size()),
00047     patch_(p),
00048     internalField_(iF)
00049 {}
00050 
00051 
00052 template<class Type>
00053 fvsPatchField<Type>::fvsPatchField
00054 (
00055     const fvPatch& p,
00056     const DimensionedField<Type, surfaceMesh>& iF,
00057     const Field<Type>& f
00058 )
00059 :
00060     Field<Type>(f),
00061     patch_(p),
00062     internalField_(iF)
00063 {}
00064 
00065 
00066 template<class Type>
00067 fvsPatchField<Type>::fvsPatchField
00068 (
00069     const fvsPatchField<Type>& ptf,
00070     const fvPatch& p,
00071     const DimensionedField<Type, surfaceMesh>& iF,
00072     const fvPatchFieldMapper& mapper
00073 )
00074 :
00075     Field<Type>(ptf, mapper),
00076     patch_(p),
00077     internalField_(iF)
00078 {}
00079 
00080 
00081 template<class Type>
00082 fvsPatchField<Type>::fvsPatchField
00083 (
00084     const fvPatch& p,
00085     const DimensionedField<Type, surfaceMesh>& iF,
00086     const dictionary& dict
00087 )
00088 :
00089     Field<Type>(p.size()),
00090     patch_(p),
00091     internalField_(iF)
00092 {
00093     if (dict.found("value"))
00094     {
00095         fvsPatchField<Type>::operator=
00096         (
00097             Field<Type>("value", dict, p.size())
00098         );
00099     }
00100     else
00101     {
00102         fvsPatchField<Type>::operator=(pTraits<Type>::zero);
00103     }
00104 }
00105 
00106 
00107 template<class Type>
00108 fvsPatchField<Type>::fvsPatchField
00109 (
00110     const fvsPatchField<Type>& ptf
00111 )
00112 :
00113     Field<Type>(ptf),
00114     patch_(ptf.patch_),
00115     internalField_(ptf.internalField_)
00116 {}
00117 
00118 
00119 template<class Type>
00120 fvsPatchField<Type>::fvsPatchField
00121 (
00122     const fvsPatchField<Type>& ptf,
00123     const DimensionedField<Type, surfaceMesh>& iF
00124 )
00125 :
00126     Field<Type>(ptf),
00127     patch_(ptf.patch_),
00128     internalField_(iF)
00129 {}
00130 
00131 
00132 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00133 
00134 template<class Type>
00135 const objectRegistry& fvsPatchField<Type>::db() const
00136 {
00137     return patch_.boundaryMesh().mesh();
00138 }
00139 
00140 
00141 template<class Type>
00142 void fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
00143 {
00144     if (&patch_ != &(ptf.patch_))
00145     {
00146         FatalErrorIn("PatchField<Type>::check(const fvsPatchField<Type>&)")
00147             << "different patches for fvsPatchField<Type>s"
00148             << abort(FatalError);
00149     }
00150 }
00151 
00152 
00153 // Map from self
00154 template<class Type>
00155 void fvsPatchField<Type>::autoMap
00156 (
00157     const fvPatchFieldMapper& m
00158 )
00159 {
00160     Field<Type>::autoMap(m);
00161 }
00162 
00163 
00164 // Reverse-map the given fvsPatchField onto this fvsPatchField
00165 template<class Type>
00166 void fvsPatchField<Type>::rmap
00167 (
00168     const fvsPatchField<Type>& ptf,
00169     const labelList& addr
00170 )
00171 {
00172     Field<Type>::rmap(ptf, addr);
00173 }
00174 
00175 
00176 // Write
00177 template<class Type>
00178 void fvsPatchField<Type>::write(Ostream& os) const
00179 {
00180     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
00181 }
00182 
00183 
00184 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00185 
00186 template<class Type>
00187 void fvsPatchField<Type>::operator=
00188 (
00189     const UList<Type>& ul
00190 )
00191 {
00192     Field<Type>::operator=(ul);
00193 }
00194 
00195 
00196 template<class Type>
00197 void fvsPatchField<Type>::operator=
00198 (
00199     const fvsPatchField<Type>& ptf
00200 )
00201 {
00202     check(ptf);
00203     Field<Type>::operator=(ptf);
00204 }
00205 
00206 
00207 template<class Type>
00208 void fvsPatchField<Type>::operator+=
00209 (
00210     const fvsPatchField<Type>& ptf
00211 )
00212 {
00213     check(ptf);
00214     Field<Type>::operator+=(ptf);
00215 }
00216 
00217 
00218 template<class Type>
00219 void fvsPatchField<Type>::operator-=
00220 (
00221     const fvsPatchField<Type>& ptf
00222 )
00223 {
00224     check(ptf);
00225     Field<Type>::operator-=(ptf);
00226 }
00227 
00228 
00229 template<class Type>
00230 void fvsPatchField<Type>::operator*=
00231 (
00232     const fvsPatchField<scalar>& ptf
00233 )
00234 {
00235     if (&patch_ != &ptf.patch())
00236     {
00237         FatalErrorIn
00238         (
00239             "PatchField<Type>::operator*=(const fvsPatchField<scalar>& ptf)"
00240         )   << "incompatible patches for patch fields"
00241             << abort(FatalError);
00242     }
00243 
00244     Field<Type>::operator*=(ptf);
00245 }
00246 
00247 
00248 template<class Type>
00249 void fvsPatchField<Type>::operator/=
00250 (
00251     const fvsPatchField<scalar>& ptf
00252 )
00253 {
00254     if (&patch_ != &ptf.patch())
00255     {
00256         FatalErrorIn
00257         (
00258             "PatchField<Type>::operator/=(const fvsPatchField<scalar>& ptf)"
00259         )   << "    incompatible patches for patch fields"
00260             << abort(FatalError);
00261     }
00262 
00263     Field<Type>::operator/=(ptf);
00264 }
00265 
00266 
00267 template<class Type>
00268 void fvsPatchField<Type>::operator+=
00269 (
00270     const Field<Type>& tf
00271 )
00272 {
00273     Field<Type>::operator+=(tf);
00274 }
00275 
00276 
00277 template<class Type>
00278 void fvsPatchField<Type>::operator-=
00279 (
00280     const Field<Type>& tf
00281 )
00282 {
00283     Field<Type>::operator-=(tf);
00284 }
00285 
00286 
00287 template<class Type>
00288 void fvsPatchField<Type>::operator*=
00289 (
00290     const scalarField& tf
00291 )
00292 {
00293     Field<Type>::operator*=(tf);
00294 }
00295 
00296 
00297 template<class Type>
00298 void fvsPatchField<Type>::operator/=
00299 (
00300     const scalarField& tf
00301 )
00302 {
00303     Field<Type>::operator/=(tf);
00304 }
00305 
00306 
00307 template<class Type>
00308 void fvsPatchField<Type>::operator=
00309 (
00310     const Type& t
00311 )
00312 {
00313     Field<Type>::operator=(t);
00314 }
00315 
00316 
00317 template<class Type>
00318 void fvsPatchField<Type>::operator+=
00319 (
00320     const Type& t
00321 )
00322 {
00323     Field<Type>::operator+=(t);
00324 }
00325 
00326 
00327 template<class Type>
00328 void fvsPatchField<Type>::operator-=
00329 (
00330     const Type& t
00331 )
00332 {
00333     Field<Type>::operator-=(t);
00334 }
00335 
00336 
00337 template<class Type>
00338 void fvsPatchField<Type>::operator*=
00339 (
00340     const scalar s
00341 )
00342 {
00343     Field<Type>::operator*=(s);
00344 }
00345 
00346 
00347 template<class Type>
00348 void fvsPatchField<Type>::operator/=
00349 (
00350     const scalar s
00351 )
00352 {
00353     Field<Type>::operator/=(s);
00354 }
00355 
00356 
00357 // Force an assignment, overriding fixedValue status
00358 template<class Type>
00359 void fvsPatchField<Type>::operator==
00360 (
00361     const fvsPatchField<Type>& ptf
00362 )
00363 {
00364     Field<Type>::operator=(ptf);
00365 }
00366 
00367 
00368 template<class Type>
00369 void fvsPatchField<Type>::operator==
00370 (
00371     const Field<Type>& tf
00372 )
00373 {
00374     Field<Type>::operator=(tf);
00375 }
00376 
00377 
00378 template<class Type>
00379 void fvsPatchField<Type>::operator==
00380 (
00381     const Type& t
00382 )
00383 {
00384     Field<Type>::operator=(t);
00385 }
00386 
00387 
00388 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00389 
00390 template<class Type>
00391 Ostream& operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
00392 {
00393     ptf.write(os);
00394 
00395     os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
00396 
00397     return os;
00398 }
00399 
00400 
00401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00402 
00403 } // End namespace Foam
00404 
00405 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00406 
00407 #   include "newFvsPatchField.C"
00408 
00409 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd