mixedFaPatchField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 Wikki Ltd
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "mixedFaPatchField.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const faPatch& p,
37 )
38 :
39  faPatchField<Type>(p, iF),
40  refValue_(p.size()),
41  refGrad_(p.size()),
42  valueFraction_(p.size())
43 {}
44 
45 
46 template<class Type>
48 (
49  const mixedFaPatchField<Type>& ptf,
50  const faPatch& p,
52  const faPatchFieldMapper& mapper
53 )
54 :
55  faPatchField<Type>(ptf, p, iF, mapper),
56  refValue_(ptf.refValue_, mapper),
57  refGrad_(ptf.refGrad_, mapper),
58  valueFraction_(ptf.valueFraction_, mapper)
59 {}
60 
61 
62 template<class Type>
64 (
65  const faPatch& p,
67  const dictionary& dict
68 )
69 :
70  faPatchField<Type>(p, iF),
71  refValue_("refValue", dict, p.size()),
72  refGrad_("refGradient", dict, p.size()),
73  valueFraction_("valueFraction", dict, p.size())
74 {
75  evaluate();
76 }
77 
78 
79 template<class Type>
81 (
82  const mixedFaPatchField<Type>& ptf
83 )
84 :
85  faPatchField<Type>(ptf),
86  refValue_(ptf.refValue_),
87  refGrad_(ptf.refGrad_),
88  valueFraction_(ptf.valueFraction_)
89 {}
90 
91 
92 template<class Type>
94 (
95  const mixedFaPatchField<Type>& ptf,
97 )
98 :
99  faPatchField<Type>(ptf, iF),
100  refValue_(ptf.refValue_),
101  refGrad_(ptf.refGrad_),
102  valueFraction_(ptf.valueFraction_)
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
108 template<class Type>
110 (
111  const faPatchFieldMapper& m
112 )
113 {
115  refValue_.autoMap(m);
116  refGrad_.autoMap(m);
117  valueFraction_.autoMap(m);
118 }
119 
120 
121 template<class Type>
123 (
124  const faPatchField<Type>& ptf,
125  const labelList& addr
126 )
127 {
128  faPatchField<Type>::rmap(ptf, addr);
129 
130  const mixedFaPatchField<Type>& mptf =
131  refCast<const mixedFaPatchField<Type>>(ptf);
132 
133  refValue_.rmap(mptf.refValue_, addr);
134  refGrad_.rmap(mptf.refGrad_, addr);
135  valueFraction_.rmap(mptf.valueFraction_, addr);
136 }
137 
138 
139 template<class Type>
141 {
142  if (!this->updated())
143  {
144  this->updateCoeffs();
145  }
146 
148  (
149  valueFraction_*refValue_
150  +
151  (1.0 - valueFraction_)*
152  (
153  this->patchInternalField()
154  + refGrad_/this->patch().deltaCoeffs()
155  )
156  );
157 
159 }
160 
161 
162 template<class Type>
164 {
165  return
166  valueFraction_
167  *(refValue_ - this->patchInternalField())
168  *this->patch().deltaCoeffs()
169  + (1.0 - valueFraction_)*refGrad_;
170 }
171 
172 
173 template<class Type>
175 (
176  const tmp<scalarField>&
177 ) const
178 {
179  return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
180 }
181 
182 
183 template<class Type>
185 (
186  const tmp<scalarField>&
187 ) const
188 {
189  return
190  valueFraction_*refValue_
191  + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
192 }
193 
194 
195 template<class Type>
198 {
199  return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
200 }
201 
202 
203 template<class Type>
206 {
207  return
208  valueFraction_*this->patch().deltaCoeffs()*refValue_
209  + (1.0 - valueFraction_)*refGrad_;
210 }
211 
212 
213 template<class Type>
215 {
217  refValue_.writeEntry("refValue", os);
218  refGrad_.writeEntry("refGradient", os);
219  valueFraction_.writeEntry("valueFraction", os);
220  this->writeEntry("value", os);
221 }
222 
223 
224 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
mixedFaPatchField.H
Foam::mixedFaPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFaPatchField.C:175
Foam::mixedFaPatchField::autoMap
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: mixedFaPatchField.C:110
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::mixedFaPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: mixedFaPatchField.C:185
Foam::mixedFaPatchField::rmap
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: mixedFaPatchField.C:123
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::mixedFaPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: mixedFaPatchField.C:205
Foam::mixedFaPatchField::mixedFaPatchField
mixedFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: mixedFaPatchField.C:34
Foam::mixedFaPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFaPatchField.C:197
Foam::mixedFaPatchField::write
virtual void write(Ostream &) const
Write.
Definition: mixedFaPatchField.C:214
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mixedFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: mixedFaPatchField.H:54
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::mixedFaPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: mixedFaPatchField.C:140
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
Foam::mixedFaPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Definition: mixedFaPatchField.C:163
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37