Skip to content

Commit

Permalink
Split Border into two abstract subclasses (#23, #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
a5kin committed Jan 2, 2018
1 parent fc1f561 commit e30798f
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions xentica/core/topology/border.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Topology:
# ...
"""
import abc

from xentica.core.topology.mixins import DimensionsMixin


Expand All @@ -32,7 +34,55 @@ def __init__(self):
self.topology = None


class TorusBorder(Border):
class WrappedBorder(Border):
"""
Base class for borders wrapping the field into different manifolds.
For correct behavior, you should implement :meth:`wrap_coords` method.
See the detailed description below.
"""

@abc.abstractmethod
def wrap_coords(self, coord_prefix):
"""
Generate C code to translate off-board coordinates to on-board ones.
This is an abstract method, you must implement it in
:class:`WrappedBorder` subclasses.
:param coord_prefix:
The prefix for variables containing cell's coordinates.
"""


class GeneratedBorder(Border):
"""
Base class for borders generating states of the off-board cells.
For correct behavior, you should implement :meth:`off_board_state` method.
See the detailed description below.
"""

@abc.abstractmethod
def off_board_state(self, coord_prefix):
"""
Generate C code to obtain off-board cell's state.
This is an abstract method, you must implement it in
:class:`GeneratedBorder` subclasses.
:param coord_prefix:
The prefix for variables containing cell's coordinates.
"""


class TorusBorder(WrappedBorder):
"""
Wraps the entire field into N-torus manifold.
Expand Down Expand Up @@ -61,7 +111,7 @@ def wrap_coords(self, coord_prefix):
return code


class StaticBorder(Border):
class StaticBorder(GeneratedBorder):
"""
Generates a static value for every off-board cell.
Expand Down

0 comments on commit e30798f

Please sign in to comment.