"""boundary.py - Classes for implementing region conditions NOTE: I've only set it up for testing X values of constants and functions. Although it should work for vectors/arrays of values, that implies knowing info about the actual triangles, and that is not how the user should operate. """ class Region: """Base class for modifying quantities based on a region. """ def __init__(self): pass def __call__(self, tag, elements, domain): msg = 'Generic class Boundary must be subclassed' raise msg class Set_Region(Region): def __init__(self, tag, quantity, X, location='vertices'): """ name: Name of quantity X: const or function location: Where values are to be stored. Permissible options are: vertices, centroid """ Region.__init__(self) self.tag = tag self.quantity = quantity self.location = location self.X = X def __repr__(self): pass def __call__(self, tag, elements, domain): """ """ if tag == self.tag: domain.set_quantity(self.quantity, self.X, indexes = elements) class Add_Value_To_Region(Region): """ Will add a value to the current quantity value. """ def __init__(self, tag, quantity, X, location='vertex'): Region.__init__(self) self.tag = tag self.quantity = quantity self.location = location self.X = X if callable(X): raise 'This class does not work with functions' def __repr__(self): pass def __call__(self, tag, elements, domain): """ """ if tag == self.tag: new_values = domain.get_quantity(self.quantity, indexes = elements) + self.X domain.set_quantity(self.quantity, new_values, indexes = elements)