Loading...
Searching...
No Matches
splinterRBF.H
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12
13License
14 This file is part of ITHACA-FV
15
16 ITHACA-FV is free software: you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 ITHACA-FV is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with ITHACA-FV. If not, see <http://www.gnu.org/licenses/>.
28
29Class
30 splinterRBF
31Description
32 RBF interpolation class using the SPLINTER library.
33SourceFiles
34 splinterRBF.C
35\*---------------------------------------------------------------------------*/
36
37#ifndef splinterRBF_H
38#define splinterRBF_H
39
40#include <Eigen/Core>
41#include <memory>
42#include <string>
43#include <rbfspline.h>
44#include <datatable.h>
45#include "dictionary.H"
46#include <iostream>
47#include <Ostream.H>
48#include <cmath>
49
50class splinterRBF
51{
52public:
53 // Constructor
54 // kernelType can be "gaussian", "thin_plate_spline", "multiquadric", "inverse_multiquadric", "inverse_quadratic"
55 splinterRBF(const Foam::word& kernelType = "gaussian",
56 bool normalize = true,
57 Foam::scalar epsilon = 1.0);
58
59 // Constructor from OpenFOAM dictionary
60 splinterRBF(const Foam::dictionary& dict);
61
62 // Destructor
63 ~splinterRBF();
64
65 // Fit function
66 void fit(const Eigen::MatrixXd& X, const Eigen::VectorXd& y);
67
68 // Predict function
69 Foam::scalar predict(const Eigen::VectorXd& x);
70
71 // Predict for multiple points
72 Eigen::VectorXd predict(const Eigen::MatrixXd& X);
73
74 // Print model info
75 void printInfo();
76
77private:
78 std::unique_ptr<SPLINTER::RBFSpline> impl_;
79 Foam::word kernelType_;
80 bool normalize_;
81 Foam::scalar epsilon_;
82
83 Eigen::VectorXd xMean_;
84 Eigen::VectorXd xStd_;
85 Foam::scalar yMean_;
86 Foam::scalar yStd_;
87
88 SPLINTER::RadialBasisFunctionType getKernelType(const Foam::word& kernelType);
89};
90
91#endif