Neko  0.8.1
A portable framework for high-order spectral element flow simulations
mathops.f90
Go to the documentation of this file.
1 ! Copyright (c) 2008-2020, UCHICAGO ARGONNE, LLC.
2 !
3 ! The UChicago Argonne, LLC as Operator of Argonne National
4 ! Laboratory holds copyright in the Software. The copyright holder
5 ! reserves all rights except those expressly granted to licensees,
6 ! and U.S. Government license rights.
7 !
8 ! Redistribution and use in source and binary forms, with or without
9 ! modification, are permitted provided that the following conditions
10 ! are met:
11 !
12 ! 1. Redistributions of source code must retain the above copyright
13 ! notice, this list of conditions and the disclaimer below.
14 !
15 ! 2. Redistributions in binary form must reproduce the above copyright
16 ! notice, this list of conditions and the disclaimer (as noted below)
17 ! in the documentation and/or other materials provided with the
18 ! distribution.
19 !
20 ! 3. Neither the name of ANL nor the names of its contributors
21 ! may be used to endorse or promote products derived from this software
22 ! without specific prior written permission.
23 !
24 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 ! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28 ! UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
29 ! ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31 ! TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 !
37 ! Additional BSD Notice
38 ! ---------------------
39 ! 1. This notice is required to be provided under our contract with
40 ! the U.S. Department of Energy (DOE). This work was produced at
41 ! Argonne National Laboratory under Contract
42 ! No. DE-AC02-06CH11357 with the DOE.
43 !
44 ! 2. Neither the United States Government nor UCHICAGO ARGONNE,
45 ! LLC nor any of their employees, makes any warranty,
46 ! express or implied, or assumes any liability or responsibility for the
47 ! accuracy, completeness, or usefulness of any information, apparatus,
48 ! product, or process disclosed, or represents that its use would not
49 ! infringe privately-owned rights.
50 !
51 ! 3. Also, reference herein to any specific commercial products, process,
52 ! or services by trade name, trademark, manufacturer or otherwise does
53 ! not necessarily constitute or imply its endorsement, recommendation,
54 ! or favoring by the United States Government or UCHICAGO ARGONNE LLC.
55 ! The views and opinions of authors expressed
56 ! herein do not necessarily state or reflect those of the United States
57 ! Government or UCHICAGO ARGONNE, LLC, and shall
58 ! not be used for advertising or product endorsement purposes.
59 !
60 
64 
65 module mathops
66  use num_types, only : rp
67  implicit none
68 
69 contains
70 
72  subroutine opchsign(a1, a2, a3, gdim, n)
73  integer, intent(in) :: n, gdim
74  real(kind=rp), dimension(n), intent(inout) :: a1, a2, a3
75  integer :: i
76 
77  if (gdim .eq. 3) then
78  do i = 1, n
79  a1(i) = -a1(i)
80  a2(i) = -a2(i)
81  a3(i) = -a3(i)
82  end do
83  else
84  do i = 1, n
85  a1(i) = -a1(i)
86  a2(i) = -a2(i)
87  end do
88  end if
89 
90  end subroutine opchsign
91 
93  subroutine opcolv(a1, a2, a3, c, gdim, n)
94  integer, intent(in) :: n, gdim
95  real(kind=rp), dimension(n), intent(inout) :: a1, a2, a3
96  real(kind=rp), dimension(n), intent(in) :: c
97  integer :: i
98 
99  if (gdim .eq. 3) then
100  do i = 1, n
101  a1(i) = a1(i)*c(i)
102  a2(i) = a2(i)*c(i)
103  a3(i) = a3(i)*c(i)
104  end do
105  else
106  do i = 1, n
107  a1(i) = a1(i)*c(i)
108  a2(i) = a2(i)*c(i)
109  end do
110  end if
111 
112  end subroutine opcolv
113 
115  subroutine opcolv3c(a1, a2, a3, b1, b2, b3, c, d, n, gdim)
116  integer, intent(in) :: n, gdim
117  real(kind=rp), dimension(n), intent(inout) :: a1, a2, a3
118  real(kind=rp), dimension(n), intent(in) :: b1, b2, b3
119  real(kind=rp), intent(in) :: c(n), d
120  integer :: i
121 
122  if (gdim .eq. 3) then
123  do i = 1, n
124  a1(i) = b1(i)*c(i)*d
125  a2(i) = b2(i)*c(i)*d
126  a3(i) = b3(i)*c(i)*d
127  end do
128  else
129  do i = 1, n
130  a1(i) = b1(i)*c(i)*d
131  a2(i) = b2(i)*c(i)*d
132  end do
133  endif
134 
135  end subroutine opcolv3c
136 
138  subroutine opadd2cm(a1, a2, a3, b1, b2, b3, c, n, gdim)
139  integer, intent(in) :: n, gdim
140  real(kind=rp), dimension(n), intent(inout) :: a1, a2, a3
141  real(kind=rp), dimension(n), intent(in) :: b1, b2, b3
142  real(kind=rp), intent(in) :: c
143  integer :: i
144 
145  if (gdim .eq. 3) then
146  do i = 1, n
147  a1(i) = a1(i) + b1(i)*c
148  a2(i) = a2(i) + b2(i)*c
149  a3(i) = a3(i) + b3(i)*c
150  end do
151  else
152  do i = 1, n
153  a1(i) = a1(i) + b1(i)*c
154  a2(i) = a2(i) + b2(i)*c
155  end do
156  endif
157 
158  end subroutine opadd2cm
159 
161  subroutine opadd2col(a1, a2, a3, b1, b2, b3, c, n, gdim)
162  integer, intent(in) :: n, gdim
163  real(kind=rp), dimension(n), intent(inout) :: a1, a2, a3
164  real(kind=rp), dimension(n), intent(in) :: b1, b2, b3
165  real(kind=rp), intent(in) :: c(n)
166  integer :: i
167 
168  if (gdim .eq. 3) then
169  do i = 1, n
170  a1(i) = a1(i) + b1(i)*c(i)
171  a2(i) = a2(i) + b2(i)*c(i)
172  a3(i) = a3(i) + b3(i)*c(i)
173  end do
174  else
175  do i = 1, n
176  a1(i) = a1(i) + b1(i)*c(i)
177  a2(i) = a2(i) + b2(i)*c(i)
178  end do
179  endif
180 
181  end subroutine opadd2col
182 
183 end module mathops
Collection of vector field operations operating on and . Note that in general the indices and ....
Definition: mathops.f90:65
subroutine opcolv3c(a1, a2, a3, b1, b2, b3, c, d, n, gdim)
Definition: mathops.f90:116
subroutine opchsign(a1, a2, a3, gdim, n)
for and .
Definition: mathops.f90:73
subroutine opcolv(a1, a2, a3, c, gdim, n)
Definition: mathops.f90:94
subroutine opadd2col(a1, a2, a3, b1, b2, b3, c, n, gdim)
Definition: mathops.f90:162
subroutine opadd2cm(a1, a2, a3, b1, b2, b3, c, n, gdim)
Definition: mathops.f90:139
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12