-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEdges.f90
618 lines (544 loc) · 19.2 KB
/
Edges.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
module EdgesModule
!> @file Edges.f90
!> Provides a primitive data structure and methods for creating edges of polyhedral meshes.
!>
!> @author Peter Bosler, Sandia National Laboratories Center for Computing Research
!>
!>
!> @defgroup Edges Edges module
!> @brief Edges of polyhedral meshes connect to vertices and faces.
!> @{
use NumberKindsModule
use LoggerModule
use STDIntVectorModule
use ParticlesModule
use SphereGeomModule, only : crossProduct, SphereMidpoint, SphereTriArea, SphereDistance, ChordDistance
use PlaneGeomModule, only : Midpoint, TriArea
use ParticlesModule
implicit none
private
public Edges
public New, Delete, Copy
public InsertEdge, DivideEdge
public RecordIncidentEdgeAtParticles
public positiveEdge
public onBoundary
public ReplaceIncidentEdgeWithChild
public GetLeafEdgesFromParent, AreaFromLeafEdges
public EdgeLength, MaxEdgeLength
public LogStats, PrintDebugInfo
public WriteEdgesToMatlab
public CountParents
!> @class Edges
!> @brief Edges know the indices (to Particles) of their origin and destination, and the indices (to Faces)
!> of their left face and right face.
type Edges
integer(kint), pointer :: orig(:) => null()
integer(kint), pointer :: dest(:) => null()
integer(kint), pointer :: rightFace(:) => null()
integer(kint), pointer :: leftFace(:) => null()
integer(kint), pointer :: child1(:) => null()
integer(kint), pointer :: child2(:) => null()
logical(klog), pointer :: hasChildren(:) => null()
integer(kint), pointer :: parent(:) => null()
integer(kint) :: N = 0
integer(kint) :: N_Max = 0
contains
final :: deletePrivate
end type
interface New
module procedure newPrivate
end interface
interface Delete
module procedure deletePrivate
end interface
interface Copy
module procedure copyPrivate
end interface
interface LogStats
module procedure LogStatsPrivate
end interface
interface PrintDebugInfo
module procedure PrintDebugPrivate
end interface
interface CountParents
module procedure countParentEdges
end interface
!
!----------------
! Logging
!----------------
!
logical(klog), save :: logInit = .FALSE.
type(Logger) :: log
character(len=28), save :: logKey = 'Edges'
integer(kint), parameter :: logLevel = DEBUG_LOGGING_LEVEL
contains
subroutine WriteEdgesToMatlab( self, fileunit )
type(Edges), intent(in) :: self
integer(kint), intent(in) :: fileunit
!
integer(kint) :: i
write(fileunit,*) "edgeVerts = [ ", self%orig(1), ", ", self%dest(1), "; ..."
do i = 2, self%N-1
write(fileunit, * ) self%orig(i), ", ", self%dest(i), "; ..."
enddo
write(fileunit, *) self%orig(self%N), ", ", self%dest(self%N), "]; "
write(fileunit,'(A)',advance='NO') "edgeHasChildren = ["
do i = 1, self%N - 1
if ( self%hasChildren(i) ) then
write(fileunit,*) 1, ", ..."
else
write(fileunit,*) 0, ", ..."
endif
enddo
if ( self%hasChildren(self%N)) then
write(fileunit,'(I4)', advance='NO') 1
else
write(fileunit,'(I4)', advance='NO') 0
endif
write(fileunit,'(A)') "];"
end subroutine
subroutine PrintDebugPrivate( self )
type(Edges), intent(in) :: self
integer(kint) :: i
print *, "Edges DEBUG info : "
print *, "edges.N = ", self%N
print *, "edges.N_Max = ", self%N_Max
print *, "edge records : "
do i = 1, self%N_Max
print *, self%orig(i), self%dest(i), self%leftFace(i), self%rightFace(i)
enddo
print *, "edge tree : "
do i = 1, self%N_Max
print *, self%hasChildren(i), self%child1(i), self%child2(i), self%parent(i)
enddo
end subroutine
subroutine LogStatsPrivate( self, aLog )
type(Edges), intent(in) :: self
type(Logger), intent(inout) :: aLog
call LogMessage(aLog, TRACE_LOGGING_LEVEL, logkey, " Edges Stats : ")
call StartSection(aLog)
call LogMessage(aLog, TRACE_LOGGING_LEVEL, "edges.N = ", self%N )
call LogMessage(aLog, TRACE_LOGGING_LEVEL, "edges.N_Max = ", self%N_Max)
call LogMessage(aLog, TRACE_LOGGING_LEVEL, "n divided edges = ", count(self%hasChildren) )
call LogMessage(aLog, TRACE_LOGGING_LEVEL, "n leaf edges = ", self%N - count(self%hasChildren))
call EndSection(aLog)
end subroutine
subroutine NewPrivate(self, nMax )
type(Edges), intent(out) :: self
integer(kint), intent(in) :: nMax
if ( .NOT. logInit ) call InitLogger(log, procRank )
if ( nMax <= 0 ) then
call LogMessage(log, ERROR_LOGGING_LEVEL, logkey, "New Edges ERROR : invalid nMax.")
return
endif
self%N_Max = nMax
self%N = 0
allocate(self%orig(nMax))
self%orig = 0
allocate(self%dest(nMax))
self%dest = 0
allocate(self%leftFace(nMax))
self%leftFace = 0
allocate(self%rightFace(nMax))
self%rightFace = 0
allocate(self%hasChildren(nMax))
self%hasChildren = .FALSE.
allocate(self%child1(nMax))
self%child1 = 0
allocate(self%child2(nMax))
self%child2 = 0
allocate(self%parent(nMax))
self%parent = 0
end subroutine
subroutine deletePrivate(self)
type(Edges), intent(inout) :: self
if ( associated(self%orig)) deallocate(self%orig)
if ( associated(self%dest)) deallocate(self%dest)
if ( associated(self%leftFace)) deallocate(self%leftFace)
if ( associated(self%rightFace)) deallocate(self%rightFace)
if ( associated(self%hasChildren)) deallocate(self%hasChildren)
if ( associated(self%child1)) deallocate(self%child1)
if ( associated(self%child2)) deallocate(self%child2)
if ( associated(self%parent)) deallocate(self%parent)
end subroutine
subroutine copyPrivate( self, other )
type(Edges), intent(inout) :: self
type(Edges), intent(in) :: other
!
integer(kint) :: j
if ( self%N_Max < other%N ) then
call LogMessage( log, ERROR_LOGGING_LEVEL, logkey, "CopyEdges ERROR : not enough memory.")
return
endif
do j = 1, other%N
self%orig(j) = other%orig(j)
self%dest(j) = other%dest(j)
self%leftFace(j) = other%leftFace(j)
self%rightFace(j) = other%rightFace(j)
self%hasChildren(j) = other%hasChildren(j)
self%child1(j) = other%child1(j)
self%child2(j) = other%child2(j)
self%parent(j) = other%parent(j)
enddo
self%N = other%N
end subroutine
subroutine InsertEdge( self, aParticles, origIndex, destIndex, leftFace, rightFace )
type(Edges), intent(inout) :: self
type(Particles), intent(inout) :: aParticles
integer(kint), intent(in) :: origIndex, destIndex, leftFace, rightFace
!
integer(kint) :: n
if ( self%N >= self%N_Max ) then
call LogMessage(log, ERROR_LOGGING_LEVEL, logKey, " InsertEdge : out of memory. ")
return
endif
n = self%N
self%orig( n + 1 ) = origIndex
self%dest( n + 1 ) = destIndex
self%leftFace( n + 1) = leftFace
self%rightFace(n + 1) = rightFace
call RecordIncidentEdgeAtParticles( self, n + 1, aParticles )
self%N = n + 1
end subroutine
function countParentEdges( self, index )
integer(kint) :: countParentEdges
type(Edges), intent(in) :: self
integer(kint), intent(in) :: index
!
logical(klog) :: keepGoing
integer(kint) :: parentIndex
countParentEdges = 0
keepGoing = ( self%parent(index) > 0 )
parentIndex = self%parent(index)
do while ( keepGoing )
countParentEdges = countParentEdges + 1
parentIndex = self%parent( parentIndex )
keepGoing = ( self%parent(parentIndex) > 0 )
enddo
end function
function MaxEdgeLength( self, aParticles )
real(kreal) :: MaxEdgeLength
type(Edges), intent(in) :: self
type(Particles), intent(in) :: aParticles
!
integer(kint) :: i
real(kreal) :: testLength
MaxEdgeLength = 0.0_kreal
do i = 1, self%N
if ( .NOT. self%hasChildren(i) ) then
testLength = EdgeLength(self, i, aParticles)
if ( testLength > MaxEdgeLength ) MaxEdgeLength = testLength
endif
enddo
end function
function EdgeLength(self, edgeIndex, aParticles )
real(kreal) :: EdgeLength
integer(kint), intent(in) :: edgeIndex
type(Edges), intent(in) :: self
type(Particles), intent(in) :: aParticles
!
real(kreal) :: v0(3), v1(3)
v0 = PhysCoord(aParticles, self%orig(edgeIndex))
v1 = PhysCoord(aParticles, self%dest(edgeIndex))
EdgeLength = 0.0_kreal
if ( aParticles%geomKind == SPHERE_GEOM ) then
EdgeLength = SphereDistance( v0, v1 )
else
EdgeLength = ChordDistance(v0, v1)
endif
end function
subroutine RecordIncidentEdgeAtParticles( self, edgeIndex, aParticles )
type(Edges), intent(in) :: self
integer(kint), intent(in) :: edgeIndex
type(Particles), intent(inout) :: aParticles
!
logical :: duplicateEdge
integer(kint) :: j, origParticle, destParticle
real(kreal) :: angleVal
if ( self%hasChildren(edgeIndex) ) then
return
else
origParticle = self%orig(edgeIndex)
destParticle = self%dest(edgeIndex)
!
! origin vertex
!
duplicateEdge = .FALSE.
do j = 1, aParticles%nEdges( origParticle )
if ( aParticles%incidentEdges( j, origParticle ) == edgeIndex ) duplicateEdge = .TRUE.
enddo
if ( .NOT. duplicateEdge ) then
if ( aParticles%nEdges( origParticle ) >= MAX_VERTEX_DEGREE ) then
call LogMessage(log,ERROR_LOGGING_LEVEL,logkey, " recordEdgeAtOrigin : out of memory.")
return
endif
angleVal = edgeAngleAtOrig( self, edgeIndex, aParticles)
aParticles%incidentEdges( aParticles%nEdges( origParticle ) + 1, origParticle ) = edgeIndex
aParticles%incidentAngles(aParticles%nEdges( origParticle ) + 1, origParticle ) = angleVal
aParticles%nEdges(origParticle) = aParticles%nEdges(origParticle) + 1
endif
!
! destination vertex
!
duplicateEdge = .FALSE.
do j = 1, aParticles%nEdges( self%dest( edgeIndex ))
if ( aParticles%incidentEdges( j, self%dest(edgeIndex)) == edgeIndex ) duplicateEdge = .TRUE.
enddo
if ( .NOT. duplicateEdge ) then
if ( aParticles%nEdges( destParticle) >= MAX_VERTEX_DEGREE ) then
call LogMessage(log,ERROR_LOGGING_LEVEL,logkey, " recordEdgeAtDestination : out of memory.")
return
endif
angleVal = edgeAngleAtDest( self, edgeIndex, aParticles )
aParticles%incidentEdges( aParticles%nEdges(destParticle) + 1, destParticle ) = edgeIndex
aParticles%incidentAngles(aParticles%nEdges(destParticle) + 1, destParticle ) = angleVal
aParticles%nEdges(destParticle) = aParticles%nEdges(destParticle) + 1
endif
endif
end subroutine
function edgeAngleAtOrig( self, edgeIndex, aParticles )
real(kreal) :: edgeAngleAtOrig
type(Edges), intent(in) :: self
integer(kint), intent(in) :: edgeIndex
type(Particles), intent(in) :: aParticles
!
real(kreal) :: edge1Vec(3), newEdgeVec(3), cp(3)
edgeAngleAtOrig = 0.0_kreal
if ( aParticles%geomKind == PLANAR_GEOM ) then
!
! define angle relative to positive real axis
!
edgeAngleAtOrig = atan2( aParticles%y( self%dest(edgeIndex)) - aParticles%y( self%orig(edgeIndex)), &
aParticles%x( self%dest(edgeIndex)) - aParticles%x( self%orig(edgeIndex)) )
elseif ( aParticles%geomKind == SPHERE_GEOM ) then
!
! define angle relative to first edge at particle
!
if ( aParticles%nEdges( self%orig(edgeIndex) ) > 1 ) then
if ( self%orig(aParticles%incidentEdges(1,self%orig(edgeIndex))) == self%orig(edgeIndex) ) then
edge1Vec = edgeVector( self, aParticles%incidentEdges(1,self%orig(edgeIndex)), aParticles )
elseif ( self%dest(aParticles%incidentEdges(1,self%orig(edgeIndex))) == self%orig(edgeIndex) ) then
edge1Vec = -edgeVector(self, aParticles%incidentEdges(1,self%orig(edgeIndex)), aParticles)
else
call LogMessage(log, ERROR_LOGGING_LEVEL, "edgeAngleAtOrig : ", "connectivity error.")
return
endif
newEdgeVec = edgeVector( self, edgeIndex, aParticles)
edge1Vec = edge1Vec/sqrt(sum( edge1Vec*edge1Vec))
newEdgeVec = newEdgeVec/sqrt(sum( newEdgeVec*newEdgeVec))
cp = crossProduct(edge1Vec, newEdgeVec)
edgeAngleAtOrig = atan2( sqrt(sum(cp*cp)), sum(edge1Vec*newEdgeVec))
endif
else
call LogMessage(log, WARNING_LOGGING_LEVEL, logkey, " geomKind not implemented yet.")
endif
end function
function edgeAngleAtDest( self, edgeIndex, aParticles )
real(kreal) :: edgeAngleAtDest
type(Edges), intent(in) :: self
integer(kint), intent(in) :: edgeIndex
type(Particles), intent(in) :: aParticles
!
real(kreal) :: edge1Vec(3), newEdgeVec(3), cp(3)
edgeAngleAtDest = 0.0_kreal
if ( aParticles%geomKind == PLANAR_GEOM ) then
!
! define angle relative to positive real axis
!
edgeAngleAtDest = atan2( aParticles%y( self%orig(edgeIndex)) - aParticles%y( self%dest(edgeIndex)), &
aParticles%x( self%orig(edgeIndex)) - aParticles%x( self%dest(edgeIndex)) )
elseif ( aParticles%geomKind == SPHERE_GEOM ) then
!
! define angle relative to first edge at particle
!
if ( aParticles%nEdges( self%dest(edgeIndex) ) > 1 ) then
if ( self%orig(aParticles%incidentEdges(1,self%dest(edgeIndex))) == self%dest(edgeIndex) ) then
edge1Vec = edgeVector(self, aParticles%incidentEdges(1,self%dest(edgeIndex)), aParticles)
elseif ( self%dest(aParticles%incidentEdges(1,self%dest(edgeIndex))) == self%dest(edgeIndex)) then
edge1Vec = -edgeVector(self, aParticles%incidentEdges(1,self%dest(edgeIndex)), aParticles)
else
call LogMessage(log, ERROR_LOGGING_LEVEL, "edgeAngleAtDest : ", "connectivity error.")
return
endif
endif
newEdgeVec = -edgeVector(self,edgeIndex,aParticles)
edge1Vec = edge1Vec/sqrt(sum( edge1Vec*edge1Vec))
newEdgeVec = newEdgeVec/sqrt(sum( newEdgeVec*newEdgeVec))
cp = crossProduct(edge1Vec, newEdgeVec)
edgeAngleAtDest = atan2( sqrt(sum(cp*cp)), sum(edge1Vec*newEdgeVec))
else
call LogMessage(log, WARNING_LOGGING_LEVEL, logkey, " geomKind not implemented yet.")
endif
end function
function edgeVector( self, edgeIndex, aParticles )
real(kreal), dimension(3) :: edgeVector
type(Edges), intent(in) :: self
integer(kint), intent(in) :: edgeIndex
type(Particles), intent(in) :: aParticles
edgeVector(1) = aParticles%x( self%dest(edgeIndex)) - aParticles%x( self%orig(edgeIndex))
edgeVector(2) = aParticles%y( self%dest(edgeIndex)) - aParticles%y( self%orig(edgeIndex))
if ( associated( aParticles%z ) ) then
edgeVector(3) = aParticles%z( self%dest(edgeIndex)) - aParticles%z( self%orig(edgeIndex))
else
edgeVector(3) = 0.0_kreal
endif
end function
subroutine DivideEdge( self, edgeIndex, aParticles )
type(Edges), intent(inout) :: self
integer(kint), intent(in) :: edgeIndex
type(Particles), intent(inout) :: aParticles
!
real(kreal) :: midPt(3), lagMidPt(3), v0(3), v1(3), lV0(3), lV1(3)
integer(kint) :: pInsertIndex
if ( self%N + 2 > self%N_Max ) then
call LogMessage(log, ERROR_LOGGING_LEVEL, logkey, " DivideEdge : out of memory.")
return
endif
v0 = PhysCoord(aParticles, self%orig(edgeIndex))
lV0 = LagCoord(aParticles, self%orig(edgeIndex))
v1 = PhysCoord(aParticles, self%dest(edgeIndex))
lV1 = LagCoord(aParticles, self%dest(edgeIndex))
if ( aParticles%geomKind == SPHERE_GEOM ) then
midPt = SphereMidpoint( v0, v1 )
lagMidPt = SphereMidpoint( lv0, lv1 )
else
midPt = 0.5_kreal * (v0 + v1)
lagMidPt = 0.5_kreal * ( lv0 + lv1)
endif
pInsertIndex = aParticles%N+1
call InsertParticle( aParticles, midPt, lagMidPt )
self%hasChildren(edgeIndex) = .TRUE.
self%child1(edgeIndex) = self%N + 1
self%child2(edgeIndex) = self%N + 2
self%parent(self%N+1) = edgeIndex
self%parent(self%N+2) = edgeIndex
self%orig( self%N + 1 ) = self%orig(edgeIndex)
self%dest( self%N + 1 ) = pInsertIndex
self%leftFace( self%N + 1 ) = self%leftFace( edgeIndex )
self%rightFace(self%N + 1 ) = self%rightFace( edgeIndex)
self%orig( self%N + 2 ) = pInsertIndex
self%dest( self%N + 2 ) = self%dest(edgeIndex)
self%leftFace( self%N + 2 ) = self%leftFace( edgeIndex )
self%rightFace(self%N + 1 ) = self%rightFace( edgeIndex)
call replaceIncidentEdgeWithChild( self, edgeIndex, aParticles)
call RecordIncidentEdgeAtParticles(self, self%N + 1, aParticles)
call RecordIncidentEdgeAtParticles(self, self%N + 2, aParticles)
self%N = self%N + 2
end subroutine
subroutine replaceIncidentEdgeWithChild( self, parentIndex, aParticles )
type(Edges), intent(in) :: self
integer(kint), intent(in) :: parentIndex
type(Particles), intent(inout) :: aParticles
!
integer(kint) :: j, pEdgeIndex
!
! replace parent edge at origin vertex
!
pEdgeIndex = 0
do j = 1, aParticles%nEdges( self%orig(parentIndex) )
if ( aParticles%incidentEdges( j, self%orig(parentIndex) ) == parentIndex ) then
pEdgeIndex = j
exit
endif
enddo
if ( pEdgeIndex == 0 ) then
call LogMessage(log, ERROR_LOGGING_LEVEL, logkey, "replaceIncidentEdgeWithChild ERROR : Parent not found.")
return
endif
aParticles%incidentEdges( pEdgeIndex, self%orig(parentIndex)) = self%child1(parentIndex)
!
! replace parent edge at destination vertex
!
pEdgeIndex = 0
do j = 1, aParticles%nEdges( self%dest(parentIndex) )
if ( aParticles%incidentEdges(j, self%dest(parentIndex)) == parentIndex ) then
pEdgeIndex = j
exit
endif
enddo
if ( pEdgeIndex == 0 ) then
call LogMessage(log, ERROR_LOGGING_LEVEL, logkey, "replaceIncidentEdgeWithChild ERROR : Parent not found.")
return
endif
aParticles%incidentEdges( pEdgeIndex, self%dest(parentIndex)) = self%child2(parentIndex)
end subroutine
function positiveEdge( anEdges, faceIndex, edgeIndex )
logical(klog) :: positiveEdge
type(Edges), intent(in) :: anEdges
integer(kint), intent(in) :: faceIndex
integer(kint), intent(in) :: edgeIndex
positiveEdge = ( faceIndex == anEdges%leftFace(edgeIndex))
end function
function onBoundary( anEdges, edgeIndex )
logical(klog) :: onBoundary
type(Edges), intent(in) :: anEdges
integer(kint), intent(in) :: edgeIndex
onBoundary = ( anEdges%leftFace(edgeIndex) < 1 .OR. anEdges%rightFace(edgeIndex) < 1 )
end function
subroutine GetLeafEdgesFromParent( anEdges, parentIndex, leafEdges )
type(Edges), intent(in) :: anEdges
integer(kint), intent(in) :: parentIndex
type(STDIntVector), intent(out) :: leafEdges
!
integer(kint) :: i, nLeaves
logical(klog) :: keepGoing
call initialize(leafEdges)
call leafEdges%pushBack(parentIndex)
nLeaves = 1
keepGoing = .FALSE.
if ( anEdges%hasChildren(parentIndex) ) keepGoing = .TRUE.
do while (keepGoing)
do i = 1, nLeaves
if ( anEdges%hasChildren( leafEdges%int(i) ) ) then
call leafEdges%replace(i, anEdges%child1(i) )
call leafEdges%insert(i+1, anEdges%child2(i))
endif
enddo
nLeaves = leafEdges%N
keepGoing = .FALSE.
do i = 1, nLeaves
if ( anEdges%hasChildren(leafEdges%int(i)) ) keepGoing = .TRUE.
enddo
enddo
end subroutine
function AreaFromLeafEdges( self, aParticles, centerParticle, leafEdges, nLeaves )
real(kreal) :: AreaFromLeafEdges
type(Edges), intent(in) :: self
type(Particles), intent(in) :: aParticles
integer(kint), intent(in) :: centerParticle
integer(kint), intent(in) :: leafEdges(:)
integer(kint), intent(in) :: nLeaves
!
integer(kint) :: i
real(kreal) :: centerVec(3), v1Vec(3), v2Vec(3)
AreaFromLeafEdges = 0.0_kreal
centerVec = PhysCoord( aParticles, centerParticle )
if ( aParticles%geomKind == PLANAR_GEOM ) then
do i = 1, nLeaves
v1Vec = PhysCoord( aParticles, self%orig(leafEdges(i)) )
v2Vec = PhysCoord( aParticles, self%dest(leafEdges(i)) )
AreaFromLeafEdges = AreaFromLeafEdges + TriArea( v1Vec(1:2), centerVec(1:2), v2Vec(1:2) )
enddo
elseif ( aParticles%geomKind == SPHERE_GEOM ) then
do i = 1, nLeaves
v1Vec = PhysCoord( aParticles, self%orig(leafEdges(i)) )
v2Vec = PhysCoord( aParticles, self%dest(leafEdges(i)) )
AreaFromLeafEdges = AreaFromLeafEdges + SphereTriArea( v1Vec, centerVec, v2Vec )
enddo
else
call LogMessage(log,ERROR_LOGGING_LEVEL,logkey//" AreaFromLeafEdges ERROR : ", "geomKind not implemented.")
return
endif
end function
subroutine InitLogger(aLog,rank)
! Initialize a logger for this module and processor
type(Logger), intent(out) :: aLog
integer(kint), intent(in) :: rank
write(logKey,'(A,A,I0.3,A)') trim(logKey),'_',rank,' : '
call New(aLog,logLevel)
logInit = .TRUE.
end subroutine
!> @}
end module