GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmInterpolator.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_INTERPOLATOR_H_
25#define _GEMA_INTERPOLATOR_H_
26
27#include "gmCoreConfig.h"
28#include "gmVector.h"
29#include "gmMatrix.h"
30
31#include <QVariant>
32
33class GmValueAccessor;
34class GmElement;
35class GmMesh;
36class GmPluginLoader;
38
45
46
56
64{
78
91
104
114
125
126 // IMPORTANT: When adding new enum values, please remember to also update
127 // GmInterpolator::interpolatorTypeToStr(),
128 // GmInterpolator::strToInterpolatorType() and
129 // GmInterpolator::interpolatorObjectFromType()
130
131 //-------- NO INSERTION BELOW THIS LINE ----------
136
137
138/*
139 Enum class used for selection of cell's subset when interpolating
140 discontinuous elements (continuum x interface)
141 The first option ignores the new behavior and is equivalent
142 to not using subsets
143*/
144enum class GmInterpolatorSubset {
145 GM_SUBSET_ALL = 0,
146 GM_SUBSET_CONTINUUM,
147 GM_SUBSET_INTERFACE,
149 GM_SUBSET_COUNT,
150};
151
156{
157public:
159 virtual GmInterpolatorType type() const = 0;
160
162 virtual bool typeParamIsValid(const QVariant& v) const { return !v.isValid(); }
163
165 virtual QString typeParamToStr(const QVariant& v) const { Q_UNUSED(v); return ""; }
166
168 virtual bool supportsInterpolatorKind(GmInterpolatorKind kind) const = 0;
169
174 virtual bool requiresElement() const { return false; }
175
180 virtual bool requiresMesh() const { return false; }
181
186 virtual bool requiresNaturalCoordinates() const { return false; }
187
188 virtual bool interpolationWeights(GmInterpolatorCoordinateSetBinding* pointSet, const GmVector& coord,
189 const QVariant& typeParam, GmVector& weights) const;
190
202 const GmVector& squaredDistances, const QVariant& typeParam,
203 GmVector& weights) const
204 {
205 Q_UNUSED(pointSet); Q_UNUSED(coord); Q_UNUSED(squaredDistances); Q_UNUSED(typeParam); Q_UNUSED(weights);
206 // This function should be reimplemented if interpolationWeights() was not reimplemented
207 assert(0);
208 return false;
209 }
210
227 QVariant& typeParam, GmMatrix& weights) const
228 {
229 Q_UNUSED(pointSet); Q_UNUSED(typeParam);
230 assert(0);
231 return weights;
232 }
233
234protected:
235 friend class GmInterpolator;
236
239};
240
245{
246public:
248 virtual ~GmInterpolator() {}
249
254 bool isValid() const { return _interp; }
255
257 const GmInterpolatorObject* interpolatorObject() const { return _interp; }
258
260 const GmMesh* mesh() const { return _mesh; }
261
263 QString interpolatorTypeToStr() const { return _interp ? interpolatorTypeToStr(_interp->type(), _interpParam) : QObject::tr("invalid"); }
264
265 static bool initInterpolators();
266
267 static QString interpolatorTypeToStr(GmInterpolatorType type, const QVariant& typeParam);
268 static int strToInterpolatorType(QString str, bool acceptsNo = false);
269
270 static bool validInterpolatorForKind(GmInterpolatorType type, const QVariant& typeParam, GmInterpolatorKind kind);
271
272protected:
274 const GmValueAccessor* coordAccessor, const GmMesh* mesh, bool skipTests = false);
275
276 bool interpolate(GmInterpolatorCoordinateSetBinding* pointSet, GmInterpolatorInputDataBinding* inData,
278
279 void gaussToNodesInterpolate(GmInterpolatorGaussCoordinateSetBinding* pointSet, GmInterpolatorInputDataBinding* inData,
281
282 static void scalarVectorListToVector(const QVector<GmVector>& vectorList, GmVector& scalarVector);
283
284 static const GmInterpolatorObject* interpolatorObjectFromType(GmInterpolatorType type);
285
286#ifdef ENABLE_TESTS
287 // Allows test function to call interpolatorObjectFromType()
288 friend Q_DECL_EXPORT void TEST_InterpolatorCoordinateBindings(GmPluginLoader*, const GmLogCategory&, GmLogLevel);
289#endif
290
294 const GmMesh* _mesh;
295
296private:
297 static const GmInterpolatorObject* _iObjects[GM_NUM_INTERPOLATORS];
298};
299
300#endif
Base interface for providing discontinuity geometry information for spatial indices.
Definition gmDiscontinuitySet.h:59
Base interface for FEM (finite element) mesh elements.
Definition gmElement.h:38
Basic interface for a set storing point cartesian coordinates. This set can be filled with points fro...
Definition gmInterpolatorCoordinateBindings.h:75
Interface for a coordinate set that stores Gauss point coordinates. Besides returning coordinates,...
Definition gmInterpolatorCoordinateBindings.h:176
Interpolator class used for managing available interpolator algorithms and providing basic support fu...
Definition gmInterpolator.h:245
const GmInterpolatorObject * _interp
The interpolator object for the requested interpolation type. NULL if this interpolator is invalid.
Definition gmInterpolator.h:291
const GmValueAccessor * _coordAc
The accessor for node coordinates.
Definition gmInterpolator.h:293
const GmInterpolatorObject * interpolatorObject() const
Returns the interpolator object used by this interpolator.
Definition gmInterpolator.h:257
const GmMesh * _mesh
The mesh containing the source data points. Can be NULL since it is required by only some interpolato...
Definition gmInterpolator.h:294
const GmMesh * mesh() const
Returns the mesh associated with this interpolator. Can be NULL.
Definition gmInterpolator.h:260
bool isValid() const
Is this a valid object? Invalid objects can arise, for example, if the interpolator type given in the...
Definition gmInterpolator.h:254
QVariant _interpParam
The interpolator parameter received on the constructor.
Definition gmInterpolator.h:292
QString interpolatorTypeToStr() const
Returns a string representing the interpolator object.
Definition gmInterpolator.h:263
virtual ~GmInterpolator()
Virtual destructor.
Definition gmInterpolator.h:248
Binding class used to store the set of known values associated with the points used in the interpolat...
Definition gmInterpolatorInputBindings.h:42
Interface class for the implementation of each of the possible interpolation algorithms available in ...
Definition gmInterpolator.h:156
GmInterpolatorObject()
Protected default constructor to make sure that Interpolator objects are created only by the GmInterp...
Definition gmInterpolator.h:238
virtual bool supportsInterpolatorKind(GmInterpolatorKind kind) const =0
Returns whether this interpolator object supports the given interpolator kind or not.
virtual bool requiresElement() const
Does this interpolator object requires that the coordinate set provided to interpolationWeights() con...
Definition gmInterpolator.h:174
virtual GmInterpolatorType type() const =0
Returns the interpolator object type.
virtual bool typeParamIsValid(const QVariant &v) const
Is the given interpolator type parameter valid? The default implementation accepts only empty variant...
Definition gmInterpolator.h:162
virtual bool distanceBasedWeights(GmInterpolatorCoordinateSetBinding *pointSet, const GmVector &coord, const GmVector &squaredDistances, const QVariant &typeParam, GmVector &weights) const
Worker function for the default implementation of interpolationWeights(). This is the function that n...
Definition gmInterpolator.h:201
virtual bool requiresNaturalCoordinates() const
Does this interpolator object requires that the coordinate passed as parameter to interpolationWeight...
Definition gmInterpolator.h:186
virtual bool requiresMesh() const
Does this interpolator object requires that the coordinate set provided to interpolationWeights() con...
Definition gmInterpolator.h:180
virtual QString typeParamToStr(const QVariant &v) const
Converts an interpolator type parameter to a string.
Definition gmInterpolator.h:165
virtual const GmMatrix & gaussToNodesExtrapolationMatrix(GmInterpolatorGaussCoordinateSetBinding *pointSet, const QVariant &typeParam, GmMatrix &weights) const
Basic function for returning the extrapolation matrix used by the GM_GAUSS_TO_NODE_INTERPOLATOR inter...
Definition gmInterpolator.h:226
Binding class used to provide the coordinate of the interpolated point, either in cartesian or natura...
Definition gmInterpolatorCoordinateBindings.h:598
Binding class used to host the data structure where calculated interpolated values will be stored....
Definition gmInterpolatorOutputBindings.h:43
Binding class used to host the data structure where calculated interpolated values will be stored for...
Definition gmInterpolatorOutputBindings.h:261
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
Class responsible for managing discovery and loading of plugins.
Definition gmPluginLoader.h:43
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
GmInterpolatorType
Available interpolation methods. Not every method is suitable for every kind of interpolator class....
Definition gmInterpolator.h:64
@ GM_MLS_INTERPOLATOR
Interpolated value is based on the moving least squares method. A method parameter specifies the RBF ...
Definition gmInterpolator.h:103
@ GM_DEFAULT_INTERPOLATOR
Interpolation should be done using the default method for the interpolator object.
Definition gmInterpolator.h:134
@ GM_IDW_INTERPOLATOR
Interpolated value is the average of the known values weighted by inverse distance from the interpola...
Definition gmInterpolator.h:90
@ GM_SHAPE_INTERPOLATOR
Interpolated value is found by using the elements shape function.
Definition gmInterpolator.h:113
@ GM_LSHAPE_INTERPOLATOR
Interpolated value is found by using the elements equivalent linear shape function....
Definition gmInterpolator.h:124
@ GM_NO_INTERPOLATOR
No interpolation needed. Not valid to construct an interpolator object but useful when defining user ...
Definition gmInterpolator.h:133
@ GM_NN_INTERPOLATOR
Interpolated value is equal to the value of the closest known value from the interpolation point....
Definition gmInterpolator.h:77
@ GM_NUM_INTERPOLATORS
The number of available interpolators.
Definition gmInterpolator.h:132
GmInterpolatorKind
Enum identifying the types of available interpolation classes.
Definition gmInterpolator.h:49
@ GM_GAUSS_TO_NODE_INTERPOLATOR_H
Classes for interpolating values in Gauss points to hierarchical element nodes.
Definition gmInterpolator.h:54
@ GM_POINTCLOUD_TO_POINT_INTERPOLATOR
Classes for interpolating values in a point cloud to another point.
Definition gmInterpolator.h:53
@ GM_GAUSS_TO_NODE_INTERPOLATOR
Classes for interpolating values in Gauss points to element nodes.
Definition gmInterpolator.h:51
@ GM_NODE_TO_POINT_INTERPOLATOR
Classes for interpolating values in cell nodes to points inside the cell.
Definition gmInterpolator.h:50
@ GM_GAUSS_TO_POINT_INTERPOLATOR
Classes for interpolating values in Gauss points to element points.
Definition gmInterpolator.h:52
GmLogLevel
Available log levels list.
Definition gmLog.h:36
Declaration of the GmMatrix class.
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
Declaration of the GmVector class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
QString tr(const char *sourceText, const char *disambiguation, int n)
bool isValid() const const