coffee.tslices package¶
Submodules¶
coffee.tslices.tslices module¶
A timeslice is the package which contains all data necessary to represent a solution of the system at a given point in time.
This module contains the abstract base class (abc) for TimeSlice objects and a default implementation that makes certain assumptions. It is highly recommended that you subclass either of these classes.
As usual the abc is intended to make you think twice about doing things differently. All other classes that interact with TimeSlice objects assume that the interface is as given below.
Now it should be noted that the variables ABCTimeSlice.data, ABCTimeSlice.domain and ABCTimeSlice.time should have been declared as abc.abstractproperty. Doing this is possible, but because of a limitation in the abc class for Python 2 a substantial amount of additional code is needed. So this hasn’t been done. In fact NONE of the methods or variables are declared as abstract.
What is recommended is that you subclass ABCTimeSlice and call it’s functions once appropriate checks have been carried out.
At some point this will need to be changed… I assume after the move to Python 3 is made.
TimeSlice objects should contain all information needed to interperet the values of the functions being numerically evolved. In particular, aim to ensure that you can restart a simulation if given a timeslice, system and solver.
- class coffee.tslices.tslices.ABCTimeSlice(data, domain, time, name=None, *args, **kwds)[source]¶
Bases:
objectThe abstract base class for TimeSlice objects.
The interface below is assumed by all other classes that interact with TimeSlice objects (which is just about everything).
- collect_data()[source]¶
A wrapper to self.domain.collect_data.
Returns a timeslice containing the almalgum of all data and domains across all subdomains. It allocates new memory for the returned timeslice. This is currently used to pass non-distributed data to actions in the ibvp method.
- Returns:
A single timeslice which represents the complete data and domain for that point of time.
- Return type:
tslice.TimeSlice
- communicate(ghost_point_processor=None, data=None)[source]¶
Returns a list of tuples that describe the boundaries of grids for internal boundaries.
This is currently used when the full domain is divided into subdomains for use with mpi. This is purely for convenience so that users don’t need to write tslice.domain.communicate().
- Parameters:
ghost_point_processor (function) – A function with signature (data, list of slices). See the documentation for ABCGrid.communicate() for more information.
data – The information to be communicated. It defaults to self.data.
- Returns:
The result of a call to self.domain.communicate(self.data)
- Return type:
list, slices
- external_slices()[source]¶
Returns a list of tuples that describe boundaries of grids for external boundaries.
This is purely for convenience so that users don’t need to write tslice.domain.external_slices().
- Returns:
The result of a call to self.domain.external_slices(self.data.shape)
- Return type:
list, slices
- class coffee.tslices.tslices.TimeSlice(data, *args, **kwds)[source]¶
Bases:
ABCTimeSliceA default subclass of ABCTimeSlice.
This implementation assumes that all data are numpy arrays of the same shape. If your data is not like this then you should subclass ABCTimeSlice. This might be appropriate when working with spectral methods, for example.
Due to the assumption that the data is represented as a numpy array, this class also implements a large number of methods which allow this object to be added, multiplied, etc…
To be honest rather than implementing all the additional methods by hand it’d be easier just to make this default TimeSlice a subclass of be.ndarray itself and allow TimeSlice.data to access the underlying array. But this hasn’t been done.