71 real(kind=
rp),
private :: constant_value(3) = 0.0_rp
75 logical,
private :: use_constant_value = .true.
76 logical,
private :: read_values_from_field = .false.
77 logical,
private :: field_interpolate = .false.
78 character(len=:),
allocatable,
private :: field_file_name
79 character(len=:),
allocatable,
private :: field_mesh_file_name
88 procedure, pass(this) :: apply_scalar_dev => &
91 procedure, pass(this) :: apply_vector_dev => &
96 procedure, pass(this) :: init_from_components => &
105 procedure, pass(this) :: get_normal_axis => &
116 type(
coef_t),
target,
intent(in) :: coef
117 type(json_file),
intent(inout) :: json
118 real(kind=
rp),
allocatable :: value(:)
119 real(kind=
rp) :: value_3(3)
120 logical :: found_file_name, found_value
122 call json%info(
"file_name", found = found_file_name)
123 call json%info(
"value", found = found_value)
125 if (found_file_name .and. found_value)
then
126 call neko_error(
"non_normal_aligned accepts either 'file_name' or " // &
127 "'value', but not both.")
130 if (found_file_name)
then
132 call this%init_base(coef)
133 call this%bc_x%init_from_components(coef, 0.0_rp)
134 call this%bc_y%init_from_components(coef, 0.0_rp)
135 call this%bc_z%init_from_components(coef, 0.0_rp)
136 call json_get(json,
"file_name", this%field_file_name)
140 this%field_mesh_file_name,
"none")
145 this%read_values_from_field = .true.
146 this%use_constant_value = .false.
151 if (
size(
value) .ne. 3)
then
152 call neko_error(
"The non_normal boundary condition requires a " // &
153 "3-component value vector.")
157 call this%init_from_components(coef, value_3)
334 real(kind=
rp),
intent(out) :: sx, sy, sz
335 integer,
intent(in) :: facet
336 integer,
intent(in) :: el
339 associate(c => this%coef, nx => this%coef%nx, ny => this%coef%ny, &
346 do l = 2, c%Xh%lx - 1
348 sx = sx + abs(abs(nx(l, j, facet, el)) - 1.0_rp)
349 sy = sy + abs(abs(ny(l, j, facet, el)) - 1.0_rp)
350 sz = sz + abs(abs(nz(l, j, facet, el)) - 1.0_rp)
354 do l = 2, c%Xh%lx - 1
355 do j = 2, c%Xh%lx - 1
356 sx = sx + abs(abs(nx(l, j, facet, el)) - 1.0_rp)
357 sy = sy + abs(abs(ny(l, j, facet, el)) - 1.0_rp)
358 sz = sz + abs(abs(nz(l, j, facet, el)) - 1.0_rp)
362 do l = 2, c%Xh%lx - 1
363 do j = 2, c%Xh%lx - 1
364 sx = sx + abs(abs(nx(l, j, facet, el)) - 1.0_rp)
365 sy = sy + abs(abs(ny(l, j, facet, el)) - 1.0_rp)
366 sz = sz + abs(abs(nz(l, j, facet, el)) - 1.0_rp)
370 sx = sx / (c%Xh%lx - 2)**2
371 sy = sy / (c%Xh%lx - 2)**2
372 sz = sz / (c%Xh%lx - 2)**2
383 integer :: scratch_idx(3)
384 type(tuple_i4_t),
pointer :: bfp(:)
385 real(kind=rp) :: sx, sy, sz
386 real(kind=rp),
parameter :: tol = 1d-3
387 type(tuple_i4_t) :: bc_facet
389 type(field_t),
pointer :: value_x_field, value_y_field, value_z_field
390 associate(c => this%coef, nx => this%coef%nx, ny => this%coef%ny, &
392 bfp => this%marked_facet%array()
393 do i = 1, this%marked_facet%size()
395 facet = bc_facet%x(1)
397 call this%get_normal_axis(sx, sy, sz, facet, el)
399 if (sx .lt. tol)
then
400 call this%bc_y%mark_facet(facet, el)
401 call this%bc_z%mark_facet(facet, el)
404 if (sy .lt. tol)
then
405 call this%bc_x%mark_facet(facet, el)
406 call this%bc_z%mark_facet(facet, el)
409 if (sz .lt. tol)
then
410 call this%bc_y%mark_facet(facet, el)
411 call this%bc_x%mark_facet(facet, el)
415 call this%bc_x%finalize()
416 call this%bc_y%finalize()
417 call this%bc_z%finalize()
419 call this%value_x%init(this%bc_x%msk(0),
'non_normal_aligned_x')
420 call this%value_y%init(this%bc_y%msk(0),
'non_normal_aligned_y')
421 call this%value_z%init(this%bc_z%msk(0),
'non_normal_aligned_z')
423 if (this%use_constant_value)
then
424 this%value_x = this%constant_value(1)
425 this%value_y = this%constant_value(2)
426 this%value_z = this%constant_value(3)
427 else if (this%read_values_from_field)
then
428 call neko_scratch_registry%request_field(value_x_field, scratch_idx(1), &
430 call neko_scratch_registry%request_field(value_y_field, scratch_idx(2), &
432 call neko_scratch_registry%request_field(value_z_field, scratch_idx(3), &
435 if (trim(this%field_mesh_file_name) .eq.
"none")
then
436 call import_fields(this%field_file_name, &
437 u = value_x_field, v = value_y_field, w = value_z_field, &
438 interpolate = this%field_interpolate, &
439 tolerance = this%field_interp_tolerance, &
440 padding = this%field_interp_padding)
442 call import_fields(this%field_file_name, this%field_mesh_file_name, &
443 u = value_x_field, v = value_y_field, w = value_z_field, &
444 interpolate = this%field_interpolate, &
445 tolerance = this%field_interp_tolerance, &
446 padding = this%field_interp_padding)
449 call vector_masked_gather_copy_0(this%value_x, &
450 value_x_field%x(:,1,1,1), this%bc_x%msk, value_x_field%size(), &
452 call vector_masked_gather_copy_0(this%value_y, &
453 value_y_field%x(:,1,1,1), this%bc_y%msk, value_y_field%size(), &
455 call vector_masked_gather_copy_0(this%value_z, &
456 value_z_field%x(:,1,1,1), this%bc_z%msk, value_z_field%size(), &
458 call neko_scratch_registry%relinquish_field(scratch_idx)
461 call this%finalize_base()