7
# Get dictionary of connectivities
8
dic_connects = get_connects(argv[0])
10
# Verify connectivities
11
check_sort(dic_connects)
13
check_2_1(dic_connects)
15
check_3_2(dic_connects)
17
check_3_1(dic_connects)
19
def check_2_1(dic_connects):
26
print "\n ---- Verifying (2-1) ----"
29
entities21 = dic_connects[dic21]
30
entities20 = dic_connects[dic20]
31
entities10 = dic_connects[dic10]
32
# Inverting dictionary
34
for e10 in entities10:
35
inv10[tuple(entities10[e10])] = [e10]
37
for e21 in entities21:
39
# Get list of edges on cell/facet to compare against
41
# Get list of vertices for cell/facet
44
# Copy vertices and remove non-incident vertices
45
le = [l2 for l2 in l20]
47
# Look for the edge with these vertices
49
# If the two list are not equal, reordering is not OK
61
print " - nothing to do"
64
def check_3_2(dic_connects):
71
print "\n ---- Verifying (3-2) ----"
74
entities32 = dic_connects[dic32]
75
entities30 = dic_connects[dic30]
76
entities20 = dic_connects[dic20]
77
# Inverting dictionary
79
for e20 in entities20:
80
inv20[tuple(entities20[e20])] = [e20]
82
for e32 in entities32:
84
# Get list of facets on cell to compare against
86
# Get list of vertices for cell
89
le = [l3 for l3 in l30]
91
# Look for the facet with these vertices
93
# If the two list are not equal, reordering is not OK
100
if ok and entities32:
105
print " - nothing to do"
108
def check_3_1(dic_connects):
113
non_inc = [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)]
115
print "\n ---- Verifying (3-1) ----"
118
entities31 = dic_connects[dic31]
119
entities30 = dic_connects[dic30]
120
entities10 = dic_connects[dic10]
121
# Inverting dictionary
123
for e10 in entities10:
124
inv10[tuple(entities10[e10])] = [e10]
126
for e31 in entities31:
128
# Get list of edges on cell to compare against
129
l31 = entities31[e31]
130
# Get list of vertices for cell
131
l30 = entities30[e31]
133
# Copy vertices and remove non-incident vertices
134
le = [l3 for l3 in l30]
137
# Look for the facet with these vertices
138
l += inv10[tuple(le)]
139
# If the two list are not equal, reordering is not OK
146
if ok and entities31:
151
print " - nothing to do"
154
def check_sort(dic_connects):
156
# Connectivities that should be sorted lexicographically
157
sort_dics = [(1,0), (2,0), (3,0)]
159
print "\n ---- Verifying that vertices are sorted on all mesh entities ----"
160
for dic in sort_dics:
163
# Get dictionary of entities
164
ent_dic = dic_connects[dic]
166
for entity in ent_dic:
167
# Get list of vertices
171
# Sort original list and compare lists
181
print " - nothing to do"
183
def get_connects(name):
185
# Supported connectivities
186
connects = [(1,0), (2,0), (3,0), (2,1), (3,1), (3,2)]
190
for entry in connects:
193
# Read file, and get lines
195
lines = f.read().split("\n")
198
lines = [line for line in lines if line.split()]
200
# Loop lines and check for supported connectivities
202
ints = ["0", "1", "2", "3"]
204
if not ("--" in line or ":" in line):
206
if "Connect" in line and "--" in line:
207
words = line.split(" ")
208
entry = tuple([int(w.replace(":","")) for w in words if w.replace(":","") in ints])
209
if not entry in connects:
215
entity = line.split(":")[0].split(" ")[-1]
216
vals = [int(v) for v in line.split(":")[1].split(" ") if v]
217
dic[entry][int(entity)] = vals
221
if __name__ == "__main__":
222
sys.exit(main(sys.argv[1:]))