fvPatchTemplates.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) 2019-2025 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 "fvPatch.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const UList<Type>& internalData,
37  const labelUList& addressing,
38  UList<Type>& pfld
39 ) const
40 {
41  // For v2412 and earlier this was a field and was resized here:
42  // const label len = this->size();
43  // pfld.resize_nocopy(len);
44  //
45  // Now uses pre-sized storage (note: behaves like a static method)
46 
47  const label len = pfld.size();
48 
49  #ifdef FULLDEBUG
50  if (FOAM_UNLIKELY((addressing.size() < len) || (this->size() < len)))
51  {
53  << "patchField size = " << len
54  << " but patch size = " << this->size()
55  << " and addressing size = " << addressing.size() << nl
56  << abort(FatalError);
57  }
58  #endif
59 
60  for (label i = 0; i < len; ++i)
61  {
62  pfld[i] = internalData[addressing[i]];
63  }
64 }
65 
66 
67 template<class Type>
69 (
70  const UList<Type>& internalData,
71  UList<Type>& pfld
72 ) const
73 {
74  // For v2412 and earlier this was a field and was resized here:
75  // pfld.resize_nocopy(this->size());
76  //
77  // Now uses pre-sized storage
78 
79  patchInternalField(internalData, this->faceCells(), pfld);
80 }
81 
82 
83 template<class Type>
85 (
86  const UList<Type>& internalData
87 ) const
88 {
89  auto tpfld = tmp<Field<Type>>::New(this->size());
90  patchInternalField(internalData, this->faceCells(), tpfld.ref());
91  return tpfld;
92 }
93 
94 
95 template<class GeometricField, class AnyType>
97 (
98  const GeometricField& gf
99 ) const
100 {
101  return gf.boundaryField()[this->index()];
102 }
103 
104 
105 // ************************************************************************* //
void patchInternalField(const UList< Type > &internalData, const labelUList &addressing, UList< Type > &pfld) const
Extract internal field next to patch using specified addressing.
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:119
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:652
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
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.
Generic GeometricField class.
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
#define FOAM_UNLIKELY(cond)
Definition: stdFoam.H:65
errorManip< error > abort(error &err)
Definition: errorManip.H:139
virtual label size() const
Patch size is the number of faces, but can be overloaded.
Definition: fvPatch.H:242
PatchField< Type > Patch
The patch field type for the GeometricBoundaryField.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.