forked from ElsevierSoftwareX/SOFTX-D-20-00060
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.f90
198 lines (181 loc) · 6.42 KB
/
main.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
! EQUIVALENT POLYNOMIAL LIBRARY V 1.1
! BY GIULIO VENTURA
! giulio.ventura@polito.it
! www.equivalent-polynomials.net
!
! WHEN USING THIS LIBRARY PLEASE ALWAYS CITE
!
! Ventura G., On the elimination of quadrature subcells for discontinuous functions in the extended finite-element method,
! International Journal for Numerical Methods in Engineering 66 (2006) 761–795.
!
! Ventura G., Benvenuti E., Equivalent polynomials for quadrature in heaviside function enriched elements,
! International Journal for Numerical Methods in Engineering 102 (2015) 688–710.
!
! THIS IS AN EXAMPLE USAGE FILE WHERE EQUIVALENT POLYNOMIALS ARE USED TO COMPUTE THE VOLUMES AND MOMENTS OF
! INERTIA OF THE POSITIVE AND NEGATIVE ELEMENT SUBDOMAIN
!
! See the Library Application Note and the above papers for details
program eqpol_test
implicit none
integer etype,ngp
double precision a,b,c,d,t,x,y,z
double precision, allocatable :: w(:),eqcv(:),gp(:),gw(:)
! note: eqcv will contain the coefficients of the equivalent polynomial
! note: w is a vector of coefficients with only one component = 1 and the others = 0.
! when HEqPol is called with w as coefficients instead of eqcv, it will give the value of
! the i-th monomial basis function at the evaluation point
! note: regardless of the particular case, the Gauss quadrature rule is set for the worst case (etype=31)
integer i,j,k,fun
interface
double precision function HEqPol(x,y,z,eqcv,etype)
implicit none
integer etype
double precision x,y,z,eqcv(:)
end function HEqPol
subroutine Heqpol_coefficients(a,b,c,d,eqcv,etype)
implicit none
integer etype
double precision a,b,c,d,eqcv(:)
end subroutine Heqpol_coefficients
end interface
write(*,*)
write(*,'(1X,A)') 'EQUIVALENT POLYNOMIAL LIBRARY TEST PROGRAM'
write(*,*)
write(*,'(1X,A)',advance='no') 'etype (20,21,30,31) : '
read (*,*) etype
if (etype.lt.30) then
! 2D case
write(*,'(1X,A)',advance='no') 'a,b,c : '
read(*,*) a,b,c
if (etype==20) ngp=1
if (etype==21) ngp=3
else
! 3D case
write(*,'(1X,A)',advance='no') 'a,b,c,d : '
read(*,*) a,b,c,d
if (etype==30) ngp=1
if (etype==31) ngp=3
end if
allocate(gp(ngp),gw(ngp))
select case (etype)
case (20)
allocate(w(1),eqcv(1))
gp=(/0.333333333333/); gw=(/0.5/)
case (30)
allocate(w(1),eqcv(1))
gp=(/0.25/); gw=(/0.16666666666666666/)
case (21)
allocate(w(6),eqcv(6))
gp=(/-0.77459667,0.,0.77459667/)
gw=(/0.55555555,0.88888889,0.55555555/)
case (31)
allocate(w(23),eqcv(23))
gp=(/-0.77459667,0.,0.77459667/)
gw=(/0.55555555,0.88888889,0.55555555/)
end select
if (etype.lt.30) then
! 2D case
z=0; d=0
! positive part
call Heqpol_coefficients(a,b,c,d,eqcv,etype)
write(*,*) 'Gauss integration result of the equivalent polynomial times basis functions - positive part'
do fun=1,size(eqcv)
t=0; w=0; w(fun)=1
if (etype==20 .or. etype==30) then
do i=1,size(gp)
x=gp(i); y=gp(i)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype) * gw(i) * HEqPol(x,y,z,w,etype)
end do
else if (etype==21 .or. etype==31) then
do i=1,size(gp)
x=gp(i)
do j=1,size(gp)
y=gp(j)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype)*gw(i)*gw(j)*HEqPol(x,y,z,w,etype)
end do
end do
end if
write(*,'(I2,5X,F10.7)') fun,t
end do
! negative part
call Heqpol_coefficients(-a,-b,-c,-d,eqcv,etype)
write(*,*) 'Gauss integration result of the equivalent polynomial times basis functions - negative part'
do fun=1,size(eqcv)
t=0; w=0; w(fun)=1
if (etype==20 .or. etype==30) then
do i=1,size(gp)
x=gp(i); y=gp(i)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype) * gw(i) * HEqPol(x,y,z,w,etype)
end do
else if (etype==21 .or. etype==31) then
do i=1,size(gp)
x=gp(i)
do j=1,size(gp)
y=gp(j)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype)*gw(i)*gw(j)*HEqPol(x,y,z,w,etype)
end do
end do
end if
write(*,'(I2,5X,F10.7)') fun,t
end do
else
! 3D case
! positive part
call Heqpol_coefficients(a,b,c,d,eqcv,etype)
write(*,*) 'Gauss integration result of the equivalent polynomial times basis functions - positive part'
do fun=1,size(eqcv)
t=0; w=0; w(fun)=1
if (etype==20 .or. etype==30) then
do i=1,size(gp)
x=gp(i); y=gp(i); z=gp(i)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype) * gw(i) * HEqPol(x,y,z,w,etype)
end do
else if (etype==21 .or. etype==31) then
do i=1,size(gp)
x=gp(i)
do j=1,size(gp)
y=gp(j)
do k=1,size(gp)
z=gp(k)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype)*gw(i)*gw(j)*gw(k)*HEqPol(x,y,z,w,etype)
end do
end do
end do
end if
write(*,'(I2,5X,F10.7)') fun,t
end do
! negative part
call Heqpol_coefficients(-a,-b,-c,-d,eqcv,etype)
write(*,*) 'Gauss integration result of the equivalent polynomial times basis functions - negative part'
do fun=1,size(eqcv)
t=0; w=0; w(fun)=1
if (etype==20 .or. etype==30) then
do i=1,size(gp)
x=gp(i); y=gp(i); z=gp(i)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype) * gw(i) * HEqPol(x,y,z,w,etype)
end do
else if (etype==21 .or. etype==31) then
do i=1,size(gp)
x=gp(i)
do j=1,size(gp)
y=gp(j)
do k=1,size(gp)
z=gp(k)
! equivalent polynomial Gauss weights fun-th monomial basis function
t=t+HEqPol(x,y,z,eqcv,etype)*gw(i)*gw(j)*gw(k)*HEqPol(x,y,z,w,etype)
end do
end do
end do
end if
write(*,'(I2,5X,F10.7)') fun,t
end do
end if
write(*,*)
end program eqpol_test