coupledFvPatchField.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "coupledFvPatchField.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
41  fvPatchField<Type>(p, iF)
42 {}
43 
44 
45 template<class Type>
47 (
48  const fvPatch& p,
50  const Field<Type>& f
51 )
52 :
54  fvPatchField<Type>(p, iF, f)
55 {}
56 
57 
58 template<class Type>
60 (
61  const coupledFvPatchField<Type>& ptf,
62  const fvPatch& p,
64  const fvPatchFieldMapper& mapper
65 )
66 :
68  fvPatchField<Type>(ptf, p, iF, mapper)
69 {}
70 
71 
72 template<class Type>
74 (
75  const fvPatch& p,
77  const dictionary& dict,
78  IOobjectOption::readOption requireValue
79 )
80 :
82  fvPatchField<Type>(p, iF, dict, requireValue)
83 {}
84 
85 
86 template<class Type>
88 (
89  const coupledFvPatchField<Type>& ptf
90 )
91 :
93  fvPatchField<Type>(ptf)
94 {}
95 
96 
97 template<class Type>
99 (
100  const coupledFvPatchField<Type>& ptf,
102 )
103 :
104  LduInterfaceField<Type>(refCast<const lduInterface>(ptf.patch())),
105  fvPatchField<Type>(ptf, iF)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class Type>
113 (
114  const scalarField& deltaCoeffs
115 ) const
116 {
117  return
118  deltaCoeffs
119  *(this->patchNeighbourField() - this->patchInternalField());
120 }
121 
122 
123 template<class Type>
125 {
126  if (!this->updated())
127  {
128  this->updateCoeffs();
129  }
130 }
131 
132 
133 template<class Type>
134 void Foam::coupledFvPatchField<Type>::evaluate(const Pstream::commsTypes)
135 {
136  if (!this->updated())
137  {
138  this->updateCoeffs();
139  }
140 
141  Field<Type>::operator=
142  (
143  lerp
144  (
145  this->patchNeighbourField(),
146  this->patchInternalField(),
147  this->patch().weights()
148  )
149  );
150 
152 }
153 
154 
155 template<class Type>
158 (
159  const tmp<scalarField>& w
160 ) const
161 {
162  return Type(pTraits<Type>::one)*w;
163 }
164 
165 
166 template<class Type>
169 (
170  const tmp<scalarField>& w
171 ) const
172 {
173  return Type(pTraits<Type>::one)*(1.0 - w);
174 }
175 
176 
177 template<class Type>
180 (
181  const scalarField& deltaCoeffs
182 ) const
183 {
184  return -Type(pTraits<Type>::one)*deltaCoeffs;
185 }
186 
187 
188 template<class Type>
191 {
193  return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs();
194 }
195 
196 
197 template<class Type>
200 (
201  const scalarField& deltaCoeffs
202 ) const
203 {
204  return -this->gradientInternalCoeffs(deltaCoeffs);
205 }
206 
207 
208 template<class Type>
211 {
213  return -this->gradientInternalCoeffs();
214 }
215 
216 
217 template<class Type>
219 {
222 }
223 
224 
225 // ************************************************************************* //
dictionary dict
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Type & refCast(U &obj)
A dynamic_cast (for references). Generates a FatalError on failed casts and uses the virtual type() m...
Definition: typeInfo.H:159
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void write(Ostream &) const
Write.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Generic templated field type.
Definition: Field.H:62
A FieldMapper for finite-volume patch fields.
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.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Abstract base class for coupled patches.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
labelList f(nPoints)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
coupledFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
readOption
Enumeration defining read preferences.