aboutsummaryrefslogtreecommitdiff
path: root/src/smooth.F90
blob: 4e0010519d260516872efc1b3ac632dc353d657c (plain)
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
! $Header$

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Functions.h"
#include "cctk_Parameters.h"

subroutine NoExcision_Smooth (CCTK_ARGUMENTS)
  implicit none
  DECLARE_CCTK_ARGUMENTS
  DECLARE_CCTK_FUNCTIONS
  DECLARE_CCTK_PARAMETERS

  CCTK_REAL, parameter :: zero=0
  CCTK_REAL :: mask (cctk_lsh(1), cctk_lsh(2), cctk_lsh(3))
  CCTK_REAL :: cx, cy, cz, radx, rady, radz
  integer   :: n
  integer   :: iter
  integer   :: ierr
  
  do iter = 1, smoothing_iterations
     
     do n = 1, num_regions
        
        cx = centre_x(n)
        cy = centre_y(n)
        cz = centre_z(n)
        if (CCTK_EQUALS(region_shape(n), "sphere")) then
           radx = radius(n)
           rady = radius(n)
           radz = radius(n)
        else if (CCTK_EQUALS(region_shape(n), "ellipsoid")) then
           radx = radius_x(n)
           rady = radius_y(n)
           radz = radius_z(n)
        else
           call CCTK_WARN (0, "internal error")
        end if
        
        mask = 1 - sqrt (((x - cx) / radx)**2 + &
             &           ((y - cy) / rady)**2 + &
             &           ((z - cz) / radz)**2)
        where (mask <= 0)
           mask = 0             ! outside
        elsewhere (mask >= smoothing_zone_width(n))
           mask = 1             ! far inside
        elsewhere
           mask = mask / smoothing_zone_width(n) ! a bit inside
        end where
        
        if (overwrite_geometry(n) /= 0) then
           
           if (conformal_state >= 1) then
              call smooth (psi)
           end if
           if (conformal_state >= 2) then
              call smooth (psix)
              call smooth (psiy)
              call smooth (psiz)
           end if
           if (conformal_state >= 3) then
              call smooth (psixx)
              call smooth (psixy)
              call smooth (psixz)
              call smooth (psiyy)
              call smooth (psiyz)
              call smooth (psizz)
           end if
           
           call smooth (gxx)
           call smooth (gxy)
           call smooth (gxz)
           call smooth (gyy)
           call smooth (gyz)
           call smooth (gzz)
           call smooth (kxx)
           call smooth (kxy)
           call smooth (kxz)
           call smooth (kyy)
           call smooth (kyz)
           call smooth (kzz)
           
        end if
        
        if (overwrite_lapse(n) /= 0) then
           
           call smooth (alp)
           
        end if
        
        if (overwrite_shift(n) /= 0) then
           
           if (shift_state /= 0) then
              call smooth (betax)
              call smooth (betay)
              call smooth (betaz)
           end if
           
        end if
        
     end do
     
     if (overwrite_geometry(n) /= 0) then
        
        if (conformal_state >= 1) then
           call CCTK_SyncGroup (ierr, cctkGH, "StaticConformal::confac")
        end if
        if (conformal_state >= 2) then
           call CCTK_SyncGroup (ierr, cctkGH, "StaticConformal::confac_1derivs")
        end if
        if (conformal_state >= 3) then
           call CCTK_SyncGroup (ierr, cctkGH, "StaticConformal::confac_2derivs")
        end if
        
        call CCTK_SyncGroup (ierr, cctkGH, "ADMBase::metric")
        call CCTK_SyncGroup (ierr, cctkGH, "ADMBase::curv")
        
     end if
     
     if (overwrite_lapse(n) /= 0) then
        
        call CCTK_SyncGroup (ierr, cctkGH, "ADMBase::lapse")
        
     end if
     
     if (overwrite_shift(n) /= 0) then
        
        if (shift_state /= 0) then
           call CCTK_SyncGroup (ierr, cctkGH, "ADMBase::shift")
        end if
        
     end if
     
  end do
  
contains
  
  subroutine smooth (val)
    CCTK_REAL, intent(inout) :: val(:,:,:)
    
    where (mask > 0)
       val =  (1 - mask * smoothing_factor) * val &
            & + (mask * smoothing_factor / 6) &
            &   * (+ eoshift(val, +1, dim=1) + eoshift(val, -1, dim=1) &
            &      + eoshift(val, +1, dim=2) + eoshift(val, -1, dim=2) &
            &      + eoshift(val, +1, dim=3) + eoshift(val, -1, dim=3))
    end where
  end subroutine smooth
  
end subroutine NoExcision_Smooth