Beispiel #1
0
 def _create_implicit_exprs(self, grid):
     if not len(self._local_bounds) == 2*len(self.dimensions):
         raise ValueError("Left and right bounds must be supplied for each dimension")
     n_domains = self.n_domains
     i_dim = self.implicit_dimension
     dat = []
     # Organise the data contained in 'bounds' into a form such that the
     # associated implicit equations can easily be created.
     for j in range(len(self._local_bounds)):
         index = floor(j/2)
         d = self.dimensions[index]
         if j % 2 == 0:
             fname = d.min_name
         else:
             fname = d.max_name
         func = Function(name=fname, shape=(n_domains, ), dimensions=(i_dim, ),
                         grid=grid, dtype=np.int32)
         # Check if shorthand notation has been provided:
         if isinstance(self._local_bounds[j], int):
             bounds = np.full((n_domains,), self._local_bounds[j], dtype=np.int32)
             func.data[:] = bounds
         else:
             func.data[:] = self._local_bounds[j]
         dat.append(Eq(d.thickness[j % 2][0], func[i_dim]))
     return as_tuple(dat)
Beispiel #2
0
 def _create_implicit_exprs(self):
     if not len(self._bounds) == 2*len(self.dimensions):
         raise ValueError("Left and right bounds must be supplied for each dimension")
     n_domains = self.n_domains
     i_dim = self.implicit_dimension
     dat = []
     # Organise the data contained in 'bounds' into a form such that the
     # associated implicit equations can easily be created.
     for j in range(len(self._bounds)):
         index = floor(j/2)
         d = self.dimensions[index]
         if j % 2 == 0:
             fname = d.min_name
         else:
             fname = d.max_name
         func = Function(name=fname, shape=(n_domains, ), dimensions=(i_dim, ),
                         dtype=np.int32)
         # Check if shorthand notation has been provided:
         if isinstance(self._bounds[j], int):
             bounds = np.full((n_domains,), self._bounds[j], dtype=np.int32)
             func.data[:] = bounds
         else:
             func.data[:] = self._bounds[j]
         dat.append(Eq(d.thickness[j % 2][0], func[i_dim]))
     return as_tuple(dat)
Beispiel #3
0
 def __init_finalize__(self, *args, **kwargs):
     if args:
         comps = flatten(args[2])
         grid = comps[0].grid
         dimensions = None if grid else comps[0].dimensions
     else:
         grid = kwargs.get('grid')
         dimensions = kwargs.get('dimensions')
     inds, _ = Function.__indices_setup__(grid=grid, dimensions=dimensions)
     self._space_dimensions = inds
Beispiel #4
0
 def __init_finalize__(self, *args, **kwargs):
     grid = kwargs.get('grid')
     dimensions = kwargs.get('dimensions')
     inds, _ = Function.__indices_setup__(grid=grid, dimensions=dimensions)
     self._space_dimensions = inds
Beispiel #5
0
 def __indices_setup__(cls, **kwargs):
     return Function.__indices_setup__(grid=kwargs.get('grid'),
                                       dimensions=kwargs.get('dimensions'))
Beispiel #6
0
 def __dtype_setup__(cls, **kwargs):
     return Function.__dtype_setup__(**kwargs)