Skip to content

Commit

Permalink
Yank modred from the package as it is unused.
Browse files Browse the repository at this point in the history
  • Loading branch information
ludgerpaehler committed Mar 16, 2024
1 parent 1ba472f commit 047fd9e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 128 deletions.
83 changes: 0 additions & 83 deletions hydrogym/firedrake/utils/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
import ufl
from firedrake import logging
from modred import PODHandles, VectorSpaceHandles
from scipy import sparse

# Type suggestions
Expand Down Expand Up @@ -91,88 +90,6 @@ def inner_product(u, v):
return inner_product


def pod(
flow: FlowConfig,
snapshot_handles: Iterable[Snapshot],
r: int,
mass_matrix,
decomp_indices=None,
remove_mean=True,
mean_dest="mean",
atol=1e-13,
rtol=None,
max_vecs_per_node=None,
verbosity=1,
output_dir=".",
modes_dest="pod",
eigvals_dest="eigvals.dat",
pvd_dest=None,
coeffs_dest="coeffs.dat",
field_name="q",
):
"""
Args:
``flow``: ``FlowConfig`` for the POD (used for weighted inner product)
``snapshots``: List of Snapshot handles
``r``: Number of modes to compute
Kwargs:
``decomp_indices``: Indices to use in method of snapshots (defaults to ``range(r)``)
NOTE: could actually take the "flow" dependence out if we replaced the PVD with a postprocessing callback...
"""
if fd.COMM_WORLD.size > 1:
raise NotImplementedError("Not yet supported in parallel")

# Compute actual POD
if decomp_indices is None:
decomp_indices = range(r)

inner_product = define_inner_product(mass_matrix)

if remove_mean:
base_vec_handle = Snapshot(f"{output_dir}/{mean_dest}")
base_vec_handle.put(vec_handle_mean(snapshot_handles))

# Redefine snapshots with mean subtraction
snapshot_handles = [
Snapshot(snap.filename, base_vec_handle=base_vec_handle)
for snap in snapshot_handles
]
logging.log(logging.DEBUG, "Mean subtracted")

logging.log(logging.DEBUG, "Computing POD")
POD = PODHandles(
inner_product=inner_product,
max_vecs_per_node=max_vecs_per_node,
verbosity=verbosity,
)
POD.compute_decomp(snapshot_handles, atol=atol, rtol=rtol)

# Vector handles for storing snapshots
mode_handles = [
Snapshot(filename=f"{output_dir}/{modes_dest}{i}") for i in range(r)
]
POD.compute_modes(range(r), mode_handles)

POD.put_eigvals(f"{output_dir}/{eigvals_dest}")

# Save for visualization
if pvd_dest is not None:
pvd = fd.File(f"{output_dir}/{pvd_dest}", "w")
for i, mode in enumerate(mode_handles):
u, p = mode.get().as_function().subfunctions
pvd.write(u, p, flow.vorticity(u))

# Compute temporal coefficients
coeffs = POD.compute_proj_coeffs().T # If all snapshots used for POD
np.savetxt(f"{output_dir}/{coeffs_dest}", coeffs, fmt="%0.6f", delimiter="\t")

return coeffs, mode_handles


def project(basis_handles, data_handles, mass_matrix):
inner_product = define_inner_product(mass_matrix)
vec_space = VectorSpaceHandles(inner_product)
Expand Down
44 changes: 0 additions & 44 deletions hydrogym/firedrake/utils/modred_interface.py

This file was deleted.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ control = "^0.9.2"
dmsuite = "^0.1.1"
gmsh = "^4.11.1"
gym = "^0.26.2"
modred = "^2.1.0"
python = "^3.10"
torch = "^2.0"

Expand Down

0 comments on commit 047fd9e

Please sign in to comment.