Loading [MathJax]/jax/input/TeX/config.js
Neko 0.9.99
A portable framework for high-order spectral element flow simulations
All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Pages
fluid_scheme_compressible.f90
Go to the documentation of this file.
1! Copyright (c) 2025, 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 use dirichlet, only : dirichlet_t
35 use field, only : field_t
40 use json_module, only : json_file
41 use logger, only : log_size
42 use num_types, only : rp
43 use mesh, only : mesh_t
45 use space, only : space_t, gll
46 use user_intf, only : user_t
47 use usr_inflow, only : usr_inflow_eval
49 implicit none
50 private
51
53 type, public, abstract, extends(fluid_scheme_base_t) :: fluid_scheme_compressible_t
55 type(field_t), pointer :: m_x => null()
56 type(field_t), pointer :: m_y => null()
57 type(field_t), pointer :: m_z => null()
58 type(field_t), pointer :: e => null()
59
60 real(kind=rp) :: gamma
61
62 type(scratch_registry_t) :: scratch
63
64 contains
66 procedure, pass(this) :: scheme_init => fluid_scheme_compressible_init
68 procedure, pass(this) :: scheme_free => fluid_scheme_compressible_free
69
71 procedure, pass(this) :: validate => fluid_scheme_compressible_validate
73 procedure, pass(this) :: compute_cfl &
76 procedure, pass(this) :: update_material_properties => &
78
80
81contains
89 subroutine fluid_scheme_compressible_init(this, msh, lx, params, scheme, user)
90 class(fluid_scheme_compressible_t), target, intent(inout) :: this
91 type(mesh_t), target, intent(inout) :: msh
92 integer, intent(in) :: lx
93 character(len=*), intent(in) :: scheme
94 type(json_file), target, intent(inout) :: params
95 type(user_t), target, intent(in) :: user
96
97 !
98 ! SEM simulation fundamentals
99 !
100
101 this%msh => msh
102
103 if (msh%gdim .eq. 2) then
104 call this%Xh%init(gll, lx, lx)
105 else
106 call this%Xh%init(gll, lx, lx, lx)
107 end if
108
109 call this%dm_Xh%init(msh, this%Xh)
110
111 call this%gs_Xh%init(this%dm_Xh)
112
113 call this%c_Xh%init(this%gs_Xh)
114
115 ! Local scratch registry
116 this%scratch = scratch_registry_t(this%dm_Xh, 10, 2)
117
118 ! Case parameters
119 this%params => params
120
121 ! Fill mu and rho field with the physical value
122 call this%mu_field%init(this%dm_Xh, "mu")
123 call this%rho_field%init(this%dm_Xh, "rho")
124 call field_cfill(this%mu_field, 0.0_rp, this%mu_field%size())
125
126 ! Assign momentum fields
127 call neko_field_registry%add_field(this%dm_Xh, "m_x")
128 call neko_field_registry%add_field(this%dm_Xh, "m_y")
129 call neko_field_registry%add_field(this%dm_Xh, "m_z")
130 this%m_x => neko_field_registry%get_field("m_x")
131 this%m_y => neko_field_registry%get_field("m_y")
132 this%m_z => neko_field_registry%get_field("m_z")
133 call this%m_x%init(this%dm_Xh, "m_x")
134 call this%m_y%init(this%dm_Xh, "m_y")
135 call this%m_z%init(this%dm_Xh, "m_z")
136
137 ! Assign energy field
138 call neko_field_registry%add_field(this%dm_Xh, "E")
139 this%E => neko_field_registry%get_field("E")
140 call this%E%init(this%dm_Xh, "E")
141
142 ! ! Assign velocity fields
143 call neko_field_registry%add_field(this%dm_Xh, "u")
144 call neko_field_registry%add_field(this%dm_Xh, "v")
145 call neko_field_registry%add_field(this%dm_Xh, "w")
146 this%u => neko_field_registry%get_field("u")
147 this%v => neko_field_registry%get_field("v")
148 this%w => neko_field_registry%get_field("w")
149 call this%u%init(this%dm_Xh, "u")
150 call this%v%init(this%dm_Xh, "v")
151 call this%w%init(this%dm_Xh, "w")
152 call neko_field_registry%add_field(this%dm_Xh, 'p')
153 this%p => neko_field_registry%get_field('p')
154 call this%p%init(this%dm_Xh, "p")
155
156 ! !! Initialize time-lag fields
157 call this%ulag%init(this%u, 1)
158 call this%vlag%init(this%v, 1)
159 call this%wlag%init(this%w, 1)
160
161 !
162 ! Setup right-hand side fields.
163 !
164 allocate(this%f_x)
165 allocate(this%f_y)
166 allocate(this%f_z)
167 call this%f_x%init(this%dm_Xh, fld_name = "fluid_rhs_x")
168 call this%f_y%init(this%dm_Xh, fld_name = "fluid_rhs_y")
169 call this%f_z%init(this%dm_Xh, fld_name = "fluid_rhs_z")
170
171 ! Compressible parameters
172 call json_get_or_default(params, 'case.fluid.gamma', this%gamma, 1.4_rp)
173 end subroutine fluid_scheme_compressible_init
174
178 class(fluid_scheme_compressible_t), intent(inout) :: this
179 call this%dm_Xh%free()
180 call this%gs_Xh%free()
181 call this%c_Xh%free()
182 call this%Xh%free()
183
184 call this%mu_field%free()
185 call this%rho_field%free()
186 call this%m_x%free()
187 call this%m_y%free()
188 call this%m_z%free()
189 call this%E%free()
190
191 nullify(this%m_x)
192 nullify(this%m_y)
193 nullify(this%m_z)
194
195 nullify(this%E)
196
197 nullify(this%u)
198 nullify(this%v)
199 nullify(this%w)
200 nullify(this%p)
201
202 call this%ulag%free()
203 call this%vlag%free()
204 call this%wlag%free()
205 end subroutine fluid_scheme_compressible_free
206
210 class(fluid_scheme_compressible_t), target, intent(inout) :: this
211 integer :: n
212 type(field_t), pointer :: temp
213 integer :: temp_indices(1)
214
215 n = this%dm_Xh%size()
216 call this%scratch%request_field(temp, temp_indices(1))
217
219 call field_col3(this%m_x, this%u, this%rho_field)
220 call field_col3(this%m_y, this%v, this%rho_field)
221 call field_col3(this%m_z, this%w, this%rho_field)
222
225 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
226 call field_col3(temp, this%u, this%u, n)
227 call field_addcol3(temp, this%v, this%v, n)
228 call field_addcol3(temp, this%w, this%w, n)
229 call field_col2(temp, this%rho_field, n)
230 call field_cmult(temp, 0.5_rp, n)
231 call field_add2(this%E, temp, n)
232
233 call this%scratch%relinquish_field(temp_indices)
234
236
241 function fluid_scheme_compressible_compute_cfl(this, dt) result(c)
242 class(fluid_scheme_compressible_t), intent(in) :: this
243 real(kind=rp), intent(in) :: dt
244 real(kind=rp) :: c
245
246 c = 0.1_rp
248
250
Abstract interface to sets rho and mu.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Abstract interface defining a user defined inflow condition (pointwise)
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
subroutine, public field_col2(a, b, n)
Vector multiplication .
subroutine, public field_cmult2(a, b, c, n)
Multiplication by constant c .
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
subroutine, public field_addcol3(a, b, c, n)
Returns .
subroutine, public field_add2(a, b, n)
Vector addition .
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
Defines a field.
Definition field.f90:34
subroutine fluid_scheme_compressible_update_material_properties(this)
Set rho and mu.
subroutine fluid_scheme_compressible_free(this)
Free allocated memory and cleanup resources.
subroutine fluid_scheme_compressible_init(this, msh, lx, params, scheme, user)
Initialize common data for compressible fluid scheme.
real(kind=rp) function fluid_scheme_compressible_compute_cfl(this, dt)
Compute CFL number.
subroutine fluid_scheme_compressible_validate(this)
Validate field initialization and compute derived quantities.
Utilities for retrieving parameters from the case files.
Logging routines.
Definition log.f90:34
integer, parameter, public log_size
Definition log.f90:42
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
Defines a function space.
Definition space.f90:34
integer, parameter, public gll
Definition space.f90:48
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
Defines inflow dirichlet conditions.
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:47
Base type of all fluid formulations.
The function space for the SEM solution fields.
Definition space.f90:62