17 &&
"keep_coefficients is set to true, but number of batches exceeds 1.");
49 &&
"No target operations added to GMLS class before calling generatePolynomialCoefficients().");
66 &&
"Cannot solve GMLS problems with the NEUMANN_GRAD_SCALAR constraint using QR Factorization.");
75 int total_added_alphas =
_pc._target_coordinates.extent(0)*
_d_ss._added_alpha_size;
77 decltype(
_d_ss._alphas)(
"alphas", (total_neighbors +
TO_GLOBAL(total_added_alphas))
81 Kokkos::deep_copy(
_d_ss._alphas, 0.0);
82 }
catch(std::exception &e) {
83 printf(
"Insufficient memory to store alphas: \n\n%s", e.what());
90 int max_num_neighbors =
_pc._nla.getMaxNumNeighbors();
93 std::pow(2,sro.use_target_site_weights),
96 this->getNeighborLists()->getNumberOfTargets() : 1,
98 max_num_neighbors : 1,
103 }
catch(std::exception &e) {
104 printf(
"Insufficient memory to store prestencil weights: \n\n%s", e.what());
135 int team_scratch_size_a = 0;
138 int team_scratch_size_b = 0;
139 int thread_scratch_size_a = 0;
140 int thread_scratch_size_b = 0;
158 const int max_manifold_NP = (manifold_NP >
_NP) ? manifold_NP :
_NP;
167 team_scratch_size_b += scratch_vector_type::shmem_size( (
_dimensions-1)*max_num_neighbors );
169 thread_scratch_size_a += scratch_vector_type::shmem_size(this_num_cols);
170 thread_scratch_size_a += scratch_vector_type::shmem_size(
173 team_scratch_size_b += scratch_vector_type::shmem_size(max_num_neighbors);
174 team_scratch_size_b += scratch_vector_type::shmem_size(max_num_neighbors);
181 Kokkos::deep_copy(
_T, 0.0);
184 "Provided tangent_directions has number of targets different than target_coordinates");
187 _pc._target_coordinates.extent(0)*manifold_NP);
196 thread_scratch_size_a += scratch_vector_type::shmem_size(this_num_cols);
197 thread_scratch_size_a += scratch_vector_type::shmem_size(
201 _pm.setTeamScratchSize(0, team_scratch_size_a);
202 _pm.setTeamScratchSize(1, team_scratch_size_b);
203 _pm.setThreadScratchSize(0, thread_scratch_size_a);
204 _pm.setThreadScratchSize(1, thread_scratch_size_b);
210 int RHS_dim_0, RHS_dim_1;
213 int P_dim_0, P_dim_1;
224 _w = Kokkos::View<double*>(
"w", max_batch_size*
TO_GLOBAL(max_num_rows));
225 _Z = Kokkos::View<double*>(
"Z", max_batch_size*
TO_GLOBAL(
_d_ss._total_alpha_values*
_d_ss._max_evaluation_sites_per_target*this_num_cols));
227 }
catch (std::exception &e) {
228 printf(
"Failed to allocate space for RHS, P, and w. Consider increasing number_of_batches: \n\n%s", e.what());
239 &&
"Normal vectors are required for solving GMLS problems with the NEUMANN_GRAD_SCALAR constraint.");
243 for (
int batch_num=0; batch_num<number_of_batches; ++batch_num) {
246 Kokkos::deep_copy(
_RHS, 0.0);
247 Kokkos::deep_copy(
_P, 0.0);
248 Kokkos::deep_copy(
_w, 0.0);
249 Kokkos::deep_copy(
_Z, 0.0);
254 auto tp =
_pm.TeamPolicyThreadsAndVectors(this_batch_size);
267 Kokkos::parallel_for(
"ComputeCoarseTangentPlane", tp, functor_compute_coarse_tangent_plane);
275 Kokkos::parallel_for(
"FixTangentDirectionOrdering", tp, functor_fix_tangent_direction_ordering);
280 Kokkos::parallel_for(
"AssembleCurvaturePsqrtW", tp, functor_assemble_curvature_psqrtw);
284 Kokkos::Profiling::pushRegion(
"Curvature LU Factorization");
288 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_left,layout_right>(
_pm,
_RHS.data(), RHS_dim_0, RHS_dim_1,
_P.data(), P_dim_1, P_dim_0, manifold_NP, manifold_NP, max_num_neighbors, this_batch_size, implicit_RHS);
289 Kokkos::Profiling::popRegion();
292 Kokkos::Profiling::pushRegion(
"Curvature QR+Pivoting Factorization");
293 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_right,layout_right>(
_pm,
_P.data(), P_dim_0, P_dim_1,
_RHS.data(), RHS_dim_0, RHS_dim_1, max_num_neighbors, manifold_NP, max_num_neighbors, this_batch_size, implicit_RHS);
294 Kokkos::Profiling::popRegion();
299 Kokkos::parallel_for(
"GetAccurateTangentDirections", tp, functor_get_accurate_tangent_directions);
302 Kokkos::deep_copy(
_P, 0.0);
304 if (batch_num==number_of_batches-1) {
306 _host_T = Kokkos::create_mirror_view(
_T);
314 Kokkos::parallel_for(
"AssembleCurvaturePsqrtW", tp, functor_assemble_curvature_psqrtw);
318 Kokkos::Profiling::pushRegion(
"Curvature LU Factorization");
319 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_left,layout_right>(
_pm,
_RHS.data(), RHS_dim_0, RHS_dim_1,
_P.data(), P_dim_1, P_dim_0, manifold_NP, manifold_NP, max_num_neighbors, this_batch_size, implicit_RHS);
320 Kokkos::Profiling::popRegion();
323 Kokkos::Profiling::pushRegion(
"Curvature QR+Pivoting Factorization");
324 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_right,layout_right>(
_pm,
_P.data(), P_dim_0, P_dim_1,
_RHS.data(), RHS_dim_0, RHS_dim_1, max_num_neighbors, manifold_NP, max_num_neighbors, this_batch_size, implicit_RHS);
325 Kokkos::Profiling::popRegion();
330 Kokkos::parallel_for(
"ApplyCurvatureTargets", tp, functor_apply_curvature_targets);
338 Kokkos::parallel_for(
"ComputePrestencilWeights", tp, functor_compute_prestencil_weights);
341 Kokkos::deep_copy(
_P, 0.0);
345 Kokkos::parallel_for(
"AssembleManifoldPsqrtW", tp, functor_assemble_manifold_psqrtw);
349 Kokkos::Profiling::pushRegion(
"Manifold LU Factorization");
350 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_left,layout_right>(
_pm,
_RHS.data(), RHS_dim_0, RHS_dim_1,
_P.data(), P_dim_1, P_dim_0, this_num_cols, this_num_cols, max_num_rows, this_batch_size, implicit_RHS);
351 Kokkos::Profiling::popRegion();
353 Kokkos::Profiling::pushRegion(
"Manifold QR+Pivoting Factorization");
354 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_right,layout_right>(
_pm,
_P.data(), P_dim_0, P_dim_1,
_RHS.data(), RHS_dim_0, RHS_dim_1, max_num_rows, this_num_cols, max_num_rows, this_batch_size, implicit_RHS);
355 Kokkos::Profiling::popRegion();
368 Kokkos::parallel_for(
"AssembleStandardPsqrtW", tp, functor_assemble_standard_psqrtw);
373 Kokkos::Profiling::pushRegion(
"LU Factorization");
374 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_left,layout_right>(
_pm,
_RHS.data(), RHS_dim_0, RHS_dim_1,
_P.data(), P_dim_1, P_dim_0, this_num_cols + added_coeff_size, this_num_cols + added_coeff_size, max_num_rows +
_d_ss._added_alpha_size, this_batch_size, implicit_RHS);
375 Kokkos::Profiling::popRegion();
377 Kokkos::Profiling::pushRegion(
"QR+Pivoting Factorization");
379 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_right,layout_right>(
_pm,
_RHS.data(), RHS_dim_0, RHS_dim_1,
_P.data(), P_dim_1, P_dim_0, this_num_cols + added_coeff_size, this_num_cols + added_coeff_size, max_num_rows +
_d_ss._added_alpha_size, this_batch_size, implicit_RHS);
381 GMLS_LinearAlgebra::batchQRPivotingSolve<layout_right,layout_right,layout_right>(
_pm,
_P.data(), P_dim_0, P_dim_1,
_RHS.data(), RHS_dim_0, RHS_dim_1, max_num_rows, this_num_cols, max_num_rows, this_batch_size, implicit_RHS);
383 Kokkos::Profiling::popRegion();
387 Kokkos::parallel_for(
"ComputePrestencilWeights", tp, functor_compute_prestencil_weights);
403 Kokkos::parallel_for(
"EvaluateManifoldTargets", tp, functor_evaluate_manifold_targets);
413 Kokkos::parallel_for(
"EvaluateStandardTargets", tp, functor_evaluate_standard_targets);
420 const auto work_item_property = Kokkos::Experimental::WorkItemProperty::HintLightWeight;
421 const auto tp2 = Kokkos::Experimental::require(tp, work_item_property);
422 auto functor_apply_targets =
ApplyTargets(gmls_solution_data);
424 Kokkos::parallel_for(
"ApplyTargets", tp2, functor_apply_targets);
433 _w = Kokkos::View<double*>(
"w",0);
434 _Z = Kokkos::View<double*>(
"Z",0);
435 if (number_of_batches > 1) {
436 _RHS = Kokkos::View<double*>(
"RHS",0);
437 _P = Kokkos::View<double*>(
"P",0);
441 _RHS = Kokkos::View<double*>(
"RHS", 0);
442 if (!keep_coefficients)
_P = Kokkos::View<double*>(
"P", 0);
445 _P = Kokkos::View<double*>(
"P", 0);
446 if (!keep_coefficients)
_RHS = Kokkos::View<double*>(
"RHS", 0);
448 _RHS = Kokkos::View<double*>(
"RHS", 0);
449 if (!keep_coefficients)
_P = Kokkos::View<double*>(
"P", 0);
460 this->
_d_ss._contains_valid_alphas =
true;
478 data._sampling_multiplier = gmls._sampling_multiplier;
479 data._initial_index_for_batch = gmls._initial_index_for_batch;
480 data._d_ss = gmls._d_ss;
483 const int max_num_neighbors = gmls._pc._nla.getMaxNumNeighbors();
484 const int max_num_rows = gmls._sampling_multiplier*max_num_neighbors;
492 data.this_num_cols = gmls._basis_multiplier*gmls._NP;
494 int RHS_dim_0, RHS_dim_1;
495 getRHSDims(gmls._dense_solver_type, gmls._constraint_type, gmls._reconstruction_space,
496 gmls._dimensions, max_num_rows, data.this_num_cols, RHS_dim_0, RHS_dim_1);
497 int P_dim_0, P_dim_1;
498 getPDims(gmls._dense_solver_type, gmls._constraint_type, gmls._reconstruction_space,
499 gmls._dimensions, max_num_rows, data.this_num_cols, P_dim_0, P_dim_1);
502 data.Coeffs_data = gmls._RHS.data();
503 data.Coeffs_dim_0 = RHS_dim_0;
504 data.Coeffs_dim_1 = RHS_dim_1;
506 data.Coeffs_data = gmls._P.data();
507 data.Coeffs_dim_0 = P_dim_1;
508 data.Coeffs_dim_1 = P_dim_0;
511 data.P_target_row_dim_0 = gmls._d_ss._total_alpha_values*gmls._d_ss._max_evaluation_sites_per_target;
512 data.P_target_row_dim_1 = data.this_num_cols;
513 data.P_target_row_data = gmls._Z.data();
515 data.operations_size = gmls._operations.size();
517 data.number_of_neighbors_list = gmls._pc._nla._number_of_neighbors_list;
518 data.additional_number_of_neighbors_list = gmls._additional_pc._nla._number_of_neighbors_list;
526 data._source_extra_data = gmls._source_extra_data;
527 data._target_extra_data = gmls._target_extra_data;
529 data._epsilons = gmls._epsilons ;
530 data._prestencil_weights = gmls._prestencil_weights ;
531 data._additional_pc = gmls._additional_pc;
532 data._poly_order = gmls._poly_order ;
533 data._curvature_poly_order = gmls._curvature_poly_order;
535 data._global_dimensions = gmls._global_dimensions;
536 data._local_dimensions = gmls._local_dimensions;
537 data._dimensions = gmls._dimensions;
538 data._reconstruction_space = gmls._reconstruction_space;
539 data._reconstruction_space_rank = gmls._reconstruction_space_rank;
540 data._dense_solver_type = gmls._dense_solver_type;
541 data._problem_type = gmls._problem_type;
542 data._constraint_type = gmls._constraint_type;
543 data._polynomial_sampling_functional = gmls._polynomial_sampling_functional;
544 data._data_sampling_functional = gmls._data_sampling_functional;
545 data._curvature_support_operations = gmls._curvature_support_operations;
546 data._operations = gmls._operations;
547 data._weighting_type = gmls._weighting_type;
548 data._curvature_weighting_type = gmls._curvature_weighting_type;
549 data._weighting_p = gmls._weighting_p;
550 data._weighting_n = gmls._weighting_n;
551 data._curvature_weighting_p = gmls._curvature_weighting_p;
552 data._curvature_weighting_n = gmls._curvature_weighting_n;
553 data._basis_multiplier = gmls._basis_multiplier;
554 data._sampling_multiplier = gmls._sampling_multiplier;
555 data._data_sampling_multiplier = gmls._data_sampling_multiplier;
556 data._initial_index_for_batch = gmls._initial_index_for_batch;
558 data._order_of_quadrature_points = gmls._order_of_quadrature_points;
559 data._dimension_of_quadrature_points = gmls._dimension_of_quadrature_points;
561 data._d_ss = gmls._d_ss;
563 data.max_num_neighbors = gmls._pc._nla.getMaxNumNeighbors();
564 data.max_num_rows = gmls._sampling_multiplier*data.max_num_neighbors;
565 int basis_powers_space_multiplier = (gmls._reconstruction_space ==
BernsteinPolynomial) ? 2 : 1;
567 data.manifold_NP =
GMLS::getNP(gmls._curvature_poly_order, gmls._dimensions-1,
569 data.max_manifold_NP = (data.manifold_NP > gmls._NP) ? data.manifold_NP : gmls._NP;
570 data.this_num_cols = gmls._basis_multiplier*data.max_manifold_NP;
571 data.max_poly_order = (gmls._poly_order > gmls._curvature_poly_order) ?
572 gmls._poly_order : gmls._curvature_poly_order;
574 data.ref_N_data = gmls._ref_N.data();
575 data.ref_N_dim = gmls._dimensions;
577 data.thread_workspace_dim = (data.max_poly_order+1)*gmls._global_dimensions*basis_powers_space_multiplier;
578 data.manifold_gradient_dim = (gmls._dimensions-1)*data.max_num_neighbors;
580 data.manifold_curvature_coefficients_data = gmls._manifold_curvature_coefficients.data();
583 data.manifold_NP = 0;
584 data.this_num_cols = gmls._basis_multiplier*gmls._NP;
585 data.thread_workspace_dim = (gmls._poly_order+1)*gmls._global_dimensions*basis_powers_space_multiplier;
586 data.manifold_gradient_dim = 0;
590 data.T_data = gmls._T.data();
592 data.P_target_row_dim_0 = gmls._d_ss._total_alpha_values*gmls._d_ss._max_evaluation_sites_per_target;
593 data.P_target_row_dim_1 = data.this_num_cols;
594 data.P_target_row_data = gmls._Z.data();
596 data.RHS_data = gmls._RHS.data();
597 getRHSDims(gmls._dense_solver_type, gmls._constraint_type, gmls._reconstruction_space,
598 gmls._dimensions, data.max_num_rows, data.this_num_cols, data.RHS_dim_0, data.RHS_dim_1);
600 data.P_data = gmls._P.data();
601 getPDims(gmls._dense_solver_type, gmls._constraint_type, gmls._reconstruction_space,
602 gmls._dimensions, data.max_num_rows, data.this_num_cols, data.P_dim_0, data.P_dim_1);
604 data.w_data = gmls._w.data();
607 data.Coeffs_data = gmls._RHS.data();
608 data.Coeffs_dim_0 = data.RHS_dim_0;
609 data.Coeffs_dim_1 = data.RHS_dim_1;
611 data.Coeffs_data = gmls._P.data();
612 data.Coeffs_dim_0 = data.P_dim_1;
613 data.Coeffs_dim_1 = data.P_dim_0;