30
30
31
31
namespace
32
32
{
33
- template < geode::index_t dimension >
34
- bool node_is_on_axis_origin (
35
- geode::local_index_t node_id, geode::local_index_t axis_id )
36
- {
37
- /* returns ((node_id / pow(2,axis_id)) modulo 2) using binary
38
- * operators (faster). */
39
- return ( ( node_id / ( 1 << axis_id ) ) & 1 ) == 0 ;
40
- }
41
-
42
33
template < geode::index_t dimension >
43
34
double local_point_value ( const geode::Point< dimension >& point_in_grid,
44
35
const typename geode::Grid< dimension >::CellIndices& cell_id,
@@ -62,24 +53,29 @@ namespace geode
62
53
{
63
54
namespace internal
64
55
{
56
+ bool local_cell_node_is_on_axis_origin (
57
+ geode::local_index_t node_id, geode::local_index_t axis_id )
58
+ {
59
+ /* returns ((node_id / pow(2,axis_id)) modulo 2) using binary
60
+ * operators (faster). */
61
+ return ( ( node_id / ( 1 << axis_id ) ) & 1 ) == 0 ;
62
+ }
63
+
65
64
template < index_t dimension >
66
65
double shape_function_value (
67
66
const typename Grid< dimension >::CellIndices& cell_id,
68
67
local_index_t node_id,
69
68
const Point< dimension >& point_in_grid )
70
69
{
71
70
double result{ 1 . };
72
- for ( const auto d : LRange{ dimension } )
71
+ for ( const auto axis : LRange{ dimension } )
73
72
{
74
- if ( node_is_on_axis_origin< dimension >( node_id, d ) )
75
- {
76
- result *= 1 .
77
- - local_point_value< dimension >(
78
- point_in_grid, cell_id, d );
79
- continue ;
80
- }
81
- result *=
82
- local_point_value< dimension >( point_in_grid, cell_id, d );
73
+ result *= local_cell_node_is_on_axis_origin ( node_id, axis )
74
+ ? 1 .
75
+ - local_point_value< dimension >(
76
+ point_in_grid, cell_id, axis )
77
+ : local_point_value< dimension >(
78
+ point_in_grid, cell_id, axis );
83
79
}
84
80
return result;
85
81
}
@@ -92,23 +88,20 @@ namespace geode
92
88
local_index_t direction )
93
89
{
94
90
double result{ 1 . };
95
- for ( const auto dim : LRange{ dimension } )
91
+ for ( const auto axis : LRange{ dimension } )
96
92
{
97
- if ( dim == direction )
98
- {
99
- continue ;
100
- }
101
- if ( node_is_on_axis_origin< dimension >( node_id, dim ) )
93
+ if ( axis == direction )
102
94
{
103
- result *= 1 .
104
- - local_point_value< dimension >(
105
- point_in_grid, cell_id, dim );
106
95
continue ;
107
96
}
108
- result *= local_point_value< dimension >(
109
- point_in_grid, cell_id, dim );
97
+ result *= local_cell_node_is_on_axis_origin ( node_id, axis )
98
+ ? 1 .
99
+ - local_point_value< dimension >(
100
+ point_in_grid, cell_id, axis )
101
+ : local_point_value< dimension >(
102
+ point_in_grid, cell_id, axis );
110
103
}
111
- if ( node_is_on_axis_origin< dimension > ( node_id, direction ) )
104
+ if ( local_cell_node_is_on_axis_origin ( node_id, direction ) )
112
105
{
113
106
result *= -1 .;
114
107
}
0 commit comments