Loading...
Searching...
No Matches
sampledPatchTemplates.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) 2018-2022 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\*---------------------------------------------------------------------------*/
29#include "sampledPatch.H"
30
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
33template<class Type>
35Foam::sampledPatch::sampleOnFaces
36(
37 const interpolation<Type>& sampler
38) const
39{
40 const auto& vField = sampler.psi();
41
42 // One value per face
43 auto tvalues = tmp<Field<Type>>::New(patchFaceLabels_.size());
44 auto& values = tvalues.ref();
45
46 forAll(patchFaceLabels_, i)
47 {
48 const label patchi = patchIDs_[patchIndex_[i]];
49 const label patchFacei = patchFaceLabels_[i];
50
51 values[i] = vField.boundaryField()[patchi][patchFacei];
52 }
54 return tvalues;
55}
56
57
58template<class Type>
60Foam::sampledPatch::sampleOnFaces
61(
62 const SurfaceField<Type>& sField
63) const
64{
65 // One value per face
66 auto tvalues = tmp<Field<Type>>::New(patchFaceLabels_.size());
67 auto& values = tvalues.ref();
68
69 forAll(patchFaceLabels_, i)
70 {
71 const label patchi = patchIDs_[patchIndex_[i]];
72 const label patchFacei = patchFaceLabels_[i];
73
74 values[i] = sField.boundaryField()[patchi][patchFacei];
75 }
77 return tvalues;
78}
79
80
81template<class Type>
83Foam::sampledPatch::sampleOnPoints
84(
85 const interpolation<Type>& interpolator
86) const
87{
88 // One value per vertex
89 auto tvalues = tmp<Field<Type>>::New(points().size());
90 auto& values = tvalues.ref();
91
92 const labelList& own = mesh().faceOwner();
93
94 bitSet pointDone(points().size());
95
96 forAll(faces(), i)
97 {
98 const face& f = faces()[i];
99 const label patchi = patchIDs_[patchIndex_[i]];
100 const label patchFacei = patchFaceLabels_[i];
101
102 const polyPatch& pp = mesh().boundaryMesh()[patchi];
103
104 const label facei = patchFacei + pp.start();
105 const label celli = own[facei];
106
107 for (const label pointi : f)
108 {
109 if (pointDone.set(pointi))
110 {
111 values[pointi] = interpolator.interpolate
112 (
113 points()[pointi],
114 celli,
115 facei
116 );
117 }
118 }
119 }
120
121 return tvalues;
122}
123
124
125// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Abstract base class for volume field interpolation.
const GeometricField< Type, fvPatchField, volMesh > & psi() const noexcept
Return the field to be interpolated.
virtual Type interpolate(const vector &position, const label celli, const label facei=-1) const =0
Interpolate field to the given point in the given cell.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
virtual const labelList & faceOwner() const
Return face owner.
Definition polyMesh.C:1101
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
virtual const faceList & faces() const
Faces of surface.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
A class for managing temporary objects.
Definition tmp.H:75
dynamicFvMesh & mesh
const pointField & points
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.
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< Type, fvsPatchField, surfaceMesh > SurfaceField
A (volume) surface field for a given type.
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299