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

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