Skip to content

Commit

Permalink
#220 remove unused imports and limit final mesh deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
acse-ej321 committed Nov 11, 2024
1 parent 1b35879 commit 9548f0f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions goalie/go_mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
Drivers for goal-oriented error estimation on sequences of meshes.
"""

import os
from collections.abc import Iterable
from copy import deepcopy

import numpy as np
import psutil
import ufl
from animate.interpolation import interpolate
from animate.utility import Mesh
Expand Down Expand Up @@ -171,13 +169,6 @@ def indicate_errors(
ADJ_NEXT = "adjoint" if self.steady else "adjoint_next"
P0_spaces = [FunctionSpace(mesh, "DG", 0) for mesh in self]

process = psutil.Process(os.getpid()) # ej321

def mem(i):
print(
f"Memory usage {i}: {process.memory_full_info().uss / 1024**2:.0f} MB"
) # ej321

# Loop over each subinterval in reverse
for i in reversed(range(len(self))):
# Solve the adjoint problem on the current subinterval
Expand Down Expand Up @@ -252,11 +243,11 @@ def mem(i):
enriched_mesh_seq.solutions[f][ADJ_NEXT].pop(-1)

# delete current subinterval enriched mesh to reduce the memory footprint
for f in self.fields:
enriched_mesh_seq._fs[f].pop(-1)

enriched_mesh_seq.meshes.pop(-1)
enriched_mesh_seq.time_partition.drop_last_subinterval()
if len(enriched_mesh_seq.meshes) > 1:
for f in self.fields:
enriched_mesh_seq._fs[f].pop(-1)
enriched_mesh_seq.meshes.pop(-1)
enriched_mesh_seq.time_partition.drop_last_subinterval()

# clear empty labels
for f in self.fields:
Expand Down

0 comments on commit 9548f0f

Please sign in to comment.