Loading [MathJax]/extensions/tex2jax.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 ! Assign a name
122 call json_get_or_default(params, 'case.fluid.name', this%name, "fluid")
123
124 ! Fill mu and rho field with the physical value
125 call this%mu_field%init(this%dm_Xh, "mu")
126 call this%rho_field%init(this%dm_Xh, "rho")
127 call field_cfill(this%mu_field, 0.0_rp, this%mu_field%size())
128
129 ! Assign momentum fields
130 call neko_field_registry%add_field(this%dm_Xh, "m_x")
131 call neko_field_registry%add_field(this%dm_Xh, "m_y")
132 call neko_field_registry%add_field(this%dm_Xh, "m_z")
133 this%m_x => neko_field_registry%get_field("m_x")
134 this%m_y => neko_field_registry%get_field("m_y")
135 this%m_z => neko_field_registry%get_field("m_z")
136 call this%m_x%init(this%dm_Xh, "m_x")
137 call this%m_y%init(this%dm_Xh, "m_y")
138 call this%m_z%init(this%dm_Xh, "m_z")
139
140 ! Assign energy field
141 call neko_field_registry%add_field(this%dm_Xh, "E")
142 this%E => neko_field_registry%get_field("E")
143 call this%E%init(this%dm_Xh, "E")
144
145 ! ! Assign velocity fields
146 call neko_field_registry%add_field(this%dm_Xh, "u")
147 call neko_field_registry%add_field(this%dm_Xh, "v")
148 call neko_field_registry%add_field(this%dm_Xh, "w")
149 this%u => neko_field_registry%get_field("u")
150 this%v => neko_field_registry%get_field("v")
151 this%w => neko_field_registry%get_field("w")
152 call this%u%init(this%dm_Xh, "u")
153 call this%v%init(this%dm_Xh, "v")
154 call this%w%init(this%dm_Xh, "w")
155 call neko_field_registry%add_field(this%dm_Xh, 'p')
156 this%p => neko_field_registry%get_field('p')
157 call this%p%init(this%dm_Xh, "p")
158
159 ! !! Initialize time-lag fields
160 call this%ulag%init(this%u, 1)
161 call this%vlag%init(this%v, 1)
162 call this%wlag%init(this%w, 1)
163
164 !
165 ! Setup right-hand side fields.
166 !
167 allocate(this%f_x)
168 allocate(this%f_y)
169 allocate(this%f_z)
170 call this%f_x%init(this%dm_Xh, fld_name = "fluid_rhs_x")
171 call this%f_y%init(this%dm_Xh, fld_name = "fluid_rhs_y")
172 call this%f_z%init(this%dm_Xh, fld_name = "fluid_rhs_z")
173
174 ! Compressible parameters
175 call json_get_or_default(params, 'case.fluid.gamma', this%gamma, 1.4_rp)
176 end subroutine fluid_scheme_compressible_init
177
181 class(fluid_scheme_compressible_t), intent(inout) :: this
182 call this%dm_Xh%free()
183 call this%gs_Xh%free()
184 call this%c_Xh%free()
185 call this%Xh%free()
186
187 call this%mu_field%free()
188 call this%rho_field%free()
189 call this%m_x%free()
190 call this%m_y%free()
191 call this%m_z%free()
192 call this%E%free()
193
194 nullify(this%m_x)
195 nullify(this%m_y)
196 nullify(this%m_z)
197
198 nullify(this%E)
199
200 nullify(this%u)
201 nullify(this%v)
202 nullify(this%w)
203 nullify(this%p)
204
205 call this%ulag%free()
206 call this%vlag%free()
207 call this%wlag%free()
208 end subroutine fluid_scheme_compressible_free
209
213 class(fluid_scheme_compressible_t), target, intent(inout) :: this
214 integer :: n
215 type(field_t), pointer :: temp
216 integer :: temp_indices(1)
217
218 n = this%dm_Xh%size()
219 call this%scratch%request_field(temp, temp_indices(1))
220
222 call field_col3(this%m_x, this%u, this%rho_field)
223 call field_col3(this%m_y, this%v, this%rho_field)
224 call field_col3(this%m_z, this%w, this%rho_field)
225
228 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
229 call field_col3(temp, this%u, this%u, n)
230 call field_addcol3(temp, this%v, this%v, n)
231 call field_addcol3(temp, this%w, this%w, n)
232 call field_col2(temp, this%rho_field, n)
233 call field_cmult(temp, 0.5_rp, n)
234 call field_add2(this%E, temp, n)
235
236 call this%scratch%relinquish_field(temp_indices)
237
239
244 function fluid_scheme_compressible_compute_cfl(this, dt) result(c)
245 class(fluid_scheme_compressible_t), intent(in) :: this
246 real(kind=rp), intent(in) :: dt
247 real(kind=rp) :: c
248
249 c = 0.1_rp
251
253
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
A type collecting all the overridable user routines.