9 #ifndef _COMPADRE_TARGETS_HPP_
10 #define _COMPADRE_TARGETS_HPP_
24 template <
typename TargetData>
25 KOKKOS_INLINE_FUNCTION
29 if (data._dimensions > 1) {
32 || data._data_sampling_multiplier!=0
34 && data._polynomial_sampling_functional==
PointSample))
35 &&
"data._reconstruction_space(VectorOfScalar clones incompatible with scalar output sampling functional which is not a PointSample");
39 bool additional_evaluation_sites_need_handled =
40 (data._additional_pc._source_coordinates.extent(0) > 0) ?
true :
false;
42 const int target_index = data._initial_index_for_batch + teamMember.league_rank();
44 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, P_target_row.extent(0)), [&] (
const int j) {
45 Kokkos::parallel_for(Kokkos::ThreadVectorRange(teamMember, P_target_row.extent(1)),
47 P_target_row(j,k) = 0;
50 for (
int j = 0; j < delta.extent_int(0); ++j) {
53 for (
int j = 0; j < thread_workspace.extent_int(0); ++j) {
54 thread_workspace(j) = 0;
56 teamMember.team_barrier();
59 int target_NP =
GMLS::getNP(data._poly_order, data._dimensions, data._reconstruction_space);
60 const int num_evaluation_sites = data._additional_pc._nla.getNumberOfNeighborsDevice(target_index) + 1;
62 for (
size_t i=0; i<data._operations.size(); ++i) {
64 bool additional_evaluation_sites_handled =
false;
66 bool operation_handled =
true;
73 if (!operation_handled) {
82 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
83 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
84 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
85 for (
int k=0; k<target_NP; ++k) {
86 P_target_row(offset, k) = delta(k);
89 additional_evaluation_sites_handled =
true;
91 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
92 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
93 switch (data._dimensions) {
95 P_target_row(offset, 4) = std::pow(data._epsilons(target_index), -2);
96 P_target_row(offset, 6) = std::pow(data._epsilons(target_index), -2);
97 P_target_row(offset, 9) = std::pow(data._epsilons(target_index), -2);
100 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -2);
101 P_target_row(offset, 5) = std::pow(data._epsilons(target_index), -2);
104 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -2);
108 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
109 for (
int d=0; d<data._dimensions; ++d) {
110 int offset = data._d_ss.getTargetOffsetIndex(i, 0, d, j);
111 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
112 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , d , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
115 additional_evaluation_sites_handled =
true;
117 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
118 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
119 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
120 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 0 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
122 additional_evaluation_sites_handled =
true;
125 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
126 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
127 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
128 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
130 additional_evaluation_sites_handled =
true;
133 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
134 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
135 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
136 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
138 additional_evaluation_sites_handled =
true;
144 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
145 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
146 switch (data._dimensions) {
148 P_target_row(offset, 4) = std::pow(data._epsilons(target_index), -2);
149 P_target_row(offset, 6) = std::pow(data._epsilons(target_index), -2);
150 P_target_row(offset, 9) = std::pow(data._epsilons(target_index), -2);
153 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -2);
154 P_target_row(offset, 5) = std::pow(data._epsilons(target_index), -2);
157 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -2);
163 "CellAverageEvaluation and CellIntegralEvaluation only support 2d or 3d with 2d manifold");
164 const double factorial[15] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
165 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
168 double cutoff_p = data._epsilons(target_index);
172 double triangle_coords[3*3];
175 for (
int j=0; j<data._global_dimensions; ++j) {
177 triangle_coords_matrix(j, 0) = data._pc.getTargetCoordinate(target_index, j);
180 size_t num_vertices = (data._target_extra_data(target_index, data._target_extra_data.extent(1)-1)
181 != data._target_extra_data(target_index, data._target_extra_data.extent(1)-1))
182 ? (data._target_extra_data.extent(1) / data._global_dimensions) - 1 :
183 (data._target_extra_data.extent(1) / data._global_dimensions);
187 double entire_cell_area = 0.0;
188 for (
size_t v=0; v<num_vertices; ++v) {
190 int v2 = (v+1) % num_vertices;
192 for (
int j=0; j<data._global_dimensions; ++j) {
193 triangle_coords_matrix(j,1) = data._target_extra_data(target_index, v1*data._global_dimensions+j)
194 - triangle_coords_matrix(j,0);
195 triangle_coords_matrix(j,2) = data._target_extra_data(target_index, v2*data._global_dimensions+j)
196 - triangle_coords_matrix(j,0);
202 auto T=triangle_coords_matrix;
203 for (
int quadrature = 0; quadrature<data._qm.getNumberOfQuadraturePoints(); ++quadrature) {
204 double transformed_qp[2] = {0,0};
205 for (
int j=0; j<data._global_dimensions; ++j) {
206 for (
int k=1; k<3; ++k) {
207 transformed_qp[j] += T(j,k)*data._qm.getSite(quadrature, k-1);
209 transformed_qp[j] += T(j,0);
214 Kokkos::subview(T, Kokkos::ALL(), 1), Kokkos::subview(T, Kokkos::ALL(), 2));
216 for (
int j=0; j<data._global_dimensions; ++j) {
217 relative_coord[j] = transformed_qp[j] - data._pc.getTargetCoordinate(target_index, j);
221 for (
int n = 0; n <= data._poly_order; n++){
222 for (alphay = 0; alphay <= n; alphay++){
224 alphaf = factorial[alphax]*factorial[alphay];
225 double val_to_sum = G_determinant * ( data._qm.getWeight(quadrature)
226 * std::pow(relative_coord.x/cutoff_p,alphax)
227 * std::pow(relative_coord.y/cutoff_p,alphay)/alphaf);
228 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
229 if (quadrature==0 && v==0) P_target_row(offset, k) = val_to_sum;
230 else P_target_row(offset, k) += val_to_sum;
235 entire_cell_area += G_determinant * data._qm.getWeight(quadrature);
240 for (
int n = 0; n <= data._poly_order; n++){
241 for (alphay = 0; alphay <= n; alphay++){
242 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
243 P_target_row(offset, k) /= entire_cell_area;
265 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
266 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
267 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
268 for (
int k=0; k<target_NP; ++k) {
269 P_target_row(offset, k) = delta(k);
272 additional_evaluation_sites_handled =
true;
274 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
275 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
276 for (
int m=0; m<data._sampling_multiplier; ++m) {
277 int output_components = data._basis_multiplier;
278 for (
int c=0; c<output_components; ++c) {
279 int offset = data._d_ss.getTargetOffsetIndex(i, m , c , e);
283 for (
int j=0; j<target_NP; ++j) {
284 P_target_row(offset, c*target_NP + j) = delta(j);
289 additional_evaluation_sites_handled =
true;
293 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
294 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
295 for (
int m=0; m<data._sampling_multiplier; ++m) {
296 int output_components = data._basis_multiplier;
297 for (
int c=0; c<output_components; ++c) {
298 int offset = data._d_ss.getTargetOffsetIndex(i, m , c , e);
302 for (
int j=0; j<target_NP; ++j) {
303 P_target_row(offset, c*target_NP + j) = delta(j);
308 additional_evaluation_sites_handled =
true;
310 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
311 int output_components = data._basis_multiplier;
312 for (
int m2=0; m2<output_components; ++m2) {
313 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , m2 , e);
314 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , m2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
315 for (
int j=0; j<target_NP; ++j) {
316 P_target_row(offset, j) = delta(j);
320 additional_evaluation_sites_handled =
true;
322 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
323 for (
int m0=0; m0<data._sampling_multiplier; ++m0) {
324 int output_components = data._basis_multiplier;
325 for (
int m1=0; m1<output_components; ++m1) {
326 for (
int m2=0; m2<output_components; ++m2) {
327 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1*output_components+m2 , e);
328 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , m2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
329 for (
int j=0; j<target_NP; ++j) {
330 P_target_row(offset, m1*target_NP + j) = delta(j);
336 additional_evaluation_sites_handled =
true;
339 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
340 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);;
341 switch (data._dimensions) {
343 P_target_row(offset, 1) = std::pow(data._epsilons(target_index), -1);
344 P_target_row(offset, target_NP + 2) = std::pow(data._epsilons(target_index), -1);
345 P_target_row(offset, 2*target_NP + 3) = std::pow(data._epsilons(target_index), -1);
348 P_target_row(offset, 1) = std::pow(data._epsilons(target_index), -1);
349 P_target_row(offset, target_NP + 2) = std::pow(data._epsilons(target_index), -1);
352 P_target_row(offset, 1) = std::pow(data._epsilons(target_index), -1);
356 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
357 for (
int m=0; m<data._sampling_multiplier; ++m) {
358 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , m , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
359 int offset = data._d_ss.getTargetOffsetIndex(i, m , 0 , e);
360 for (
int j=0; j<target_NP; ++j) {
361 P_target_row(offset, m*target_NP + j) = delta(j);
365 additional_evaluation_sites_handled =
true;
368 if (data._dimensions==3) {
369 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
373 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , 0 , 0);
377 offset = data._d_ss.getTargetOffsetIndex(i, 1 , 0 , 0);
380 P_target_row(offset, target_NP + 3) = -std::pow(data._epsilons(target_index), -1);
382 offset = data._d_ss.getTargetOffsetIndex(i, 2 , 0 , 0);
385 P_target_row(offset, 2*target_NP + 2) = std::pow(data._epsilons(target_index), -1);
391 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , 1 , 0);
394 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -1);
400 offset = data._d_ss.getTargetOffsetIndex(i, 2 , 1 , 0);
403 P_target_row(offset, 2*target_NP + 1) = -std::pow(data._epsilons(target_index), -1);
409 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , 2 , 0);
412 P_target_row(offset, 2) = -std::pow(data._epsilons(target_index), -1);
414 offset = data._d_ss.getTargetOffsetIndex(i, 1 , 2 , 0);
417 P_target_row(offset, target_NP + 1) = std::pow(data._epsilons(target_index), -1);
424 }
else if (data._dimensions==2) {
425 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
429 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , 0 , 0);
433 offset = data._d_ss.getTargetOffsetIndex(i, 1 , 0 , 0);
436 P_target_row(offset, target_NP + 2) = std::pow(data._epsilons(target_index), -1);
442 int offset = data._d_ss.getTargetOffsetIndex(i, 0 , 1 , 0);
445 P_target_row(offset, 1) = -std::pow(data._epsilons(target_index), -1);
469 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
470 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
471 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
472 for (
int k=0; k<target_NP; ++k) {
473 P_target_row(offset, k) = delta(k);
476 additional_evaluation_sites_handled =
true;
478 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
479 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, e);
480 for (
int m=0; m<data._sampling_multiplier; ++m) {
481 for (
int c=0; c<data._data_sampling_multiplier; ++c) {
482 int offset = data._d_ss.getTargetOffsetIndex(i, c , c , e);
483 for (
int j=0; j<target_NP; ++j) {
484 P_target_row(offset, j) = delta(j);
489 additional_evaluation_sites_handled =
true;
492 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
493 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
494 switch (data._dimensions) {
496 P_target_row(offset, 4) = std::pow(data._epsilons(target_index), -2);
497 P_target_row(offset, 6) = std::pow(data._epsilons(target_index), -2);
498 P_target_row(offset, 9) = std::pow(data._epsilons(target_index), -2);
501 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -2);
502 P_target_row(offset, 5) = std::pow(data._epsilons(target_index), -2);
505 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -2);
510 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
511 for (
int d=0; d<data._dimensions; ++d) {
512 int offset = data._d_ss.getTargetOffsetIndex(i, 0, d, j);
513 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
514 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , d , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
517 additional_evaluation_sites_handled =
true;
519 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
520 for (
int m0=0; m0<data._dimensions; ++m0) {
521 for (
int m1=0; m1<data._dimensions; ++m1) {
522 for (
int m2=0; m2<data._dimensions; ++m2) {
523 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1*data._dimensions+m2 , j);
524 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
525 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , m2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
530 additional_evaluation_sites_handled =
true;
533 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
534 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
535 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
536 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 0 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
538 additional_evaluation_sites_handled =
true;
541 if (data._dimensions>1) {
542 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
543 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
544 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
545 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
547 additional_evaluation_sites_handled =
true;
551 if (data._dimensions>2) {
552 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
553 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
554 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
555 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
557 additional_evaluation_sites_handled =
true;
560 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
561 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
562 for (
int j=0; j<target_NP; ++j) {
563 P_target_row(offset, j) = 0;
566 P_target_row(offset, 1) = std::pow(data._epsilons(target_index), -1);
568 if (data._dimensions>1) {
569 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
570 for (
int j=0; j<target_NP; ++j) {
571 P_target_row(offset, j) = 0;
573 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -1);
576 if (data._dimensions>2) {
577 offset = data._d_ss.getTargetOffsetIndex(i, 2, 0, 0);
578 for (
int j=0; j<target_NP; ++j) {
579 P_target_row(offset, j) = 0;
581 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -1);
588 if (data._dimensions==3) {
589 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
593 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
594 for (
int j=0; j<target_NP; ++j) {
595 P_target_row(offset, j) = 0;
600 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
601 for (
int j=0; j<target_NP; ++j) {
602 P_target_row(offset, j) = 0;
606 P_target_row(offset, 3) = -std::pow(data._epsilons(target_index), -1);
608 offset = data._d_ss.getTargetOffsetIndex(i, 2, 0, 0);
609 for (
int j=0; j<target_NP; ++j) {
610 P_target_row(offset, j) = 0;
614 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -1);
620 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
621 for (
int j=0; j<target_NP; ++j) {
622 P_target_row(offset, j) = 0;
626 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -1);
628 offset = data._d_ss.getTargetOffsetIndex(i, 1, 1, 0);
629 for (
int j=0; j<target_NP; ++j) {
630 P_target_row(offset, j) = 0;
635 offset = data._d_ss.getTargetOffsetIndex(i, 2, 1, 0);
636 for (
int j=0; j<target_NP; ++j) {
637 P_target_row(offset, j) = 0;
641 P_target_row(offset, 1) = -std::pow(data._epsilons(target_index), -1);
647 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 2, 0);
648 for (
int j=0; j<target_NP; ++j) {
649 P_target_row(offset, j) = 0;
653 P_target_row(offset, 2) = -std::pow(data._epsilons(target_index), -1);
655 offset = data._d_ss.getTargetOffsetIndex(i, 1, 2, 0);
656 for (
int j=0; j<target_NP; ++j) {
657 P_target_row(offset, j) = 0;
661 P_target_row(offset, 1) = std::pow(data._epsilons(target_index), -1);
663 offset = data._d_ss.getTargetOffsetIndex(i, 2, 2, 0);
664 for (
int j=0; j<target_NP; ++j) {
665 P_target_row(offset, j) = 0;
671 }
else if (data._dimensions==2) {
672 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
676 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
677 for (
int j=0; j<target_NP; ++j) {
678 P_target_row(offset, j) = 0;
683 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
684 for (
int j=0; j<target_NP; ++j) {
685 P_target_row(offset, j) = 0;
689 P_target_row(offset, 2) = std::pow(data._epsilons(target_index), -1);
695 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
696 for (
int j=0; j<target_NP; ++j) {
697 P_target_row(offset, j) = 0;
701 P_target_row(offset, 1) = -std::pow(data._epsilons(target_index), -1);
703 offset = data._d_ss.getTargetOffsetIndex(i, 1, 1, 0);
704 for (
int j=0; j<target_NP; ++j) {
705 P_target_row(offset, j) = 0;
728 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
729 for (
int m0=0; m0<data._sampling_multiplier; ++m0) {
730 for (
int m1=0; m1<data._sampling_multiplier; ++m1) {
732 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(m1+1) , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial,
VectorPointSample, e);
734 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1 , e );
735 for (
int j=0; j<target_NP; ++j) {
736 P_target_row(offset, j) = delta(j);
741 additional_evaluation_sites_handled =
true;
743 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
744 for (
int m0=0; m0<data._sampling_multiplier; ++m0) {
745 for (
int m1=0; m1<data._sampling_multiplier; ++m1) {
746 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1 , e );
747 if (data._dimensions==3) {
751 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
753 for (int j=0; j<target_NP; ++j) {
754 P_target_row(offset, j) = delta(j);
756 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
758 for (int j=0; j<target_NP; ++j) {
759 P_target_row(offset, j) -= delta(j);
765 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
767 for (int j=0; j<target_NP; ++j) {
768 P_target_row(offset, j) = -delta(j);
770 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
772 for (int j=0; j<target_NP; ++j) {
773 P_target_row(offset, j) += delta(j);
779 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
781 for (int j=0; j<target_NP; ++j) {
782 P_target_row(offset, j) = delta(j);
784 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
786 for (int j=0; j<target_NP; ++j) {
787 P_target_row(offset, j) -= delta(j);
795 P_target_row(offset, 2) = -std::pow(data._epsilons(target_index), -1);
796 P_target_row(offset, 3) = std::pow(data._epsilons(target_index), -1);
798 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 0 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial,
VectorPointSample, e);
800 for (
int j=0; j<target_NP; ++j) {
801 P_target_row(offset, j) = delta(j);
803 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial,
VectorPointSample, e);
805 for (
int j=0; j<target_NP; ++j) {
806 P_target_row(offset, j) -= delta(j);
814 additional_evaluation_sites_handled =
true;
816 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
817 for (
int m0=0; m0<data._sampling_multiplier; ++m0) {
818 for (
int m1=0; m1<data._sampling_multiplier; ++m1) {
819 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1 , e );
820 if (data._dimensions == 3) {
825 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 0 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
827 for (int j=0; j<target_NP; ++j) {
828 P_target_row(offset, j) = delta(j);
830 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
832 for (int j=0; j<target_NP; ++j) {
833 P_target_row(offset, j) -= delta(j);
835 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 0 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
837 for (int j=0; j<target_NP; ++j) {
838 P_target_row(offset, j) += delta(j);
840 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 2 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
842 for (int j=0; j<target_NP; ++j) {
843 P_target_row(offset, j) -= delta(j);
849 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 0 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
851 for (int j=0; j<target_NP; ++j) {
852 P_target_row(offset, j) = -delta(j);
854 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 1 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
856 for (int j=0; j<target_NP; ++j) {
857 P_target_row(offset, j) += delta(j);
859 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 1 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
861 for (int j=0; j<target_NP; ++j) {
862 P_target_row(offset, j) += delta(j);
864 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 2 , 2 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
866 for (int j=0; j<target_NP; ++j) {
867 P_target_row(offset, j) -= delta(j);
873 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 0 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
875 for (int j=0; j<target_NP; ++j) {
876 P_target_row(offset, j) = -delta(j);
878 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 2 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
880 for (int j=0; j<target_NP; ++j) {
881 P_target_row(offset, j) += delta(j);
883 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(2+1) , 1 , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
885 for (int j=0; j<target_NP; ++j) {
886 P_target_row(offset, j) -= delta(j);
888 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 2 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
890 for (int j=0; j<target_NP; ++j) {
891 P_target_row(offset, j) += delta(j);
897 if (data._dimensions == 2) {
902 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 0 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
904 for (int j=0; j<target_NP; ++j) {
905 P_target_row(offset, j) = delta(j);
907 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 1 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
909 for (int j=0; j<target_NP; ++j) {
910 P_target_row(offset, j) += delta(j);
912 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 0 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
914 for (int j=0; j<target_NP; ++j) {
915 P_target_row(offset, j) -= delta(j);
917 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
919 for (int j=0; j<target_NP; ++j) {
920 P_target_row(offset, j) -= delta(j);
926 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(0+1) , 1 , 0 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
928 for (int j=0; j<target_NP; ++j) {
929 P_target_row(offset, j) = delta(j);
931 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
933 for (int j=0; j<target_NP; ++j) {
934 P_target_row(offset, j) += delta(j);
936 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 0 , 0 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
938 for (int j=0; j<target_NP; ++j) {
939 P_target_row(offset, j) -= delta(j);
941 calcHessianPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(1+1) , 1 , 1 , 1 , data._dimensions, data._poly_order, false , NULL , ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial, VectorPointSample, e);
943 for (int j=0; j<target_NP; ++j) {
944 P_target_row(offset, j) -= delta(j);
953 additional_evaluation_sites_handled =
true;
955 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int e) {
956 for (
int m0=0; m0<data._sampling_multiplier; ++m0) {
957 for (
int m1=0; m1<data._sampling_multiplier; ++m1) {
958 for (
int m2=0; m2<data._sampling_multiplier; ++m2) {
959 int offset = data._d_ss.getTargetOffsetIndex(i, m0 , m1*data._sampling_multiplier+m2 , e);
960 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -(m1+1) , 1 , m2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::DivergenceFreeVectorTaylorPolynomial,
VectorPointSample, e);
961 for (
int j=0; j<target_NP; ++j) {
962 P_target_row(offset, j) = delta(j);
968 additional_evaluation_sites_handled =
true;
984 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
985 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::BernsteinPolynomial,
PointSample, j);
986 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
987 for (
int k=0; k<target_NP; ++k) {
988 P_target_row(offset, k) = delta(k);
991 additional_evaluation_sites_handled =
true;
993 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
994 for (
int d=0; d<data._dimensions; ++d) {
995 int offset = data._d_ss.getTargetOffsetIndex(i, 0, d, j);
996 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
997 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , d , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::BernsteinPolynomial,
PointSample, j);
1000 additional_evaluation_sites_handled =
true;
1002 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
1003 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
1004 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
1005 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 0 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::BernsteinPolynomial,
PointSample, j);
1007 additional_evaluation_sites_handled =
true;
1010 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
1011 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
1012 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
1013 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 1 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::BernsteinPolynomial,
PointSample, j);
1015 additional_evaluation_sites_handled =
true;
1018 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
1019 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
1020 auto row = Kokkos::subview(P_target_row, offset, Kokkos::ALL());
1021 calcGradientPij<TargetData>(data, teamMember, row.data(), thread_workspace.data(), target_index, -1 , 1 , 2 , data._dimensions, data._poly_order,
false , NULL ,
ReconstructionSpace::BernsteinPolynomial,
PointSample, j);
1023 additional_evaluation_sites_handled =
true;
1036 compadre_kernel_assert_release(((additional_evaluation_sites_need_handled && additional_evaluation_sites_handled) || (!additional_evaluation_sites_need_handled)) &&
"Auxiliary evaluation coordinates are specified by user, but are calling a target operation that can not handle evaluating additional sites.");
1039 teamMember.team_barrier();
1053 template <
typename TargetData>
1054 KOKKOS_INLINE_FUNCTION
1057 compadre_kernel_assert_release((thread_workspace.extent_int(0)>=(data._curvature_poly_order+1)*data._local_dimensions) &&
"Workspace thread_workspace not large enough.");
1059 const int target_index = data._initial_index_for_batch + teamMember.league_rank();
1061 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, P_target_row.extent(0)), [&] (
const int j) {
1062 Kokkos::parallel_for(Kokkos::ThreadVectorRange(teamMember, P_target_row.extent(1)),
1063 [&] (const int& k) {
1064 P_target_row(j,k) = 0;
1067 for (
int j = 0; j < delta.extent_int(0); ++j) {
1070 for (
int j = 0; j < thread_workspace.extent_int(0); ++j) {
1071 thread_workspace(j) = 0;
1073 teamMember.team_barrier();
1077 for (
size_t i=0; i<data._curvature_support_operations.size(); ++i) {
1079 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1080 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1081 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, local_neighbor_index, 0 , data._dimensions-1, data._curvature_poly_order,
false , V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample);
1082 for (
int j=0; j<manifold_NP; ++j) {
1083 P_target_row(offset, j) = delta(j);
1087 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1089 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1090 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, local_neighbor_index, 0 , 0 , data._dimensions-1, data._curvature_poly_order,
false , V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample);
1091 for (
int j=0; j<manifold_NP; ++j) {
1092 P_target_row(offset, j) = delta(j);
1094 if (data._dimensions>2) {
1096 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
1097 calcGradientPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, local_neighbor_index, 0 , 1 , data._dimensions-1, data._curvature_poly_order,
false , V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample);
1098 for (
int j=0; j<manifold_NP; ++j) {
1099 P_target_row(offset, j) = delta(j);
1107 teamMember.team_barrier();
1122 template <
typename TargetData>
1123 KOKKOS_INLINE_FUNCTION
1126 compadre_kernel_assert_release((thread_workspace.extent_int(0)>=(data._poly_order+1)*data._local_dimensions) &&
"Workspace thread_workspace not large enough.");
1129 const int target_index = data._initial_index_for_batch + teamMember.league_rank();
1131 int target_NP = GMLS::getNP(data._poly_order, data._dimensions-1, data._reconstruction_space);
1133 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, P_target_row.extent(0)), [&] (
const int j) {
1134 Kokkos::parallel_for(Kokkos::ThreadVectorRange(teamMember, P_target_row.extent(1)),
1135 [&] (const int& k) {
1136 P_target_row(j,k) = 0;
1139 for (
int j = 0; j < delta.extent_int(0); ++j) {
1142 for (
int j = 0; j < thread_workspace.extent_int(0); ++j) {
1143 thread_workspace(j) = 0;
1145 teamMember.team_barrier();
1148 bool additional_evaluation_sites_need_handled =
1149 (data._additional_pc._source_coordinates.extent(0) > 0) ?
true :
false;
1151 const int num_evaluation_sites = data._additional_pc._nla.getNumberOfNeighborsDevice(target_index) + 1;
1153 for (
size_t i=0; i<data._operations.size(); ++i) {
1155 bool additional_evaluation_sites_handled =
false;
1157 bool operation_handled =
true;
1164 if (!operation_handled) {
1165 if (data._dimensions>2) {
1167 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
1168 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions-1, data._poly_order,
false , &V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
1169 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
1170 for (
int k=0; k<target_NP; ++k) {
1171 P_target_row(offset, k) = delta(k);
1174 additional_evaluation_sites_handled =
true;
1177 if (data._reconstruction_space_rank == 1) {
1178 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int k) {
1180 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions-1, data._poly_order,
false , &V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, k);
1181 for (
int m=0; m<data._sampling_multiplier; ++m) {
1182 int output_components = data._basis_multiplier;
1183 for (
int c=0; c<output_components; ++c) {
1184 int offset = data._d_ss.getTargetOffsetIndex(i, m , c , k);
1188 for (
int j=0; j<target_NP; ++j) {
1189 P_target_row(offset, c*target_NP + j) = delta(j);
1194 additional_evaluation_sites_handled =
true;
1196 }
else if (data._reconstruction_space_rank == 0) {
1197 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int k) {
1199 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions-1, data._poly_order,
false , &V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, k);
1200 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, k);
1201 for (
int j=0; j<target_NP; ++j) {
1202 P_target_row(offset, j) = delta(j);
1204 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, k);
1205 for (
int j=0; j<target_NP; ++j) {
1206 P_target_row(offset, j) = 0;
1210 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, k);
1211 for (
int j=0; j<target_NP; ++j) {
1212 P_target_row(offset, j) = 0;
1214 offset = data._d_ss.getTargetOffsetIndex(i, 1, 1, k);
1215 for (
int j=0; j<target_NP; ++j) {
1216 P_target_row(offset, j) = delta(j);
1219 additional_evaluation_sites_handled =
true;
1225 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1227 double h = data._epsilons(target_index);
1228 double a1=0, a2=0, a3=0, a4=0, a5=0;
1229 if (data._curvature_poly_order > 0) {
1230 a1 = curvature_coefficients(1);
1231 a2 = curvature_coefficients(2);
1233 if (data._curvature_poly_order > 1) {
1234 a3 = curvature_coefficients(3);
1235 a4 = curvature_coefficients(4);
1236 a5 = curvature_coefficients(5);
1238 double den = (h*h + a1*a1 + a2*a2);
1245 const int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1246 for (
int j=0; j<target_NP; ++j) {
1247 P_target_row(offset, j) = 0;
1250 if (data._poly_order > 0 && data._curvature_poly_order > 1) {
1251 P_target_row(offset, 1) = (-a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5))/den/den/(h*h);
1252 P_target_row(offset, 2) = (-a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5))/den/den/(h*h);
1254 if (data._poly_order > 1 && data._curvature_poly_order > 0) {
1255 P_target_row(offset, 3) = (h*h+a2*a2)/den/(h*h);
1256 P_target_row(offset, 4) = -2*a1*a2/den/(h*h);
1257 P_target_row(offset, 5) = (h*h+a1*a1)/den/(h*h);
1263 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1265 double h = data._epsilons(target_index);
1266 double a1=0, a2=0, a3=0, a4=0, a5=0;
1267 if (data._curvature_poly_order > 0) {
1268 a1 = curvature_coefficients(1);
1269 a2 = curvature_coefficients(2);
1271 if (data._curvature_poly_order > 1) {
1272 a3 = curvature_coefficients(3);
1273 a4 = curvature_coefficients(4);
1274 a5 = curvature_coefficients(5);
1276 double den = (h*h + a1*a1 + a2*a2);
1278 double c0a = -a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5)/den/den/h;
1279 double c1a = (h*h+a2*a2)/den/h;
1280 double c2a = -a1*a2/den/h;
1282 double c0b = -a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5)/den/den/h;
1283 double c1b = -a1*a2/den/h;
1284 double c2b = (h*h+a1*a1)/den/h;
1287 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1288 for (
int j=0; j<target_NP; ++j) {
1289 P_target_row(offset, j) = 0;
1290 P_target_row(offset, target_NP + j) = 0;
1292 P_target_row(offset, 0) = c0a;
1293 P_target_row(offset, 1) = c1a;
1294 P_target_row(offset, 2) = c2a;
1295 P_target_row(offset, target_NP + 0) = c0b;
1296 P_target_row(offset, target_NP + 1) = c1b;
1297 P_target_row(offset, target_NP + 2) = c2b;
1300 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1302 double h = data._epsilons(target_index);
1303 double a1=0, a2=0, a3=0, a4=0, a5=0;
1304 if (data._curvature_poly_order > 0) {
1305 a1 = curvature_coefficients(1);
1306 a2 = curvature_coefficients(2);
1308 if (data._curvature_poly_order > 1) {
1309 a3 = curvature_coefficients(3);
1310 a4 = curvature_coefficients(4);
1311 a5 = curvature_coefficients(5);
1313 double den = (h*h + a1*a1 + a2*a2);
1315 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1316 for (
int j=0; j<target_NP; ++j) {
1317 P_target_row(offset, j) = 0;
1321 if (data._poly_order > 0 && data._curvature_poly_order > 1) {
1322 P_target_row(offset, 1) = (-a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5))/den/den/(h*h);
1323 P_target_row(offset, 2) = (-a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5))/den/den/(h*h);
1325 if (data._poly_order > 1 && data._curvature_poly_order > 0) {
1326 P_target_row(offset, 3) = (h*h+a2*a2)/den/(h*h);
1327 P_target_row(offset, 4) = -2*a1*a2/den/(h*h);
1328 P_target_row(offset, 5) = (h*h+a1*a1)/den/(h*h);
1337 if (data._reconstruction_space_rank == 1) {
1338 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1340 double h = data._epsilons(target_index);
1341 double a1=0, a2=0, a3=0, a4=0, a5=0;
1342 if (data._curvature_poly_order > 0) {
1343 a1 = curvature_coefficients(1);
1344 a2 = curvature_coefficients(2);
1346 if (data._curvature_poly_order > 1) {
1347 a3 = curvature_coefficients(3);
1348 a4 = curvature_coefficients(4);
1349 a5 = curvature_coefficients(5);
1351 double den = (h*h + a1*a1 + a2*a2);
1353 for (
int j=0; j<target_NP; ++j) {
1358 if (data._poly_order > 0 && data._curvature_poly_order > 1) {
1359 delta(1) = (-a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4+(h*h+a1*a1)*a5))/den/den/(h*h);
1360 delta(2) = (-a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4+(h*h+a1*a1)*a5))/den/den/(h*h);
1362 if (data._poly_order > 1 && data._curvature_poly_order > 0) {
1363 delta(3) = (h*h+a2*a2)/den/(h*h);
1364 delta(4) = -2*a1*a2/den/(h*h);
1365 delta(5) = (h*h+a1*a1)/den/(h*h);
1369 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1370 for (
int j=0; j<target_NP; ++j) {
1371 P_target_row(offset, j) = delta(j);
1372 P_target_row(offset, target_NP + j) = 0;
1374 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
1375 for (
int j=0; j<target_NP; ++j) {
1376 P_target_row(offset, j) = 0;
1377 P_target_row(offset, target_NP + j) = 0;
1381 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
1382 for (
int j=0; j<target_NP; ++j) {
1383 P_target_row(offset, j) = 0;
1384 P_target_row(offset, target_NP + j) = 0;
1386 offset = data._d_ss.getTargetOffsetIndex(i, 1, 1, 0);
1387 for (
int j=0; j<target_NP; ++j) {
1388 P_target_row(offset, j) = 0;
1389 P_target_row(offset, target_NP + j) = delta(j);
1394 }
else if (data._reconstruction_space_rank == 0) {
1395 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1397 double h = data._epsilons(target_index);
1398 double a1=0, a2=0, a3=0, a4=0, a5=0;
1399 if (data._curvature_poly_order > 0) {
1400 a1 = curvature_coefficients(1);
1401 a2 = curvature_coefficients(2);
1403 if (data._curvature_poly_order > 1) {
1404 a3 = curvature_coefficients(3);
1405 a4 = curvature_coefficients(4);
1406 a5 = curvature_coefficients(5);
1408 double den = (h*h + a1*a1 + a2*a2);
1410 for (
int j=0; j<target_NP; ++j) {
1415 if (data._poly_order > 0 && data._curvature_poly_order > 1) {
1416 delta(1) = (-a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4+(h*h+a1*a1)*a5))/den/den/(h*h);
1417 delta(2) = (-a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4+(h*h+a1*a1)*a5))/den/den/(h*h);
1419 if (data._poly_order > 1 && data._curvature_poly_order > 0) {
1420 delta(3) = (h*h+a2*a2)/den/(h*h);
1421 delta(4) = -2*a1*a2/den/(h*h);
1422 delta(5) = (h*h+a1*a1)/den/(h*h);
1426 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1427 for (
int j=0; j<target_NP; ++j) {
1428 P_target_row(offset, j) = delta(j);
1430 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
1431 for (
int j=0; j<target_NP; ++j) {
1432 P_target_row(offset, j) = 0;
1436 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
1437 for (
int j=0; j<target_NP; ++j) {
1438 P_target_row(offset, j) = 0;
1440 offset = data._d_ss.getTargetOffsetIndex(i, 1, 1, 0);
1441 for (
int j=0; j<target_NP; ++j) {
1442 P_target_row(offset, j) = delta(j);
1449 if (data._reconstruction_space_rank == 0
1450 && (data._polynomial_sampling_functional ==
PointSample
1452 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1454 double h = data._epsilons(target_index);
1455 double a1 = curvature_coefficients(1);
1456 double a2 = curvature_coefficients(2);
1458 double q1 = (h*h + a2*a2)/(h*h*h + h*a1*a1 + h*a2*a2);
1459 double q2 = -(a1*a2)/(h*h*h + h*a1*a1 + h*a2*a2);
1460 double q3 = (h*h + a1*a1)/(h*h*h + h*a1*a1 + h*a2*a2);
1462 double t1a = q1*1 + q2*0;
1463 double t2a = q1*0 + q2*1;
1465 double t1b = q2*1 + q3*0;
1466 double t2b = q2*0 + q3*1;
1469 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1470 for (
int j=0; j<target_NP; ++j) {
1471 P_target_row(offset, j) = 0;
1473 if (data._poly_order > 0 && data._curvature_poly_order > 0) {
1474 P_target_row(offset, 1) = t1a + t2a;
1475 P_target_row(offset, 2) = 0;
1478 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, 0);
1479 for (
int j=0; j<target_NP; ++j) {
1480 P_target_row(offset, j) = 0;
1482 if (data._poly_order > 0 && data._curvature_poly_order > 0) {
1483 P_target_row(offset, 1) = 0;
1484 P_target_row(offset, 2) = t1b + t2b;
1490 }
else if (data._reconstruction_space_rank == 1
1491 && data._polynomial_sampling_functional
1497 }
else if (data._reconstruction_space_rank == 0
1498 && data._polynomial_sampling_functional
1507 if (data._reconstruction_space_rank == 1
1509 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1511 double h = data._epsilons(target_index);
1512 double a1=0, a2=0, a3=0, a4=0, a5=0;
1513 if (data._curvature_poly_order > 0) {
1514 a1 = curvature_coefficients(1);
1515 a2 = curvature_coefficients(2);
1517 if (data._curvature_poly_order > 1) {
1518 a3 = curvature_coefficients(3);
1519 a4 = curvature_coefficients(4);
1520 a5 = curvature_coefficients(5);
1522 double den = (h*h + a1*a1 + a2*a2);
1526 double c0a = (a1*a3+a2*a4)/(h*den);
1530 double c0b = (a1*a4+a2*a5)/(h*den);
1535 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1536 for (
int j=0; j<target_NP; ++j) {
1537 P_target_row(offset, j) = 0;
1538 P_target_row(offset, target_NP + j) = 0;
1540 P_target_row(offset, 0) = c0a;
1541 P_target_row(offset, 1) = c1a;
1542 P_target_row(offset, 2) = c2a;
1545 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
1546 for (
int j=0; j<target_NP; ++j) {
1547 P_target_row(offset, j) = 0;
1548 P_target_row(offset, target_NP + j) = 0;
1550 P_target_row(offset, target_NP + 0) = c0b;
1551 P_target_row(offset, target_NP + 1) = c1b;
1552 P_target_row(offset, target_NP + 2) = c2b;
1555 }
else if (data._reconstruction_space_rank == 0
1557 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1559 double h = data._epsilons(target_index);
1560 double a1=0, a2=0, a3=0, a4=0, a5=0;
1561 if (data._curvature_poly_order > 0) {
1562 a1 = curvature_coefficients(1);
1563 a2 = curvature_coefficients(2);
1565 if (data._curvature_poly_order > 1) {
1566 a3 = curvature_coefficients(3);
1567 a4 = curvature_coefficients(4);
1568 a5 = curvature_coefficients(5);
1570 double den = (h*h + a1*a1 + a2*a2);
1574 double c0a = (a1*a3+a2*a4)/(h*den);
1578 double c0b = (a1*a4+a2*a5)/(h*den);
1583 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1584 for (
int j=0; j<target_NP; ++j) {
1585 P_target_row(offset, j) = 0;
1587 P_target_row(offset, 0) = c0a;
1588 P_target_row(offset, 1) = c1a;
1589 P_target_row(offset, 2) = c2a;
1592 offset = data._d_ss.getTargetOffsetIndex(i, 1, 0, 0);
1593 for (
int j=0; j<target_NP; ++j) {
1594 P_target_row(offset, j) = 0;
1596 P_target_row(offset, 0) = c0b;
1597 P_target_row(offset, 1) = c1b;
1598 P_target_row(offset, 2) = c2b;
1601 }
else if (data._reconstruction_space_rank == 1
1602 && data._polynomial_sampling_functional
1605 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1607 double h = data._epsilons(target_index);
1608 double a1=0, a2=0, a3=0, a4=0, a5=0;
1609 if (data._curvature_poly_order > 0) {
1610 a1 = curvature_coefficients(1);
1611 a2 = curvature_coefficients(2);
1613 if (data._curvature_poly_order > 1) {
1614 a3 = curvature_coefficients(3);
1615 a4 = curvature_coefficients(4);
1616 a5 = curvature_coefficients(5);
1618 double den = (h*h + a1*a1 + a2*a2);
1622 double c0a = -a1*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5)/den/den/h;
1623 double c1a = (h*h+a2*a2)/den/h;
1624 double c2a = -a1*a2/den/h;
1626 double c0b = -a2*((h*h+a2*a2)*a3 - 2*a1*a2*a4 + (h*h+a1*a1)*a5)/den/den/h;
1627 double c1b = -a1*a2/den/h;
1628 double c2b = (h*h+a1*a1)/den/h;
1631 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1632 for (
int j=0; j<target_NP; ++j) {
1633 P_target_row(offset, j) = 0;
1634 P_target_row(offset, target_NP + j) = 0;
1636 P_target_row(offset, 0) = c0a;
1637 P_target_row(offset, 1) = c1a;
1638 P_target_row(offset, 2) = c2a;
1639 P_target_row(offset, target_NP + 0) = c0b;
1640 P_target_row(offset, target_NP + 1) = c1b;
1641 P_target_row(offset, target_NP + 2) = c2b;
1648 double h = data._epsilons(target_index);
1650 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int k) {
1653 for (
int d=0; d<data._dimensions-1; ++d) {
1656 relative_coord[d] = data._additional_pc.getNeighborCoordinate(target_index, k-1, d, &V);
1657 relative_coord[d] -= data._pc.getTargetCoordinate(target_index, d, &V);
1660 for (
int j=0; j<3; ++j) relative_coord[j] = 0;
1663 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, k);
1664 P_target_row(offset, 0) =
GaussianCurvature(curvature_coefficients, h, relative_coord.x, relative_coord.y);
1666 additional_evaluation_sites_handled =
true;
1668 double h = data._epsilons(target_index);
1670 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int k) {
1674 for (
int d=0; d<data._dimensions-1; ++d) {
1677 relative_coord[d] = data._additional_pc.getNeighborCoordinate(target_index, k-1, d, &V);
1678 relative_coord[d] -= data._pc.getTargetCoordinate(target_index, d, &V);
1681 for (
int j=0; j<3; ++j) relative_coord[j] = 0;
1684 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, k);
1686 for (
int n = 0; n <= data._poly_order; n++){
1687 for (alphay = 0; alphay <= n; alphay++){
1688 alphax = n - alphay;
1689 P_target_row(offset, index) =
SurfaceCurlOfScalar(curvature_coefficients, h, relative_coord.x, relative_coord.y, alphax, alphay, 0);
1694 offset = data._d_ss.getTargetOffsetIndex(i, 0, 1, k);
1696 for (
int n = 0; n <= data._poly_order; n++){
1697 for (alphay = 0; alphay <= n; alphay++){
1698 alphax = n - alphay;
1699 P_target_row(offset, index) =
SurfaceCurlOfScalar(curvature_coefficients, h, relative_coord.x, relative_coord.y, alphax, alphay, 1);
1704 additional_evaluation_sites_handled =
true;
1708 "CellAverageEvaluation and CellIntegralEvaluation only support 2d or 3d with 2d manifold");
1709 const double factorial[15] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
1710 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, 0);
1712 double cutoff_p = data._epsilons(target_index);
1719 double triangle_coords[3*3];
1720 for (
int j=0; j<data._global_dimensions*3; ++j) G_data[j] = 0;
1721 for (
int j=0; j<data._global_dimensions*3; ++j) triangle_coords[j] = 0;
1726 double radius = 0.0;
1727 for (
int j=0; j<data._global_dimensions; ++j) {
1729 triangle_coords_matrix(j, 0) = data._pc.getTargetCoordinate(target_index, j);
1730 radius += triangle_coords_matrix(j, 0)*triangle_coords_matrix(j, 0);
1732 radius = std::sqrt(radius);
1736 int num_vertices = 0;
1737 for (
int j=0; j<data._target_extra_data.extent_int(1); ++j) {
1738 auto val = data._target_extra_data(target_index, j);
1745 num_vertices = num_vertices / data._global_dimensions;
1746 auto T = triangle_coords_matrix;
1750 double entire_cell_area = 0.0;
1751 for (
int v=0; v<num_vertices; ++v) {
1753 int v2 = (v+1) % num_vertices;
1755 for (
int j=0; j<data._global_dimensions; ++j) {
1756 triangle_coords_matrix(j,1) = data._target_extra_data(target_index,
1757 v1*data._global_dimensions+j)
1758 - triangle_coords_matrix(j,0);
1759 triangle_coords_matrix(j,2) = data._target_extra_data(target_index,
1760 v2*data._global_dimensions+j)
1761 - triangle_coords_matrix(j,0);
1768 for (
int quadrature = 0; quadrature<data._qm.getNumberOfQuadraturePoints(); ++quadrature) {
1769 double unscaled_transformed_qp[3] = {0,0,0};
1770 double scaled_transformed_qp[3] = {0,0,0};
1771 for (
int j=0; j<data._global_dimensions; ++j) {
1772 for (
int k=1; k<3; ++k) {
1775 unscaled_transformed_qp[j] += T(j,k)*data._qm.getSite(quadrature, k-1);
1778 unscaled_transformed_qp[j] += T(j,0);
1782 double transformed_qp_norm = 0;
1783 for (
int j=0; j<data._global_dimensions; ++j) {
1784 transformed_qp_norm += unscaled_transformed_qp[j]*unscaled_transformed_qp[j];
1786 transformed_qp_norm = std::sqrt(transformed_qp_norm);
1789 for (
int j=0; j<data._global_dimensions; ++j) {
1790 scaled_transformed_qp[j] = unscaled_transformed_qp[j] * radius / transformed_qp_norm;
1810 double qp_norm_sq = transformed_qp_norm*transformed_qp_norm;
1811 for (
int j=0; j<data._global_dimensions; ++j) {
1812 G(j,1) = T(j,1)/transformed_qp_norm;
1813 G(j,2) = T(j,2)/transformed_qp_norm;
1814 for (
int k=0; k<data._global_dimensions; ++k) {
1815 G(j,1) += unscaled_transformed_qp[j]*(-0.5)*std::pow(qp_norm_sq,-1.5)
1816 *2*(unscaled_transformed_qp[k]*T(k,1));
1817 G(j,2) += unscaled_transformed_qp[j]*(-0.5)*std::pow(qp_norm_sq,-1.5)
1818 *2*(unscaled_transformed_qp[k]*T(k,2));
1822 Kokkos::subview(G, Kokkos::ALL(), 1), Kokkos::subview(G, Kokkos::ALL(), 2));
1823 G_determinant *= radius*radius;
1824 XYZ qp = XYZ(scaled_transformed_qp[0], scaled_transformed_qp[1], scaled_transformed_qp[2]);
1825 for (
int j=0; j<data._local_dimensions; ++j) {
1826 relative_coord[j] = data._pc.convertGlobalToLocalCoordinate(qp,j,V)
1827 - data._pc.getTargetCoordinate(target_index,j,&V);
1832 for (
int n = 0; n <= data._poly_order; n++){
1833 for (alphay = 0; alphay <= n; alphay++){
1834 alphax = n - alphay;
1835 alphaf = factorial[alphax]*factorial[alphay];
1836 double val_to_sum = G_determinant * (data._qm.getWeight(quadrature)
1837 * std::pow(relative_coord.x/cutoff_p,alphax)
1838 * std::pow(relative_coord.y/cutoff_p,alphay) / alphaf);
1839 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1840 if (quadrature==0 && v==0) P_target_row(offset, k) = val_to_sum;
1841 else P_target_row(offset, k) += val_to_sum;
1846 entire_cell_area += G_determinant * data._qm.getWeight(quadrature);
1851 for (
int n = 0; n <= data._poly_order; n++){
1852 for (alphay = 0; alphay <= n; alphay++){
1853 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
1854 P_target_row(offset, k) /= entire_cell_area;
1865 "FaceNormalIntegralSample, EdgeTangentIntegralSample, FaceNormalAverageSample, \
1866 and EdgeTangentAverageSample only support 2d or 3d with 2d manifold");
1868 &&
"Only 1d quadrature may be specified for edge integrals");
1870 &&
"Quadrature points not generated");
1872 const double factorial[15] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
1874 double cutoff_p = data._epsilons(target_index);
1885 int quadrature_point_loop = data._qm.getNumberOfQuadraturePoints();
1888 double G_data[3*TWO];
1889 double edge_coords[3*TWO];
1890 for (
int j=0; j<data._global_dimensions*TWO; ++j) G_data[j] = 0;
1891 for (
int j=0; j<data._global_dimensions*TWO; ++j) edge_coords[j] = 0;
1900 double radius = 0.0;
1902 for (
int j=0; j<data._global_dimensions; ++j) {
1903 edge_coords_matrix(j, 0) = data._target_extra_data(target_index, j);
1904 edge_coords_matrix(j, 1) = data._target_extra_data(target_index, data._global_dimensions + j) - edge_coords_matrix(j, 0);
1905 radius += edge_coords_matrix(j, 0)*edge_coords_matrix(j, 0);
1907 radius = std::sqrt(radius);
1911 auto E = edge_coords_matrix;
1916 XYZ a = {E(0,0), E(1,0), E(2,0)};
1917 XYZ b = {E(0,1)+E(0,0), E(1,1)+E(1,0), E(2,1)+E(2,0)};
1918 double a_dot_b = a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
1920 theta = std::atan(norm_a_cross_b / a_dot_b);
1923 for (
int c=0; c<data._local_dimensions; ++c) {
1924 int input_component = (data._sampling_multiplier==1 && data._reconstruction_space_rank==1) ? 0 : c;
1925 int offset = data._d_ss.getTargetOffsetIndex(i, input_component , 0 , 0);
1926 int column_offset = (data._reconstruction_space_rank==1) ? c*target_NP : 0;
1927 for (
int j=0; j<target_NP; ++j) {
1928 P_target_row(offset, column_offset + j) = 0;
1933 double entire_edge_length = 0.0;
1935 for (
int quadrature = 0; quadrature<quadrature_point_loop; ++quadrature) {
1937 double G_determinant = 1.0;
1938 double scaled_transformed_qp[3] = {0,0,0};
1939 double unscaled_transformed_qp[3] = {0,0,0};
1940 for (
int j=0; j<data._global_dimensions; ++j) {
1941 unscaled_transformed_qp[j] += E(j,1)*data._qm.getSite(quadrature, 0);
1943 unscaled_transformed_qp[j] += E(j,0);
1952 double transformed_qp_norm = 0;
1953 for (
int j=0; j<data._global_dimensions; ++j) {
1954 transformed_qp_norm += unscaled_transformed_qp[j]*unscaled_transformed_qp[j];
1956 transformed_qp_norm = std::sqrt(transformed_qp_norm);
1958 for (
int j=0; j<data._global_dimensions; ++j) {
1959 scaled_transformed_qp[j] = unscaled_transformed_qp[j] * radius / transformed_qp_norm;
1962 G_determinant = radius * theta;
1963 XYZ qp = XYZ(scaled_transformed_qp[0], scaled_transformed_qp[1], scaled_transformed_qp[2]);
1964 for (
int j=0; j<data._local_dimensions; ++j) {
1965 relative_coord[j] = data._pc.convertGlobalToLocalCoordinate(qp,j,V)
1966 - data._pc.getTargetCoordinate(target_index,j,&V);
1969 relative_coord[2] = 0;
1971 XYZ endpoints_difference = {E(0,1), E(1,1), 0};
1972 G_determinant = data._pc.EuclideanVectorLength(endpoints_difference, 2);
1973 for (
int j=0; j<data._local_dimensions; ++j) {
1974 relative_coord[j] = unscaled_transformed_qp[j]
1975 - data._pc.getTargetCoordinate(target_index,j,&V);
1978 relative_coord[2] = 0;
1985 for (
int j=0; j<data._global_dimensions; ++j) {
1987 direction[j] = data._target_extra_data(target_index, 2*data._global_dimensions + j);
1992 XYZ k = {scaled_transformed_qp[0], scaled_transformed_qp[1], scaled_transformed_qp[2]};
1994 double k_norm = std::sqrt(k[0]*k[0]+k[1]*k[1]+k[2]*k[2]);
1995 k[0] = k[0]/k_norm; k[1] = k[1]/k_norm; k[2] = k[2]/k_norm;
1996 XYZ n = {data._target_extra_data(target_index, 2*data._global_dimensions + 0),
1997 data._target_extra_data(target_index, 2*data._global_dimensions + 1),
1998 data._target_extra_data(target_index, 2*data._global_dimensions + 2)};
2001 direction[0] = (k[1]*n[2] - k[2]*n[1]) / norm_k_cross_n;
2002 direction[1] = (k[2]*n[0] - k[0]*n[2]) / norm_k_cross_n;
2003 direction[2] = (k[0]*n[1] - k[1]*n[0]) / norm_k_cross_n;
2005 for (
int j=0; j<data._global_dimensions; ++j) {
2007 direction[j] = data._target_extra_data(target_index, 3*data._global_dimensions + j);
2013 XYZ local_direction;
2015 for (
int j=0; j<data._local_dimensions; ++j) {
2020 local_direction[j] = data._pc.convertGlobalToLocalCoordinate(direction,j,V);
2028 for (
int c=0; c<data._local_dimensions; ++c) {
2029 int input_component = (data._sampling_multiplier==1 && data._reconstruction_space_rank==1) ? 0 : c;
2030 int offset = data._d_ss.getTargetOffsetIndex(i, input_component, 0 , 0);
2031 int column_offset = (data._reconstruction_space_rank==1) ? c*target_NP : 0;
2033 for (
int n = 0; n <= data._poly_order; n++){
2034 for (alphay = 0; alphay <= n; alphay++){
2035 alphax = n - alphay;
2036 alphaf = factorial[alphax]*factorial[alphay];
2040 v0 = (c==0) ? std::pow(relative_coord.x/cutoff_p,alphax)
2041 *std::pow(relative_coord.y/cutoff_p,alphay)/alphaf : 0;
2042 v1 = (c==1) ? std::pow(relative_coord.x/cutoff_p,alphax)
2043 *std::pow(relative_coord.y/cutoff_p,alphay)/alphaf : 0;
2046 double dot_product = 0.0;
2049 dot_product = local_direction[0]*v0 + local_direction[1]*v1;
2051 dot_product = direction[0]*v0 + direction[1]*v1;
2055 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
2056 if (quadrature==0 && c==0) P_target_row(offset, column_offset + k) =
2057 dot_product * data._qm.getWeight(quadrature) * G_determinant;
2058 else P_target_row(offset, column_offset + k) +=
2059 dot_product * data._qm.getWeight(quadrature) * G_determinant;
2065 entire_edge_length += G_determinant * data._qm.getWeight(quadrature);
2069 for (
int c=0; c<data._local_dimensions; ++c) {
2074 int input_component = (data._sampling_multiplier==1 && data._reconstruction_space_rank==1) ? 0 : c;
2076 int offset = data._d_ss.getTargetOffsetIndex(i, input_component, 0 , 0);
2077 int column_offset = (data._reconstruction_space_rank == 1) ? c*target_NP : 0;
2078 for (
int n = 0; n <= data._poly_order; n++){
2079 for (alphay = 0; alphay <= n; alphay++){
2080 Kokkos::single(Kokkos::PerTeam(teamMember), [&] () {
2081 P_target_row(offset, column_offset + k) /= entire_edge_length;
2091 }
else if (data._dimensions==2) {
2093 Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, num_evaluation_sites), [&] (
const int j) {
2094 calcPij<TargetData>(data, teamMember, delta.data(), thread_workspace.data(), target_index, -1 , 1 , data._dimensions-1, data._poly_order,
false , &V,
ReconstructionSpace::ScalarTaylorPolynomial,
PointSample, j);
2095 int offset = data._d_ss.getTargetOffsetIndex(i, 0, 0, j);
2096 for (
int k=0; k<target_NP; ++k) {
2097 P_target_row(offset, k) = delta(k);
2100 additional_evaluation_sites_handled =
true;
2107 compadre_kernel_assert_release(((additional_evaluation_sites_need_handled && additional_evaluation_sites_handled) || (!additional_evaluation_sites_need_handled)) &&
"Auxiliary evaluation coordinates are specified by user, but are calling a target operation that can not handle evaluating additional sites.");
2110 teamMember.team_barrier();
#define compadre_kernel_assert_debug(condition)
Kokkos::View< double *, Kokkos::MemoryTraits< Kokkos::Unmanaged > > scratch_vector_type
#define compadre_kernel_assert_release(condition)
compadre_kernel_assert_release is similar to compadre_assert_release, but is a call on the device,...
team_policy::member_type member_type
Kokkos::View< double **, layout_right, Kokkos::MemoryTraits< Kokkos::Unmanaged > > scratch_matrix_right_type
if(some_conditions_for_a_user_defined_operation)
static KOKKOS_INLINE_FUNCTION int getNP(const int m, const int dimension=3, const ReconstructionSpace r_space=ReconstructionSpace::ScalarTaylorPolynomial)
Returns size of the basis for a given polynomial order and dimension General to dimension 1....
KOKKOS_INLINE_FUNCTION void computeCurvatureFunctionals(const TargetData &data, const member_type &teamMember, scratch_vector_type delta, scratch_vector_type thread_workspace, scratch_matrix_right_type P_target_row, const scratch_matrix_right_type *V, const local_index_type local_neighbor_index=-1)
Evaluates a polynomial basis for the curvature with a gradient target functional applied.
KOKKOS_INLINE_FUNCTION void computeTargetFunctionals(const TargetData &data, const member_type &teamMember, scratch_vector_type delta, scratch_vector_type thread_workspace, scratch_matrix_right_type P_target_row)
Evaluates a polynomial basis with a target functional applied to each member of the basis.
constexpr SamplingFunctional StaggeredEdgeIntegralSample
Samples consist of the result of integrals of a vector dotted with the tangent along edges between ne...
KOKKOS_INLINE_FUNCTION double GaussianCurvature(const scratch_vector_type a_, const double h, const double u1, const double u2)
Gaussian curvature K at any point in the local chart.
constexpr SamplingFunctional PointSample
Available sampling functionals.
@ DivergenceFreeVectorTaylorPolynomial
Divergence-free vector polynomial basis.
@ BernsteinPolynomial
Bernstein polynomial basis.
@ VectorTaylorPolynomial
Vector polynomial basis having # of components _dimensions, or (_dimensions-1) in the case of manifol...
@ ScalarTaylorPolynomial
Scalar polynomial basis centered at the target site and scaled by sum of basis powers e....
@ VectorOfScalarClonesTaylorPolynomial
Scalar basis reused as many times as there are components in the vector resulting in a much cheaper p...
constexpr SamplingFunctional StaggeredEdgeAnalyticGradientIntegralSample
Analytical integral of a gradient source vector is just a difference of the scalar source at neighbor...
@ MANIFOLD
Solve GMLS problem on a manifold (will use QR or SVD to solve the resultant GMLS problem dependent on...
constexpr SamplingFunctional ManifoldVectorPointSample
Point evaluations of the entire vector source function (but on a manifold, so it includes a transform...
constexpr SamplingFunctional VectorPointSample
Point evaluations of the entire vector source function.
KOKKOS_INLINE_FUNCTION void computeTargetFunctionalsOnManifold(const TargetData &data, const member_type &teamMember, scratch_vector_type delta, scratch_vector_type thread_workspace, scratch_matrix_right_type P_target_row, scratch_matrix_right_type V, scratch_vector_type curvature_coefficients)
Evaluates a polynomial basis with a target functional applied, using information from the manifold cu...
@ FaceNormalIntegralEvaluation
Integral value of vector dotted with normal direction Supported on 1D edges in 3D problems (2D-manifo...
@ LaplacianOfScalarPointEvaluation
Point evaluation of the laplacian of a scalar (could be on a manifold or not)
@ FaceNormalAverageEvaluation
Average value of vector dotted with normal direction Supported on 1D edges in 3D problems (2D-manifol...
@ GradientOfScalarPointEvaluation
Point evaluation of the gradient of a scalar.
@ CurlOfVectorPointEvaluation
Point evaluation of the curl of a vector (results in a vector)
@ PartialYOfScalarPointEvaluation
Point evaluation of the partial with respect to y of a scalar.
@ ChainedStaggeredLaplacianOfScalarPointEvaluation
Point evaluation of the chained staggered Laplacian acting on VectorTaylorPolynomial basis + Staggere...
@ GaussianCurvaturePointEvaluation
Point evaluation of Gaussian curvature.
@ CurlCurlOfVectorPointEvaluation
Point evaluation of the curl of a curl of a vector (results in a vector)
@ GradientOfVectorPointEvaluation
Point evaluation of the gradient of a vector (results in a matrix, NOT CURRENTLY IMPLEMENTED)
@ EdgeTangentAverageEvaluation
Average value of vector dotted with tangent directions Supported on 1D edges in 3D problems (2D-manif...
@ PartialZOfScalarPointEvaluation
Point evaluation of the partial with respect to z of a scalar.
@ DivergenceOfVectorPointEvaluation
Point evaluation of the divergence of a vector (results in a scalar)
@ CellIntegralEvaluation
Integral values over cell using quadrature Supported on 2D faces in 3D problems (manifold) and 2D cel...
@ CellAverageEvaluation
Average values of a cell using quadrature Supported on 2D faces in 3D problems (manifold) and 2D cell...
@ EdgeTangentIntegralEvaluation
Integral value of vector dotted with tangent directions Supported on 1D edges in 3D problems (2D-mani...
@ VectorPointEvaluation
Point evaluation of a vector (reconstructs entire vector at once, requiring a ReconstructionSpace hav...
@ VectorLaplacianPointEvaluation
Point evaluation of the laplacian of each component of a vector.
@ ScalarPointEvaluation
Point evaluation of a scalar.
@ PartialXOfScalarPointEvaluation
Point evaluation of the partial with respect to x of a scalar.
KOKKOS_INLINE_FUNCTION double SurfaceCurlOfScalar(const scratch_vector_type a_, const double h, const double u1, const double u2, int x_pow, int y_pow, const int component)
Surface curl at any point in the local chart.
KOKKOS_INLINE_FUNCTION double getAreaFromVectors(const member_type &teamMember, view_type_1 v1, view_type_2 v2)