Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
48d95a0
fundamental functions for face properties and cyl mesh averaging.
dccowan Feb 3, 2023
aaa39f0
Revert "fundamental functions for face properties and cyl mesh averag…
dccowan Feb 3, 2023
29f0b77
Starting Mass matrix funs
dccowan Feb 3, 2023
a716702
basic face properties implementation
dccowan Mar 16, 2023
cbd8e18
Merge branch 'main' into face_props_mass_matrices
dccowan Mar 16, 2023
df15517
Merge branch 'main' into face_props_mass_matrices
dccowan Mar 19, 2023
103014c
Merge branch 'main' into face_props_mass_matrices
dccowan Jun 10, 2023
7064873
re-add property
dccowan Jun 12, 2023
6f1d107
remove average edge to face by component
dccowan Jun 16, 2023
021ba3d
Test tensor for inner products with face properties
dccowan Jun 17, 2023
6118afa
Merge branch 'main' into face_props_mass_matrices
dccowan Jun 17, 2023
e115854
face/edge properties for tree meshes
dccowan Jun 19, 2023
166358e
add 2D tensor and tree tests for face and edge property inner products
dccowan Jun 19, 2023
df9ca18
add derivative tests for face and edge properties (TENSOR and TREE)
dccowan Jun 20, 2023
f4fc514
Add analytic, order and derivative tests for cyl mesh (face properties)
dccowan Jun 21, 2023
3dae379
finalize new inner product names, black and flake8
dccowan Jun 22, 2023
60559fb
add documentation
dccowan Jun 23, 2023
1129e0b
review and bug fixes
dccowan Jun 24, 2023
a4d2d49
Merge branch 'main' into face_props_mass_matrices
dccowan Jun 24, 2023
acf55f5
Merge branch 'main' into face_props_mass_matrices
dccowan Jun 29, 2023
f894add
add ignore lambda fun for flake8 in tests
dccowan Jun 29, 2023
6ba8477
Eliminate 'fast inner products' for face and edge properties. Done na…
dccowan Jul 4, 2023
f8862fb
final style check
dccowan Jul 4, 2023
1e42b16
base mesh tests
dccowan Jul 5, 2023
9380206
code coverage and error raise tests
dccowan Jul 5, 2023
8cac8f7
post Joe comments
dccowan Jul 5, 2023
6cad723
More coverage tests
dccowan Jul 6, 2023
73d6b64
fix broken examples
dccowan Jul 6, 2023
a8dbe89
fix broken example
dccowan Jul 6, 2023
e360437
Merge branch 'main' into face_props_mass_matrices
dccowan Jul 17, 2023
51c16c0
remove main from tests
dccowan Jul 17, 2023
0246f5e
style check
dccowan Jul 17, 2023
e729631
style checks
dccowan Jul 17, 2023
df6fce6
one more format...sigh
dccowan Jul 17, 2023
990cca1
remove NOQA E731
dccowan Jul 18, 2023
76581e3
Merge branch 'main' into face_props_mass_matrices
dccowan Jul 18, 2023
861080b
Address latest round of review
dccowan Jul 18, 2023
97bc7cb
add correct exception
dccowan Jul 18, 2023
ac968f5
initial tests
dccowan Jul 21, 2023
7ee4923
Merge branch 'main' into face_props_mass_matrices
dccowan Jul 21, 2023
098cbc1
fix edge inner product surface bugs
dccowan Jul 21, 2023
96d5507
add 3d tests
dccowan Jul 21, 2023
6174069
Create and comment out simplex deriv tests for face and edge properties
dccowan Jul 21, 2023
d1b89f7
Merge branch 'main' into face_props_mass_matrices
dccowan May 12, 2025
fefa235
tree ext
dccowan Jul 7, 2025
67d7272
Merge branch 'main' into face_props_mass_matrices
dccowan Jul 7, 2025
6e02972
Merge branch 'main' into face_props_mass_matrices
dccowan Sep 18, 2025
662d1cb
Merge branch 'main' into face_props_mass_matrices
dccowan Oct 9, 2025
b8f8c34
Merge branch 'main' into face_props_mass_matrices
dccowan Feb 18, 2026
42fa3d6
uncomment inner product tests
dccowan Feb 20, 2026
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
5 changes: 4 additions & 1 deletion discretize/curvilinear_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,13 @@ def _get_edge_surf_int_proj_mats(self, only_boundary=False, with_area=True):
edge_dirs = self.edge_tangents[node_edges]
t_for = np.concatenate((edge_dirs, face_normals[:, None, :]), axis=1)
t_inv = np.linalg.inv(t_for)
t_inv = t_inv[:, :, :-1] / 4 # n_edges_per_thing
t_inv = t_inv[:, :, :-1]

if with_area:
t_inv *= face_areas[:, None, None]
t_inv /= 4 # n_edges_per_thing
else:
t_inv /= 2 # sqrt n_edges_per_thing

T = C2F @ sp.csr_matrix(
(t_inv.reshape(-1), T_col_inds, T_ind_ptr),
Expand Down
62 changes: 61 additions & 1 deletion discretize/unstructured_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,64 @@ def get_edge_inner_product( # NOQA D102
"The inverse of the inner product matrix with a tetrahedral mesh is not supported."
)
return self.__get_inner_product("E", model, invert_model)

def get_edge_inner_product_surface( # NOQA D102
self,
model=None,
invert_model=False,
invert_matrix=False
):
# Documentation inherited from discretize.base.BaseMesh
if invert_matrix:
raise NotImplementedError(
"The inverse of the inner product matrix with a tetrahedral mesh is not supported."
)

# Edge inner product surface projection matrices
n_faces = self.n_faces
face_areas = self.face_areas
dim = self.dim

if dim == 2:

if model is None:
Mu = sp.diags(face_areas)
else:
if invert_model:
model = 1.0 / model

if (model.size == 1) | (model.size == n_faces):
Mu = sp.diags(model * face_areas)
else:
raise ValueError(
"Unrecognized size of model vector.",
"Must be scalar or have length equal to total number of faces."
)

return Mu

else:
Ps = self._get_edge_surf_int_proj_mats(with_area=False)

if model is None:
Mu = sp.diags(np.tile(face_areas, dim))
else:
if invert_model:
model = 1.0 / model

if (model.size == 1) | (model.size == n_faces):
Mu = sp.diags(np.tile(model * face_areas, dim))
else:
raise ValueError(
"Unrecognized size of model vector.",
"Must be scalar or have length equal to total number of faces."
)

A = np.sum([P.T @ Mu @ P for P in Ps])

return A


def __get_inner_product_deriv_func(self, i_type, model):
Ps, _ = self.__get_inner_product_projection_matrices(i_type)
dim = self.dim
Expand Down Expand Up @@ -668,10 +725,13 @@ def _get_edge_surf_int_proj_mats(self, only_boundary=False, with_area=True):
edge_dirs = self.edge_tangents[node_edges]
t_for = np.concatenate((edge_dirs, face_normals[:, None, :]), axis=1)
t_inv = invert_blocks(t_for)
t_inv = t_inv[:, :, :-1] / 3 # n_edges_per_thing
t_inv = t_inv[:, :, :-1]

if with_area:
t_inv *= face_areas[:, None, None]
t_inv /= 3 # n_edges_per_thing
else:
t_inv /= np.sqrt(3) # sqrt n_edges_per_thing

T = C2F @ sp.csr_matrix(
(t_inv.reshape(-1), T_col_inds, T_ind_ptr),
Expand Down
Loading
Loading