Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
bitpit::RBFKernel Class Referenceabstract

Base class to handle Radial Basis Function with a large set of nodes. More...

Inheritance diagram for bitpit::RBFKernel:
Inheritance graph
[legend]
Collaboration diagram for bitpit::RBFKernel:
Collaboration graph
[legend]

Public Member Functions

 RBFKernel ()
 
 RBFKernel (const RBFKernel &other)
 
void activateAllNodes ()
 
bool activateNode (const std::vector< int > &)
 
bool activateNode (int)
 
int addData ()
 
int addData (const std::vector< double > &)
 
void deactivateAllNodes ()
 
bool deactivateNode (const std::vector< int > &)
 
bool deactivateNode (int)
 
void enablePolynomial (bool enable=true)
 
double evalBasis (double)
 
double evalBasisPair (int i, int j)
 
std::vector< double > evalRBF (const std::array< double, 3 > &)
 
std::vector< double > evalRBF (int jnode)
 
void fitDataToNodes ()
 
void fitDataToNodes (int)
 
int getActiveCount ()
 
std::vector< int > getActiveSet ()
 
int getDataCount ()
 
RBFBasisFunction getFunctionType ()
 
RBFMode getMode ()
 
int getPolynomialDimension ()
 
int getPolynomialWeightsCount ()
 
double getSupportRadius ()
 
double getSupportRadius (int)
 
const std::vector< std::vector< double > > & getWeights () const
 
int greedy (double)
 
bool isActive (int)
 
void removeAllData ()
 
bool removeData (int)
 
bool removeData (std::vector< int > &)
 
void setDataToAllNodes (int, const std::vector< double > &)
 
void setDataToNode (int, const std::vector< double > &)
 
void setFunction (double(&funct)(double))
 
void setFunction (RBFBasisFunction)
 
void setMode (RBFMode mode)
 
void setSupportRadius (const std::vector< double > &)
 
void setSupportRadius (double)
 
int solve ()
 

Protected Member Functions

int addGreedyPoint ()
 
double evalError ()
 
int solveLSQ ()
 
void swap (RBFKernel &x) noexcept
 

Protected Attributes

std::vector< bool > m_activeNodes
 
int m_maxFields
 
int m_nodes
 
std::vector< int > m_polyActiveBasis
 
bool m_polyEnabled
 
LinearPolynomial m_polynomial
 
std::vector< std::vector< double > > m_value
 
std::vector< std::vector< double > > m_weight
 

Detailed Description

Base class to handle Radial Basis Function with a large set of nodes.

The class can be used in two different ways:

The User can switch between modes, according to its needs. Some internal methods of the class can change their behaviour according to the class mode selected. Please check documentation of each single method to appreciate the differences. Default mode of the class is the "INTERP" RBFMode:: In case of interpolation the contribution of a linear polynomial can be added to regularize the interpolation problem by enabling the polynomial usage.
The actual abstract class does not implement the type of node you want to use; it can be a 3D point or an unstructured mesh. Anyway what you have to do in deriving your own RBF class is to specify a type of node you want to use and implement an evaluator of distances node/node or anywhere point in space/node.

Definition at line 69 of file rbf.hpp.

Constructor & Destructor Documentation

◆ RBFKernel() [1/2]

bitpit::RBFKernel::RBFKernel ( )

Default constructor. RBFBasisFunction is WENDLANDC2 by default. RBFMode is INTERP, by default. Use setFunction and setMode for changing it.

Definition at line 64 of file rbf.cpp.

◆ RBFKernel() [2/2]

bitpit::RBFKernel::RBFKernel ( const RBFKernel & other)

Copy Constructor

Definition at line 87 of file rbf.cpp.

Member Function Documentation

◆ activateAllNodes()

void bitpit::RBFKernel::activateAllNodes ( )

Activate all nodes actually available in your RBFKernel node list. Supported in both modes.

Definition at line 325 of file rbf.cpp.

◆ activateNode() [1/2]

bool bitpit::RBFKernel::activateNode ( const std::vector< int > & list)

Activate a node ensamble in your RBFKernel node list. Supported in both modes.

Parameters
[in]listlist of node indices to be activated
Returns
boolean, true if all nodes are activated successfully, false if at least one of them is not

Definition at line 309 of file rbf.cpp.

◆ activateNode() [2/2]

bool bitpit::RBFKernel::activateNode ( int n)

Activate a node in your RBFKernel node list. Supported in both modes.

Parameters
[in]nindex of node to be activated
Returns
boolean, true if node is activated successfully, false if not

Definition at line 294 of file rbf.cpp.

◆ addData() [1/2]

int bitpit::RBFKernel::addData ( )

