FreeFOAM The Cross-Platform CFD Toolkit
fanFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fanFvPatchField.H"
27 #include <OpenFOAM/IOmanip.H>
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const fvPatch& p,
41 )
42 :
44  f_(0),
45  jump_(this->size()/2, 0.0)
46 {}
47 
48 
49 template<class Type>
51 (
52  const fanFvPatchField<Type>& ptf,
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper),
59  f_(ptf.f_),
60  jump_(ptf.jump_, mapper)
61 {}
62 
63 
64 template<class Type>
66 (
67  const fvPatch& p,
69  const dictionary& dict
70 )
71 :
73  f_(),
74  jump_(this->size()/2, 0.0)
75 {
76  {
77  Istream& is = dict.lookup("f");
79  is >> f_;
80  }
81 
82  if (dict.found("value"))
83  {
85  (
86  Field<Type>("value", dict, p.size())
87  );
88  }
89  else
90  {
91  this->evaluate(Pstream::blocking);
92  }
93 }
94 
95 
96 template<class Type>
98 (
99  const fanFvPatchField<Type>& ptf
100 )
101 :
104  f_(ptf.f_),
105  jump_(ptf.jump_)
106 {}
107 
108 
109 template<class Type>
111 (
112  const fanFvPatchField<Type>& ptf,
114 )
115 :
117  f_(ptf.f_),
118  jump_(ptf.jump_)
119 {}
120 
121 
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 
124 template<class Type>
126 (
127  const fvPatchFieldMapper& m
128 )
129 {
131 
132  // Jump is half size. Expand to full size, map and truncate.
133  if (jump_.size() && jump_.size() == this->size()/2)
134  {
135  label oldSize = jump_.size();
136  jump_.setSize(this->size());
137 
138  for (label i = oldSize; i < jump_.size(); i++)
139  {
140  jump_[i] = jump_[i-oldSize];
141  }
142 
143  jump_.autoMap(m);
144  jump_.setSize(oldSize);
145  }
146 }
147 
148 
149 template<class Type>
151 (
152  const fvPatchField<Type>& ptf,
153  const labelList& addr
154 )
155 {
157 
158  // Jump is half size. Expand to full size, map and truncate.
159  if (jump_.size() && jump_.size() == this->size()/2)
160  {
161  label oldSize = jump_.size();
162  jump_.setSize(this->size());
163 
164  for (label i = oldSize; i < jump_.size(); i++)
165  {
166  jump_[i] = jump_[i-oldSize];
167  }
168 
169  const fanFvPatchField<Type>& tiptf =
170  refCast<const fanFvPatchField<Type> >(ptf);
171 
172  jump_.rmap(tiptf.jump_, addr);
173 
174  jump_.setSize(oldSize);
175  }
176 }
177 
178 
179 template<class Type>
181 {
183  os.writeKeyword("patchType") << "cyclic" << token::END_STATEMENT << nl;
184 
186  os.writeKeyword("f") << f_ << token::END_STATEMENT << nl;
187  os.format(fmt0);
188 
189  this->writeEntry("value", os);
190 }
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // ************************ vim: set sw=4 sts=4 et: ************************ //