Neko  0.8.99
A portable framework for high-order spectral element flow simulations
vreman.f90
Go to the documentation of this file.
1 ! Copyright (c) 2023, 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 !
33 !
35 module vreman
36  use num_types, only : rp
37  use field, only : field_t
38  use les_model, only : les_model_t
39  use dofmap , only : dofmap_t
41  use json_module, only : json_file
42  use utils, only : neko_error
43  use neko_config, only : neko_bcknd_device
44  use vreman_cpu, only : vreman_compute_cpu
45  use coefs, only : coef_t
46  implicit none
47  private
48 
51  type, public, extends(les_model_t) :: vreman_t
53  real(kind=rp) :: c
54  contains
56  procedure, pass(this) :: init => vreman_init
58  procedure, pass(this) :: init_from_components => &
61  procedure, pass(this) :: free => vreman_free
63  procedure, pass(this) :: compute => vreman_compute
64  end type vreman_t
65 
66 contains
71  subroutine vreman_init(this, dofmap, coef, json)
72  class(vreman_t), intent(inout) :: this
73  type(dofmap_t), intent(in) :: dofmap
74  type(coef_t), intent(in) :: coef
75  type(json_file), intent(inout) :: json
76  character(len=:), allocatable :: nut_name
77  real(kind=rp) :: c
78  character(len=:), allocatable :: delta_type
79 
80  call json_get_or_default(json, "nut_field", nut_name, "nut")
81  call json_get_or_default(json, "delta_type", delta_type, "pointwise")
82  ! Based on the Smagorinsky Cs = 0.17.
83  call json_get_or_default(json, "c", c, 0.07_rp)
84 
85  call vreman_init_from_components(this, dofmap, coef, c, nut_name, &
86  delta_type)
87  end subroutine vreman_init
88 
94  subroutine vreman_init_from_components(this, dofmap, coef, c, nut_name, &
95  delta_type)
96  class(vreman_t), intent(inout) :: this
97  type(dofmap_t), intent(in) :: dofmap
98  type(coef_t), intent(in) :: coef
99  real(kind=rp) :: c
100  character(len=*), intent(in) :: nut_name
101  character(len=*), intent(in) :: delta_type
102 
103  call this%free()
104 
105  call this%init_base(dofmap, coef, nut_name, delta_type)
106  this%c = c
107 
108  end subroutine vreman_init_from_components
109 
111  subroutine vreman_free(this)
112  class(vreman_t), intent(inout) :: this
113 
114  call this%free_base()
115  end subroutine vreman_free
116 
120  subroutine vreman_compute(this, t, tstep)
121  class(vreman_t), intent(inout) :: this
122  real(kind=rp), intent(in) :: t
123  integer, intent(in) :: tstep
124 
125  if (neko_bcknd_device .eq. 1) then
126  call neko_error("Vreman model not implemented on accelarators.")
127  else
128  call vreman_compute_cpu(t, tstep, this%coef, this%nut, this%delta,&
129  this%c)
130  end if
131 
132  end subroutine vreman_compute
133 
134 end module vreman
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Definition: json_utils.f90:53
Retrieves a parameter by name or throws an error.
Definition: json_utils.f90:44
Coefficients.
Definition: coef.f90:34
Defines a mapping of the degrees of freedom.
Definition: dofmap.f90:35
Defines a field.
Definition: field.f90:34
Utilities for retrieving parameters from the case files.
Definition: json_utils.f90:34
Implements les_model_t.
Definition: les_model.f90:35
Build configurations.
Definition: neko_config.f90:34
integer, parameter neko_bcknd_device
Definition: neko_config.f90:44
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Utilities.
Definition: utils.f90:35
Implements the CPU kernel for the vreman_t type.
Definition: vreman_cpu.f90:34
subroutine, public vreman_compute_cpu(t, tstep, coef, nut, delta, c)
Compute eddy viscosity on the CPU.
Definition: vreman_cpu.f90:59
Implements vreman_t.
Definition: vreman.f90:35
subroutine vreman_init(this, dofmap, coef, json)
Constructor.
Definition: vreman.f90:72
subroutine vreman_free(this)
Destructor for the les_model_t (base) class.
Definition: vreman.f90:112
subroutine vreman_compute(this, t, tstep)
Compute eddy viscosity.
Definition: vreman.f90:121
subroutine vreman_init_from_components(this, dofmap, coef, c, nut_name, delta_type)
Constructor from components.
Definition: vreman.f90:96
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition: coef.f90:55
Base abstract type for LES models based on the Boussinesq approximation.
Definition: les_model.f90:51
Implements the Vreman LES model.
Definition: vreman.f90:51