Compadre  1.5.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GMLS_Staggered_Manifold.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Compadre: COMpatible PArticle Discretization and REmap Toolkit
4 //
5 // Copyright 2018 NTESS and the Compadre contributors.
6 // SPDX-License-Identifier: BSD-2-Clause
7 // *****************************************************************************
8 // @HEADER
9 #include <iostream>
10 #include <string>
11 #include <vector>
12 #include <map>
13 #include <stdlib.h>
14 #include <cstdio>
15 #include <random>
16 
17 #include <Compadre_Config.h>
18 #include <Compadre_GMLS.hpp>
19 #include <Compadre_Evaluator.hpp>
21 
22 #include "GMLS_Manifold.hpp"
23 #include "CommandLineProcessor.hpp"
24 
25 #ifdef COMPADRE_USE_MPI
26 #include <mpi.h>
27 #endif
28 
29 #include <Kokkos_Timer.hpp>
30 #include <Kokkos_Core.hpp>
31 
32 using namespace Compadre;
33 
34 //! [Parse Command Line Arguments]
35 
36 // called from command line
37 int main (int argc, char* args[]) {
38 
39 // initializes MPI (if available) with command line arguments given
40 #ifdef COMPADRE_USE_MPI
41 MPI_Init(&argc, &args);
42 #endif
43 
44 // initializes Kokkos with command line arguments given
45 Kokkos::initialize(argc, args);
46 
47 // code block to reduce scope for all Kokkos View allocations
48 // otherwise, Views may be deallocating when we call Kokkos::finalize() later
49 {
50 
51  CommandLineProcessor clp(argc, args);
52  auto order = clp.order;
53  auto dimension = clp.dimension;
54  auto number_target_coords = clp.number_target_coords;
55  auto constraint_name = clp.constraint_name;
56  auto solver_name = clp.solver_name;
57  auto problem_name = clp.problem_name;
58  int N_pts_on_sphere = (clp.number_source_coords>=0) ? clp.number_source_coords : 1000;
59 
60  // minimum neighbors for unisolvency is the same as the size of the polynomial basis
61  // dimension has one subtracted because it is a D-1 manifold represented in D dimensions
62  const int min_neighbors = Compadre::GMLS::getNP(order, dimension-1);
63 
64  //! [Parse Command Line Arguments]
65  Kokkos::Timer timer;
66  Kokkos::Profiling::pushRegion("Setup Point Data");
67  //! [Setting Up The Point Cloud]
68 
69 
70  // coordinates of source sites, bigger than needed then resized later
71  Kokkos::View<double**, Kokkos::DefaultExecutionSpace> source_coords_device("source coordinates",
72  1.25*N_pts_on_sphere, 3);
73  Kokkos::View<double**>::HostMirror source_coords = Kokkos::create_mirror_view(source_coords_device);
74 
75  double r = 1.0;
76 
77  // set number of source coordinates from what was calculated
78  int number_source_coords;
79 
80  { // fill source coordinates from surface of a sphere with quasiuniform points
81  // algorithm described at https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf
82  int N_count = 0;
83  double a = 4*PI*r*r/N_pts_on_sphere;
84  double d = std::sqrt(a);
85  int M_theta = std::round(PI/d);
86  double d_theta = PI/M_theta;
87  double d_phi = a/d_theta;
88  for (int i=0; i<M_theta; ++i) {
89  double theta = PI*(i + 0.5)/M_theta;
90  int M_phi = std::round(2*PI*std::sin(theta)/d_phi);
91  for (int j=0; j<M_phi; ++j) {
92  double phi = 2*PI*j/M_phi;
93  source_coords(N_count, 0) = theta;
94  source_coords(N_count, 1) = phi;
95  N_count++;
96  }
97  }
98 
99  for (int i=0; i<N_count; ++i) {
100  double theta = source_coords(i,0);
101  double phi = source_coords(i,1);
102  source_coords(i,0) = r*std::sin(theta)*std::cos(phi);
103  source_coords(i,1) = r*std::sin(theta)*std::sin(phi);
104  source_coords(i,2) = r*cos(theta);
105  //printf("%f %f %f\n", source_coords(i,0), source_coords(i,1), source_coords(i,2));
106  }
107  number_source_coords = N_count;
108  }
109 
110  // resize source_coords to the size actually needed
111  Kokkos::resize(source_coords, number_source_coords, 3);
112  Kokkos::resize(source_coords_device, number_source_coords, 3);
113 
114  // coordinates of target sites
115  Kokkos::View<double**, Kokkos::DefaultExecutionSpace> target_coords_device("target coordinates",
116  number_target_coords, 3);
117  Kokkos::View<double**>::HostMirror target_coords = Kokkos::create_mirror_view(target_coords_device);
118 
119  // seed random number generator
120  std::mt19937 rng(50);
121 
122  // generate random integers in [0...number_source_coords-1] (used to pick target sites)
123  std::uniform_int_distribution<int> gen_num_neighbors(0, number_source_coords-1); // uniform, unbiased
124 
125  // fill target sites with random selections from source sites
126  for (int i=0; i<number_target_coords; ++i) {
127  const int source_site_to_copy = gen_num_neighbors(rng);
128  for (int j=0; j<3; ++j) {
129  target_coords(i,j) = source_coords(source_site_to_copy,j);
130  }
131  }
132 
133 
134  //! [Setting Up The Point Cloud]
135 
136  Kokkos::Profiling::popRegion();
137  Kokkos::fence();
138  Kokkos::Profiling::pushRegion("Creating Data");
139 
140  //! [Creating The Data]
141 
142 
143  // source coordinates need copied to device before using to construct sampling data
144  Kokkos::deep_copy(source_coords_device, source_coords);
145  Kokkos::deep_copy(target_coords_device, target_coords);
146 
147  // ensure that source coordinates are sent to device before evaluating sampling data based on them
148  Kokkos::fence();
149 
150 
151  // need Kokkos View storing true solution (for samples)
152  Kokkos::View<double*, Kokkos::DefaultExecutionSpace> sampling_data_device("samples of true solution",
153  source_coords_device.extent(0));
154 
155  // need Kokkos View storing true vector solution (for samples)
156  Kokkos::View<double**, Kokkos::DefaultExecutionSpace> sampling_vector_data_device("samples of vector true solution",
157  source_coords_device.extent(0), 3);
158 
159  Kokkos::parallel_for("Sampling Manufactured Solutions", Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>
160  (0,source_coords.extent(0)), KOKKOS_LAMBDA(const int i) {
161 
162  // coordinates of source site i
163  double xval = source_coords_device(i,0);
164  double yval = (dimension>1) ? source_coords_device(i,1) : 0;
165  double zval = (dimension>2) ? source_coords_device(i,2) : 0;
166 
167  // data for targets with scalar input
168  sampling_data_device(i) = sphere_harmonic54(xval, yval, zval);
169  //printf("%f\n", sampling_data_device(i));
170 
171  for (int j=0; j<3; ++j) {
172  double gradient[3] = {0,0,0};
173  gradient_sphereHarmonic54_ambient(gradient, xval, yval, zval);
174  sampling_vector_data_device(i,j) = gradient[j];
175  }
176  //printf("%f %f %f\n", sampling_vector_data_device(i,0), sampling_vector_data_device(i,1), sampling_vector_data_device(i,2));
177  });
178 
179 
180  //! [Creating The Data]
181 
182  Kokkos::Profiling::popRegion();
183  Kokkos::Profiling::pushRegion("Neighbor Search");
184 
185  //! [Performing Neighbor Search]
186 
187 
188  // Point cloud construction for neighbor search
189  // CreatePointCloudSearch constructs an object of type PointCloudSearch, but deduces the templates for you
190  auto point_cloud_search(CreatePointCloudSearch(source_coords, dimension));
191 
192  // each row is a neighbor list for a target site, with the first column of each row containing
193  // the number of neighbors for that rows corresponding target site
194  double epsilon_multiplier = 1.5;
195  int estimated_upper_bound_number_neighbors =
196  point_cloud_search.getEstimatedNumberNeighborsUpperBound(min_neighbors, dimension, epsilon_multiplier);
197 
198  Kokkos::View<int**, Kokkos::DefaultExecutionSpace> neighbor_lists_device("neighbor lists",
199  number_target_coords, estimated_upper_bound_number_neighbors); // first column is # of neighbors
200  Kokkos::View<int**>::HostMirror neighbor_lists = Kokkos::create_mirror_view(neighbor_lists_device);
201 
202  // each target site has a window size
203  Kokkos::View<double*, Kokkos::DefaultExecutionSpace> epsilon_device("h supports", number_target_coords);
204  Kokkos::View<double*>::HostMirror epsilon = Kokkos::create_mirror_view(epsilon_device);
205 
206  // query the point cloud to generate the neighbor lists using a kdtree to produce the n nearest neighbor
207  // to each target site, adding (epsilon_multiplier-1)*100% to whatever the distance away the further neighbor used is from
208  // each target to the view for epsilon
209  point_cloud_search.generate2DNeighborListsFromKNNSearch(false /*not dry run*/, target_coords, neighbor_lists,
210  epsilon, min_neighbors, epsilon_multiplier);
211 
212 
213  //! [Performing Neighbor Search]
214 
215  Kokkos::Profiling::popRegion();
216  Kokkos::fence(); // let call to build neighbor lists complete before copying back to device
217  timer.reset();
218 
219  //! [Setting Up The GMLS Object]
220 
221 
222  // Copy data back to device (they were filled on the host)
223  // We could have filled Kokkos Views with memory space on the host
224  // and used these instead, and then the copying of data to the device
225  // would be performed in the GMLS class
226  Kokkos::deep_copy(neighbor_lists_device, neighbor_lists);
227  Kokkos::deep_copy(epsilon_device, epsilon);
228 
229  // initialize an instance of the GMLS class
232  order, dimension,
233  solver_name.c_str(), problem_name.c_str(), constraint_name.c_str(),
234  order /*manifold order*/);
235 
236  // pass in neighbor lists, source coordinates, target coordinates, and window sizes
237  //
238  // neighbor lists have the format:
239  // dimensions: (# number of target sites) X (# maximum number of neighbors for any given target + 1)
240  // the first column contains the number of neighbors for that rows corresponding target index
241  //
242  // source coordinates have the format:
243  // dimensions: (# number of source sites) X (dimension)
244  // entries in the neighbor lists (integers) correspond to rows of this 2D array
245  //
246  // target coordinates have the format:
247  // dimensions: (# number of target sites) X (dimension)
248  // # of target sites is same as # of rows of neighbor lists
249  //
250  my_GMLS_vector_1.setProblemData(neighbor_lists_device, source_coords_device, target_coords_device, epsilon_device);
251 
252  // create a vector of target operations
253  std::vector<TargetOperation> lro_vector_1(1);
254  lro_vector_1[0] = DivergenceOfVectorPointEvaluation;
255 
256  // and then pass them to the GMLS class
257  my_GMLS_vector_1.addTargets(lro_vector_1);
258 
259  // sets the weighting kernel function from WeightingFunctionType for curvature
260  my_GMLS_vector_1.setCurvatureWeightingType(WeightingFunctionType::Power);
261 
262  // power to use in the weighting kernel function for curvature coefficients
263  my_GMLS_vector_1.setCurvatureWeightingParameter(2);
264 
265  // sets the weighting kernel function from WeightingFunctionType
266  my_GMLS_vector_1.setWeightingType(WeightingFunctionType::Power);
267 
268  // power to use in that weighting kernel function
269  my_GMLS_vector_1.setWeightingParameter(2);
270 
271  // setup quadrature for StaggeredEdgeIntegralSample
272  my_GMLS_vector_1.setOrderOfQuadraturePoints(2);
273  my_GMLS_vector_1.setDimensionOfQuadraturePoints(1);
274  my_GMLS_vector_1.setQuadratureType("LINE");
275 
276  // generate the alphas that to be combined with data for each target operation requested in lro
277  my_GMLS_vector_1.generateAlphas();
278 
279  // initialize another instance of the GMLS class
283  order, dimension,
284  solver_name.c_str(), problem_name.c_str(), constraint_name.c_str(),
285  order /*manifold order*/);
286 
287  my_GMLS_vector_2.setProblemData(neighbor_lists_device, source_coords_device, target_coords_device, epsilon_device);
288  std::vector<TargetOperation> lro_vector_2(2);
290  lro_vector_2[1] = DivergenceOfVectorPointEvaluation;
291  //lro_vector_2[2] = GradientOfScalarPointEvaluation;
292  my_GMLS_vector_2.addTargets(lro_vector_2);
293  my_GMLS_vector_2.setCurvatureWeightingType(WeightingFunctionType::Power);
294  my_GMLS_vector_2.setCurvatureWeightingParameter(2);
295  my_GMLS_vector_2.setWeightingType(WeightingFunctionType::Power);
296  my_GMLS_vector_2.setWeightingParameter(2);
297  my_GMLS_vector_2.setOrderOfQuadraturePoints(2);
298  my_GMLS_vector_2.setDimensionOfQuadraturePoints(1);
299  my_GMLS_vector_2.setQuadratureType("LINE");
300  my_GMLS_vector_2.generateAlphas();
301 
302  // initialize another instance of the GMLS class
305  order, dimension,
306  solver_name.c_str(), problem_name.c_str(), constraint_name.c_str(),
307  order /*manifold order*/);
308 
309  my_GMLS_scalar.setProblemData(neighbor_lists_device, source_coords_device, target_coords_device, epsilon_device);
310 
311  std::vector<TargetOperation> lro_scalar(1);
313  //lro_scalar[1] = GradientOfScalarPointEvaluation;
314  my_GMLS_scalar.addTargets(lro_scalar);
315  my_GMLS_scalar.setCurvatureWeightingType(WeightingFunctionType::Power);
316  my_GMLS_scalar.setCurvatureWeightingParameter(2);
317  my_GMLS_scalar.setWeightingType(WeightingFunctionType::Power);
318  my_GMLS_scalar.setWeightingParameter(2);
319  my_GMLS_scalar.generateAlphas();
320 
321 
322  //! [Setting Up The GMLS Object]
323 
324  double instantiation_time = timer.seconds();
325  std::cout << "Took " << instantiation_time << "s to complete alphas generation." << std::endl;
326  Kokkos::fence(); // let generateAlphas finish up before using alphas
327  Kokkos::Profiling::pushRegion("Apply Alphas to Data");
328 
329  //! [Apply GMLS Alphas To Data]
330 
331 
332  // it is important to note that if you expect to use the data as a 1D view, then you should use double*
333  // however, if you know that the target operation will result in a 2D view (vector or matrix output),
334  // then you should template with double** as this is something that can not be infered from the input data
335  // or the target operator at compile time. Additionally, a template argument is required indicating either
336  // Kokkos::HostSpace or Kokkos::DefaultExecutionSpace::memory_space()
337 
338  // The Evaluator class takes care of handling input data views as well as the output data views.
339  // It uses information from the GMLS class to determine how many components are in the input
340  // as well as output for any choice of target functionals and then performs the contactions
341  // on the data using the alpha coefficients generated by the GMLS class, all on the device.
342  Evaluator vector_1_gmls_evaluator(&my_GMLS_vector_1);
343  Evaluator vector_2_gmls_evaluator(&my_GMLS_vector_2);
344  Evaluator scalar_gmls_evaluator(&my_GMLS_scalar);
345 
346 
347  //auto output_gradient_vectorbasis =
348  // vector_2_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double**, Kokkos::HostSpace>
349  // (sampling_data_device, GradientOfScalarPointEvaluation, StaggeredEdgeAnalyticGradientIntegralSample);
350 
351  //auto output_gradient_scalarbasis =
352  // scalar_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double**, Kokkos::HostSpace>
353  // (sampling_data_device, GradientOfScalarPointEvaluation, StaggeredEdgeAnalyticGradientIntegralSample);
354 
355  auto output_divergence_vectorsamples =
356  vector_1_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double*, Kokkos::HostSpace>
357  (sampling_vector_data_device, DivergenceOfVectorPointEvaluation, StaggeredEdgeIntegralSample);
358 
359  auto output_divergence_scalarsamples =
360  vector_2_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double*, Kokkos::HostSpace>
362 
363  auto output_laplacian_vectorbasis =
364  vector_2_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double*, Kokkos::HostSpace>
366 
367  auto output_laplacian_scalarbasis =
368  scalar_gmls_evaluator.applyAlphasToDataAllComponentsAllTargetSites<double*, Kokkos::HostSpace>
370 
371 
372  //! [Apply GMLS Alphas To Data]
373 
374  Kokkos::fence(); // let application of alphas to data finish before using results
375  Kokkos::Profiling::popRegion();
376  // times the Comparison in Kokkos
377  Kokkos::Profiling::pushRegion("Comparison");
378 
379  //! [Check That Solutions Are Correct]
380 
381  double laplacian_vectorbasis_error = 0;
382  double laplacian_vectorbasis_norm = 0;
383 
384  double laplacian_scalarbasis_error = 0;
385  double laplacian_scalarbasis_norm = 0;
386 
387  double gradient_vectorbasis_ambient_error = 0;
388  double gradient_vectorbasis_ambient_norm = 0;
389 
390  double gradient_scalarbasis_ambient_error = 0;
391  double gradient_scalarbasis_ambient_norm = 0;
392 
393  double divergence_vectorsamples_ambient_error = 0;
394  double divergence_vectorsamples_ambient_norm = 0;
395 
396  double divergence_scalarsamples_ambient_error = 0;
397  double divergence_scalarsamples_ambient_norm = 0;
398 
399  // loop through the target sites
400  for (int i=0; i<number_target_coords; i++) {
401 
402  // target site i's coordinate
403  double xval = target_coords(i,0);
404  double yval = (dimension>1) ? target_coords(i,1) : 0;
405  double zval = (dimension>2) ? target_coords(i,2) : 0;
406 
407  // evaluation of various exact solutions
408  double actual_Laplacian = laplace_beltrami_sphere_harmonic54(xval, yval, zval);
409  double actual_Gradient_ambient[3] = {0,0,0}; // initialized for 3, but only filled up to dimension
410  gradient_sphereHarmonic54_ambient(actual_Gradient_ambient, xval, yval, zval);
411 
412  laplacian_vectorbasis_error += (output_laplacian_vectorbasis(i) - actual_Laplacian)*(output_laplacian_vectorbasis(i) - actual_Laplacian);
413  laplacian_vectorbasis_norm += actual_Laplacian*actual_Laplacian;
414 
415  //printf("Error of %f, %f vs %f\n", (output_laplacian_scalarbasis(i) - actual_Laplacian), output_laplacian_scalarbasis(i), actual_Laplacian);
416  laplacian_scalarbasis_error += (output_laplacian_scalarbasis(i) - actual_Laplacian)*(output_laplacian_scalarbasis(i) - actual_Laplacian);
417  laplacian_scalarbasis_norm += actual_Laplacian*actual_Laplacian;
418 
419  //for (int j=0; j<dimension; ++j) {
420  // //printf("VectorBasis Error of %f, %f vs %f\n", (output_gradient_vectorbasis(i,j) - actual_Gradient_ambient[j]), output_gradient_vectorbasis(i,j), actual_Gradient_ambient[j]);
421  // gradient_vectorbasis_ambient_error += (output_gradient_vectorbasis(i,j) - actual_Gradient_ambient[j])*(output_gradient_vectorbasis(i,j) - actual_Gradient_ambient[j]);
422  // gradient_vectorbasis_ambient_norm += actual_Gradient_ambient[j]*actual_Gradient_ambient[j];
423  //}
424 
425  //for (int j=0; j<dimension; ++j) {
426  // //printf("ScalarBasis Error of %f, %f vs %f\n", (output_gradient_scalarbasis(i,j) - actual_Gradient_ambient[j]), output_gradient_scalarbasis(i,j), actual_Gradient_ambient[j]);
427  // gradient_scalarbasis_ambient_error += (output_gradient_scalarbasis(i,j) - actual_Gradient_ambient[j])*(output_gradient_scalarbasis(i,j) - actual_Gradient_ambient[j]);
428  // gradient_scalarbasis_ambient_norm += actual_Gradient_ambient[j]*actual_Gradient_ambient[j];
429  //}
430 
431  //printf("Error of %f, %f vs %f\n", (output_divergence(i) - actual_Laplacian), output_divergence(i), actual_Laplacian);
432  divergence_vectorsamples_ambient_error += (output_divergence_vectorsamples(i) - actual_Laplacian)*(output_divergence_vectorsamples(i) - actual_Laplacian);
433  divergence_vectorsamples_ambient_norm += actual_Laplacian*actual_Laplacian;
434 
435  divergence_scalarsamples_ambient_error += (output_divergence_scalarsamples(i) - actual_Laplacian)*(output_divergence_scalarsamples(i) - actual_Laplacian);
436  divergence_scalarsamples_ambient_norm += actual_Laplacian*actual_Laplacian;
437 
438  }
439 
440  laplacian_vectorbasis_error /= number_target_coords;
441  laplacian_vectorbasis_error = std::sqrt(laplacian_vectorbasis_error);
442  laplacian_vectorbasis_norm /= number_target_coords;
443  laplacian_vectorbasis_norm = std::sqrt(laplacian_vectorbasis_norm);
444 
445  laplacian_scalarbasis_error /= number_target_coords;
446  laplacian_scalarbasis_error = std::sqrt(laplacian_scalarbasis_error);
447  laplacian_scalarbasis_norm /= number_target_coords;
448  laplacian_scalarbasis_norm = std::sqrt(laplacian_scalarbasis_norm);
449 
450  gradient_vectorbasis_ambient_error /= number_target_coords;
451  gradient_vectorbasis_ambient_error = std::sqrt(gradient_vectorbasis_ambient_error);
452  gradient_vectorbasis_ambient_norm /= number_target_coords;
453  gradient_vectorbasis_ambient_norm = std::sqrt(gradient_vectorbasis_ambient_norm);
454 
455  gradient_scalarbasis_ambient_error /= number_target_coords;
456  gradient_scalarbasis_ambient_error = std::sqrt(gradient_scalarbasis_ambient_error);
457  gradient_scalarbasis_ambient_norm /= number_target_coords;
458  gradient_scalarbasis_ambient_norm = std::sqrt(gradient_scalarbasis_ambient_norm);
459 
460  divergence_vectorsamples_ambient_error /= number_target_coords;
461  divergence_vectorsamples_ambient_error = std::sqrt(divergence_vectorsamples_ambient_error);
462  divergence_vectorsamples_ambient_norm /= number_target_coords;
463  divergence_vectorsamples_ambient_norm = std::sqrt(divergence_vectorsamples_ambient_norm);
464 
465  divergence_scalarsamples_ambient_error /= number_target_coords;
466  divergence_scalarsamples_ambient_error = std::sqrt(divergence_scalarsamples_ambient_error);
467  divergence_scalarsamples_ambient_norm /= number_target_coords;
468  divergence_scalarsamples_ambient_norm = std::sqrt(divergence_scalarsamples_ambient_norm);
469 
470  printf("Staggered Laplace-Beltrami (VectorBasis) Error: %g\n", laplacian_vectorbasis_error / laplacian_vectorbasis_norm);
471  printf("Staggered Laplace-Beltrami (ScalarBasis) Error: %g\n", laplacian_scalarbasis_error / laplacian_scalarbasis_norm);
472  printf("Surface Staggered Gradient (VectorBasis) Error: %g\n", gradient_vectorbasis_ambient_error / gradient_vectorbasis_ambient_norm);
473  printf("Surface Staggered Gradient (ScalarBasis) Error: %g\n", gradient_scalarbasis_ambient_error / gradient_scalarbasis_ambient_norm);
474  printf("Surface Staggered Divergence (VectorSamples) Error: %g\n", divergence_vectorsamples_ambient_error / divergence_vectorsamples_ambient_norm);
475  printf("Surface Staggered Divergence (ScalarSamples) Error: %g\n", divergence_scalarsamples_ambient_error / divergence_scalarsamples_ambient_norm);
476  //! [Check That Solutions Are Correct]
477  // popRegion hidden from tutorial
478  // stop timing comparison loop
479  Kokkos::Profiling::popRegion();
480  //! [Finalize Program]
481 
482 
483 } // end of code block to reduce scope, causing Kokkos View de-allocations
484 // otherwise, Views may be deallocating when we call Kokkos::finalize() later
485 
486 // finalize Kokkos and MPI (if available)
487 Kokkos::finalize();
488 #ifdef COMPADRE_USE_MPI
489 MPI_Finalize();
490 #endif
491 
492 return 0;
493 
494 } // main
495 
496 
497 //! [Finalize Program]
KOKKOS_INLINE_FUNCTION double sphere_harmonic54(double x, double y, double z)
Lightweight Evaluator Helper This class is a lightweight wrapper for extracting and applying all rele...
PointCloudSearch< view_type > CreatePointCloudSearch(view_type src_view, const local_index_type dimensions=-1, const local_index_type max_leaf=-1)
CreatePointCloudSearch allows for the construction of an object of type PointCloudSearch with templat...
int main(int argc, char **argv)
#define PI
Vector polynomial basis having # of components _dimensions, or (_dimensions-1) in the case of manifol...
constexpr SamplingFunctional StaggeredEdgeAnalyticGradientIntegralSample
Analytical integral of a gradient source vector is just a difference of the scalar source at neighbor...
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...
constexpr SamplingFunctional StaggeredEdgeIntegralSample
Samples consist of the result of integrals of a vector dotted with the tangent along edges between ne...
Scalar polynomial basis centered at the target site and scaled by sum of basis powers e...
import subprocess import os import re import math import sys import argparse d d d
Point evaluation of the divergence of a vector (results in a scalar)
KOKKOS_INLINE_FUNCTION void gradient_sphereHarmonic54_ambient(double *gradient, double x, double y, double z)
Generalized Moving Least Squares (GMLS)
Kokkos::View< output_data_type, output_array_layout, output_memory_space > applyAlphasToDataAllComponentsAllTargetSites(view_type_input_data sampling_data, TargetOperation lro, const SamplingFunctional sro_in=PointSample, bool scalar_as_vector_if_needed=true, const int evaluation_site_local_index=0) const
Transformation of data under GMLS (allocates memory for output)
void setProblemData(view_type_1 neighbor_lists, view_type_2 source_coordinates, view_type_3 target_coordinates, view_type_4 epsilons)
Sets basic problem data (neighbor lists, source coordinates, and target coordinates) ...
KOKKOS_INLINE_FUNCTION double laplace_beltrami_sphere_harmonic54(double x, double y, double z)
Point evaluation of the chained staggered Laplacian acting on VectorTaylorPolynomial basis + Staggere...