coupledFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
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 "coupledFvPatchField.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const fvPatch& p,
35 )
36 :
37  LduInterfaceField<Type>(refCast<const lduInterface>(p)),
38  fvPatchField<Type>(p, iF)
39 {}
40 
41 
42 template<class Type>
44 (
45  const fvPatch& p,
47  const Field<Type>& f
48 )
49 :
50  LduInterfaceField<Type>(refCast<const lduInterface>(p)),
51  fvPatchField<Type>(p, iF, f)
52 {}
53 
54 
55 template<class Type>
57 (
58  const fvPatch& p,
60  const dictionary& dict,
61  const bool valueRequired
62 )
63 :
64  LduInterfaceField<Type>(refCast<const lduInterface>(p)),
65  fvPatchField<Type>(p, iF, dict, valueRequired)
66 {}
67 
68 
69 template<class Type>
71 (
72  const coupledFvPatchField<Type>& ptf,
73  const fvPatch& p,
75  const fieldMapper& mapper
76 )
77 :
78  LduInterfaceField<Type>(refCast<const lduInterface>(p)),
79  fvPatchField<Type>(ptf, p, iF, mapper, false)
80 {
81  mapper(*this, ptf, pTraits<Type>::nan);
82 }
83 
84 
85 template<class Type>
87 (
88  const coupledFvPatchField<Type>& ptf,
90 )
91 :
92  LduInterfaceField<Type>(refCast<const lduInterface>(ptf.patch())),
93  fvPatchField<Type>(ptf, iF)
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class Type>
101 (
102  const fvPatchField<Type>& ptf,
103  const fieldMapper& mapper
104 )
105 {
106  mapper(*this, ptf, pTraits<Type>::nan);
107 }
108 
109 
110 template<class Type>
112 (
113  const scalarField& deltaCoeffs
114 ) const
115 {
116  return
117  deltaCoeffs
118  *(this->patchNeighbourField() - this->patchInternalField());
119 }
120 
121 
122 template<class Type>
124 {
125  if (!this->updated())
126  {
127  this->updateCoeffs();
128  }
129 }
130 
131 
132 template<class Type>
134 {
136  (
137  this->patch().weights()*this->patchInternalField()
138  + (1.0 - this->patch().weights())*this->patchNeighbourField()
139  );
140 }
141 
142 
143 template<class Type>
145 {
146  if (!this->updated())
147  {
148  this->updateCoeffs();
149  }
150 
151  evaluateNoUpdateCoeffs();
152 
154 }
155 
156 
157 template<class Type>
160 (
161  const tmp<scalarField>& w
162 ) const
163 {
164  return Type(pTraits<Type>::one)*w;
165 }
166 
167 
168 template<class Type>
171 (
172  const tmp<scalarField>& w
173 ) const
174 {
175  return Type(pTraits<Type>::one)*(1.0 - w);
176 }
177 
178 
179 template<class Type>
182 (
183  const scalarField& deltaCoeffs
184 ) const
185 {
186  return -Type(pTraits<Type>::one)*deltaCoeffs;
187 }
188 
189 
190 template<class Type>
193 {
195  return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs();
196 }
197 
198 
199 template<class Type>
202 (
203  const scalarField& deltaCoeffs
204 ) const
205 {
206  return -this->gradientInternalCoeffs(deltaCoeffs);
207 }
208 
209 
210 template<class Type>
213 {
215  return -this->gradientInternalCoeffs();
216 }
217 
218 
219 template<class Type>
221 {
223  writeEntry(os, "value", *this);
224 }
225 
226 
227 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
Abstract base class for coupled patches.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
void evaluateNoUpdateCoeffs()
Evaluate the patch field, but don't update the coeffs.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
coupledFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:209
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Traits class for primitives.
Definition: pTraits.H:53
A class for managing temporary objects.
Definition: tmp.H:55
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:129
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
labelList f(nPoints)
dictionary dict
volScalarField & p