-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmod_cell_2D.f90
114 lines (85 loc) · 3.26 KB
/
mod_cell_2D.f90
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
module mod_cell_2D
use mod_read_gmsh
implicit none
type face
type(point) :: p1,p2
end type face
type cell_2D
integer(4) :: ident = 0
type(point) :: vertex(4)
type(face),dimension(4) :: faces
type(cell_2D),pointer :: neighbor1 => null()
type(cell_2D),pointer :: neighbor2 => null()
type(cell_2D),pointer :: neighbor3 => null()
type(cell_2D),pointer :: neighbor4 => null()
end type cell_2D
type list_cell_2D
type(cell_2D),pointer :: p
end type
type(list_cell_2D),dimension(:),allocatable :: cell
contains
subroutine construct_cells
implicit none
integer(4) :: i,j
integer(4) :: idnode
allocate(cell(1:nbelm))
do i = 1, nbelm
allocate(cell(i)%p)
end do
! Assign vertexes of a cell
do i = 1, nbelm
cell(i)%p%ident = i
cell(i)%p%vertex(1)%ident = id_nodes(i)%pn%id_node(6)
idnode = cell(i)%p%vertex(1)%ident
do j = 1, nbnode
if (idnode == coord_nodes(j)%p%ident) then
cell(i)%p%vertex(1)%x = coord_nodes(j)%p%x
cell(i)%p%vertex(1)%y = coord_nodes(j)%p%y
end if
end do
cell(i)%p%vertex(2)%ident = id_nodes(i)%pn%id_node(7)
idnode = cell(i)%p%vertex(2)%ident
do j = 1, nbnode
if (idnode == coord_nodes(j)%p%ident) then
cell(i)%p%vertex(2)%x = coord_nodes(j)%p%x
cell(i)%p%vertex(2)%y = coord_nodes(j)%p%y
end if
end do
cell(i)%p%vertex(3)%ident = id_nodes(i)%pn%id_node(8)
idnode = cell(i)%p%vertex(3)%ident
do j = 1, nbnode
if (idnode == coord_nodes(j)%p%ident) then
cell(i)%p%vertex(3)%x = coord_nodes(j)%p%x
cell(i)%p%vertex(3)%y = coord_nodes(j)%p%y
end if
end do
cell(i)%p%vertex(4)%ident = id_nodes(i)%pn%id_node(9)
idnode = cell(i)%p%vertex(4)%ident
do j = 1, nbnode
if (idnode == coord_nodes(j)%p%ident) then
cell(i)%p%vertex(4)%x = coord_nodes(j)%p%x
cell(i)%p%vertex(4)%y = coord_nodes(j)%p%y
end if
end do
end do
! Assign faces for each cell
do i = 1, nbelm
cell(i)%p%faces(1)%p1%x = cell(i)%p%vertex(1)%x
cell(i)%p%faces(1)%p1%y = cell(i)%p%vertex(1)%y
cell(i)%p%faces(1)%p2%x = cell(i)%p%vertex(2)%x
cell(i)%p%faces(1)%p2%y = cell(i)%p%vertex(2)%y
cell(i)%p%faces(2)%p1%x = cell(i)%p%vertex(2)%x
cell(i)%p%faces(2)%p1%y = cell(i)%p%vertex(2)%y
cell(i)%p%faces(2)%p2%x = cell(i)%p%vertex(3)%x
cell(i)%p%faces(2)%p2%y = cell(i)%p%vertex(3)%y
cell(i)%p%faces(3)%p1%x = cell(i)%p%vertex(3)%x
cell(i)%p%faces(3)%p1%y = cell(i)%p%vertex(3)%y
cell(i)%p%faces(3)%p2%x = cell(i)%p%vertex(4)%x
cell(i)%p%faces(3)%p2%y = cell(i)%p%vertex(4)%y
cell(i)%p%faces(4)%p1%x = cell(i)%p%vertex(4)%x
cell(i)%p%faces(4)%p1%y = cell(i)%p%vertex(4)%y
cell(i)%p%faces(4)%p2%x = cell(i)%p%vertex(1)%x
cell(i)%p%faces(4)%p2%y = cell(i)%p%vertex(1)%y
end do
end subroutine
end module