Increment container size for RBFKernel control data.The RBFKernel::fitDataToNodes() method is implicitly called, to ensure dimension consistency between data dimension and number of RBFKernel nodes. Use RBFKernel::setDataToAllNodes to fill them. In INTERP mode, increments and fits fields container, in PARAM mode, the weights one.

Returns
id of virtual data within the class
Examples
RBF_example_00001.cpp.

Definition at line 504 of file rbf.cpp.

◆ addData() [2/2]

int bitpit::RBFKernel::addData ( const std::vector< double > & data)

Adds data attached to RBFKernel nodes to current set, a field to be interpolated in INTERP mode, a RBFKernel weight component in PARAM mode. Note: data vector is added even if its size is different from actual number of RBFKernel nodes. To ensure consistency use fitDataToNodes() method.

Parameters
[in]datavalues of weight/fields for each RBFKernel node
Returns
id of data within the class

Definition at line 525 of file rbf.cpp.

◆ addGreedyPoint()

int bitpit::RBFKernel::addGreedyPoint ( )
protected

Determines which node has to be added to active set. Supported only in INTERP mode.

Returns
index with max error; if no index available, or dummy call -1 is returned

Definition at line 908 of file rbf.cpp.

◆ deactivateAllNodes()

void bitpit::RBFKernel::deactivateAllNodes ( )

Deactivate all nodes actually available in your RBFKernel node list. Supported in both modes.

Definition at line 366 of file rbf.cpp.

◆ deactivateNode() [1/2]

bool bitpit::RBFKernel::deactivateNode ( const std::vector< int > & list)

Deactivate a node ensamble in your RBFKernel node list. Supported in both modes.

Parameters
[in]listlist of node indices to be deactivated
Returns
boolean, true if all nodes are deactivated successfully, false if at least one of them is not

Definition at line 350 of file rbf.cpp.

◆ deactivateNode() [2/2]

bool bitpit::RBFKernel::deactivateNode ( int n)

Deactivate a node in your RBFKernel node list. Supported in both modes.

Parameters
[in]nindex of node to be dactivated
Returns
boolean, true if node is activated successfully, false if not

Definition at line 335 of file rbf.cpp.

◆ enablePolynomial()

void bitpit::RBFKernel::enablePolynomial ( bool enable = true)

Enable/disable the use of polynomial term during interpolation.

Parameters
[in]enabletrue/false to enable/disable polynomial usage term

Definition at line 1100 of file rbf.cpp.

◆ evalBasis()

double bitpit::RBFKernel::evalBasis ( double dist)

Evaluates the basis function. Supported in both modes

Parameters
[in]distdistance
Returns
value of basis function

Definition at line 884 of file rbf.cpp.

◆ evalBasisPair()

double bitpit::RBFKernel::evalBasisPair ( int i,
int j )

Evaluates the contribution of the node j on the value of the basis at node i

Parameters
[in]ipoint at which the basis function contribution is computed
[in]jpoint from which the basis function contribution is computed
Returns
basis function contribution from j to i
Examples
RBF_example_00001.cpp.

Definition at line 897 of file rbf.cpp.

◆ evalError()

double bitpit::RBFKernel::evalError ( )
protected

Calculates the relative error between rbf interpolation and exact values at nodes. Supported only in INTERP mode.

Returns
max error, if lesser then 0, dummy call triggered.

Definition at line 940 of file rbf.cpp.

◆ evalRBF() [1/2]

std::vector< double > bitpit::RBFKernel::evalRBF ( const std::array< double, 3 > & point)

Evaluates the RBF. Supported in both modes. Its size matches the number of fields/weights attached to RBF.

Parameters
[in]pointpoint where to evaluate the basis
Returns
vector containing interpolated/parameterized values.
Examples
RBF_example_00001.cpp.

Definition at line 597 of file rbf.cpp.

◆ evalRBF() [2/2]

std::vector< double > bitpit::RBFKernel::evalRBF ( int jnode)

Evaluates the RBF on a target RBF node. Supported in both modes. Its size matches the number of fields/weights attached to RBF.

Parameters
[in]jnodeindex of the RBF node in the node list
Returns
vector containing interpolated/parameterized values.

Definition at line 638 of file rbf.cpp.

◆ fitDataToNodes() [1/2]

void bitpit::RBFKernel::fitDataToNodes ( )

Check dimensions of already available data and resize them to current RBFKernel node list dimension. The method resizes all data structures to current RBFKernel node list dimension and does not destroy any previous stored data within such dimension. Anyway, mismatches definitions could occur. Please use RBFKernel::setDataToAllNodesto load your data again. In RBFMode::PARAM mode data are meant as RBFKernel weights In RBFMode::INTERP mode data are meant as fields to be interpolated

Definition at line 856 of file rbf.cpp.

◆ fitDataToNodes() [2/2]

void bitpit::RBFKernel::fitDataToNodes ( int id)

