Skip to content

Commit

Permalink
Merge branch 'main' into remove-sparsity-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth authored Nov 6, 2023
2 parents 261e4cd + a3860e9 commit 1a1d202
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/darsia/measure/wasserstein.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def transport_density(
# Apply numerical integration of RT0 extensions into cells.
# Underlying functional for mixed finite element method (MFEM).
quad_pts, quad_weights = darsia.quadrature.gauss_reference_cell(
self.grid.dim, 3
self.grid.dim, "max"
)

elif self.l1_mode == "constant_subcell_projection":
Expand Down Expand Up @@ -1216,6 +1216,9 @@ def _solve(self, flat_mass_diff: np.ndarray) -> tuple[float, np.ndarray, dict]:
self.darcy_init.copy(), rhs.copy(), solution_i
)

# Initialize distance in case below iteration fails
new_distance = 0

# Initialize container for storing the convergence history
convergence_history = {
"distance": [],
Expand Down Expand Up @@ -1493,6 +1496,9 @@ def _solve(self, flat_mass_diff: np.ndarray) -> tuple[float, np.ndarray, dict]:
self.darcy_init.copy(), rhs.copy(), solution_i
)

# Initialize distance in case below iteration fails
new_distance = 0

# Initialize container for storing the convergence history
convergence_history = {
"distance": [],
Expand Down
10 changes: 9 additions & 1 deletion src/darsia/utils/quadrature.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Quadrature rules for numerical integration."""

from typing import Union

import numpy as np


def gauss(dim: int, order: int) -> tuple[np.ndarray, np.ndarray]:
def gauss(dim: int, order: Union[int, str]) -> tuple[np.ndarray, np.ndarray]:
"""Return the Gauss points and weights for the given dimension and order.
These are the Gauss points and weights for the reference element [-1, 1]^dim.
Expand All @@ -17,6 +19,8 @@ def gauss(dim: int, order: int) -> tuple[np.ndarray, np.ndarray]:
"""
if dim == 1:
if order == "max":
order = 4
if order == 0:
return np.array([0.0]), np.array([2.0])
elif order == 1:
Expand Down Expand Up @@ -73,6 +77,8 @@ def gauss(dim: int, order: int) -> tuple[np.ndarray, np.ndarray]:
f"Gauss points of order {order} not implemented for dimension {dim}."
)
elif dim == 2:
if order == "max":
order = 3
if order == 0:
return (
np.array([[0.0, 0.0]]),
Expand Down Expand Up @@ -215,6 +221,8 @@ def gauss(dim: int, order: int) -> tuple[np.ndarray, np.ndarray]:
f"Gauss points of order {order} not implemented for dimension {dim}."
)
elif dim == 3:
if order == "max":
order = 2
if order == 0:
return (
np.array([[0.0, 0.0, 0.0]]),
Expand Down

0 comments on commit 1a1d202

Please sign in to comment.