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

fvPatchField.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 #include <OpenFOAM/IOobject.H>
00027 #include <OpenFOAM/dictionary.H>
00028 #include <finiteVolume/fvMesh.H>
00029 #include "fvPatchFieldMapper.H"
00030 //#include "fvMatrices.H"
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 template<class Type>
00035 Foam::fvPatchField<Type>::fvPatchField
00036 (
00037     const fvPatch& p,
00038     const DimensionedField<Type, volMesh>& iF
00039 )
00040 :
00041     Field<Type>(p.size()),
00042     patch_(p),
00043     internalField_(iF),
00044     updated_(false),
00045     patchType_(word::null)
00046 {}
00047 
00048 
00049 template<class Type>
00050 Foam::fvPatchField<Type>::fvPatchField
00051 (
00052     const fvPatch& p,
00053     const DimensionedField<Type, volMesh>& iF,
00054     const Field<Type>& f
00055 )
00056 :
00057     Field<Type>(f),
00058     patch_(p),
00059     internalField_(iF),
00060     updated_(false),
00061     patchType_(word::null)
00062 {}
00063 
00064 
00065 template<class Type>
00066 Foam::fvPatchField<Type>::fvPatchField
00067 (
00068     const fvPatchField<Type>& ptf,
00069     const fvPatch& p,
00070     const DimensionedField<Type, volMesh>& iF,
00071     const fvPatchFieldMapper& mapper
00072 )
00073 :
00074     Field<Type>(ptf, mapper),
00075     patch_(p),
00076     internalField_(iF),
00077     updated_(false),
00078     patchType_(ptf.patchType_)
00079 {}
00080 
00081 
00082 template<class Type>
00083 Foam::fvPatchField<Type>::fvPatchField
00084 (
00085     const fvPatch& p,
00086     const DimensionedField<Type, volMesh>& iF,
00087     const dictionary& dict,
00088     const bool valueRequired
00089 )
00090 :
00091     Field<Type>(p.size()),
00092     patch_(p),
00093     internalField_(iF),
00094     updated_(false),
00095     patchType_(dict.lookupOrDefault<word>("patchType", word::null))
00096 {
00097     if (dict.found("value"))
00098     {
00099         fvPatchField<Type>::operator=
00100         (
00101             Field<Type>("value", dict, p.size())
00102         );
00103     }
00104     else if (!valueRequired)
00105     {
00106         fvPatchField<Type>::operator=(pTraits<Type>::zero);
00107     }
00108     else
00109     {
00110         FatalIOErrorIn
00111         (
00112             "fvPatchField<Type>::fvPatchField"
00113             "("
00114             "const fvPatch& p,"
00115             "const DimensionedField<Type, volMesh>& iF,"
00116             "const dictionary& dict,"
00117             "const bool valueRequired"
00118             ")",
00119             dict
00120         )   << "Essential entry 'value' missing"
00121             << exit(FatalIOError);
00122     }
00123 }
00124 
00125 
00126 template<class Type>
00127 Foam::fvPatchField<Type>::fvPatchField
00128 (
00129     const fvPatchField<Type>& ptf
00130 )
00131 :
00132     Field<Type>(ptf),
00133     patch_(ptf.patch_),
00134     internalField_(ptf.internalField_),
00135     updated_(false),
00136     patchType_(ptf.patchType_)
00137 {}
00138 
00139 
00140 template<class Type>
00141 Foam::fvPatchField<Type>::fvPatchField
00142 (
00143     const fvPatchField<Type>& ptf,
00144     const DimensionedField<Type, volMesh>& iF
00145 )
00146 :
00147     Field<Type>(ptf),
00148     patch_(ptf.patch_),
00149     internalField_(iF),
00150     updated_(false),
00151     patchType_(ptf.patchType_)
00152 {}
00153 
00154 
00155 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00156 
00157 template<class Type>
00158 const Foam::objectRegistry& Foam::fvPatchField<Type>::db() const
00159 {
00160     return patch_.boundaryMesh().mesh();
00161 }
00162 
00163 
00164 template<class Type>
00165 void Foam::fvPatchField<Type>::check(const fvPatchField<Type>& ptf) const
00166 {
00167     if (&patch_ != &(ptf.patch_))
00168     {
00169         FatalErrorIn("PatchField<Type>::check(const fvPatchField<Type>&)")
00170             << "different patches for fvPatchField<Type>s"
00171             << abort(FatalError);
00172     }
00173 }
00174 
00175 
00176 // Return gradient at boundary
00177 template<class Type>
00178 Foam::tmp<Foam::Field<Type> > Foam::fvPatchField<Type>::snGrad() const
00179 {
00180     return (*this - patchInternalField())*patch_.deltaCoeffs();
00181 }
00182 
00183 
00184 // Return internal field next to patch as patch field
00185 template<class Type>
00186 Foam::tmp<Foam::Field<Type> >
00187 Foam::fvPatchField<Type>::patchInternalField() const
00188 {
00189     return patch_.patchInternalField(internalField_);
00190 }
00191 
00192 
00193 template<class Type>
00194 void Foam::fvPatchField<Type>::autoMap
00195 (
00196     const fvPatchFieldMapper& m
00197 )
00198 {
00199     Field<Type>::autoMap(m);
00200 }
00201 
00202 
00203 template<class Type>
00204 void Foam::fvPatchField<Type>::rmap
00205 (
00206     const fvPatchField<Type>& ptf,
00207     const labelList& addr
00208 )
00209 {
00210     Field<Type>::rmap(ptf, addr);
00211 }
00212 
00213 
00214 template<class Type>
00215 void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
00216 {
00217     if (!updated_)
00218     {
00219         updateCoeffs();
00220     }
00221 
00222     updated_ = false;
00223 }
00224 
00225 
00226 template<class Type>
00227 void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
00228 {
00229     // do nothing
00230 }
00231 
00232 
00233 template<class Type>
00234 void Foam::fvPatchField<Type>::write(Ostream& os) const
00235 {
00236     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
00237 
00238     if (patchType_.size())
00239     {
00240         os.writeKeyword("patchType") << patchType_
00241             << token::END_STATEMENT << nl;
00242     }
00243 }
00244 
00245 
00246 template<class Type>
00247 template<class EntryType>
00248 void Foam::fvPatchField<Type>::writeEntryIfDifferent
00249 (
00250     Ostream& os,
00251     const word& entryName,
00252     const EntryType& value1,
00253     const EntryType& value2
00254 ) const
00255 {
00256     if (value1 != value2)
00257     {
00258         os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
00259     }
00260 }
00261 
00262 
00263 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00264 
00265 template<class Type>
00266 void Foam::fvPatchField<Type>::operator=
00267 (
00268     const UList<Type>& ul
00269 )
00270 {
00271     Field<Type>::operator=(ul);
00272 }
00273 
00274 
00275 template<class Type>
00276 void Foam::fvPatchField<Type>::operator=
00277 (
00278     const fvPatchField<Type>& ptf
00279 )
00280 {
00281     check(ptf);
00282     Field<Type>::operator=(ptf);
00283 }
00284 
00285 
00286 template<class Type>
00287 void Foam::fvPatchField<Type>::operator+=
00288 (
00289     const fvPatchField<Type>& ptf
00290 )
00291 {
00292     check(ptf);
00293     Field<Type>::operator+=(ptf);
00294 }
00295 
00296 
00297 template<class Type>
00298 void Foam::fvPatchField<Type>::operator-=
00299 (
00300     const fvPatchField<Type>& ptf
00301 )
00302 {
00303     check(ptf);
00304     Field<Type>::operator-=(ptf);
00305 }
00306 
00307 
00308 template<class Type>
00309 void Foam::fvPatchField<Type>::operator*=
00310 (
00311     const fvPatchField<scalar>& ptf
00312 )
00313 {
00314     if (&patch_ != &ptf.patch())
00315     {
00316         FatalErrorIn
00317         (
00318             "PatchField<Type>::operator*=(const fvPatchField<scalar>& ptf)"
00319         )   << "incompatible patches for patch fields"
00320             << abort(FatalError);
00321     }
00322 
00323     Field<Type>::operator*=(ptf);
00324 }
00325 
00326 
00327 template<class Type>
00328 void Foam::fvPatchField<Type>::operator/=
00329 (
00330     const fvPatchField<scalar>& ptf
00331 )
00332 {
00333     if (&patch_ != &ptf.patch())
00334     {
00335         FatalErrorIn
00336         (
00337             "PatchField<Type>::operator/=(const fvPatchField<scalar>& ptf)"
00338         )   << "    incompatible patches for patch fields"
00339             << abort(FatalError);
00340     }
00341 
00342     Field<Type>::operator/=(ptf);
00343 }
00344 
00345 
00346 template<class Type>
00347 void Foam::fvPatchField<Type>::operator+=
00348 (
00349     const Field<Type>& tf
00350 )
00351 {
00352     Field<Type>::operator+=(tf);
00353 }
00354 
00355 
00356 template<class Type>
00357 void Foam::fvPatchField<Type>::operator-=
00358 (
00359     const Field<Type>& tf
00360 )
00361 {
00362     Field<Type>::operator-=(tf);
00363 }
00364 
00365 
00366 template<class Type>
00367 void Foam::fvPatchField<Type>::operator*=
00368 (
00369     const scalarField& tf
00370 )
00371 {
00372     Field<Type>::operator*=(tf);
00373 }
00374 
00375 
00376 template<class Type>
00377 void Foam::fvPatchField<Type>::operator/=
00378 (
00379     const scalarField& tf
00380 )
00381 {
00382     Field<Type>::operator/=(tf);
00383 }
00384 
00385 
00386 template<class Type>
00387 void Foam::fvPatchField<Type>::operator=
00388 (
00389     const Type& t
00390 )
00391 {
00392     Field<Type>::operator=(t);
00393 }
00394 
00395 
00396 template<class Type>
00397 void Foam::fvPatchField<Type>::operator+=
00398 (
00399     const Type& t
00400 )
00401 {
00402     Field<Type>::operator+=(t);
00403 }
00404 
00405 
00406 template<class Type>
00407 void Foam::fvPatchField<Type>::operator-=
00408 (
00409     const Type& t
00410 )
00411 {
00412     Field<Type>::operator-=(t);
00413 }
00414 
00415 
00416 template<class Type>
00417 void Foam::fvPatchField<Type>::operator*=
00418 (
00419     const scalar s
00420 )
00421 {
00422     Field<Type>::operator*=(s);
00423 }
00424 
00425 
00426 template<class Type>
00427 void Foam::fvPatchField<Type>::operator/=
00428 (
00429     const scalar s
00430 )
00431 {
00432     Field<Type>::operator/=(s);
00433 }
00434 
00435 
00436 // Force an assignment, overriding fixedValue status
00437 template<class Type>
00438 void Foam::fvPatchField<Type>::operator==
00439 (
00440     const fvPatchField<Type>& ptf
00441 )
00442 {
00443     Field<Type>::operator=(ptf);
00444 }
00445 
00446 
00447 template<class Type>
00448 void Foam::fvPatchField<Type>::operator==
00449 (
00450     const Field<Type>& tf
00451 )
00452 {
00453     Field<Type>::operator=(tf);
00454 }
00455 
00456 
00457 template<class Type>
00458 void Foam::fvPatchField<Type>::operator==
00459 (
00460     const Type& t
00461 )
00462 {
00463     Field<Type>::operator=(t);
00464 }
00465 
00466 
00467 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00468 
00469 template<class Type>
00470 Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
00471 {
00472     ptf.write(os);
00473 
00474     os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
00475 
00476     return os;
00477 }
00478 
00479 
00480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00481 
00482 #   include "newFvPatchField.C"
00483 
00484 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines