35 const auto lo = lbound(bx);
36 const auto hi = ubound(bx);
38 for(
int k = lo.z; k <= hi.z; ++k) {
39 for(
int j = lo.y; j <= hi.y; ++j) {
40 for(
int i = lo.x; i <= hi.x; ++i) {
52 if(flag(i,j,k).isSingleValued()) {
56 Real axm = apx(i ,j ,k );
57 Real axp = apx(i+1,j ,k );
58 Real aym = apy(i ,j ,k );
59 Real ayp = apy(i ,j+1,k );
60 Real azm = apz(i ,j ,k );
61 Real azp = apz(i ,j ,k+1);
63 Real adx = (axm-axp) * dx[1] * dx[2];
64 Real ady = (aym-ayp) * dx[0] * dx[2];
65 Real adz = (azm-azp) * dx[0] * dx[1];
67 Real apnorm = std::sqrt(adx*adx + ady*ady + adz*adz);
68 Real apnorminv = Real(1.0)/apnorm;
70 std::array<Real,3> normal, centroid;
71 std::array<std::array<Real,3>,8> vertex;
73 normal[0] = adx * apnorminv;
74 normal[1] = ady * apnorminv;
75 normal[2] = adz * apnorminv;
79 centroid[0] = problo[0] + bcent(i,j,k,0)*dx[0] + (
static_cast<Real
>(i) + Real(0.5))*dx[0];
80 centroid[1] = problo[1] + bcent(i,j,k,1)*dx[1] + (
static_cast<Real
>(j) + Real(0.5))*dx[1];
81 centroid[2] = problo[2] + bcent(i,j,k,2)*dx[2] + (
static_cast<Real
>(k) + Real(0.5))*dx[2];
84 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]};
85 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]};
86 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]};
87 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]};
88 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]};
89 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]};
90 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]};
91 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]};
104 std::array<Real,3> n0;
105 std::array<Real,12> alpha;
106 std::array<bool,12> alpha_intersect;
108 calc_hesse(distance, n0, p, normal, centroid);
118 if((count < 3) || (count > 6)) {
121 std::array<Real,3> n0_d;
122 std::array<Real,12> alpha_d;
123 std::array<bool,12> alpha_d_intersect;
125 Real tol = std::min({dx[0], dx[1], dx[2]})/Real(100.);
127 std::array<Real,3> centroid_d;
128 for(
int idim = 0; idim < 3; ++idim) {
129 centroid_d[idim] = centroid[idim] + tol*normal[idim];
132 calc_hesse(distance, n0_d, p_d, normal, centroid_d);
135 if((count_d >= 3) && (count_d <= 6)) {
137 alpha_intersect = alpha_d_intersect;
140 for(
int idim = 0; idim < 3; ++idim) {
141 centroid_d[idim] = centroid[idim] - tol*normal[idim];
144 calc_hesse(distance, n0_d, p_d, normal, centroid_d);
147 if((count_d >= 3) && (count_d <= 6)) {
149 alpha_intersect = alpha_d_intersect;
155 if((count >=3) && (count <=6)) {
159 std::array<std::array<Real,3>,12> a_points;
161 std::array<Real,3> ihat = {1, 0, 0};
162 std::array<Real,3> jhat = {0, 1, 0};
163 std::array<Real,3> khat = {0, 0, 1};
165 for(
int idim = 0; idim < 3; ++idim) {
166 a_points[ 0][idim] = vertex[0][idim] + ihat[idim]*dx[0]*alpha[ 0];
167 a_points[ 1][idim] = vertex[1][idim] + jhat[idim]*dx[1]*alpha[ 1];
168 a_points[ 2][idim] = vertex[2][idim] + ihat[idim]*dx[0]*alpha[ 2];
169 a_points[ 3][idim] = vertex[0][idim] + jhat[idim]*dx[1]*alpha[ 3];
170 a_points[ 4][idim] = vertex[0][idim] + khat[idim]*dx[2]*alpha[ 4];
171 a_points[ 5][idim] = vertex[1][idim] + khat[idim]*dx[2]*alpha[ 5];
172 a_points[ 6][idim] = vertex[3][idim] + khat[idim]*dx[2]*alpha[ 6];
173 a_points[ 7][idim] = vertex[2][idim] + khat[idim]*dx[2]*alpha[ 7];
174 a_points[ 8][idim] = vertex[4][idim] + ihat[idim]*dx[0]*alpha[ 8];
175 a_points[ 9][idim] = vertex[5][idim] + jhat[idim]*dx[1]*alpha[ 9];
176 a_points[10][idim] = vertex[6][idim] + ihat[idim]*dx[0]*alpha[10];
177 a_points[11][idim] = vertex[4][idim] + jhat[idim]*dx[1]*alpha[11];
181 for(
int lc1 = 0; lc1 < 12; ++lc1) {
182 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:385
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:251
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:352
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:332