-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDomain.py
86 lines (71 loc) · 2.09 KB
/
Domain.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 21 12:29:28 2018
@author: Ricardo Rivas
"""
import numpy as np
import matplotlib.pyplot as plt
class DomainC():
"""
This class generates a 2D C-shape domain
---|-------- length -----|
. * * * * * * * * * * * *
. * * * * * * * * * * * *
. * * * * * * * * * * * *
. * * * * * *
height . * * * * * *
. * * * * * *
. * * * * * * * * * * * *
. * * * * * * * * * * * *
---* * * * * * * * * * * *
"""
def __init__(self, length = 3, height = 3):
"""
Constructor
Parameters
-----------
length : int
Number of nodes of the horizontal longer side
height : int
Number of nodes of the vertical side
"""
self.__length = length
self.__heigth = height
def __del__(self):
"""
Destructor
"""
del(self.__length)
del(self.__heigth)
def generateDomain(self):
"""
Generate three subdomains of the C-Shape domain and
return an arrays with the list of points for each subdomain
"""
L = self.__length
H = self.__heigth
x1 = []
for i in range(0, round(H/3)):
for j in range(0,L):
x1.append([i,j])
x2 = []
for i in range(int(H/3), round(2*H/3)):
for j in range(0,round(L/2)):
x2.append([i,j])
x3 = []
for i in range(round(2*H/3), H):
for j in range(0,L):
x3.append([i,j])
return np.array(x1), np.array(x2), np.array(x3)
if __name__ == "__main__":
L = 30
H = 60
ob = DomainC(L, H)
dom1, dom2, dom3 = ob.generateDomain()
theta = np.radians(-90)
c, s = np.cos(theta), np.sin(theta)
R = np.array(((c, -s), (s, c)))
x = np.concatenate((dom1, dom2, dom3), axis=0)
x = (R@x.T).T
plt.scatter(x[:,0], x[:,1]+H)