Skip to content

Commit

Permalink
Pre-allocate function to store vorticity (#180)
Browse files Browse the repository at this point in the history
* Pre-allocate function to store vorticity

* Project instead of interpolate vorticity
  • Loading branch information
jcallaham authored Apr 7, 2024
1 parent be10c46 commit 7462583
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/cylinder/pressure-probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Re=100,
mesh=mesh,
velocity_order=velocity_order,
observation_type="pressure_probes",
observation_type="vorticity_probes",
probes=probes,
)

Expand Down
7 changes: 4 additions & 3 deletions hydrogym/firedrake/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def initialize_state(self):

self.split_solution() # Break out and rename main solution

self._vorticity = fd.Function(self.pressure_space, name="vort")

def set_state(self, q: fd.Function):
"""Set the current state fields
Expand Down Expand Up @@ -207,9 +209,8 @@ def vorticity(self, u: fd.Function = None) -> fd.Function:
"""
if u is None:
u = self.u
vort = fd.project(curl(u), self.pressure_space)
vort.rename("vort")
return vort
self._vorticity.project(curl(u))
return self._vorticity

def function_spaces(self, mixed: bool = True):
"""Function spaces for velocity and pressure
Expand Down

0 comments on commit 7462583

Please sign in to comment.