Neko  0.8.1
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 !
35  use num_types, only : rp
37  use coefs, only : coef_t
38  use device, only : device_free
39  use, intrinsic :: iso_c_binding, only : c_associated
40  use json_utils, only : json_get
41  use json_module, only : json_file
42  implicit none
43  private
44 
45  public :: advection_factory
46 
47 contains
48 
54  subroutine advection_factory(this, json, coef)
55  implicit none
56  class(advection_t), allocatable, intent(inout) :: this
57  type(json_file), intent(inout) :: json
58  type(coef_t), target :: coef
59  logical :: dealias, found
60  integer :: lxd, order
61 
62  call json_get(json, 'case.numerics.dealias', dealias)
63  call json%get('case.numerics.dealiased_polynomial_order', lxd, found)
64  if (.not. found) then
65  call json_get(json, 'case.numerics.polynomial_order', order)
66  ! Note, assumes odd polynomial order
67  lxd = 3.0_rp / 2.0_rp * (order + 1)
68  end if
69 
70  ! Free allocatables if necessary
71  if (allocated(this)) then
72  call this%free
73  deallocate(this)
74  end if
75 
76  if (dealias) then
77  allocate(adv_dealias_t::this)
78  else
79  allocate(adv_no_dealias_t::this)
80  end if
81 
82  select type(adv => this)
83  type is(adv_dealias_t)
84  if (lxd .gt. 0) then
85  call adv%init(lxd, coef)
86  else
87  call adv%init(coef%Xh%lx * 3/2, coef)
88  end if
89  type is(adv_no_dealias_t)
90  call adv%init(coef)
91  end select
92 
93  end subroutine advection_factory
94 
95 
96 end module advection_fctry
Retrieves a parameter by name or throws an error.
Definition: json_utils.f90:44
Contains the factory routine for advection_t children.
subroutine, public advection_factory(this, json, coef)
A factory for advection_t decendants.
Subroutines to add advection terms to the RHS of a transport equation.
Definition: advection.f90:34
Coefficients.
Definition: coef.f90:34
Device abstraction, common interface for various accelerators.
Definition: device.F90:34
subroutine, public device_free(x_d)
Deallocate memory on the device.
Definition: device.F90:172
Utilities for retrieving parameters from the case files.
Definition: json_utils.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Type encapsulating advection routines with dealiasing.
Definition: advection.f90:79
Type encapsulating advection routines with no dealiasing applied.
Definition: advection.f90:61
Base abstract type for computing the advection operator.
Definition: advection.f90:53
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition: coef.f90:54