Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
math_ext.f90
Go to the documentation of this file.
1module math_ext
2 use num_types, only: rp, xp
3 use comm, only: neko_comm, mpi_extra_precision
4 use mpi_f08, only: mpi_allreduce, mpi_sum, mpi_in_place
5 implicit none
6
7contains
8
12 subroutine copy_mask(a, b, size, mask, mask_size)
13 integer, intent(in) :: size, mask_size
14 real(kind=rp), dimension(size), intent(inout) :: a
15 real(kind=rp), dimension(size), intent(in) :: b
16 integer, dimension(mask_size), intent(in) :: mask
17 integer :: i
18
19 do i = 1, mask_size
20 a(mask(i)) = b(mask(i))
21 end do
22
23 end subroutine copy_mask
24
27 subroutine cadd_mask(a, c, size, mask, mask_size)
28 integer, intent(in) :: size, mask_size
29 real(kind=rp), dimension(size), intent(inout) :: a
30 real(kind=rp), intent(in) :: c
31 integer, dimension(mask_size), intent(in) :: mask
32 integer :: i
33
34 do i = 1, mask_size
35 a(mask(i)) = a(mask(i)) + c
36 end do
37
38 end subroutine cadd_mask
39
42 subroutine invcol1_mask(a, size, mask, mask_size)
43 integer, intent(in) :: size, mask_size
44 real(kind=rp), dimension(size), intent(inout) :: a
45 integer, dimension(mask_size), intent(in) :: mask
46 integer :: i
47
48 do i = 1, mask_size
49 a(mask(i)) = 1.0_rp / a(mask(i))
50 end do
51
52 end subroutine invcol1_mask
53
56 subroutine cmult_mask(a, c, size, mask, mask_size)
57 integer, intent(in) :: size, mask_size
58 real(kind=rp), dimension(size), intent(inout) :: a
59 real(kind=rp), intent(in) :: c
60 integer, dimension(mask_size), intent(in) :: mask
61 integer :: i
62
63 do i = 1, mask_size
64 a(mask(i)) = c * a(mask(i))
65 end do
66
67 end subroutine cmult_mask
68
71 subroutine col2_mask(a, b, size, mask, mask_size)
72 integer, intent(in) :: size, mask_size
73 real(kind=rp), dimension(size), intent(inout) :: a
74 real(kind=rp), dimension(size), intent(in) :: b
75 integer, dimension(mask_size), intent(in) :: mask
76 integer :: i
77
78 do i = 1, mask_size
79 a(mask(i)) = a(mask(i)) * b(mask(i))
80 end do
81
82 end subroutine col2_mask
83
86 subroutine col3_mask(a, b, c, size, mask, mask_size)
87 integer, intent(in) :: size, mask_size
88 real(kind=rp), dimension(size), intent(inout) :: a
89 real(kind=rp), dimension(size), intent(in) :: b, c
90 integer, dimension(mask_size), intent(in) :: mask
91 integer :: i
92
93 do i = 1, mask_size
94 a(mask(i)) = b(mask(i)) * c(mask(i))
95 end do
96
97 end subroutine col3_mask
98
101 subroutine sub3_mask(a, b, c, size, mask, mask_size)
102 integer, intent(in) :: size, mask_size
103 real(kind=rp), dimension(size), intent(inout) :: a
104 real(kind=rp), dimension(size), intent(in) :: b, c
105 integer, dimension(mask_size), intent(in) :: mask
106 integer :: i
107
108 do i = 1, mask_size
109 a(mask(i)) = b(mask(i)) - c(mask(i))
110 end do
111
112 end subroutine sub3_mask
113
116 function glsc2_mask(a, b, size, mask, mask_size)
117 integer, intent(in) :: size, mask_size
118 real(kind=rp), dimension(size), intent(in) :: a
119 real(kind=rp), dimension(size), intent(in) :: b
120 integer, dimension(mask_size), intent(in) :: mask
121 real(kind=rp) :: glsc2_mask
122 real(kind=xp) :: tmp
123 integer :: i, ierr
124
125 tmp = 0.0_xp
126 do i = 1, mask_size
127 tmp = tmp + a(mask(i)) * b(mask(i))
128 end do
129
130 call mpi_allreduce(mpi_in_place, tmp, 1, &
131 mpi_extra_precision, mpi_sum, neko_comm, ierr)
132 glsc2_mask = tmp
133 end function glsc2_mask
134end module math_ext
subroutine col3_mask(a, b, c, size, mask, mask_size)
Multiply 2 masked vectors. Save the result in a new vector. .
Definition math_ext.f90:87
subroutine col2_mask(a, b, size, mask, mask_size)
Multiply 2 masked vectors. Save the result in a new vector. .
Definition math_ext.f90:72
subroutine invcol1_mask(a, size, mask, mask_size)
Invert a masked vector. .
Definition math_ext.f90:43
subroutine copy_mask(a, b, size, mask, mask_size)
Copy within a mask. NOTE, this differs from masked_copy in the indexing. .
Definition math_ext.f90:13
subroutine sub3_mask(a, b, c, size, mask, mask_size)
Subtract 2 masked vectors. Save the result in a new vector. .
Definition math_ext.f90:102
subroutine cmult_mask(a, c, size, mask, mask_size)
Multiply a masked vector by a constant. .
Definition math_ext.f90:57
subroutine cadd_mask(a, c, size, mask, mask_size)
Add a constant to a masked vector. .
Definition math_ext.f90:28
real(kind=rp) function glsc2_mask(a, b, size, mask, mask_size)
Weighted inner product for indices in the mask.
Definition math_ext.f90:117