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-2022 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>& f,
37  const labelUList& edgeFaces,
38  Field<Type>& pfld
39 ) const
40 {
41  pfld.resize(size());
42 
43  forAll(pfld, i)
44  {
45  pfld[i] = f[edgeFaces[i]];
46  }
47 }
48 
49 
50 template<class Type>
52 (
53  const UList<Type>& f
54 ) const
55 {
56  auto tpfld = tmp<Field<Type>>::New(size());
57  patchInternalField(f, this->edgeFaces(), tpfld.ref());
58  return tpfld;
59 }
60 
61 
62 template<class Type>
64 (
65  const UList<Type>& f,
66  const labelUList& edgeFaces
67 ) const
68 {
69  auto tpfld = tmp<Field<Type>>::New(size());
70  patchInternalField(f, edgeFaces, tpfld.ref());
71  return tpfld;
72 }
73 
74 
75 template<class Type>
77 (
78  const UList<Type>& f,
79  Field<Type>& pfld
80 ) const
81 {
82  patchInternalField(f, this->edgeFaces(), pfld);
83 }
84 
85 
86 template<class GeometricField, class AnyType>
88 (
89  const GeometricField& gf
90 ) const
91 {
92  return gf.boundaryField()[this->index()];
93 }
94 
95 
96 // ************************************************************************* //
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:132
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition: faPatch.H:385
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
Generic templated field type.
Definition: Field.H:61
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:422
labelList f(nPoints)
void patchInternalField(const UList< Type > &f, const labelUList &edgeFaces, Field< Type > &pfld) const
Extract internal field next to patch using edgeFaces mapping.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.