faPatchTemplates.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) 2019-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 "faPatch.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const UList<Type>& internalData,
37  const labelUList& addressing,
38  Field<Type>& pfld
39 ) const
40 {
41  const label len = this->size();
42 
43  pfld.resize_nocopy(len);
44 
45  for (label i = 0; i < len; ++i)
46  {
47  pfld[i] = internalData[addressing[i]];
48  }
49 }
50 
51 
52 template<class Type>
54 (
55  const UList<Type>& internalData,
56  Field<Type>& pfld
57 ) const
58 {
59  patchInternalField(internalData, this->edgeFaces(), pfld);
60 }
61 
62 
63 template<class Type>
65 (
66  const UList<Type>& internalData
67 ) const
68 {
69  auto tpfld = tmp<Field<Type>>::New();
70  patchInternalField(internalData, this->edgeFaces(), tpfld.ref());
71  return tpfld;
72 }
73 
74 
75 template<class GeometricField, class AnyType>
77 (
78  const GeometricField& gf
79 ) const
80 {
81  return gf.boundaryField()[this->index()];
82 }
83 
84 
85 // ************************************************************************* //
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
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.
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition: faPatch.H:392
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition: ListI.H:175
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
Generic templated field type.
Definition: Field.H:62
void patchInternalField(const UList< Type > &internalData, const labelUList &addressing, Field< Type > &pfld) const
Extract internal field next to patch using specified addressing.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.