Check dimensions id-th data and resize it to current RBFKernel node list dimension. The method resizes id-th data structure to current RBFKernel node list dimension and does not destroy any previous stored data within such dimension. Anyway, mismatches definitions could occur. Please use RBFKernel::setDataToAllNodes to load your data again. In RBFMode::PARAM mode data are meant as RBFKernel weights In RBFMode::INTERP mode data are meant as fields to be interpolated

Parameters
[in]idid of data

Definition at line 873 of file rbf.cpp.

◆ getActiveCount()

int bitpit::RBFKernel::getActiveCount ( )

Get the number of active nodes. Supported in both nodes

Returns
number of active nodes

Definition at line 245 of file rbf.cpp.

◆ getActiveSet()

std::vector< int > bitpit::RBFKernel::getActiveSet ( )

Get the indices of the active nodes. Supported in both modes.

Returns
indices of active nodes

Definition at line 259 of file rbf.cpp.

◆ getDataCount()

int bitpit::RBFKernel::getDataCount ( )

Gets the number of data set attached to RBFKernel nodes. In INTERP mode, it is the number of different field that need to be interpolated; In PARAM mode, it identifies the dimension of the weights array for each node.

Returns
number of data

Definition at line 236 of file rbf.cpp.

◆ getFunctionType()

RBFBasisFunction bitpit::RBFKernel::getFunctionType ( )

Gets the type of RBFBasisFunction linked to the class.

Returns
type of RBFBasisFunction linked

Definition at line 225 of file rbf.cpp.

◆ getMode()

RBFMode bitpit::RBFKernel::getMode ( )

Return currently usage mode of your class.

Returns
class mode

Definition at line 423 of file rbf.cpp.

◆ getPolynomialWeightsCount()

int bitpit::RBFKernel::getPolynomialWeightsCount ( )
Returns
The dimension of active polynomial terms

Definition at line 1108 of file rbf.cpp.

◆ getSupportRadius() [1/2]

double bitpit::RBFKernel::getSupportRadius ( )

Return currently set support radius used by the RBFKernel kernel functions. If functions are using a variable support radius, the radius of the first function is returned. Supported in both modes.

Returns
support radius

Definition at line 397 of file rbf.cpp.

◆ getSupportRadius() [2/2]

double bitpit::RBFKernel::getSupportRadius ( int i)

Return currently set support radius used by the ith RBFKernel kernel function. Supported in both modes. It's up to the caller to ensure the function index is valid. Invalid function indexes will lead to undefined beahviour.

Returns
support radius

Definition at line 409 of file rbf.cpp.

◆ getWeights()

const std::vector< std::vector< double > > & bitpit::RBFKernel::getWeights ( ) const

Returns the weights associated to each node.

Returns
vector containing interpolated/parameterized weights.

Definition at line 842 of file rbf.cpp.

◆ greedy()

int bitpit::RBFKernel::greedy ( double tolerance)

Determines effective set of nodes to be used using greedy algorithm and calculate weights on them. Automatically choose which set of RBFKernel nodes is active or not, according to the given tolerance. Supported ONLY in INTERP mode.

Parameters
[in]toleranceerror tolerance for adding nodes
Returns
integer error flag . If 0-successfull computation and tolerance met, if 1-errors occurred, not enough nodes, if -1 dummy method call

Definition at line 788 of file rbf.cpp.

◆ isActive()

bool bitpit::RBFKernel::isActive ( int n)

Checks if a node is active. Supported in both modes.

Parameters
[in]nindex of node to be checked
Returns
true if active

Definition at line 280 of file rbf.cpp.

◆ removeAllData()

void bitpit::RBFKernel::removeAllData ( )

Remove all data set in RBF list. All fields for interpolation in INTERP mode, or all RBF weights for PARAM mode

Definition at line 582 of file rbf.cpp.

◆ removeData() [1/2]

bool bitpit::RBFKernel::removeData ( int id)

Remove pre-existent data set. Data list is resized and renumbered after extraction. Remove fields to be interpolated in INTERP mode, weights component in PARAM mode.

Parameters
[in]idid of node
Returns
boolean, true if successfully extracted, false otherwise

Definition at line 543 of file rbf.cpp.

◆ removeData() [2/2]

bool bitpit::RBFKernel::removeData ( std::vector< int > & list)

Remove pre-existent set of data. RBF Data list is resized and renumbered after extraction. In PARAM mode data are meant as RBF weights In INTERP mode data are meant as fields to be interpolated

Parameters
[in]listid list of candidates to extraction
Returns
boolean, true if all data set are successfully extracted, false if any of them are not extracted

Definition at line 563 of file rbf.cpp.

◆ setDataToAllNodes()

void bitpit::RBFKernel::setDataToAllNodes ( int id,
const std::vector< double > & value )

Sets the values of a data set to all currently available nodes. In INTERP mode, set one field to all nodes In PARAM mode, set one weight array component for all nodes.

