Loading...
Searching...
No Matches
patchExprDriverFields.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) 2019-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "patchExprDriver.H"
29#include "fvPatch.H"
30#include "error.H"
31
32// * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
33
34template<>
37(
38 const word& name
39)
40{
41 return getVariable<bool>(name, this->size());
42}
43
44
45template<>
48(
49 const word& name
50)
51{
53}
54
55
56// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57
60(
61 const word& name,
62 enum topoSetSource::sourceType setType
63) const
64{
65 refPtr<labelList> tselected;
66 switch (setType)
67 {
70 {
71 tselected = getTopoSetLabels(name, setType);
72 break;
73 }
74
75 default:
76 {
78 << "Unexpected sourceType: " << int(setType) << nl
79 << exit(FatalError);
80 break;
81 }
82 }
83
84 // Not particularly efficient...
85 labelHashSet inSelection(tselected());
86
87 const labelUList& faceCells = patch_.faceCells();
88 auto tresult = tmp<boolField>::New(this->size(), false);
89 auto& result = tresult.ref();
90
91 forAll(result, facei)
92 {
93 if (inSelection.found(faceCells[facei]))
94 {
95 result[facei] = true;
96 }
97 }
98
99 return tresult;
100}
101
102
105(
106 const word& name,
107 enum topoSetSource::sourceType setType
108) const
109{
110 refPtr<labelList> tselected;
111 switch (setType)
112 {
115 {
116 tselected = getTopoSetLabels(name, setType);
117 break;
118 }
119
120 default:
121 {
123 << "Unexpected sourceType: " << int(setType) << nl
124 << exit(FatalError);
125 break;
126 }
127 }
128
129 // Not particularly efficient...
130 labelHashSet inSelection(tselected());
131
132 const label patchStart = patch_.start();
133
134 auto tresult = tmp<boolField>::New(this->size(), false);
135 auto& result = tresult.ref();
136
137 forAll(result, facei)
138 {
139 if (inSelection.found(facei + patchStart))
140 {
141 result[facei] = true;
142 }
144
145 return tresult;
146}
147
148
154
155
161
162
168
169
175
176
179{
180 return patch_.patch().localPoints();
181}
182
183
186(
187 label seed,
188 bool gaussian
189) const
190{
191 auto tfld = tmp<scalarField>::New(this->size());
192
193 exprDriver::fill_random(tfld.ref(), seed, gaussian);
194
195 return tfld;
196}
197
198
199// ************************************************************************* //
bool found(const Key &key) const
Same as contains().
Definition HashTable.H:1370
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
const exprResult & result() const noexcept
Const access to expression result.
Definition exprDriver.H:463
tmp< Field< Type > > getVariable(const word &name, const label expectSize, const bool mandatory=true) const
Retrieve local/global variable as a tmp field.
refPtr< labelList > getTopoSetLabels(const word &name, enum topoSetSource::sourceType setType) const
Get the labels associated with the topo set.
virtual label size() const
The natural field size for the expression.
virtual label pointSize() const
The point field size for the expression.
tmp< vectorField > field_faceCentre() const
The face centres - (swak = pos).
tmp< Field< Type > > getPointField(const word &fldName)
Retrieve field (point field).
tmp< boolField > field_cellSelection(const word &name, enum topoSetSource::sourceType setType) const
Cell selections (as logical).
tmp< vectorField > field_unitNormal() const
The face unit normal direction [nf] - (expression: normal).
tmp< Field< Type > > getSurfaceField(const word &fldName)
Retrieve field (surface field).
tmp< scalarField > field_rand(label seed=0, bool gaussian=false) const
A uniform random field.
tmp< boolField > field_faceSelection(const word &name, enum topoSetSource::sourceType setType) const
Face selections (as logical).
const fvPatch & patch_
The referenced patch.
tmp< scalarField > field_faceArea() const
The face area magnitudes [magSf] - (swak = area).
tmp< vectorField > field_areaNormal() const
The face areas with their vector direction [Sf] - (swak = face).
tmp< vectorField > field_pointField() const
The patch point locations - (swak = pts).
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
sourceType
Enumeration defining the types of sources.
@ FACESET_SOURCE
Faces as set.
@ FACEZONE_SOURCE
Faces as zone.
@ CELLSET_SOURCE
Cells as set.
@ CELLZONE_SOURCE
Cells as zone.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299