PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
MapHexahedron.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __MapHexahedron_H
13#define __MapHexahedron_H
14
15#include "Eigen/Eigen"
16
17namespace Gedim
18{
20{
21 public:
23 {
24 Eigen::MatrixXd ReferenceVertices;
25 Eigen::MatrixXd A;
26 Eigen::MatrixXd Coefficients;
27 Eigen::MatrixXd Vertices;
28 std::map<unsigned int, unsigned int> VertexOrder;
29 };
30
31 private:
32 static inline Eigen::MatrixXd Psi(const Eigen::MatrixXd &points)
33 {
34 const Eigen::ArrayXd x = points.row(0);
35 const Eigen::ArrayXd y = points.row(1);
36 const Eigen::ArrayXd z = points.row(2);
37
38 Eigen::MatrixXd evalPsi = Eigen::MatrixXd::Zero(8, points.cols());
39 evalPsi.row(0) = (1.0 - x) * (1.0 - y) * (1.0 - z);
40 evalPsi.row(1) = x * (1.0 - y) * (1.0 - z);
41 evalPsi.row(2) = x * y * (1.0 - z);
42 evalPsi.row(3) = y * (1.0 - x) * (1.0 - z);
43 evalPsi.row(4) = (1.0 - x) * (1.0 - y) * z;
44 evalPsi.row(5) = x * (1.0 - y) * z;
45 evalPsi.row(6) = x * y * z;
46 evalPsi.row(7) = y * (1.0 - x) * z;
47
48 return evalPsi;
49 }
50
51 static inline std::vector<Eigen::MatrixXd> dPsi(const Eigen::MatrixXd &points)
52 {
53 const Eigen::ArrayXd x = points.row(0);
54 const Eigen::ArrayXd y = points.row(1);
55 const Eigen::ArrayXd z = points.row(2);
56
57 std::vector<Eigen::MatrixXd> evaldPsi(3, Eigen::MatrixXd(8, points.cols()));
58
59 evaldPsi[0].row(0) = -(1.0 - y) * (1.0 - z);
60 evaldPsi[0].row(1) = (1.0 - y) * (1.0 - z);
61 evaldPsi[0].row(2) = y * (1.0 - z);
62 evaldPsi[0].row(3) = -y * (1.0 - z);
63 evaldPsi[0].row(4) = -(1.0 - y) * z;
64 evaldPsi[0].row(5) = (1.0 - y) * z;
65 evaldPsi[0].row(6) = y * z;
66 evaldPsi[0].row(7) = -y * z;
67
68 evaldPsi[1].row(0) = -(1.0 - x) * (1.0 - z);
69 evaldPsi[1].row(1) = -x * (1.0 - z);
70 evaldPsi[1].row(2) = x * (1.0 - z);
71 evaldPsi[1].row(3) = (1.0 - x) * (1.0 - z);
72 evaldPsi[1].row(4) = -(1.0 - x) * z;
73 evaldPsi[1].row(5) = -x * z;
74 evaldPsi[1].row(6) = x * z;
75 evaldPsi[1].row(7) = (1.0 - x) * z;
76
77 evaldPsi[2].row(0) = -(1.0 - x) * (1.0 - y);
78 evaldPsi[2].row(1) = -x * (1.0 - y);
79 evaldPsi[2].row(2) = -x * y;
80 evaldPsi[2].row(3) = -y * (1.0 - x);
81 evaldPsi[2].row(4) = (1.0 - x) * (1.0 - y);
82 evaldPsi[2].row(5) = x * (1.0 - y);
83 evaldPsi[2].row(6) = x * y;
84 evaldPsi[2].row(7) = y * (1.0 - x);
85
86 return evaldPsi;
87 }
88
89 public:
91 {
92 }
94 {
95 }
96
97 static MapHexahedronData Compute(const Eigen::MatrixXd &vertices, const std::vector<Eigen::MatrixXi> &faces);
98
99 static Eigen::MatrixXd F(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints);
100
101 static Eigen::MatrixXd FInv(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &points);
102
103 static Eigen::MatrixXd J(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints);
104
105 static Eigen::MatrixXd JInv(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints);
106
107 static Eigen::VectorXd DetJ(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints);
108};
109} // namespace Gedim
110
111#endif // __MapHexahedron_H
Eigen column vector.
Definition Eigen_Array.hpp:23
Definition MapHexahedron.hpp:20
static Eigen::MatrixXd J(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints)
Definition MapHexahedron.cpp:75
~MapHexahedron()
Definition MapHexahedron.hpp:93
static MapHexahedronData Compute(const Eigen::MatrixXd &vertices, const std::vector< Eigen::MatrixXi > &faces)
Definition MapHexahedron.cpp:21
static Eigen::MatrixXd F(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints)
Definition MapHexahedron.cpp:69
MapHexahedron()
Definition MapHexahedron.hpp:90
static Eigen::MatrixXd FInv(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &points)
Definition MapHexahedron.cpp:95
static Eigen::MatrixXd JInv(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints)
Definition MapHexahedron.cpp:103
static Eigen::VectorXd DetJ(const MapHexahedron::MapHexahedronData &mapData, const Eigen::MatrixXd &referencePoints)
Definition MapHexahedron.cpp:115
Definition Eigen_Array.cpp:22
Definition MapHexahedron.hpp:23
Eigen::MatrixXd Coefficients
Definition MapHexahedron.hpp:26
Eigen::MatrixXd ReferenceVertices
Definition MapHexahedron.hpp:24
Eigen::MatrixXd A
Definition MapHexahedron.hpp:25
Eigen::MatrixXd Vertices
Definition MapHexahedron.hpp:27
std::map< unsigned int, unsigned int > VertexOrder
Definition MapHexahedron.hpp:28