FLASH-X
Doxygen Generated Documentation From Interface Source Code
ut_contourSurfaceAreaBlock.F90
Go to the documentation of this file.
1!! NOTICE
2!! Copyright 2022 UChicago Argonne, LLC and contributors
3!!
4!! Licensed under the Apache License, Version 2.0 (the "License");
5!! you may not use this file except in compliance with the License.
6!!
7!! Unless required by applicable law or agreed to in writing, software
8!! distributed under the License is distributed on an "AS IS" BASIS,
9!! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10!! See the License for the specific language governing permissions and
11!! limitations under the License.
12!!
30
31subroutine ut_contourSurfaceAreaBlock(nlevels,isolevels,ctrData, blkLimits, blkIndex, areas)
32
33use Grid_interface, ONLY : Grid_getDeltas, Grid_getBlkBoundBox
35
36 implicit none
37#include "Simulation.h"
38#include "constants.h"
39
40 integer, intent(IN) :: nlevels
41 real,dimension(nlevels), intent(IN) :: isolevels
42 real,dimension(:,:,:), intent(IN) :: ctrData
43 integer,dimension(HIGH,MDIM),intent(IN) :: blkLimits
44 integer, intent(IN) :: blkIndex
45 real,dimension(nlevels), intent(OUT) :: areas
46
47 real, allocatable, dimension(:,:,:) :: mcData
48
49 integer, dimension(3) :: mcdataSize
50
51 integer :: i,j,k,ii,jj,kk, istat
52 real :: datamin, datamax
53 real, dimension(MDIM) :: deltas
54
55 real :: xmin,ymin,zmin,xmax,ymax,zmax
56 real, dimension(2,MDIM) :: boundBox
57
58 call Grid_getBlkBoundBox(blkIndex, boundBox)
59
60 xmin = boundBox(1,IAXIS)
61 ymin = boundBox(1,JAXIS)
62 zmin = boundBox(1,KAXIS)
63 xmax = boundBox(2,IAXIS)
64 ymax = boundBox(2,JAXIS)
65 zmax = boundBox(2,KAXIS)
66#if NDIM == 2
67 zmax = zmin+xmax-xmin
68#endif
69
70 call Grid_getDeltas(blkIndex, deltas)
71
72 if (NDIM==2) deltas(KAXIS) = deltas(IAXIS)
73
74 ! allocate space for data to be passed to marching cubes routines
75 ! need one layer of guard cells on all sides
76 ! always keep three cells in z direction for faking
77 mcdataSize(1) = blkLimits(HIGH,IAXIS)-blkLimits(LOW,IAXIS)+3
78 mcdataSize(2) = blkLimits(HIGH,JAXIS)-blkLimits(LOW,JAXIS)+3
79 mcdataSize(3) = blkLimits(HIGH,KAXIS)-blkLimits(LOW,KAXIS)+3
80 allocate(mcData(mcdataSize(1), mcdataSize(2), mcdataSize(3)),STAT=istat)
81 if (istat /= 0) call Driver_abort("Cannot allocate celldata in ut_contourSurfaceAreaBlock")
82
83 datamax = -HUGE(1.0)
84 datamin = HUGE(1.0)
85
86
87
88 if (NDIM==2) then
89
90 kk = blkLimits(LOW,KAXIS)
91 do j = 1, mcdataSize(2)
92 jj = blkLimits(LOW,JAXIS)-2 + j
93 do i = 1, mcdataSize(1)
94 ii = blkLimits(LOW,IAXIS)-2 + i
95 mcData(i,j,1) = ctrData(ii,jj,kk)
96 mcData(i,j,2) = mcData(i,j,1)
97 mcData(i,j,3) = mcData(i,j,1)
98 datamax = max(datamax,mcData(i,j,1))
99 datamin = min(datamin,mcData(i,j,1))
100 end do
101 end do
102
103 else if (NDIM==3) then
104
105 do k = 1, mcdataSize(3)
106 kk = blkLimits(LOW,KAXIS)-2 + k
107 do j = 1, mcdataSize(2)
108 jj = blkLimits(LOW,JAXIS)-2 + j
109 do i = 1, mcdataSize(1)
110 ii = blkLimits(LOW,IAXIS)-2 + i
111 mcData(i,j,k) = ctrData(ii,jj,kk)
112 datamax = max(datamax,mcData(i,j,k))
113 datamin = min(datamin,mcData(i,j,k))
114 end do
115 end do
116 end do
117
118 else
119
120 call Driver_abort("Surface area measurement only works in 2 or 3 dimensions")
121
122 endif
123
124 do i = 1, nlevels
125 if( datamin <= isolevels(i) .AND. isolevels(i) <= datamax ) then
126 call interior_iso_surface_area(mcData,mcdatasize(1),mcdataSize(2),mcdataSize(3), &
127 deltas(1),deltas(2),deltas(3),isolevels(i),areas(i))
128#if NDIM == 2
129 areas(i) = areas(i)/(zmax-zmin)
130#endif
131 else
132 areas(i) = 0.0
133 end if
134 enddo
135
136 deallocate(mcData)
137
138end subroutine ut_contourSurfaceAreaBlock
139
140
#define IAXIS
Definition: constants.h:130
#define JAXIS
Definition: constants.h:131
#define LOW
Definition: constants.h:144
#define KAXIS
Definition: constants.h:132
subroutine ut_contourSurfaceAreaBlock(nlevels, isolevels, ctrData, blkLimits, blkIndex, areas)