45 use json_module,
only: json_file, json_core, json_value
73 procedure,
public, pass(this) :: init => &
97 type(json_file),
intent(inout) :: json
99 type(
coef_t),
intent(in),
target :: coef
100 real(kind=
rp) :: start_time, end_time
102 character(len=:),
allocatable :: filter_type
103 real(kind=
rp),
dimension(:),
allocatable :: brinkman_limits
104 real(kind=
rp) :: brinkman_penalty
106 type(json_value),
pointer :: json_object_list
107 type(json_core) :: core
109 character(len=:),
allocatable :: object_type
110 type(json_file) :: object_settings
119 call json_get(json,
'brinkman.limits', brinkman_limits)
120 call json_get(json,
'brinkman.penalty', brinkman_penalty)
122 if (
size(brinkman_limits) .ne. 2)
then
123 call neko_error(
'brinkman_limits must be a 2 element array of reals')
127 call this%init_base(fields, coef, start_time, end_time)
134 call neko_error(
'Brinkman field already exists.')
137 call this%indicator%init(coef%dof)
138 call this%brinkman%init(coef%dof)
143 call json%get(
'objects', json_object_list)
144 call json%info(
'objects', n_children = n_regions)
145 call json%get_core(core)
151 select case (object_type)
152 case (
'boundary_mesh')
153 call this%init_boundary_mesh(object_settings)
155 call this%init_point_zone(object_settings)
158 call object_settings%print()
159 call neko_error(
'Brinkman source term objects require a region type')
161 call neko_error(
'Brinkman source term unknown region type')
169 select case (filter_type)
173 call neko_error(
'Brinkman source term unknown filter type')
179 this%brinkman = this%indicator
181 brinkman_limits(1), brinkman_limits(2), brinkman_penalty)
189 call this%indicator%free()
190 call this%brinkman%free()
191 call this%free_base()
200 real(kind=
rp),
intent(in) :: t
201 integer,
intent(in) :: tstep
202 type(
field_t),
pointer :: u, v, w, fu, fv, fw
205 n = this%fields%item_size(1)
211 fu => this%fields%get(1)
212 fv => this%fields%get(2)
213 fw => this%fields%get(3)
227 type(json_file),
intent(inout) :: json
230 character(len=:),
allocatable :: mesh_file_name
231 character(len=:),
allocatable :: distance_transform
232 character(len=:),
allocatable :: filter_type
233 character(len=:),
allocatable :: mesh_transform
238 real(kind=
rp) :: scalar_r
239 real(kind=
dp) :: scalar_d
242 real(kind=
dp),
dimension(:),
allocatable :: box_min, box_max
243 logical :: keep_aspect_ratio
244 real(kind=
dp),
dimension(3) :: scaling
245 real(kind=
dp),
dimension(3) :: translation
247 type(
aabb_t) :: mesh_box, target_box
249 character(len=LOG_SIZE) :: log_msg
254 call json_get(json,
'name', mesh_file_name)
257 call json_get(json,
'distance_transform.type', distance_transform)
262 mesh_file =
file_t(mesh_file_name)
263 call mesh_file%read(boundary_mesh)
265 if (boundary_mesh%nelv .eq. 0)
then
266 call neko_error(
'No elements in the boundary mesh')
273 mesh_transform,
'none')
275 select case (mesh_transform)
278 case (
'bounding_box')
279 call json_get(json,
'mesh_transform.box_min', box_min)
280 call json_get(json,
'mesh_transform.box_max', box_max)
282 keep_aspect_ratio, .true.)
284 if (
size(box_min) .ne. 3 .or.
size(box_max) .ne. 3)
then
286 &box_min and box_max must be 3 element arrays of reals')
289 call target_box%init(box_min, box_max)
293 scaling = target_box%get_diagonal() / mesh_box%get_diagonal()
294 if (keep_aspect_ratio)
then
295 scaling = minval(scaling)
298 translation = - scaling * mesh_box%get_min() + target_box%get_min()
300 do idx_p = 1, boundary_mesh%mpts
301 boundary_mesh%points(idx_p)%x = &
302 scaling * boundary_mesh%points(idx_p)%x + translation
306 write(log_msg,
'(A)')
"The following transformation was applied:"
308 write(log_msg,
'(A, 3F12.6)')
"Scaling: ", scaling
310 write(log_msg,
'(A, 3F12.6)')
"Translation: ", translation
325 call temp_field%init(this%coef%dof)
328 select case (distance_transform)
330 call json_get(json,
'distance_transform.value', scalar_d)
331 scalar_r =
real(scalar_d, kind=
rp)
338 call json_get(json,
'distance_transform.value', scalar_d)
339 scalar_r =
real(scalar_d, kind=
rp)
352 select case (filter_type)
362 this%indicator%size())
364 this%indicator%x =
max(this%indicator%x, temp_field%x)
372 type(json_file),
intent(inout) :: json
375 character(len=:),
allocatable :: zone_name
376 character(len=:),
allocatable :: filter_type
385 call json_get(json,
'name', zone_name)
389 call temp_field%init(this%coef%dof)
395 my_point_zone%mask_d, my_point_zone%size)
397 call cfill_mask(temp_field%x, 1.0_rp, temp_field%size(), &
398 my_point_zone%mask, my_point_zone%size)
403 select case (filter_type)
413 this%indicator%size())
415 this%indicator%x =
max(this%indicator%x, temp_field%x)
Copy data between host and device (or device and device)
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.
Axis Aligned Bounding Box (aabb) implementation in Fortran.
type(aabb_t) function, public get_aabb(object, padding)
Construct the aabb of a predefined object.
Implements the brinkman_source_term_t type.
subroutine init_point_zone(this, json)
Initializes the source term from a point zone.
subroutine init_boundary_mesh(this, json)
Initializes the source term from a boundary mesh.
subroutine brinkman_source_term_compute(this, t, tstep)
Computes the source term and adds the result to fields.
subroutine brinkman_source_term_free(this)
Destructor.
subroutine brinkman_source_term_init_from_json(this, json, fields, coef)
The common constructor using a JSON object.
subroutine, public device_cfill_mask(a_d, c, size, mask_d, mask_size)
Fill a constant to a masked vector. .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
subroutine, public field_subcol3(a, b, c, n)
Returns .
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
Module for file I/O operations.
A module containing filter functions and subroutines. These functions are used to modify fields in a ...
subroutine, public permeability_field(f, k_0, k_1, q)
Apply a permeability function to a field.
subroutine, public smooth_step_field(f, edge0, edge1)
Apply a smooth step function to a field.
subroutine, public step_function_field(f, x0, value0, value1)
Apply a step function to a field.
Utilities for retrieving parameters from the case files.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
subroutine, public cfill_mask(a, c, size, mask, mask_size)
Fill a constant to a masked vector. .
integer, parameter neko_bcknd_device
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
type(point_zone_registry_t), target, public neko_point_zone_registry
Global point_zone registry.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
subroutine, public profiler_end_region(name, region_id)
End the most recently started profiler region.
Module containing Signed Distance Functions.
subroutine, public signed_distance_field(field_data, object, max_distance)
Signed distance field.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Defines a triangular surface mesh.
Axis Aligned Bounding Box (aabb) data structure.
A Brinkman source term. The region and strength are controlled by assigning regions types and brinkma...
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
field_list_t, To be able to group fields together
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Base abstract type for point zones.
Base abstract type for source terms.