38 const auto lo = lbound(bx);
39 const auto hi = ubound(bx);
41 for(
int k = lo.z; k <= hi.z; ++k) {
42 for(
int j = lo.y; j <= hi.y; ++j) {
43 for(
int i = lo.x; i <= hi.x; ++i) {
55 if(flag(i,j,k).isSingleValued()) {
59 Real axm = apx(i ,j ,k );
60 Real axp = apx(i+1,j ,k );
61 Real aym = apy(i ,j ,k );
62 Real ayp = apy(i ,j+1,k );
63 Real azm = apz(i ,j ,k );
64 Real azp = apz(i ,j ,k+1);
66 Real adx = (axm-axp) * dx[1] * dx[2];
67 Real ady = (aym-ayp) * dx[0] * dx[2];
68 Real adz = (azm-azp) * dx[0] * dx[1];
70 Real apnorm = std::sqrt(adx*adx + ady*ady + adz*adz);
73 std::array<Real,3> normal, centroid;
74 std::array<std::array<Real,3>,8> vertex;
76 normal[0] = adx * apnorminv;
77 normal[1] = ady * apnorminv;
78 normal[2] = adz * apnorminv;
82 centroid[0] = problo[0] + bcent(i,j,k,0)*dx[0] + (
static_cast<Real>(i) +
Real(0.5))*dx[0];
83 centroid[1] = problo[1] + bcent(i,j,k,1)*dx[1] + (
static_cast<Real>(j) +
Real(0.5))*dx[1];
84 centroid[2] = problo[2] + bcent(i,j,k,2)*dx[2] + (
static_cast<Real>(k) +
Real(0.5))*dx[2];
87 vertex[0] = {problo[0] +
static_cast<Real>(i )*dx[0], problo[1] +
static_cast<Real>(j )*dx[1], problo[2] +
static_cast<Real>(k )*dx[2]};
88 vertex[1] = {problo[0] +
static_cast<Real>(i+1)*dx[0], problo[1] +
static_cast<Real>(j )*dx[1], problo[2] +
static_cast<Real>(k )*dx[2]};
89 vertex[2] = {problo[0] +
static_cast<Real>(i )*dx[0], problo[1] +
static_cast<Real>(j+1)*dx[1], problo[2] +
static_cast<Real>(k )*dx[2]};
90 vertex[3] = {problo[0] +
static_cast<Real>(i+1)*dx[0], problo[1] +
static_cast<Real>(j+1)*dx[1], problo[2] +
static_cast<Real>(k )*dx[2]};
91 vertex[4] = {problo[0] +
static_cast<Real>(i )*dx[0], problo[1] +
static_cast<Real>(j )*dx[1], problo[2] +
static_cast<Real>(k+1)*dx[2]};
92 vertex[5] = {problo[0] +
static_cast<Real>(i+1)*dx[0], problo[1] +
static_cast<Real>(j )*dx[1], problo[2] +
static_cast<Real>(k+1)*dx[2]};
93 vertex[6] = {problo[0] +
static_cast<Real>(i )*dx[0], problo[1] +
static_cast<Real>(j+1)*dx[1], problo[2] +
static_cast<Real>(k+1)*dx[2]};
94 vertex[7] = {problo[0] +
static_cast<Real>(i+1)*dx[0], problo[1] +
static_cast<Real>(j+1)*dx[1], problo[2] +
static_cast<Real>(k+1)*dx[2]};
107 std::array<Real,3> n0;
108 std::array<Real,12> alpha;
109 std::array<bool,12> alpha_intersect;
111 calc_hesse(distance, n0, p, normal, centroid);
121 if((count < 3) || (count > 6)) {
124 std::array<Real,3> n0_d;
125 std::array<Real,12> alpha_d;
126 std::array<bool,12> alpha_d_intersect;
128 Real tol = std::min({dx[0], dx[1], dx[2]})/
Real(100.);
130 std::array<Real,3> centroid_d;
131 for(
int idim = 0; idim < 3; ++idim) {
132 centroid_d[idim] = centroid[idim] + tol*normal[idim];
135 calc_hesse(distance, n0_d, p_d, normal, centroid_d);
138 if((count_d >= 3) && (count_d <= 6)) {
140 alpha_intersect = alpha_d_intersect;
143 for(
int idim = 0; idim < 3; ++idim) {
144 centroid_d[idim] = centroid[idim] - tol*normal[idim];
147 calc_hesse(distance, n0_d, p_d, normal, centroid_d);
150 if((count_d >= 3) && (count_d <= 6)) {
152 alpha_intersect = alpha_d_intersect;
158 if((count >=3) && (count <=6)) {
162 std::array<std::array<Real,3>,12> a_points;
164 std::array<Real,3> ihat = {1, 0, 0};
165 std::array<Real,3> jhat = {0, 1, 0};
166 std::array<Real,3> khat = {0, 0, 1};
168 for(
int idim = 0; idim < 3; ++idim) {
169 a_points[ 0][idim] = vertex[0][idim] + ihat[idim]*dx[0]*alpha[ 0];
170 a_points[ 1][idim] = vertex[1][idim] + jhat[idim]*dx[1]*alpha[ 1];
171 a_points[ 2][idim] = vertex[2][idim] + ihat[idim]*dx[0]*alpha[ 2];
172 a_points[ 3][idim] = vertex[0][idim] + jhat[idim]*dx[1]*alpha[ 3];
173 a_points[ 4][idim] = vertex[0][idim] + khat[idim]*dx[2]*alpha[ 4];
174 a_points[ 5][idim] = vertex[1][idim] + khat[idim]*dx[2]*alpha[ 5];
175 a_points[ 6][idim] = vertex[3][idim] + khat[idim]*dx[2]*alpha[ 6];
176 a_points[ 7][idim] = vertex[2][idim] + khat[idim]*dx[2]*alpha[ 7];
177 a_points[ 8][idim] = vertex[4][idim] + ihat[idim]*dx[0]*alpha[ 8];
178 a_points[ 9][idim] = vertex[5][idim] + jhat[idim]*dx[1]*alpha[ 9];
179 a_points[10][idim] = vertex[6][idim] + ihat[idim]*dx[0]*alpha[10];
180 a_points[11][idim] = vertex[4][idim] + jhat[idim]*dx[1]*alpha[11];
184 for(
int lc1 = 0; lc1 < 12; ++lc1) {
185 if(alpha_intersect[lc1]) {
std::vector< std::array< Real, 3 > > m_points
Definition: ERF_EBToPVD.H:54
static void calc_intersects(int &int_count, std::array< bool, 12 > &intersects_flags, const std::array< Real, 12 > &alpha)
Definition: ERF_EBToPVD.cpp:393
void reorder_polygon(const std::vector< std::array< Real, 3 >> &lpoints, std::array< int, 7 > &lconnect, const std::array< Real, 3 > &lnormal)
Definition: ERF_EBToPVD.cpp:255
static void calc_alpha(std::array< Real, 12 > &alpha, const std::array< Real, 3 > &n0, Real p, const std::array< std::array< Real, 3 >, 8 > &vertex, const Real *dx)
Definition: ERF_EBToPVD.cpp:360
std::vector< std::array< int, 7 > > m_connectivity
Definition: ERF_EBToPVD.H:55
static void calc_hesse(Real &distance, std::array< Real, 3 > &n0, Real &p, const std::array< Real, 3 > &normal, const std::array< Real, 3 > ¢roid)
Definition: ERF_EBToPVD.cpp:336