38 use json_module,
only: json_file
57 type(
field_t),
pointer :: indicator => null()
59 type(
field_t),
pointer :: brinkman => null()
90 use json_module,
only: json_core, json_value
94 type(json_file),
intent(inout) :: json
96 type(
coef_t),
intent(inout) :: coef
97 real(kind=
rp) :: start_time, end_time
99 character(len=:),
allocatable :: filter_type
100 real(kind=
rp),
dimension(:),
allocatable :: brinkman_limits
101 real(kind=
rp) :: brinkman_penalty
103 type(json_value),
pointer :: json_object_list
104 type(json_core) :: core
106 character(len=:),
allocatable :: object_type
107 type(json_file) :: object_settings
116 call json_get(json,
'brinkman.limits', brinkman_limits)
117 call json_get(json,
'brinkman.penalty', brinkman_penalty)
119 if (
size(brinkman_limits) .ne. 2)
then
120 call neko_error(
'brinkman_limits must be a 2 element array of reals')
124 call this%init_base(fields, coef, start_time, end_time)
131 call neko_error(
'Brinkman field already exists.')
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')
180 & brinkman_limits(1), brinkman_limits(2), brinkman_penalty)
194 this%brinkman => null()
195 call this%free_base()
206 real(kind=
rp),
intent(in) :: t
207 integer,
intent(in) :: tstep
231 type(json_file),
intent(inout) :: json
234 character(len=:),
allocatable :: mesh_file_name
235 character(len=:),
allocatable :: distance_transform
236 character(len=:),
allocatable :: filter_type
237 character(len=:),
allocatable :: mesh_transform
242 real(kind=
rp) :: scalar_r
243 real(kind=
dp) :: scalar_d
246 real(kind=
dp),
dimension(:),
allocatable :: box_min, box_max
247 logical :: keep_aspect_ratio
248 real(kind=
dp),
dimension(3) :: scaling
249 real(kind=
dp),
dimension(3) :: translation
251 type(
aabb_t) :: mesh_box, target_box
257 call json_get(json,
'name', mesh_file_name)
260 call json_get(json,
'distance_transform.type', distance_transform)
265 mesh_file =
file_t(mesh_file_name)
266 call mesh_file%read(boundary_mesh)
268 if (boundary_mesh%nelv .eq. 0)
then
269 call neko_error(
'No elements in the boundary mesh')
277 select case (mesh_transform)
280 case (
'bounding_box')
281 call json_get(json,
'mesh_transform.box_min', box_min)
282 call json_get(json,
'mesh_transform.box_max', box_max)
284 keep_aspect_ratio, .true.)
286 if (
size(box_min) .ne. 3 .or.
size(box_max) .ne. 3)
then
288 &box_min and box_max must be 3 element arrays of reals')
291 call target_box%init(box_min, box_max)
295 scaling = target_box%get_diagonal() / mesh_box%get_diagonal()
296 if (keep_aspect_ratio)
then
297 scaling = minval(scaling)
300 translation = - scaling * mesh_box%get_min() + target_box%get_min()
302 do idx_p = 1, boundary_mesh%mpts
303 boundary_mesh%points(idx_p)%x = &
304 scaling * boundary_mesh%points(idx_p)%x + translation
319 call temp_field%init(this%indicator%dof)
322 select case (distance_transform)
324 call json_get(json,
'distance_transform.value', scalar_d)
325 scalar_r =
real(scalar_d, kind=
rp)
332 call json_get(json,
'distance_transform.value', scalar_d)
345 select case (filter_type)
353 this%indicator%x =
max(this%indicator%x, temp_field%x)
368 type(json_file),
intent(inout) :: json
371 character(len=:),
allocatable :: zone_name
372 character(len=:),
allocatable :: filter_type
381 call json_get(json,
'name', zone_name)
386 call temp_field%init(this%indicator%dof)
390 do i = 1, my_point_zone%size
391 temp_field%x(my_point_zone%mask(i), 1, 1, 1) = 1.0_rp
396 select case (filter_type)
404 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 cpu kernel for the brinkman_source_term_t type.
subroutine, public brinkman_source_term_compute_cpu(fields, brinkman)
Computes the Brinkman source term on the cpu.
Implements the device kernel for the brinkman_source_term_t type.
subroutine, public brinkman_source_term_compute_device(fields, brinkman)
Computes the Brinkman source term on the device.
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.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
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 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.
subroutine, public permeability_field(F_out, x, k_0, k_1, q)
Apply a permeability function to a field.
Utilities for retrieving parameters from the case files.
subroutine, public json_extract_item(core, array, i, item)
Extract ith item from a JSON array as a separate JSON object.
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_end_region
End the most recently started profiler region.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
Module containing Signed Distance Functions.
subroutine 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.