DISPATCH
patch_types.py
1 # -*- coding: utf-8 -*-
2 '''
3  Patch types for Python.
4 '''
5 
6 import numpy as np
7 from abc import ABCMeta
8 from dispatch_data import Patch
9 
10 class MHDPatch(Patch):
11  """An abstract derived class for MHD patches."""
12 
13  __metaclass__ = ABCMeta
14 
15  varidx = dict()
16 
18  """A concrete derived class for Stagger MHD patches."""
19 
20  def __init__ (self, filename, verbose=False, read_derivs=False):
21  super(MHDPatch, self).__init__(filename, verbose)
22 
23  # it's possible that the dump also contains the time derivatives.
24  # note that the following only works because the `data` property has
25  # not yet been used.
26  if read_derivs: self.nvar = 2 * self.nvar
27 
28  self.nbytes = 4
29  self.varidx = self.variable_indices(read_derivs)
30 
32  """A concrete derived class for Zeus-3D/AZEuS MHD patches."""
33 
34  def __init__ (self, filename, verbose=False):
35  super(MHDPatch, self).__init__(filename, verbose)
36 
37  self.nbytes = 8
38  self.varidx = self.variable_indices(read_derivs=False)
39 
41  """A concrete derived class for immersed boundary patches."""
42 
43  def __init__ (self, filename, verbose=False):
44  super(Patch, self).__init__(filename, verbose)
45 
47  """A concrete derived class for Stagger MHD patches."""
48 
49  def __init__ (self, filename, verbose=False, read_derivs=False):
50  super(MHDPatch, self).__init__(filename, verbose)
51 
52  # it's possible that the dump also contains the time derivatives.
53  # note that the following only works because the `data` property has
54  # not yet been used.
55  if read_derivs: self.nvar = 2 * self.nvar
56 
57  self.nbytes = 4
58  self.varidx = self.variable_indices(read_derivs)
59 
61  """A concrete derived class for RAMSES hydro patches."""
62 
63  def __init__ (self, filename, verbose=False):
64  super(MHDPatch, self).__init__(filename, verbose)
65 
66  self.nbytes = 4
67  self.varidx = self.variable_indices(read_derivs=False)
68 
70  """A concrete derived class for RT patches."""
71 
72  def __init__ (self, filename, verbose=False, read_derivs=False):
73  super(MHDPatch, self).__init__(filename, verbose)
74 
75  # it's possible that the dump also contains the time derivatives.
76  # note that the following only works because the `data` property has
77  # not yet been used.
78  if read_derivs: self.nvar = 2 * self.nvar
79 
80  self.nbytes = 4
81  self.varidx = elf.variable_indices(read_derivs)
def variable_indices(self, read_derivs=False)