Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13.0)

project(meshfields VERSION 1.0.0 LANGUAGES CXX)
project(meshfields VERSION 1.0.1 LANGUAGES CXX)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
1 change: 1 addition & 0 deletions src/MeshField_Defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ enum Mesh_Topology {
static bool Debug = false;
const Real MachinePrecision = 1e-15;
const Real Epsilon = 1e-12;
const Real ParametricCoordTol = 1e-6;
} // namespace MeshField
#endif
76 changes: 38 additions & 38 deletions src/MeshField_Shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace {
* @param val Reference value
* @return true if xi >= val within machine precision
*/
KOKKOS_INLINE_FUNCTION bool greaterThanOrEqual(MeshField::Real xi, const MeshField::Real val) {
KOKKOS_INLINE_FUNCTION bool greaterThanOrEqual(MeshField::Real xi, const MeshField::Real val, const MeshField::Real tol) {
if ( xi > val ) return true;
return (Kokkos::fabs(xi - val) <= MeshField::MachinePrecision);
return (Kokkos::fabs(xi - val) <= tol);
}

/**
Expand All @@ -36,10 +36,10 @@ KOKKOS_INLINE_FUNCTION bool greaterThanOrEqual(MeshField::Real xi, const MeshFie
* @return true if all xi[i] >= val within machine precision
*/
template <typename Array>
KOKKOS_INLINE_FUNCTION bool eachGreaterThanOrEqual(Array &xi, const MeshField::Real val) {
KOKKOS_INLINE_FUNCTION bool eachGreaterThanOrEqual(Array &xi, const MeshField::Real val, const MeshField::Real tol) {
auto gt = true;
for (size_t i = 0; i < xi.size(); i++) {
gt = gt && greaterThanOrEqual(xi[i],val);
gt = gt && greaterThanOrEqual(xi[i],val,tol);
}
return gt;
}
Expand All @@ -50,9 +50,9 @@ KOKKOS_INLINE_FUNCTION bool eachGreaterThanOrEqual(Array &xi, const MeshField::R
* @param val Reference value
* @return true if xi <= val within machine precision
*/
KOKKOS_INLINE_FUNCTION bool lessThanOrEqual(MeshField::Real xi, const MeshField::Real val) {
KOKKOS_INLINE_FUNCTION bool lessThanOrEqual(MeshField::Real xi, const MeshField::Real val, const MeshField::Real tol) {
if ( xi < val ) return true;
return (Kokkos::fabs(xi - val) <= MeshField::MachinePrecision);
return (Kokkos::fabs(xi - val) <= tol);
}

/**
Expand All @@ -63,10 +63,10 @@ KOKKOS_INLINE_FUNCTION bool lessThanOrEqual(MeshField::Real xi, const MeshField:
* @return true if all xi[i] <= val within machine precision
*/
template <typename Array>
KOKKOS_INLINE_FUNCTION bool eachLessThanOrEqual(Array &xi, const MeshField::Real val) {
KOKKOS_INLINE_FUNCTION bool eachLessThanOrEqual(Array &xi, const MeshField::Real val, const MeshField::Real tol) {
auto lt = true;
for (size_t i = 0; i < xi.size(); i++) {
lt = lt && lessThanOrEqual(xi[i],val);
lt = lt && lessThanOrEqual(xi[i],val,tol);
}
return lt;
}
Expand Down Expand Up @@ -117,8 +117,8 @@ struct LinearEdgeShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector1 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,-1.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,-1.0,ParametricCoordTol));
// clang-format off
return {(1.0 - xi[0]) / 2.0,
(1.0 + xi[0]) / 2.0};
Expand Down Expand Up @@ -180,11 +180,11 @@ struct LinearTriangleShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector2 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
// clang-format off
return {L0,
xi[0], //L1
Expand Down Expand Up @@ -241,11 +241,11 @@ struct LinearTriangleCoordinateShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector2 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
// clang-format off
return {L0,
xi[0],
Expand Down Expand Up @@ -307,11 +307,11 @@ struct QuadraticTriangleShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector2 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
const Real L1 = xi[0];
const Real L2 = xi[1];
// clang-format off
Expand All @@ -332,11 +332,11 @@ struct QuadraticTriangleShape {
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, meshEntDim * numNodes>
getLocalGradients(Vector2 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
const Real L1 = xi[0];
const Real L2 = xi[1];
// clang-format off
Expand Down Expand Up @@ -395,11 +395,11 @@ struct LinearTetrahedronShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector3 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1] - xi[2];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
// clang-format off
return {L0,
xi[0], //L1
Expand Down Expand Up @@ -482,11 +482,11 @@ struct QuadraticTetrahedronShape {
*/
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, numNodes> getValues(Vector3 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1] - xi[2];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
const Real L1 = xi[0];
const Real L2 = xi[1];
const Real L3 = xi[2];
Expand All @@ -512,11 +512,11 @@ struct QuadraticTetrahedronShape {
KOKKOS_INLINE_FUNCTION
Kokkos::Array<Real, meshEntDim * numNodes>
getLocalGradients(Vector3 const &xi) const {
assert(eachLessThanOrEqual(xi,1.0));
assert(eachGreaterThanOrEqual(xi,0.0));
assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
const Real L0 = 1 - xi[0] - xi[1] - xi[2];
assert(greaterThanOrEqual(L0,0.0));
assert(lessThanOrEqual(L0,1.0));
assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
const Real L1 = xi[0];
const Real L2 = xi[1];
const Real L3 = xi[2];
Expand Down
Loading