SFEMaNS  version 5.3
Reference documentation for SFEMaNS
basis_change.f90
Go to the documentation of this file.
2  PUBLIC :: p1_p2, p2_p3
3  PRIVATE
4  !===Compute change of basis matrices for p1 to p2 and p2 to p3
5  !===P(k-1) basis: phi_i; P_k basis: psi_j
6  !===phi_i = sum_j (a_ij psi_j)
7  !===a_ij = phi_i(x_j), where x_j is the jth Lagrange node such that psi_k(x_j)=delta_kj
8 CONTAINS
9  subroutine p1_p2(aij)
10  IMPLICIT NONE
11  INTEGER, PARAMETER :: type_fe_p2 = 1, nw_p2=(type_fe_p2+2)*(type_fe_p2+1)/2, &
12  type_fe_p3 = 2, nw_p3=(type_fe_p3+2)*(type_fe_p3+1)/2
13  REAL(KIND=8), DIMENSION(:,:), POINTER :: aij
14  INTEGER, DIMENSION(nw_p3) :: Cart_FE
15  REAL(KIND=8) :: f1, f2, f3, x, y, delta, one = 1.d0
16  REAL(KIND=8), DIMENSION(nw_p3) :: xx, yy, xxp, yyp
17  INTEGER :: j, h, k
18 
19  f1(x, y) = one - x - y
20  f2(x, y) = x
21  f3(x, y) = y
22 
23  ALLOCATE(aij(nw_p2,nw_p3))
24  delta = 1.d0/type_fe_p3
25  j = 0
26  DO h = 1, type_fe_p3+1
27  DO k = 1, type_fe_p3+2-h
28  j = j+1
29  xxp(j) = (h-1)*delta
30  yyp(j) = (k-1)*delta
31  END DO
32  END DO
33 
34  cart_fe(1) = 1
35  cart_fe(2) = 5
36  cart_fe(3) = 3
37  cart_fe(4) = 6
38  cart_fe(5) = 4
39  cart_fe(6) = 2
40  xx(cart_fe) = xxp
41  yy(cart_fe) = yyp
42 
43  DO j = 1, nw_p3
44  aij(1,j) = f1(xx(j),yy(j))
45  aij(2,j) = f2(xx(j),yy(j))
46  aij(3,j) = f3(xx(j),yy(j))
47  END DO
48  END subroutine p1_p2
49 
50  subroutine p2_p3(aij)
51  IMPLICIT NONE
52  INTEGER, PARAMETER :: type_fe_p2 = 2, nw_p2=(type_fe_p2+2)*(type_fe_p2+1)/2, &
53  type_fe_p3 = 3, nw_p3=(type_fe_p3+2)*(type_fe_p3+1)/2
54  REAL(KIND=8), DIMENSION(:,:), POINTER :: aij
55  INTEGER, DIMENSION(nw_p3) :: Cart_FE
56  REAL(KIND=8) :: f1, f2, f3, f4, f5, f6, x, y, delta, half = 0.5d0, one = 1.d0, two=2.d0, four=4.d0
57  REAL(KIND=8), DIMENSION(nw_p3) :: xx, yy, xxp, yyp
58  INTEGER :: j, h, k
59 
60  f1(x, y) = (half - x - y) * (one - x - y) * two
61  f2(x, y) = x * (x - half) * two
62  f3(x, y) = y * (y - half) * two
63  f4(x, y) = x * y * four
64  f5(x, y) = y * (one - x - y) * four
65  f6(x, y) = x * (one - x - y) * four
66 
67  ALLOCATE(aij(nw_p2,nw_p3))
68  delta = 1.d0/type_fe_p3
69  j = 0
70  DO h = 1, type_fe_p3+1
71  DO k = 1, type_fe_p3+2-h
72  j = j+1
73  xxp(j) = (h-1)*delta
74  yyp(j) = (k-1)*delta
75  END DO
76  END DO
77 
78  cart_fe(1) = 1
79  cart_fe(2) = 6
80  cart_fe(3) = 7
81  cart_fe(4) = 3
82  cart_fe(5) = 8
83  cart_fe(6) = 10
84  cart_fe(7) = 5
85  cart_fe(8) = 9
86  cart_fe(9) = 4
87  cart_fe(10) = 2
88  xx(cart_fe) = xxp
89  yy(cart_fe) = yyp
90 
91  DO j = 1, nw_p3
92  aij(1,j) = f1(xx(j),yy(j))
93  aij(2,j) = f2(xx(j),yy(j))
94  aij(3,j) = f3(xx(j),yy(j))
95  aij(4,j) = f4(xx(j),yy(j))
96  aij(5,j) = f5(xx(j),yy(j))
97  aij(6,j) = f6(xx(j),yy(j))
98  END DO
99  END subroutine p2_p3
100 
101 END MODULE basis_change
102 
103 !!$program t
104 !!$ USE basis_change
105 !!$ REAL(KIND=8), DIMENSION(:,:), POINTER :: aij_p2, aij_p3
106 !!$ INTEGER :: i
107 !!$ CALL p1_p2(aij_p2)
108 !!$ DO i = 1, 3
109 !!$ write(*,'(7(f8.3,3x))') aij_p2(i,:)
110 !!$ END DO
111 !!$ DO i = 1, 6
112 !!$ write(*,'(f8.3)') sum(aij_p2(:,i))
113 !!$ END DO
114 !!$ CALL p2_p3(aij_p3)
115 !!$ write(*,*) aij_p2(:,4)
116 !!$ !DO i = 1, 6
117 !!$ ! write(*,'(11(f8.3,3x))') aij_p3(i,:)
118 !!$ !END DO
119 !!$ !DO i = 1, 10
120 !!$ ! write(*,'(f8.3)') sum(aij_p3(:,i))
121 !!$ !END DO
122 !!$end program t
subroutine, public p2_p3(aij)
subroutine, public p1_p2(aij)