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

fanFvPatchField.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 "fanFvPatchField.H"
00028 #include "IOmanip.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 fanFvPatchField<Type>::fanFvPatchField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<Type, volMesh>& iF
00042 )
00043 :
00044     jumpCyclicFvPatchField<Type>(p, iF),
00045     f_(0),
00046     jump_(this->size()/2, 0.0)
00047 {}
00048 
00049 
00050 template<class Type>
00051 fanFvPatchField<Type>::fanFvPatchField
00052 (
00053     const fanFvPatchField<Type>& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<Type, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper),
00060     f_(ptf.f_),
00061     jump_(ptf.jump_, mapper)
00062 {}
00063 
00064 
00065 template<class Type>
00066 fanFvPatchField<Type>::fanFvPatchField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<Type, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     jumpCyclicFvPatchField<Type>(p, iF),
00074     f_(),
00075     jump_(this->size()/2, 0.0)
00076 {
00077     {
00078         Istream& is = dict.lookup("f");
00079         is.format(IOstream::ASCII);
00080         is >> f_;
00081     }
00082 
00083     if (dict.found("value"))
00084     {
00085         fvPatchField<Type>::operator=
00086         (
00087             Field<Type>("value", dict, p.size())
00088         );
00089     }
00090     else
00091     {
00092         this->evaluate(Pstream::blocking);
00093     }
00094 }
00095 
00096 
00097 template<class Type>
00098 fanFvPatchField<Type>::fanFvPatchField
00099 (
00100     const fanFvPatchField<Type>& ptf
00101 )
00102 :
00103     cyclicLduInterfaceField(),
00104     jumpCyclicFvPatchField<Type>(ptf),
00105     f_(ptf.f_),
00106     jump_(ptf.jump_)
00107 {}
00108 
00109 
00110 template<class Type>
00111 fanFvPatchField<Type>::fanFvPatchField
00112 (
00113     const fanFvPatchField<Type>& ptf,
00114     const DimensionedField<Type, volMesh>& iF
00115 )
00116 :
00117     jumpCyclicFvPatchField<Type>(ptf, iF),
00118     f_(ptf.f_),
00119     jump_(ptf.jump_)
00120 {}
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00124 
00125 template<class Type>
00126 void fanFvPatchField<Type>::autoMap
00127 (
00128     const fvPatchFieldMapper& m
00129 )
00130 {
00131     jumpCyclicFvPatchField<Type>::autoMap(m);
00132 
00133     // Jump is half size. Expand to full size, map and truncate.
00134     if (jump_.size() && jump_.size() == this->size()/2)
00135     {
00136         label oldSize = jump_.size();
00137         jump_.setSize(this->size());
00138 
00139         for (label i = oldSize; i < jump_.size(); i++)
00140         {
00141             jump_[i] = jump_[i-oldSize];
00142         }
00143 
00144         jump_.autoMap(m);
00145         jump_.setSize(oldSize);
00146     }
00147 }
00148 
00149 
00150 template<class Type>
00151 void fanFvPatchField<Type>::rmap
00152 (
00153     const fvPatchField<Type>& ptf,
00154     const labelList& addr
00155 )
00156 {
00157     jumpCyclicFvPatchField<Type>::rmap(ptf, addr);
00158 
00159     // Jump is half size. Expand to full size, map and truncate.
00160     if (jump_.size() && jump_.size() == this->size()/2)
00161     {
00162         label oldSize = jump_.size();
00163         jump_.setSize(this->size());
00164 
00165         for (label i = oldSize; i < jump_.size(); i++)
00166         {
00167             jump_[i] = jump_[i-oldSize];
00168         }
00169 
00170         const fanFvPatchField<Type>& tiptf =
00171             refCast<const fanFvPatchField<Type> >(ptf);
00172 
00173         jump_.rmap(tiptf.jump_, addr);
00174 
00175         jump_.setSize(oldSize);
00176     }
00177 }
00178 
00179 
00180 template<class Type>
00181 void fanFvPatchField<Type>::write(Ostream& os) const
00182 {
00183     fvPatchField<Type>::write(os);
00184     os.writeKeyword("patchType") << "cyclic" << token::END_STATEMENT << nl;
00185 
00186     IOstream::streamFormat fmt0 = os.format(IOstream::ASCII);
00187     os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
00188     os.format(fmt0);
00189 
00190     this->writeEntry("value", os);
00191 }
00192 
00193 
00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00195 
00196 } // End namespace Foam
00197 
00198 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd