FreeFOAM The Cross-Platform CFD Toolkit
mixedPointPatchField.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 "mixedPointPatchField.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 
36 template<class Type>
37 void mixedPointPatchField<Type>::checkFieldSize() const
38 {
39  if
40  (
41  this->size() != this->patch().size()
42  || refValue_.size() != this->patch().size()
43  || valueFraction_.size() != this->patch().size()
44  )
45  {
47  (
48  "void mixedPointPatchField<Type>::checkField() const"
49  ) << "field does not correspond to patch. " << endl
50  << "Field size: " << this->size() << " value size: "
51  << refValue_.size()
52  << " valueFraction size: " << valueFraction_.size()
53  << " patch size: " << this->patch().size()
54  << abort(FatalError);
55  }
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
61 template<class Type>
63 (
64  const pointPatch& p,
66 )
67 :
69  refValue_(p.size()),
70  valueFraction_(p.size())
71 {}
72 
73 
74 template<class Type>
76 (
77  const pointPatch& p,
79  const dictionary& dict
80 )
81 :
82  valuePointPatchField<Type>(p, iF, dict, false),
83  refValue_("refValue", dict, p.size()),
84  valueFraction_("valueFraction", dict, p.size())
85 {}
86 
87 
88 template<class Type>
90 (
91  const mixedPointPatchField<Type>& ptf,
92  const pointPatch& p,
94  const pointPatchFieldMapper& mapper
95 )
96 :
98  (
99  ptf,
100  p,
101  iF,
102  mapper
103  ),
104  refValue_(ptf.refValue_, mapper),
105  valueFraction_(ptf.valueFraction_, mapper)
106 
107 {}
108 
109 
110 template<class Type>
112 (
113  const mixedPointPatchField<Type>& ptf,
115 )
116 :
118  refValue_(ptf.refValue_),
119  valueFraction_(ptf.valueFraction_)
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
125 // Map and resize from self given a mapper
126 template<class Type>
128 (
129  const pointPatchFieldMapper& m
130 )
131 {
133  refValue_.autoMap(m);
134  valueFraction_.autoMap(m);
135 }
136 
137 
138 // Grab the values using rmap
139 template<class Type>
141 (
142  const pointPatchField<Type>& ptf,
143  const labelList& addr
144 )
145 {
146  const mixedPointPatchField<Type>& mptf =
147  refCast<const mixedPointPatchField<Type> >(ptf);
148 
149  Field<Type>::rmap(mptf, addr);
150  refValue_.rmap(mptf.refValue_, addr);
151  valueFraction_.rmap(mptf.valueFraction_, addr);
152 }
153 
154 
155 // Evaluate patch field
156 template<class Type>
158 {
160  (
161  valueFraction_*refValue_
162  + (1.0 - valueFraction_)*this->patchInternalField()
163  );
164 
165  // Get internal field to insert values into
166  Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
167 
168  setInInternalField(iF, *this);
169 }
170 
171 
172 // Write
173 template<class Type>
175 {
177  refValue_.writeEntry("refValue", os);
178  valueFraction_.writeEntry("valueFraction", os);
179 }
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace Foam
185 
186 // ************************ vim: set sw=4 sts=4 et: ************************ //