NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
polyApprox.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_POLYAPPROX_H_
30 #define NEMOSYS_POLYAPPROX_H_
31 
32 #include "nemosys_export.h"
33 
34 #include <vector>
35 #include <memory>
36 
37 #include <Eigen/Core>
38 
39 class NEMOSYS_EXPORT polyApprox
40 {
41  public:
42  // assumes coordinates are preconditioned
43  polyApprox(int _order,
44  const std::vector<std::vector<double>> &coords);
45 
46  ~polyApprox() = default;
47 
48  // disable copy and copy-assignment constructors
49  polyApprox(const polyApprox &) = delete;
50  polyApprox &operator=(const polyApprox &) = delete;
51 
52  // compute coefficients for polynomial expansion of sampled function
53  void computeCoeff(const Eigen::VectorXd &data);
54  void resetCoeff();
55  double eval(const std::vector<double> &coord) const;
56 
57  static std::unique_ptr<polyApprox>
58  CreateUnique(int order,
59  const std::vector<std::vector<double>> &coords);
60 
61  private:
62  int order;
63  // matrix of basis polynomials evaluated at all coords
64  std::vector<Eigen::VectorXd> basis;
65  // lhs matrix in normal equation (phiTphi*a = phiT*f <=> A*a = b)
66  Eigen::MatrixXd A;
67  // rhs vector in normal equation
68  Eigen::VectorXd b;
69  // coefficients of polynomial approximant
70  Eigen::VectorXd a;
71 
72  Eigen::VectorXd computeBasis(const std::vector<double> &coord) const;
73 };
74 
75 #endif // NEMOSYS_POLYAPPROX_H_
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
Eigen::VectorXd a
Definition: polyApprox.H:70
std::vector< Eigen::VectorXd > basis
Definition: polyApprox.H:64
Eigen::MatrixXd A
Definition: polyApprox.H:66
Eigen::VectorXd b
Definition: polyApprox.H:68