Skip to content

Commit 1df50ed

Browse files
Merge pull request #1038 from Geode-solutions/fix/better_gradient_computation_and-gradient_shape_functions
fix(gradient computation): Added functions to compute gradient giving…
2 parents e79de32 + 513a98c commit 1df50ed

File tree

8 files changed

+293
-71
lines changed

8 files changed

+293
-71
lines changed

include/geode/mesh/helpers/generic_edged_curve_accessor.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ namespace geode
5252
{
5353
}
5454

55+
[[nodiscard]] index_t nb_vertices() const
56+
{
57+
return mesh_.nb_vertices();
58+
}
59+
5560
[[nodiscard]] index_t nb_elements() const
5661
{
5762
return mesh_.nb_edges();

include/geode/mesh/helpers/generic_solid_accessor.hpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ namespace geode
5353
{
5454
}
5555

56+
[[nodiscard]] index_t nb_vertices() const
57+
{
58+
return mesh_.nb_vertices();
59+
}
60+
5661
[[nodiscard]] index_t nb_elements() const
5762
{
5863
return mesh_.nb_polyhedra();
@@ -68,6 +73,18 @@ namespace geode
6873
return mesh_.nb_polyhedron_facets( polyhedron_id );
6974
}
7075

76+
[[nodiscard]] index_t element_index(
77+
const ElementFacet& polyhedron_facet ) const
78+
{
79+
return polyhedron_facet.polyhedron_id;
80+
}
81+
82+
[[nodiscard]] index_t facet_index(
83+
const ElementFacet& polyhedron_facet ) const
84+
{
85+
return polyhedron_facet.facet_id;
86+
}
87+
7188
[[nodiscard]] index_t element_vertex(
7289
const ElementVertex& polyhedron_vertex ) const
7390
{
@@ -87,21 +104,21 @@ namespace geode
87104
}
88105

89106
[[nodiscard]] ElementFacetVertices element_facet_vertices(
90-
const ElementFacet& polyhedron_facet ) const
107+
const ElementFacet& element_facet ) const
91108
{
92-
return mesh_.polyhedron_facet_vertices( polyhedron_facet );
109+
return mesh_.polyhedron_facet_vertices( element_facet );
93110
}
94111

95112
[[nodiscard]] std::optional< index_t > element_adjacent(
96-
const ElementFacet& polyhedron_facet ) const
113+
const ElementFacet& element_facet ) const
97114
{
98-
return mesh_.polyhedron_adjacent( polyhedron_facet );
115+
return mesh_.polyhedron_adjacent( element_facet );
99116
}
100117

101118
[[nodiscard]] std::optional< ElementFacet > element_adjacent_facet(
102-
const ElementFacet& polyhedron_facet ) const
119+
ElementFacet element_facet ) const
103120
{
104-
return mesh_.polyhedron_adjacent_facet( polyhedron_facet );
121+
return mesh_.polyhedron_adjacent_facet( element_facet );
105122
}
106123

107124
[[nodiscard]] const uuid& id() const

include/geode/mesh/helpers/generic_surface_accessor.hpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ namespace geode
5353
{
5454
}
5555

56+
[[nodiscard]] index_t nb_vertices() const
57+
{
58+
return mesh_.nb_vertices();
59+
}
60+
5661
[[nodiscard]] index_t nb_elements() const
5762
{
5863
return mesh_.nb_polygons();
@@ -68,6 +73,18 @@ namespace geode
6873
return mesh_.nb_polygon_edges( polygon_id );
6974
}
7075

76+
[[nodiscard]] index_t element_index(
77+
const ElementFacet& polygon_edge ) const
78+
{
79+
return polygon_edge.polygon_id;
80+
}
81+
82+
[[nodiscard]] index_t facet_index(
83+
const ElementFacet& polygon_edge ) const
84+
{
85+
return polygon_edge.edge_id;
86+
}
87+
7188
[[nodiscard]] index_t element_vertex(
7289
const ElementVertex& polygon_vertex ) const
7390
{
@@ -87,21 +104,21 @@ namespace geode
87104
}
88105

89106
[[nodiscard]] ElementFacetVertices element_facet_vertices(
90-
const ElementFacet& polygon_edge ) const
107+
const ElementFacet& element_facet ) const
91108
{
92-
return mesh_.polygon_edge_vertices( polygon_edge );
109+
return mesh_.polygon_edge_vertices( element_facet );
93110
}
94111

95112
[[nodiscard]] std::optional< index_t > element_adjacent(
96-
const ElementFacet& polygon_edge ) const
113+
const ElementFacet& element_facet ) const
97114
{
98-
return mesh_.polygon_adjacent( polygon_edge );
115+
return mesh_.polygon_adjacent( element_facet );
99116
}
100117

101118
[[nodiscard]] std::optional< ElementFacet > element_adjacent_facet(
102-
const ElementFacet& polygon_edge ) const
119+
const ElementFacet& element_facet ) const
103120
{
104-
return mesh_.polygon_adjacent_edge( polygon_edge );
121+
return mesh_.polygon_adjacent_edge( element_facet );
105122
}
106123

107124
[[nodiscard]] const uuid& id() const

include/geode/mesh/helpers/gradient_computation.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,20 @@ namespace geode
4343
[[nodiscard]] std::string opengeode_mesh_api
4444
compute_solid_scalar_function_gradient(
4545
const SolidMesh3D& mesh, std::string_view scalar_function_name );
46+
47+
namespace internal
48+
{
49+
template < index_t dimension >
50+
[[nodiscard]] std::tuple< std::string, std::vector< index_t > >
51+
compute_surface_scalar_function_gradient(
52+
const SurfaceMesh< dimension >& mesh,
53+
std::string_view scalar_function_name,
54+
absl::Span< const index_t > no_value_vertices );
55+
56+
[[nodiscard]] std::tuple< std::string, std::vector< index_t > >
57+
opengeode_mesh_api compute_solid_scalar_function_gradient(
58+
const SolidMesh3D& mesh,
59+
std::string_view scalar_function_name,
60+
absl::Span< const index_t > no_value_vertices );
61+
} // namespace internal
4662
} // namespace geode

include/geode/mesh/helpers/internal/grid_shape_function.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
namespace geode
3030
{
3131
FORWARD_DECLARATION_DIMENSION_CLASS( Point );
32+
FORWARD_DECLARATION_DIMENSION_CLASS( Vector );
3233
FORWARD_DECLARATION_DIMENSION_CLASS( Grid );
3334
} // namespace geode
3435

@@ -41,5 +42,12 @@ namespace geode
4142
const typename Grid< dimension >::CellIndices& cell_id,
4243
local_index_t node_id,
4344
const Point< dimension >& point_in_grid );
45+
46+
template < index_t dimension >
47+
[[nodiscard]] double gradient_shape_function_value(
48+
const typename Grid< dimension >::CellIndices& cell_id,
49+
local_index_t node_id,
50+
const Point< dimension >& point_in_grid,
51+
local_index_t derivative_direction );
4452
} // namespace internal
4553
} // namespace geode

0 commit comments

Comments
 (0)