Loading...
Searching...
No Matches
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-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 "faPatch.H"
30
31// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33template<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
67template<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->edgeFaces(), pfld);
80}
81
82
83template<class Type>
85(
86 const UList<Type>& internalData
87) const
88{
89 auto tpfld = tmp<Field<Type>>::New(this->size());
90 patchInternalField(internalData, this->edgeFaces(), tpfld.ref());
91 return tpfld;
92}
93
94
95template<class GeometricField, class AnyType>
97(
98 const GeometricField& gf
99) const
100{
101 return gf.boundaryField()[this->index()];
102}
103
104
105// ************************************************************************* //
Generic GeometricField class.
PatchField< Type > Patch
The patch field type for the GeometricBoundaryField.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
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
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition faPatch.H:392
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition faPatch.C:424
void patchInternalField(const UList< Type > &internalData, const labelUList &addressing, UList< Type > &pfld) const
Extract internal field next to patch using specified addressing.
label index() const noexcept
The index of this patch in the boundaryMesh.
A class for managing temporary objects.
Definition tmp.H:75
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
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.
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
Definition UList.H:75
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define FOAM_UNLIKELY(cond)
Definition stdFoam.H:64