Parameters
[in]idid of data
[in]valuedata values

Definition at line 476 of file rbf.cpp.

◆ setDataToNode()

void bitpit::RBFKernel::setDataToNode ( int id,
const std::vector< double > & value )

Sets all the type of available data at one node. In INTERP mode, set each field value at the target node In PARAM mode, set the weight coefficient array at node

Parameters
[in]idid of node
[in]valuedata values to be set as RBFKernel parameters for the given node

Definition at line 444 of file rbf.cpp.

◆ setFunction() [1/2]

void bitpit::RBFKernel::setFunction ( double(&)(double) bfunc)

Sets the rbf function to a user specified function. Supported in both modes.

Parameters
[in]bfuncbasis function to be used

Definition at line 215 of file rbf.cpp.

◆ setFunction() [2/2]

void bitpit::RBFKernel::setFunction ( RBFBasisFunction bfunc)

Sets the rbf function to be used. Supported in both modes.

Parameters
[in]bfuncbasis function to be used
Examples
RBF_example_00001.cpp.

Definition at line 125 of file rbf.cpp.

◆ setMode()

void bitpit::RBFKernel::setMode ( RBFMode mode)

Set usage mode of your class.

Parameters
[in]modeclass mode. Ref to RBFMode enum
Examples
RBF_example_00001.cpp.

Definition at line 432 of file rbf.cpp.

◆ setSupportRadius() [1/2]

void bitpit::RBFKernel::setSupportRadius ( const std::vector< double > & radius)

Set the support radius of all RBFKernel kernel functions. Supported in both modes.

Parameters
[in]radiussupport radius

Definition at line 385 of file rbf.cpp.

◆ setSupportRadius() [2/2]

void bitpit::RBFKernel::setSupportRadius ( double radius)

Set the support radius of all RBFKernel kernel functions. Supported in both modes.

Parameters
[in]radiussupport radius
Examples
RBF_example_00001.cpp.

Definition at line 375 of file rbf.cpp.

◆ solve()

int bitpit::RBFKernel::solve ( )

Calculates the RBF weights using all currently active nodes and just given target fields. Regular LU solver for linear system A*X=B is employed (LAPACKE dgesv). Supported ONLY in INTERP mode.

Returns
integer error flag . If 0-successfull computation, if 1-errors occurred, if -1 dummy method call

Definition at line 682 of file rbf.cpp.

◆ solveLSQ()

int bitpit::RBFKernel::solveLSQ ( )
protected

Calculates the RBFKernel weights using all active nodes and just given target fields. Compute weights as solution of a linear least squares problem (LAPACKE dglsd). Supported ONLY in INTERP mode.

Returns
integer error flag . If 0-successfull computation, if 1-errors occurred , -1 dummy call

Definition at line 982 of file rbf.cpp.

◆ swap()

void bitpit::RBFKernel::swap ( RBFKernel & other)
protectednoexcept

Swap method. Exchange contents of each class member with those corresponding in the argument object.

Parameters
[in]otherobject to be swapped

Definition at line 103 of file rbf.cpp.

Member Data Documentation

◆ m_activeNodes

std::vector<bool> bitpit::RBFKernel::m_activeNodes
protected

Vector of active/inactive node (m_activeNodes[i] = true/false -> the i-th node is used/not used during RBF evaluation).

Definition at line 104 of file rbf.hpp.

◆ m_maxFields

int bitpit::RBFKernel::m_maxFields
protected

fix the maximum number of fields that can be added to your class

Definition at line 105 of file rbf.hpp.

◆ m_nodes

int bitpit::RBFKernel::m_nodes
protected

Number of RBF nodes.

Definition at line 106 of file rbf.hpp.

◆ m_polyActiveBasis

std::vector<int> bitpit::RBFKernel::m_polyActiveBasis
protected

Active terms of linear polynomial, 0 is constant, i+1 the i-th system coordinate

Definition at line 108 of file rbf.hpp.

◆ m_polyEnabled

bool bitpit::RBFKernel::m_polyEnabled
protected

Enable/disable the use of the linear polynomial term in interpolation

Definition at line 107 of file rbf.hpp.

◆ m_polynomial

LinearPolynomial bitpit::RBFKernel::m_polynomial
protected

Linear polynomial object

Definition at line 109 of file rbf.hpp.

◆ m_value

std::vector<std::vector<double> > bitpit::RBFKernel::m_value
protected

displ value to be interpolated on RBF nodes

Definition at line 102 of file rbf.hpp.

◆ m_weight

std::vector<std::vector<double> > bitpit::RBFKernel::m_weight
protected

weight of your RBF interpolation

Definition at line 103 of file rbf.hpp.


The documentation for this class was generated from the following files:
--- layout: doxygen_footer ---