45 use json_module,
only: json_file, json_core, json_value
81 procedure,
public, pass(this) :: init => &
106 type(json_file),
intent(inout) :: json
108 type(
coef_t),
intent(in),
target :: coef
109 real(kind=
rp) :: start_time, end_time
111 character(len=:),
allocatable :: filter_type
112 real(kind=
rp) :: filter_radius
113 real(kind=
rp),
dimension(:),
allocatable :: brinkman_limits
114 real(kind=
rp) :: brinkman_penalty
116 type(json_value),
pointer :: json_object_list
117 type(json_core) :: core
119 character(len=:),
allocatable :: object_type
120 type(json_file) :: object_settings
131 call json_get(json,
'brinkman.limits', brinkman_limits)
132 call json_get(json,
'brinkman.penalty', brinkman_penalty)
134 if (
size(brinkman_limits) .ne. 2)
then
135 call neko_error(
'brinkman_limits must be a 2 element array of reals')
139 call this%init_base(fields, coef, start_time, end_time)
146 call neko_error(
'Brinkman field already exists.')
149 call this%indicator%init(coef%dof)
150 call this%brinkman%init(coef%dof)
155 call json%get(
'objects', json_object_list)
156 call json%info(
'objects', n_children = n_regions)
157 call json%get_core(core)
163 select case (object_type)
164 case (
'boundary_mesh')
165 call this%init_boundary_mesh(object_settings)
167 call this%init_point_zone(object_settings)
170 call object_settings%print()
171 call neko_error(
'Brinkman source term objects require a region type')
173 call neko_error(
'Brinkman source term unknown region type')
182 select case (filter_type)
185 call this%indicator_unfiltered%init(coef%dof)
191 call this%filter%init(json, coef)
194 call field_copy(this%indicator_unfiltered, this%indicator)
197 call this%filter%apply(this%indicator, this%indicator_unfiltered)
201 call output%fields%assign_to_field(1, this%indicator_unfiltered)
202 call output%fields%assign_to_field(2, this%indicator)
203 call output%fields%assign_to_field(3, this%brinkman)
208 call output%fields%assign_to_field(1, this%indicator)
209 call output%fields%assign_to_field(2, this%brinkman)
212 call neko_error(
'Brinkman source term unknown filter type')
218 this%brinkman = this%indicator
220 brinkman_limits(1), brinkman_limits(2), brinkman_penalty)
223 call output%sample(0.0_rp)
231 call this%indicator%free()
232 call this%brinkman%free()
233 call this%free_base()
242 real(kind=
rp),
intent(in) :: t
243 integer,
intent(in) :: tstep
244 type(
field_t),
pointer :: u, v, w, fu, fv, fw
247 n = this%fields%item_size(1)
253 fu => this%fields%get(1)
254 fv => this%fields%get(2)
255 fw => this%fields%get(3)
269 type(json_file),
intent(inout) :: json
272 character(len=:),
allocatable :: mesh_file_name
273 character(len=:),
allocatable :: distance_transform
274 character(len=:),
allocatable :: filter_type
275 character(len=:),
allocatable :: mesh_transform
280 real(kind=
rp) :: scalar_r
281 real(kind=
dp) :: scalar_d
284 real(kind=
dp),
dimension(:),
allocatable :: box_min, box_max
285 logical :: keep_aspect_ratio
286 real(kind=
dp),
dimension(3) :: scaling
287 real(kind=
dp),
dimension(3) :: translation
289 type(
aabb_t) :: mesh_box, target_box
291 character(len=LOG_SIZE) :: log_msg
296 call json_get(json,
'name', mesh_file_name)
299 call json_get(json,
'distance_transform.type', distance_transform)
304 mesh_file =
file_t(mesh_file_name)
305 call mesh_file%read(boundary_mesh)
307 if (boundary_mesh%nelv .eq. 0)
then
308 call neko_error(
'No elements in the boundary mesh')
315 mesh_transform,
'none')
317 select case (mesh_transform)
320 case (
'bounding_box')
321 call json_get(json,
'mesh_transform.box_min', box_min)
322 call json_get(json,
'mesh_transform.box_max', box_max)
324 keep_aspect_ratio, .true.)
326 if (
size(box_min) .ne. 3 .or.
size(box_max) .ne. 3)
then
328 &box_min and box_max must be 3 element arrays of reals')
331 call target_box%init(box_min, box_max)
335 scaling = target_box%get_diagonal() / mesh_box%get_diagonal()
336 if (keep_aspect_ratio)
then
337 scaling = minval(scaling)
340 translation = - scaling * mesh_box%get_min() + target_box%get_min()
342 do idx_p = 1, boundary_mesh%mpts
343 boundary_mesh%points(idx_p)%x = &
344 scaling * boundary_mesh%points(idx_p)%x + translation
348 write(log_msg,
'(A)')
"The following transformation was applied:"
350 write(log_msg,
'(A, 3F12.6)')
"Scaling: ", scaling
352 write(log_msg,
'(A, 3F12.6)')
"Translation: ", translation
367 call temp_field%init(this%coef%dof)
370 select case (distance_transform)
372 call json_get(json,
'distance_transform.value', scalar_d)
373 scalar_r =
real(scalar_d, kind=
rp)
380 call json_get(json,
'distance_transform.value', scalar_d)
381 scalar_r =
real(scalar_d, kind=
rp)
393 this%indicator%size())
395 this%indicator%x =
max(this%indicator%x, temp_field%x)
403 type(json_file),
intent(inout) :: json
406 character(len=:),
allocatable :: zone_name
415 call json_get(json,
'name', zone_name)
418 call temp_field%init(this%coef%dof)
424 my_point_zone%mask_d, my_point_zone%size)
426 call cfill_mask(temp_field%x, 1.0_rp, temp_field%size(), &
427 my_point_zone%mask, my_point_zone%size)
433 this%indicator%size())
435 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_copy(a, b, n)
Copy a vector .
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.
Filter to be applied to a scalar field.
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.
Implements fld_file_output_t.
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 sp
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 class for filter.
A simple output saving a list of fields to a .fld file.
A PDE based filter mapping $\rho \mapsto \tilde{\rho}$, see Lazarov & O. Sigmund 2010,...
Base abstract type for point zones.
Base abstract type for source terms.