File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,6 @@ enum Mesh_Topology {
1717};
1818static bool Debug = false ;
1919const Real MachinePrecision = 1e-15 ;
20+ const Real Epsilon = 1e-12 ;
2021} // namespace MeshField
2122#endif
Original file line number Diff line number Diff line change 66// SCOREC/core apf/apfShape.cc @ 7cd76473
77
88namespace {
9- template <typename Array> KOKKOS_INLINE_FUNCTION bool sumsToOne (Array &xi) {
10- auto sum = 0.0 ;
11- for (size_t i = 0 ; i < xi.size (); i++) {
12- sum += xi[i];
13- }
14- return (Kokkos::fabs (sum - 1 ) <= MeshField::MachinePrecision);
9+ template <typename Array>
10+ KOKKOS_INLINE_FUNCTION bool
11+ sumsToOne (Array &xi, double tol = 10 * MeshField::MachinePrecision) {
12+ // IIFE, capture by reference is preferred
13+ const bool sums_to_one = [&]() {
14+ auto sum = 0.0 ;
15+ for (size_t i = 0 ; i < xi.size (); i++) {
16+ sum += xi[i];
17+ }
18+ return (Kokkos::fabs (sum - 1 ) <= tol);
19+ }();
20+ return sums_to_one;
1521}
1622
1723template <typename Array>
18- KOKKOS_INLINE_FUNCTION bool greaterThanOrEqualZero (Array &xi) {
19- auto gt = true ;
24+ KOKKOS_INLINE_FUNCTION bool
25+ greaterThanOrEqualZero (Array &xi, double tol = MeshField::Epsilon) {
2026 for (size_t i = 0 ; i < xi.size (); i++) {
21- gt = gt && (xi[i] >= 0 );
27+ if (xi[i] < -tol) {
28+ return false ;
29+ }
2230 }
23- return gt ;
31+ return true ;
2432}
2533} // namespace
2634
You can’t perform that action at this time.
0 commit comments