Neko  0.9.99
A portable framework for high-order spectral element flow simulations
advection_fctry.f90
Go to the documentation of this file.
1 ! Copyright (c) 2024, The Neko Authors
2 ! All rights reserved.
3 !
4 ! Redistribution and use in source and binary forms, with or without
5 ! modification, are permitted provided that the following conditions
6 ! are met:
7 !
8 ! * Redistributions of source code must retain the above copyright
9 ! notice, this list of conditions and the following disclaimer.
10 !
11 ! * Redistributions in binary form must reproduce the above
12 ! copyright notice, this list of conditions and the following
13 ! disclaimer in the documentation and/or other materials provided
14 ! with the distribution.
15 !
16 ! * Neither the name of the authors nor the names of its
17 ! contributors may be used to endorse or promote products derived
18 ! from this software without specific prior written permission.
19 !
20 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 ! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 ! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 ! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 ! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 ! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 ! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 ! POSSIBILITY OF SUCH DAMAGE.
32 !
34 submodule(advection) advection_fctry
36 
37  ! Advection and derivatives
38  use adv_dealias, only : adv_dealias_t
40  use adv_oifs, only : adv_oifs_t
41  use adv_dummy, only : adv_dummy_t
42 
43 
44 contains
45 
59  module subroutine advection_factory(object, json, coef, ulag, vlag, wlag, &
60  dtlag, tlag, time_scheme, use_dummy, slag)
61  class(advection_t), allocatable, intent(inout) :: object
62  type(json_file), intent(inout) :: json
63  type(coef_t), intent(inout), target :: coef
64  type(field_series_t), intent(in), target :: ulag, vlag, wlag
65  real(kind=rp), intent(in), target :: dtlag(10)
66  real(kind=rp), intent(in), target :: tlag(10)
67  type(time_scheme_controller_t), intent(in), target :: time_scheme
68  logical, optional, intent(in) :: use_dummy
69  type(field_series_t), target, optional, intent(in) :: slag
70 
71  logical :: dealias, oifs
72  real(kind=rp) :: ctarget
73  integer :: lxd, order
74 
75  ! Free allocatables if necessary
76  if (allocated(object)) then
77  call object%free
78  deallocate(object)
79  end if
80 
81  if (present(use_dummy)) then
82  if (use_dummy .eqv. .true.) then
83  allocate(adv_dummy_t::object)
84  return
85  end if
86  end if
87 
88  ! Read the parameters from the json file
89  call json_get(json, 'case.numerics.dealias', dealias)
90  call json_get(json, 'case.numerics.polynomial_order', order)
91  call json_get_or_default(json, 'case.numerics.oifs', oifs, .false.)
92 
93  call json_get_or_default(json, 'case.numerics.dealiased_polynomial_order', &
94  lxd, ( 3 * (order + 1) ) / 2)
95 
96  call json_get_or_default(json, 'case.numerics.target_cfl', ctarget, 1.9_rp)
97 
98 
99  if (oifs) then
100  allocate(adv_oifs_t::object)
101  else
102  if (dealias) then
103  allocate(adv_dealias_t::object)
104  else
105  allocate(adv_no_dealias_t::object)
106  end if
107  end if
108 
109  select type (adv => object)
110  type is (adv_dealias_t)
111  call adv%init(lxd, coef)
112  type is (adv_no_dealias_t)
113  call adv%init(coef)
114  type is (adv_oifs_t)
115  if (present(slag)) then
116  call adv%init(lxd, coef, ctarget, ulag, vlag, wlag, &
117  dtlag, tlag, time_scheme, slag)
118  else
119  call adv%init(lxd, coef, ctarget, ulag, vlag, wlag, &
120  dtlag, tlag, time_scheme)
121  end if
122  end select
123 
124  end subroutine advection_factory
125 
126 
127 end submodule advection_fctry
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Definition: json_utils.f90:54
Retrieves a parameter by name or throws an error.
Definition: json_utils.f90:45
Subroutines to add advection terms to the RHS of a transport equation.
Definition: adv_dealias.f90:34
Implements adv_dummy_t
Definition: adv_dummy.f90:34
Subroutines to add advection terms to the RHS of a transport equation.
Subroutines to add advection terms to the RHS of a transport equation.
Definition: adv_oifs.f90:34
Subroutines to add advection terms to the RHS of a transport equation.
Definition: advection.f90:34
Utilities for retrieving parameters from the case files.
Definition: json_utils.f90:34
Base class for time integration schemes.
Definition: time_scheme.f90:61
Type encapsulating advection routines with dealiasing.
Definition: adv_dealias.f90:52
A zero-valued advection that can be used to kill the advection term.
Definition: adv_dummy.f90:44
Type encapsulating advection routines with no dealiasing applied.