Base class to handle Radial Basis Function with a large set of nodes. More...
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 |
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.
bitpit::RBFKernel::RBFKernel | ( | ) |
bitpit::RBFKernel::RBFKernel | ( | const RBFKernel & | other | ) |
void bitpit::RBFKernel::activateAllNodes | ( | ) |
bool bitpit::RBFKernel::activateNode | ( | const std::vector< int > & | list | ) |
bool bitpit::RBFKernel::activateNode | ( | int | n | ) |
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.
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.
[in] | data | values of weight/fields for each RBFKernel node |
|
protected |
void bitpit::RBFKernel::deactivateAllNodes | ( | ) |
bool bitpit::RBFKernel::deactivateNode | ( | const std::vector< int > & | list | ) |
bool bitpit::RBFKernel::deactivateNode | ( | int | n | ) |
void bitpit::RBFKernel::enablePolynomial | ( | bool | enable = true | ) |
double bitpit::RBFKernel::evalBasis | ( | double | dist | ) |
double bitpit::RBFKernel::evalBasisPair | ( | int | i, |
int | j ) |
Evaluates the contribution of the node j on the value of the basis at node i
[in] | i | point at which the basis function contribution is computed |
[in] | j | point from which the basis function contribution is computed |
|
protected |
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.
[in] | point | point where to evaluate the basis |
std::vector< double > bitpit::RBFKernel::evalRBF | ( | int | jnode | ) |
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
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
[in] | id | id of data |
int bitpit::RBFKernel::getActiveCount | ( | ) |
std::vector< int > bitpit::RBFKernel::getActiveSet | ( | ) |
int bitpit::RBFKernel::getDataCount | ( | ) |
RBFBasisFunction bitpit::RBFKernel::getFunctionType | ( | ) |
RBFMode bitpit::RBFKernel::getMode | ( | ) |
int bitpit::RBFKernel::getPolynomialWeightsCount | ( | ) |
double bitpit::RBFKernel::getSupportRadius | ( | ) |
double bitpit::RBFKernel::getSupportRadius | ( | int | i | ) |
const std::vector< std::vector< double > > & bitpit::RBFKernel::getWeights | ( | ) | const |
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.
[in] | tolerance | error tolerance for adding nodes |
bool bitpit::RBFKernel::isActive | ( | int | n | ) |
void bitpit::RBFKernel::removeAllData | ( | ) |
bool bitpit::RBFKernel::removeData | ( | int | id | ) |
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
[in] | list | id list of candidates to extraction |
void bitpit::RBFKernel::setDataToAllNodes | ( | int | id, |
const std::vector< double > & | value ) |
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
[in] | id | id of node |
[in] | value | data values to be set as RBFKernel parameters for the given node |
void bitpit::RBFKernel::setFunction | ( | double(&)(double) | bfunc | ) |
void bitpit::RBFKernel::setFunction | ( | RBFBasisFunction | bfunc | ) |
Sets the rbf function to be used. Supported in both modes.
[in] | bfunc | basis function to be used |
void bitpit::RBFKernel::setMode | ( | RBFMode | mode | ) |
Set usage mode of your class.
[in] | mode | class mode. Ref to RBFMode enum |
void bitpit::RBFKernel::setSupportRadius | ( | const std::vector< double > & | radius | ) |
void bitpit::RBFKernel::setSupportRadius | ( | double | radius | ) |
Set the support radius of all RBFKernel kernel functions. Supported in both modes.
[in] | radius | support radius |
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.
|
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.
|
protectednoexcept |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |