Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / fan / fanFvPatchField.C
blob76cdfaae03e4a34b030a892b98b4243cdb73c12b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fanFvPatchField.H"
28 #include "IOmanip.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 fanFvPatchField<Type>::fanFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     jumpCyclicFvPatchField<Type>(p, iF),
45     f_(0),
46     jump_(this->size()/2, 0.0)
50 template<class Type>
51 fanFvPatchField<Type>::fanFvPatchField
53     const fvPatch& p,
54     const DimensionedField<Type, volMesh>& iF,
55     const dictionary& dict
58     jumpCyclicFvPatchField<Type>(p, iF),
59     f_(),
60     jump_(this->size()/2, 0.0)
62     {
63         Istream& is = dict.lookup("f");
64         is.format(IOstream::ASCII);
65         is >> f_;
66     }
68     if (dict.found("value"))
69     {
70         fvPatchField<Type>::operator=
71         (
72             Field<Type>("value", dict, p.size())
73         );
74     }
75     else
76     {
77         this->evaluate(Pstream::blocking);
78     }
82 template<class Type>
83 fanFvPatchField<Type>::fanFvPatchField
85     const fanFvPatchField<Type>& ptf,
86     const fvPatch& p,
87     const DimensionedField<Type, volMesh>& iF,
88     const fvPatchFieldMapper& mapper
91     jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper),
92     f_(ptf.f_),
93     jump_(ptf.jump_, mapper)
97 template<class Type>
98 fanFvPatchField<Type>::fanFvPatchField
100     const fanFvPatchField<Type>& ptf
103     cyclicLduInterfaceField(),
104     jumpCyclicFvPatchField<Type>(ptf),
105     f_(ptf.f_),
106     jump_(ptf.jump_)
110 template<class Type>
111 fanFvPatchField<Type>::fanFvPatchField
113     const fanFvPatchField<Type>& ptf,
114     const DimensionedField<Type, volMesh>& iF
117     jumpCyclicFvPatchField<Type>(ptf, iF),
118     f_(ptf.f_),
119     jump_(ptf.jump_)
123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
125 template<class Type>
126 void fanFvPatchField<Type>::autoMap
128     const fvPatchFieldMapper& m
131     jumpCyclicFvPatchField<Type>::autoMap(m);
133     // Jump is half size. Expand to full size, map and truncate.
134     if (jump_.size() > 0 && jump_.size() == this->size()/2)
135     {
136         label oldSize = jump_.size();
137         jump_.setSize(this->size());
139         for (label i = oldSize; i < jump_.size(); i++)
140         {
141             jump_[i] = jump_[i-oldSize];
142         }
144         jump_.autoMap(m);
145         jump_.setSize(oldSize);
146     }
150 template<class Type>
151 void fanFvPatchField<Type>::rmap
153     const fvPatchField<Type>& ptf,
154     const labelList& addr
157     jumpCyclicFvPatchField<Type>::rmap(ptf, addr);
159     // Jump is half size. Expand to full size, map and truncate.
160     if (jump_.size() > 0 && jump_.size() == this->size()/2)
161     {
162         label oldSize = jump_.size();
163         jump_.setSize(this->size());
165         for (label i = oldSize; i < jump_.size(); i++)
166         {
167             jump_[i] = jump_[i-oldSize];
168         }
170         const fanFvPatchField<Type>& tiptf =
171             refCast<const fanFvPatchField<Type> >(ptf);
173         jump_.rmap(tiptf.jump_, addr);
175         jump_.setSize(oldSize);
176     }
180 template<class Type>
181 void fanFvPatchField<Type>::write(Ostream& os) const
183     fvPatchField<Type>::write(os);
184     os.writeKeyword("patchType")
185         << cyclicFvPatch::typeName << token::END_STATEMENT << nl;
187     IOstream::streamFormat fmt0 = os.format(IOstream::ASCII);
188     os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
189     os.format(fmt0);
191     this->writeEntry("value", os);
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 } // End namespace Foam
199 // ************************************************************************* //