Neko  0.9.0
A portable framework for high-order spectral element flow simulations
bdf_time_scheme.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 !
62  use neko_config
63  use num_types, only : rp
64  use time_scheme, only: time_scheme_t
65  use math, only : rzero
66  use utils, only : neko_error
67  implicit none
68  private
69 
103  type, public, extends(time_scheme_t) :: bdf_time_scheme_t
104  contains
107  end type bdf_time_scheme_t
108 
109 contains
110 
114  subroutine bdf_time_scheme_compute_coeffs(coeffs, dt, order)
115  implicit none
116  real(kind=rp), intent(out) :: coeffs(4)
117  real(kind=rp), intent(in) :: dt(10)
118  integer, intent(in) :: order
119 
120  call rzero(coeffs, 4)
121 
122  ! Note, these are true coeffs, multiplied by dt(1)
123  select case (order)
124  case (1)
125  coeffs(1) = 1.0_rp
126  coeffs(2) = 1.0_rp
127  case (2)
128  coeffs(1) = (1 + dt(1)/(dt(1) + dt(2)))
129  coeffs(3) = -dt(1)**2/dt(2)/(dt(1) + dt(2))
130  coeffs(2) = coeffs(1) - coeffs(3)
131  case (3)
132  coeffs(2) = (dt(1) + dt(2)) * (dt(1) + dt(2) + dt(3)) / &
133  (dt(1) * dt(2) * (dt(2) + dt(3)))
134  coeffs(3) = -dt(1) * (dt(1) + dt(2) + dt(3)) / &
135  (dt(2) * dt(3) * (dt(1) + dt(2)))
136  coeffs(4) = dt(1) * (dt(1) + dt(2)) / &
137  (dt(3) * (dt(2) + dt(3)) * (dt(1) + dt(2) + dt(3)))
138  coeffs(1) = coeffs(2) + coeffs(3) + coeffs(4)
139  coeffs = coeffs * dt(1)
140  case default
141  call neko_error("The order of the BDF time scheme must be 1 to 3.")
142  end select
143 
144  end subroutine bdf_time_scheme_compute_coeffs
145 
146 end module bdf_time_scheme
Interface for setting the scheme coefficients.
Definition: time_scheme.f90:79
Backward-differencing scheme for time integration.
subroutine bdf_time_scheme_compute_coeffs(coeffs, dt, order)
Compute the scheme coefficients.
Definition: math.f90:60
subroutine, public rzero(a, n)
Zero a real vector.
Definition: math.f90:195
Build configurations.
Definition: neko_config.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Base class for time integration schemes.
Definition: time_scheme.f90:61
Utilities.
Definition: utils.f90:35
Implicit backward-differencing scheme for time integration.
Base abstract class for time integration schemes.
Definition: time_scheme.f90:69