initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / fan / fanFvPatchField.C
blob78bf1745353454effb3dbbd01207790b88af7fa4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 fanFvPatchField<Type>& ptf,
54     const fvPatch& p,
55     const DimensionedField<Type, volMesh>& iF,
56     const fvPatchFieldMapper& mapper
59     jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper),
60     f_(ptf.f_),
61     jump_(ptf.jump_, mapper)
65 template<class Type>
66 fanFvPatchField<Type>::fanFvPatchField
68     const fvPatch& p,
69     const DimensionedField<Type, volMesh>& iF,
70     const dictionary& dict
73     jumpCyclicFvPatchField<Type>(p, iF),
74     f_(),
75     jump_(this->size()/2, 0.0)
77     {
78         Istream& is = dict.lookup("f");
79         is.format(IOstream::ASCII);
80         is >> f_;
81     }
83     if (dict.found("value"))
84     {
85         fvPatchField<Type>::operator=
86         (
87             Field<Type>("value", dict, p.size())
88         );
89     }
90     else
91     {
92         this->evaluate(Pstream::blocking);
93     }
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() && 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() && 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") << "cyclic" << token::END_STATEMENT << nl;
186     IOstream::streamFormat fmt0 = os.format(IOstream::ASCII);
187     os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
188     os.format(fmt0);
190     this->writeEntry("value", os);
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // ************************************************************************* //