Skip to content

Commit

Permalink
Add a time dependent geometry provider
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 653165315
  • Loading branch information
tamaranorman authored and Torax team committed Jul 17, 2024
1 parent 4a86307 commit f7ed8da
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions torax/geometry_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ class ConstantGeometryProvider(GeometryProvider):
def __init__(self, geo: geometry.Geometry):
self._geo = geo

def __call__(
self,
t: chex.Numeric,
) -> geometry.Geometry:
def __call__(self, t: chex.Numeric) -> geometry.Geometry:
# The API includes time as an arg even though it is unused in order
# to match the API of a GeometryProvider.
del t # Ignored.
Expand All @@ -93,3 +90,17 @@ def __call__(
@property
def torax_mesh(self) -> geometry.Grid1D:
return self._geo.torax_mesh


class TimeDependentGeometryProvider(GeometryProvider):
"""Returns a Geometry that changes over time."""

def __init__(self, geometry_provider: geometry.GeometryProvider):
self._geometry_provider = geometry_provider

def __call__(self, t: chex.Numeric) -> geometry.Geometry:
return self._geometry_provider.get_geometry(t)

@property
def torax_mesh(self) -> geometry.Grid1D:
return self._geometry_provider.torax_mesh

0 comments on commit f7ed8da

Please sign in to comment.