forked from RiccardoRossi/pyKratos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_square.py
61 lines (47 loc) · 1.79 KB
/
generate_square.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from __future__ import print_function, absolute_import, division
from numpy import *
def GenerateSquare(nx, dx, ny, dy):
nodelist = {}
id_counter = 0
for j in range(0, ny):
for i in range(0, nx):
x = i * dx
y = j * dy
nodelist.update({id_counter: array([x, y])})
id_counter += 1
# generate triangle
connectivities = {}
el_counter = 0
for j in range(0, ny - 1):
base_i = j * nx
base_i1 = (j + 1) * nx
for i in range(0, nx - 1):
connectivities.update(
{el_counter: [0, [base_i + i, base_i1 + 1 + i, base_i1 + i]]})
el_counter += 1
connectivities.update(
{el_counter: [0, [base_i + i, base_i + 1 + i, base_i1 + 1 + i]]})
el_counter += 1
#generate face connectivities
face_connectivities = {}
cond_counter = 0
#create faces of the bottom side
for i in range(0, nx - 1):
face_connectivities.update( {cond_counter: [0, [i, i+1] ] } )
cond_counter += 1
#create faces of the right side
for i in range(nx-1, ny*nx-1, nx ):
face_connectivities.update( {cond_counter: [0, [i, i+nx] ]} )
cond_counter += 1
#create faces of the top side
for i in range(ny*nx-1, (ny-1)*nx, -1 ):
face_connectivities.update( {cond_counter: [0, [i, i-1] ]} )
cond_counter += 1
#create faces of the left side
for i in range((ny-1)*nx, 0, -nx ):
face_connectivities.update( {cond_counter: [0, [i, i-nx] ]} )
cond_counter += 1
return nodelist, connectivities, face_connectivities
#nodelist,connectivities,face_connectivities = GenerateSquare(2,0.1,3,0.1)
# for aaa in connectivities.values():
# print aaa