Newer
Older
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! ||===\\ |
! || \\ |
! || || //==\\ || || //==|| ||/==\\ |
! || || || || || || || || || || |
! || // || || || || || || || |
! ||===// \\==// \\==\\ \\==\\ || |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! POSITIVE_VOLUME Nov. 2006 |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
subroutine compute_positive_volume (phi,vol,levelmax)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine ))))))))))))))))))))))))))))))))))))))
!------------------------------------------------------------------------------|
! finds the volume of a cube that is defined by the positive value of a lsf
! known at the nodes of the cube
! phi are the lsf values
! vol is the returned volume
! levelmax is the max level for accuracy (power of 2)
! this routine has been tested and provides accurate solutions in
! all ranges of phi with levelmax=3
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
implicit none
double precision vol,phi(8)
integer levelmax
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
call volume_lsf (phi,vol,1,levelmax)
return
end
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
! |
! VOLUME_LSF Nov. 2006 |
! |
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
recursive subroutine volume_lsf (phi,volp,level,levelmax)
!------------------------------------------------------------------------------|
!(((((((((((((((( Purpose of the routine ))))))))))))))))))))))))))))))))))))))
!------------------------------------------------------------------------------|
! used by positive_volume
! internal routine
! should not be changed
! it computes the volume based on Marthijn's simple formula
! the algorithm has been improved by allowing
! multi-level estimates up to levelmax by simple octree
! division before the formula is used
! phi are the lsf values at the 8 nodes
! volp is volume where lsf is negative
! level is current level in octree division
! levelmax is maximum level of octree division
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine arguments ))))))))))))))))))))
!------------------------------------------------------------------------------|
implicit none
double precision phi(8)
double precision volp
integer level
integer levelmax
!------------------------------------------------------------------------------|
!(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
!------------------------------------------------------------------------------|
double precision phip(8),rat
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|
if (level.eq.1) then
volp=0.d0
endif
if (level.eq.levelmax) then
rat=(sum(phi)/sum(abs(phi))+1.d0)/2.d0
volp=volp+rat*(2.d0**(-level+1))**3
return
endif
if (phi(1).gt.0.d0 .and. phi(2).gt.0.d0 .and. &
phi(3).gt.0.d0 .and. phi(4).gt.0.d0 .and. &
phi(5).gt.0.d0 .and. phi(6).gt.0.d0 .and. &
phi(7).gt.0.d0 .and. phi(8).gt.0.d0) then
volp=volp+(2.d0**(-level+1))**3
return
endif
if (phi(1).lt.0.d0 .and. phi(2).lt.0.d0 .and. &
phi(3).lt.0.d0 .and. phi(4).lt.0.d0 .and. &
phi(5).lt.0.d0 .and. phi(6).lt.0.d0 .and. &
phi(7).lt.0.d0 .and. phi(8).lt.0.d0) then
return
endif
phip(1)=phi(1)
phip(2)=(phi(1)+phi(2))/2.d0
phip(3)=(phi(1)+phi(3))/2.d0
phip(4)=(phi(1)+phi(2)+phi(3)+phi(4))/4.d0
phip(5)=(phi(1)+phi(5))/2.d0
phip(6)=(phi(1)+phi(2)+phi(5)+phi(6))/4.d0
phip(7)=(phi(1)+phi(3)+phi(5)+phi(7))/4.d0
phip(8)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(2))/2.d0
phip(2)=phi(2)
phip(3)=(phi(1)+phi(2)+phi(3)+phi(4))/4.d0
phip(4)=(phi(2)+phi(4))/2.d0
phip(5)=(phi(1)+phi(2)+phi(5)+phi(6))/4.d0
phip(6)=(phi(2)+phi(6))/2.d0
phip(7)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(8)=(phi(2)+phi(4)+phi(6)+phi(8))/4.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(3))/2.d0
phip(2)=(phi(1)+phi(2)+phi(3)+phi(4))/4.d0
phip(3)=phi(3)
phip(4)=(phi(3)+phi(4))/2.d0
phip(5)=(phi(1)+phi(3)+phi(5)+phi(7))/4.d0
phip(6)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(7)=(phi(3)+phi(7))/2.d0
phip(8)=(phi(3)+phi(4)+phi(7)+phi(8))/4.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(2)+phi(3)+phi(4))/4.d0
phip(2)=(phi(2)+phi(4))/2.d0
phip(3)=(phi(3)+phi(4))/2.d0
phip(4)=phi(4)
phip(5)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(6)=(phi(2)+phi(4)+phi(6)+phi(8))/4.d0
phip(7)=(phi(3)+phi(4)+phi(7)+phi(8))/4.d0
phip(8)=(phi(4)+phi(8))/2.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(5))/2.d0
phip(2)=(phi(1)+phi(2)+phi(5)+phi(6))/4.d0
phip(3)=(phi(1)+phi(3)+phi(5)+phi(7))/4.d0
phip(4)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(5)=phi(5)
phip(6)=(phi(5)+phi(6))/2.d0
phip(7)=(phi(5)+phi(7))/2.d0
phip(8)=(phi(5)+phi(6)+phi(7)+phi(8))/4.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(2)+phi(5)+phi(6))/4.d0
phip(2)=(phi(2)+phi(6))/2.d0
phip(3)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(4)=(phi(2)+phi(4)+phi(6)+phi(8))/4.d0
phip(5)=(phi(5)+phi(6))/2.d0
phip(6)=phi(6)
phip(7)=(phi(5)+phi(6)+phi(7)+phi(8))/4.d0
phip(8)=(phi(6)+phi(8))/2.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(3)+phi(5)+phi(7))/4.d0
phip(2)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(3)=(phi(3)+phi(7))/2.d0
phip(4)=(phi(3)+phi(4)+phi(7)+phi(8))/4.d0
phip(5)=(phi(5)+phi(7))/2.d0
phip(6)=(phi(5)+phi(6)+phi(7)+phi(8))/4.d0
phip(7)=phi(7)
phip(8)=(phi(7)+phi(8))/2.d0
call volume_lsf (phip,volp,level+1,levelmax)
phip(1)=(phi(1)+phi(2)+phi(3)+phi(4)+phi(5)+phi(6)+phi(7)+phi(8))/8.d0
phip(2)=(phi(2)+phi(4)+phi(6)+phi(8))/4.d0
phip(3)=(phi(3)+phi(4)+phi(7)+phi(8))/4.d0
phip(4)=(phi(4)+phi(8))/2.d0
phip(5)=(phi(5)+phi(6)+phi(7)+phi(8))/4.d0
phip(6)=(phi(6)+phi(8))/2.d0
phip(7)=(phi(7)+phi(8))/2.d0
phip(8)=phi(8)
call volume_lsf (phip,volp,level+1,levelmax)
return
end
!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|