1 """Data structures in Foam-Files that can't be directly represented by Python-Structures"""
2
3 import FoamFileGenerator
4 from copy import deepcopy
5 import string
6
9 self.val=val
10 self.name=name
11 if self.name==None:
12 self.uniform=True
13 else:
14 assert(type(val)==list)
15 self.uniform=False
16
25
27 if other==None:
28 return 1
29 if self.uniform!=other.uniform:
30 return cmp(self.uniform,other.uniform)
31 elif self.name!=other.name:
32 return cmp(self.name,other.name)
33 else:
34 return cmp(self.val,other.val)
35
37 assert(not self.uniform)
38 return self.val[key]
39
41 assert(not self.uniform)
42 self.val[key]=value
43
45 return self.uniform
46
48 return self.val
49
54
57 assert(len(dims)==7)
58 self.dims=list(dims)
59
61 result="[ "
62 for v in self.dims:
63 result+=str(v)+" "
64 result+="]"
65 return result
66
68 if other==None:
69 return 1
70 return cmp(self.dims,other.dims)
71
73 return self.dims[key]
74
77
80 self.vals=vals[:]
81
83 return "("+string.join(map(lambda v:"%g"%v,self.vals))+")"
84
86 if other==None:
87 return 1
88 return cmp(self.vals,other.vals)
89
91 return self.vals[key]
92
95
99
101 - def __init__(self,v1,v2,v3,v4,v5,v6,v7,v8,v9):
103
107
109 """A class that acts like a dictionary, but preserves the order
110 of the entries. Used to beautify the output"""
111
113 dict.__init__(self)
114 self._order=[]
115
117 dict.__setitem__(self,key,value)
118 if key not in self._order:
119 self._order.append(key)
120
122 dict.__delitem__(self,key)
123 self._order.remove(key)
124
126 new=DictProxy()
127 for k in self._order:
128 new[k]=deepcopy(self[k],memo)
129 return new
130