Loading...
Searching...
No Matches
coupledFaPatchField.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 Copyright (C) 2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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 "coupledFaPatchField.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const faPatch& p,
38)
41 faPatchField<Type>(p, iF)
42{}
43
44
45template<class Type>
47(
48 const faPatch& p,
50 const Field<Type>& f
51)
54 faPatchField<Type>(p, iF, f)
55{}
56
57
58template<class Type>
60(
62 const faPatch& p,
64 const faPatchFieldMapper& mapper
65)
68 faPatchField<Type>(ptf, p, iF, mapper)
69{}
70
71
72template<class Type>
74(
75 const faPatch& p,
77 const dictionary& dict,
79)
82 faPatchField<Type>(p, iF, dict, requireValue)
83{}
84
85
86template<class Type>
88(
90)
93 faPatchField<Type>(ptf)
94{}
95
96
97template<class Type>
99(
100 const coupledFaPatchField<Type>& ptf,
102)
103:
104 lduInterfaceField(refCast<const lduInterface>(ptf.patch())),
105 faPatchField<Type>(ptf, iF)
106{}
107
108
109// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110
111template<class Type>
113(
114 UList<Type>& result
115) const
116{
117 // Get patch neighbour field, store temporarily in result
118 this->patchNeighbourField(result);
119 const auto& pnf = result;
120
121 // Same as patchInternalField(...), assuming edgeFaces are an indirection
122 // into internal field, but without additional storage...
123 const auto& addr = this->patch().edgeFaces();
124 const auto& iF = this->primitiveField();
125
126 const auto& deltaCoeffs = this->patch().deltaCoeffs();
127
128 // snGrad = deltaCoeffs * (patchNeighbourField - patchInternalField)
129
130 const label len = result.size();
131
132 for (label i = 0; i < len; ++i)
134 result[i] = deltaCoeffs[i]*(pnf[i] - iF[addr[i]]);
135 }
136}
137
138
139template<class Type>
141{
142 auto tresult = tmp<Field<Type>>::New(this->size());
143 this->snGrad(static_cast<UList<Type>&>(tresult.ref()));
144 return tresult;
145}
146
147
148template<class Type>
150{
151 if (!this->updated())
153 this->updateCoeffs();
154 }
155}
156
157
158template<class Type>
159void Foam::coupledFaPatchField<Type>::evaluate(const Pstream::commsTypes)
160{
161 Field<Type>::operator=
162 (
163 lerp
164 (
165 this->patchNeighbourField(),
166 this->patchInternalField(),
167 this->patch().weights()
169 );
170}
171
172
173template<class Type>
176(
177 const tmp<scalarField>& w
178) const
180 return Type(pTraits<Type>::one)*w;
181}
182
183
184template<class Type>
187(
188 const tmp<scalarField>& w
189) const
191 return Type(pTraits<Type>::one)*(1.0 - w);
192}
193
194
195template<class Type>
199 return -Type(pTraits<Type>::one)*this->patch().deltaCoeffs();
200}
201
202
203template<class Type>
210
211template<class Type>
213{
216}
217
218
219// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
readOption
Enumeration defining read preferences.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
commsTypes
Communications types.
Definition UPstream.H:81
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
coupledFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
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 tmp< Field< Type > > patchNeighbourField() const =0
Return neighbour field of internal field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool updated() const noexcept
True if the boundary condition has already been updated.
const faPatch & patch() const noexcept
Return the patch.
A FieldMapper for finite-area patch fields.
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
static tmp< faPatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const faPatch &, const DimensionedField< Type, areaMesh > &)
Return a pointer to a new patchField created on freestore given patch and internal field.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
const Field< Type > & primitiveField() const noexcept
Return const-reference to the internal field values.
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
lduInterfaceField(const lduInterfaceField &)=delete
No copy construct.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
labelList f(nPoints)
dictionary dict