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-2021 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<>
36Foam::expressions::patchExpr::parseDriver::getSurfaceField<bool>
37(
38 const word& name
39)
40{
41 return getVariable<bool>(name, this->size());
42}
43
44
45template<>
47Foam::expressions::patchExpr::parseDriver::getPointField<bool>
48(
49 const word& name
50)
51{
52 return getVariable<bool>(name, this->pointSize());
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 labelList& 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 }
143 }
144
145 return tresult;
146}
147
148
151{
152 return patch_.magSf();
153}
154
155
158{
159 return patch_.Cf();
160}
161
162
165{
166 return patch_.Sf();
167}
168
169
172{
173 return patch_.patch().localPoints();
174}
175
176
179(
180 label seed,
181 bool gaussian
182) const
183{
184 auto tfld = tmp<scalarField>::New(this->size());
185
186 exprDriver::fill_random(tfld.ref(), seed, gaussian);
187
188 return tfld;
189}
190
191
192// ************************************************************************* //
bool found(const Key &key) const
Return true if hashed entry is found in table.
Definition: HashTableI.H:100
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void fill_random(scalarField &field, label seed=0, const bool gaussian=false) const
Fill a random field.
virtual label size() const
The natural field size for the expression.
tmp< vectorField > field_faceCentre() const
The face centres - (swak = pos)
tmp< boolField > field_cellSelection(const word &name, enum topoSetSource::sourceType setType) const
Cell selections (as logical)
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)
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:59
A class for managing references or pointers (no reference counting)
Definition: refPtr.H:58
A class for managing temporary objects.
Definition: tmp.H:65
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:75
@ FACESET_SOURCE
Faces as set.
Definition: topoSetSource.H:83
@ FACEZONE_SOURCE
Faces as zone.
Definition: topoSetSource.H:88
@ CELLSET_SOURCE
Cells as set.
Definition: topoSetSource.H:82
@ CELLZONE_SOURCE
Cells as zone.
Definition: topoSetSource.H:87
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333