Loading...
Searching...
No Matches
MappedFileFilterField.H
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) 2022 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
26Class
27 Foam::PatchFunction1Types::FilterField
28
29Description
30 The FilterField helper class provides a multi-sweep median filter
31 for a Field of data associated with a geometric point cloud.
32
33 The points can be freestanding or the faceCentres (or points)
34 of a meshedSurface, for example.
35
36 Using an initial specified search radius, the nearest point
37 neighbours are gathered and addressing/weights are built for them.
38 This currently uses an area-weighted, linear RBF interpolator
39 with provision for quadratic RBF interpolator etc.
40
41 After the weights and addressing are established,
42 the evaluate() method can be called to apply a median filter
43 to data fields, with a specified number of sweeps.
44
45Note
46 When handling large search radii and/or an extensive number of
47 filter sweeps, compiling with openmp can yield some speedup.
48
49SourceFiles
50 MappedFileFilterField.C
51 MappedFileFilterFieldTemplates.C
52
53\*---------------------------------------------------------------------------*/
54
55#ifndef Foam_PatchFunction1Types_MappedFileFilterField_H
56#define Foam_PatchFunction1Types_MappedFileFilterField_H
57
58#include "primitiveFields.H"
59#include "pointField.H"
60#include "Enum.H"
61#include "className.H"
62#include "MeshedSurfacesFwd.H"
63
64// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65
66namespace Foam
67{
68namespace PatchFunction1Types
69{
71/*---------------------------------------------------------------------------*\
72 Class FilterField Declaration
73\*---------------------------------------------------------------------------*/
74
75class FilterField
76{
77public:
78
79 // Data Types
80
81 //- Basis type
83 {
86 };
87
88
89private:
90
91 // Private Data
92
93 //- Names for RBF basis types
94 static const Enum<RBF_type> RBF_typeNames_;
95
96 //- Addressing
97 List<labelList> addressing_;
98
99 //- Weights
100 List<scalarField> weights_;
101
102
103 // Private Member Functions
104
105 //- Construct neighbour point weights and addressing based
106 //- on specified search radius
107 //
108 // Search with local sphere
109 //
110 // RadiusSqrOp (index) -> radiusSqr
111 // BasisFunctionOp(point, point, radius^2) -> RBF
112 // PointWeightFieldType [index] -> weighting
113 template
114 <
115 class TreeType,
116 class RadiusSqrOp,
117 class BasisFunctionOp,
118 class PointWeightFieldType
119 >
120 void buildWeightsImpl
121 (
122 const TreeType& tree,
123 const RadiusSqrOp& radiusSqrOp,
124 const BasisFunctionOp& basisFuncOp,
125 const PointWeightFieldType& pointWeightFld
126 );
127
128
129public:
130
131 //- Runtime type information
132 ClassName("filterField");
133
134
135 // Constructors
136
137 //- Default construct
138 FilterField() noexcept = default;
139
140 //- Construct with weights for a field of points
141 //- (constant search radius)
143 (
144 const pointField& points,
145 const scalar radius,
146 const RBF_type interp = RBF_type::RBF_linear
147 );
149 //- Construct with weights for faceCentres of a meshedSurface
150 //- using a constant search radius search
151 //- (or relative radius multiplier for the face bounding spheres).
153 (
154 const meshedSurface& geom,
155 const scalar radius,
156 const bool relative = false,
157 const RBF_type interp = RBF_type::RBF_linear
158 );
159
160
161 // Member Functions
162
163 //- Reset to unweighted (pass-through)
164 void reset();
165
166 //- Create weights for field of points (constant search radius)
167 void reset
168 (
169 const pointField& points,
170 const scalar radius,
171 const RBF_type interp = RBF_type::RBF_linear
172 );
173
174 //- Create weights for meshedSurface using a constant search radius
175 //- or optionally with a search radius multiplier for the
176 //- face bounding spheres.
177 void reset
178 (
179 const meshedSurface& geom,
180 const scalar radius,
181 const bool relative = false,
182 const RBF_type interp = RBF_type::RBF_linear
183 );
184
185
186 // Evaluation
187
188 //- Return the median smoothed field
189 template<class Type>
190 tmp<Field<Type>> evaluate
191 (
192 const tmp<Field<Type>>& tinput,
193 const label nSweeps
194 ) const;
195};
196
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200} // End namespace PatchFunction1Types
201} // End namespace Foam
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205#ifdef NoRepository
207#endif
208
209// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210
211#endif
213// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
tmp< Field< Type > > evaluate(const tmp< Field< Type > > &tinput, const label nSweeps) const
Return the median smoothed field.
FilterField() noexcept=default
Default construct.
void reset()
Reset to unweighted (pass-through).
ClassName("filterField")
Runtime type information.
A class for managing temporary objects.
Definition tmp.H:75
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
const pointField & points
Namespace for OpenFOAM.
MeshedSurface< face > meshedSurface
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
Specialisations of Field<T> for scalar, vector and tensor.
Tree tree(triangles.begin(), triangles.end())