Skip to content

Commit

Permalink
Implement periodic boundary conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
maroba committed Dec 16, 2024
1 parent 3725089 commit 33ec230
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 387 deletions.
18 changes: 12 additions & 6 deletions findiff/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ class Grid(ABC):

class EquidistantGrid(Grid):

def __init__(self, spacing: dict):
for axis, h in spacing.items():
if h <= 0:
def __init__(self, config: dict):

self.spacing = {}
self.periodic = {}
for axis, spacing_or_dict in config.items():
if isinstance(spacing_or_dict, dict):
self.spacing[axis] = spacing_or_dict["h"]
self.periodic[axis] = spacing_or_dict.get("periodic", False)
else:
self.spacing[axis] = spacing_or_dict
self.periodic[axis] = False
if self.spacing[axis] <= 0:
raise ValueError("spacing must be greater than zero")

# key -> value == axis -> spacing for axis
self.spacing = spacing


class TensorProductGrid(Grid):

Expand Down
306 changes: 0 additions & 306 deletions findiff/legacy/diff.py

This file was deleted.

Loading

0 comments on commit 33ec230

Please sign in to comment.