Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
centrifugal_source_term.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!
35
37 use num_types, only : rp
38 use field_list, only : field_list_t
39 use json_module, only : json_file
41 use source_term, only : source_term_t
42 use coefs, only : coef_t
44 use utils, only : neko_error
48 use field, only : field_t
50 use time_state, only : time_state_t
51 implicit none
52 private
53
62 type, public, extends(source_term_t) :: centrifugal_source_term_t
64 real(kind=rp) :: omega(3)
66 real(kind=rp) :: ref_point(3)
67 contains
69 procedure, pass(this) :: init => centrifugal_source_term_init_from_json
71 procedure, pass(this) :: init_from_compenents => &
74 procedure, pass(this) :: free => centrifugal_source_term_free
76 procedure, pass(this) :: compute_ => centrifugal_source_term_compute
78
79contains
85 subroutine centrifugal_source_term_init_from_json(this, json, fields, coef, &
86 variable_name)
87 class(centrifugal_source_term_t), intent(inout) :: this
88 type(json_file), intent(inout) :: json
89 type(field_list_t), intent(in), target :: fields
90 type(coef_t), intent(in), target :: coef
91 character(len=*), intent(in) :: variable_name
92 ! Rotation vector and reference point
93 real(kind=rp), allocatable :: rotation_vec(:), ref_point(:)
94 real(kind=rp) :: start_time, end_time
95
96 call json_get_or_default(json, "start_time", start_time, 0.0_rp)
97 call json_get_or_default(json, "end_time", end_time, huge(0.0_rp))
98
99 if (json%valid_path("rotation_vector")) then
100 call json_get(json, "rotation_vector", rotation_vec)
101 else
102 call neko_error("Specify rotation_vector &
103 &for the centrifugal source term.")
104 end if
105
106 if (json%valid_path("reference_point")) then
107 call json_get(json, "reference_point", ref_point)
108 else
109 call neko_error("Specify reference_point &
110 &for the centrifugal source term.")
111 end if
112
114 rotation_vec, ref_point, coef, start_time, end_time)
115
117
125 subroutine centrifugal_source_term_init_from_components(this, fields, omega, &
126 ref_point, coef, start_time, end_time)
127 class(centrifugal_source_term_t), intent(inout) :: this
128 class(field_list_t), intent(in), target :: fields
129 real(kind=rp), intent(in) :: omega(3)
130 real(kind=rp), intent(in) :: ref_point(3)
131 type(coef_t) :: coef
132 real(kind=rp), intent(in) :: start_time
133 real(kind=rp), intent(in) :: end_time
134
135 call this%free()
136 call this%init_base(fields, coef, start_time, end_time)
137
138 if (fields%size() .ne. 3) then
139 call neko_error("Number of fields for the centrifugal force must be 3.")
140 end if
141
142 this%omega = omega
143 this%ref_point = ref_point
145
148 class(centrifugal_source_term_t), intent(inout) :: this
149
150 call this%free_base()
151 end subroutine centrifugal_source_term_free
152
155 subroutine centrifugal_source_term_compute(this, time)
156 class(centrifugal_source_term_t), intent(inout) :: this
157 type(time_state_t), intent(in) :: time
158
159 if (neko_bcknd_device .eq. 1) then
160 call centrifugal_source_term_compute_device(this%omega, this%ref_point, &
161 this%fields)
162 else
163 call centrifugal_source_term_compute_cpu(this%omega, this%ref_point, &
164 this%fields)
165 end if
167
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Implements the cpu kernel for the centrifugal_source_term_t type. Maintainer: Adam Peplinski.
subroutine, public centrifugal_source_term_compute_cpu(omega, ref_point, fields)
Computes the centrifugal source term on the cpu.
Implements the device kernel for the centrifugal_source_term_t type.
subroutine, public centrifugal_source_term_compute_device(omega, ref_point, fields)
Computes the centrifugal source term on the device.
Implements the centrifugal_source_term_t type. Maintainer: Adam Peplinski.
subroutine centrifugal_source_term_free(this)
Destructor.
subroutine centrifugal_source_term_init_from_json(this, json, fields, coef, variable_name)
The common constructor using a JSON object.
subroutine centrifugal_source_term_init_from_components(this, fields, omega, ref_point, coef, start_time, end_time)
The constructor from type components.
subroutine centrifugal_source_term_compute(this, time)
Computes the source term and adds the result to fields.
Coefficients.
Definition coef.f90:34
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
Utilities for retrieving parameters from the case files.
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
This source term adds the centrifugal force.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:55
field_list_t, To be able to group fields together
Base abstract type for source terms.
A struct that contains all info about the time, expand as needed.