Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
source_term_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2023-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!
33!
35submodule(source_term) source_term_fctry
46 use json_utils, only : json_get
48 implicit none
49
50 ! List of all possible types created by the factory routine
51 character(len=25) :: SOURCE_KNOWN_TYPES(10) = [character(len=25) :: &
52 "constant", &
53 "boussinesq", &
54 "coriolis", &
55 "centrifugal", &
56 "gradient_jump_penalty", &
57 "brinkman", &
58 "sponge", &
59 "field", &
60 "hpfrt", &
61 "translation" &
62 ]
63
64contains
65
70 module subroutine source_term_factory(object, json, fields, coef, &
71 variable_name)
72 class(source_term_t), allocatable, intent(inout) :: object
73 type(json_file), intent(inout) :: json
74 type(field_list_t), intent(inout) :: fields
75 type(coef_t), intent(inout) :: coef
76 character(len=*), intent(in) :: variable_name
77 character(len=:), allocatable :: type_name
78 character(len=:), allocatable :: type_string
79
80 call json_get(json, "type", type_name)
81
82 ! Allocate
83 call source_term_allocator(object, type_name)
84
85 ! Initialize
86 call object%init(json, fields, coef, variable_name)
87
88 end subroutine source_term_factory
89
93 module subroutine source_term_allocator(object, type_name)
94 class(source_term_t), allocatable, intent(inout) :: object
95 character(len=:), allocatable, intent(in) :: type_name
96 integer :: i
97
98 if (allocated(object)) then
99 call object%free()
100 deallocate(object)
101 end if
102
103 select case (trim(type_name))
104 case ("constant")
105 allocate(const_source_term_t::object)
106 case ("boussinesq")
107 allocate(boussinesq_source_term_t::object)
108 case ("coriolis")
109 allocate(coriolis_source_term_t::object)
110 case ("centrifugal")
111 allocate(centrifugal_source_term_t::object)
112 case ("brinkman")
113 allocate(brinkman_source_term_t::object)
114 case ("sponge")
115 allocate(sponge_source_term_t::object)
116 case ("gradient_jump_penalty")
117 allocate(gradient_jump_penalty_t::object)
118 case ("translation")
119 allocate(translation_source_term_t::object)
120 case ("field")
121 allocate(field_source_term_t::object)
122 case ("hpfrt")
123 allocate(hpfrt_source_term_t::object)
124 case default
125 do i = 1, source_term_registry_size
126 if (trim(type_name) .eq. trim(source_term_registry(i)%type_name)) then
127 call source_term_registry(i)%allocator(object)
128 return
129 end if
130 end do
131
132 call neko_type_error("source term", type_name, source_known_types)
133 end select
134 end subroutine source_term_allocator
135
141 module subroutine register_source_term(type_name, allocator)
142 character(len=*), intent(in) :: type_name
143 procedure(source_term_allocate), pointer, intent(in) :: allocator
144 type(allocator_entry), allocatable :: temp(:)
145 integer :: i
146
147 do i = 1, size(source_known_types)
148 if (trim(type_name) .eq. trim(source_known_types(i))) then
149 call neko_type_registration_error("source term", type_name, .true.)
150 end if
151 end do
152
153 do i = 1, source_term_registry_size
154 if (trim(type_name) .eq. trim(source_term_registry(i)%type_name)) then
155 call neko_type_registration_error("source term", type_name, .false.)
156 end if
157 end do
158
159 ! Expand registry
160 if (source_term_registry_size .eq. 0) then
161 allocate(source_term_registry(1))
162 else
163 allocate(temp(source_term_registry_size + 1))
164 temp(1:source_term_registry_size) = source_term_registry
165 call move_alloc(temp, source_term_registry)
166 end if
167
168 source_term_registry_size = source_term_registry_size + 1
169 source_term_registry(source_term_registry_size)%type_name = type_name
170 source_term_registry(source_term_registry_size)%allocator => allocator
171 end subroutine register_source_term
172
173end submodule source_term_fctry
Retrieves a parameter by name or throws an error.
Implements the boussinesq_source_term_t type.
Implements the brinkman_source_term_t type.
Implements the centrifugal_source_term_t type. Maintainer: Adam Peplinski.
Implements the const_source_term_t type.
Implements the coriolis_source_term_t type. Maintainer: Timofey Mukha.
Implements the field_source_term_t type.
Implements gradient_jump_penalty_t.
Implements the hpfrt_source_term_t type.
Utilities for retrieving parameters from the case files.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Implements the sponge_t type.
Implements the coriolis_source_term_t type. Implements the translation_source_term_t type.
Utilities.
Definition utils.f90:35
subroutine, public neko_type_registration_error(base_type, wrong_type, known)
Definition utils.f90:374
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:359
Bouyancy source term accroding to the Boussinesq approximation.
A Brinkman source term. The region and strength are controlled by assigning regions types and brinkma...
This source term adds the centrifugal force.
A constant source term. The strength is specified with the values keyword, which should be an array,...
This source term adds the Coriolis force.
A source term that grabs the values from fields in the registry. The fields are specified with the fi...
High-pass filter relaxation source term.
This source term adds the translation force.