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.
patchRecovery.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_PATCHRECOVERY_H_
30 #define NEMOSYS_PATCHRECOVERY_H_
31 
32 #include "nemosys_export.h"
33 
34 #include "Integration/Cubature.H"
35 
36 #include <Eigen/Core>
37 
38 // pair type for coordinate and data there
39 //using pntDataPair = std::pair<std::vector<double>, std::vector<double>>;
40 
41 // holds gauss points and data at these points as pairs
42 //using pntDataPairVec = std::vector<pntDataPair>;
43 
44 class NEMOSYS_EXPORT PatchRecovery
45 {
46  public:
47  PatchRecovery(vtkDataSet *_dataSet, int _order,
48  const std::vector<int> &arrayIDs);
49 
50  ~PatchRecovery() = default;
51 
52  // disabled copy and copy-assignment constructors
53  PatchRecovery(const PatchRecovery &that) = delete;
54  PatchRecovery &operator=(const PatchRecovery &that) = delete;
55 
56  // approximates nodal values with polynomial approximant over patch of node
57  // sets recovered nodal values as new point data
58  void recoverNodalSolution(bool ortho);
59  /* 1) approximates nodal values with polynomial approximant over patch of node
60  2) sets error^2 in recovered values as new point data
61  3) sets RMSE integrated over each cell, normalized by cell vol as new cell data
62  4) sets patch averaged element size as new point data
63  returns array of integrals of errors over entire mesh */
64  std::vector<std::vector<double>> computeNodalError();
65 
66  private:
67  std::unique_ptr<GaussCubature> cubature;
68  int order;
69 
70  // get min max of each coord (for regularization)
71  std::vector<double>
72  getMinMaxCoords(const std::vector<std::vector<double>> &coords) const;
73  // regularize coordinates as x_new = -1 + 2*(x_old - x_min)/(x_max - x_min)
74  // for proper conditioning of least squares matrix
75  void regularizeCoords(std::vector<std::vector<double>> &coords,
76  std::vector<double> &genNodeCoord) const;
77 
78  // extract coordinates and data from pntDataPair
79  void extractAxesAndData(const pntDataPairVec &pntsAndData,
80  std::vector<std::vector<double>> &coords,
81  std::vector<Eigen::VectorXd> &data,
82  const std::vector<int> &numComponents,
83  int &pntNum) const;
84 };
85 
86 #endif // NEMOSYS_PATCHRECOVERY_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).
std::vector< pntDataPair > pntDataPairVec
Definition: Cubature.H:55
std::unique_ptr< GaussCubature > cubature
Definition: patchRecovery.H:67