9 integer,
parameter :: max_boundary_conds = 10
12 integer :: n_variables
13 double precision :: origin(3)
14 double precision :: dx(3)
15 integer :: n_points(3)
16 character(len=40),
allocatable :: names(:)
17 double precision,
allocatable :: values(:, :, :, :)
20 type(LT_t) :: lt_1d(max_boundary_conds)
21 type(LT2_t) :: lt_2d(max_boundary_conds)
22 type(LT3_t) :: lt_3d(max_boundary_conds)
28 integer,
public,
protected,
allocatable ::
bc_data_ix(:, :)
48 integer :: i, iw, ib, n_files, n_bc
49 double precision :: xmax(3)
61 xmax = bc%origin + (bc%n_points-1) * bc%dx
74 call mpistop(
"bc_data_init: 1D case not supported")
79 xmax(1:
ndim), bc%values(:, :, 1:1, n_bc))
83 xmax(1), bc%values(:, 1, 1:1, n_bc))
89 xmax(1:
ndim), bc%values(:, :, :, n_bc:n_bc))
93 xmax(1:
ndim-1), bc%values(:, :, 1:1, n_bc))
105 character(len=*),
intent(in) :: files(:)
111 do n = 1,
size(files)
112 open(
unitpar, file=trim(files(n)), status=
"old")
113 read(
unitpar, bd_list,
end=111)
120 integer,
intent(in) :: n_bc
121 double precision,
intent(in) :: x1, x2, qt
122 double precision :: val
125 val = lt3_get_col(lt_3d(n_bc), 1, x1, x2, qt)
127 val = lt2_get_col(lt_2d(n_bc), 1, x1, x2)
132 integer,
intent(in) :: n_bc
133 double precision,
intent(in) :: x1, qt
134 double precision :: val
137 val = lt2_get_col(lt_2d(n_bc), 1, x1, qt)
139 val = lt_get_col(lt_1d(n_bc), 1, x1)
149 integer,
intent(in) :: ixi^
l, ixo^
l, ib
150 double precision,
intent(in) :: qt, x(ixi^s,1:
ndim)
151 double precision,
intent(inout) :: w(ixi^s,1:nw)
152 double precision :: tmp(ixo^s)
153 integer :: i, ix, iw, n_bc
196 if (n_bc == -1) cycle
199 x(ixomin1, ixomin2:ixomax2, 2), qt)
204 do i = 0, ixoomax1-ixoomin1
205 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
206 2 * tmp(ixomin1, ixomin2:ixomax2) - &
207 w(ix, ixomin2:ixomax2, iw)
211 do i = 0, ixoomax1-ixoomin1
213 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
214 4 * tmp(ixomin1, ixomin2:ixomax2) - &
215 3 * w(ix, ixomin2:ixomax2, iw)
217 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
218 2 * tmp(ixomin1, ixomin2:ixomax2) - &
219 w(ix, ixomin2:ixomax2, iw)
221 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
222 tmp(ixomin1, ixomin2:ixomax2)
227 do i = 0, ixoomax1-ixoomin1
228 if (i==ixoomax1-ixoomin1)
then
229 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
230 4 * tmp(ixomin1, ixomin2:ixomax2) - &
231 3 * w(ix, ixomin2:ixomax2, iw)
232 elseif (i==ixoomax1-ixoomin1-1)
then
233 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
234 2 * tmp(ixomin1, ixomin2:ixomax2) - &
235 w(ix, ixomin2:ixomax2, iw)
237 w(ixoomin1+i, ixomin2:ixomax2, iw) = &
238 tmp(ixomin1, ixomin2:ixomax2)
246 do i = ixoomin1, ixoomax1
247 w(i, ixomin2:ixomax2, iw) = &
248 tmp(ixomin1, ixomin2:ixomax2)
291 if (n_bc == -1) cycle
294 x(ixomin1:ixomax1, ixomin2, 1), qt)
301 do i = 0, ixoomax2-ixoomin2
302 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
303 2 * tmp(ixomin1:ixomax1, ixomin2) - &
304 w(ixomin1:ixomax1, ix, iw)
308 do i = 0, ixoomax2-ixoomin2
310 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
311 4 * tmp(ixomin1:ixomax1, ixomin2) - &
312 3 * w(ixomin1:ixomax1, ix, iw)
314 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
315 2 * tmp(ixomin1:ixomax1, ixomin2) - &
316 w(ixomin1:ixomax1, ix, iw)
318 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
319 tmp(ixomin1:ixomax1, ixomin2)
324 do i = 0, ixoomax2-ixoomin2
325 if (i==ixoomax2-ixoomin2)
then
326 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
327 4 * tmp(ixomin1:ixomax1, ixomin2) - &
328 3 * w(ixomin1:ixomax1, ix, iw)
329 elseif (i==ixoomax2-ixoomin2-1)
then
330 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
331 2 * tmp(ixomin1:ixomax1, ixomin2) - &
332 w(ixomin1:ixomax1, ix, iw)
334 w(ixomin1:ixomax1, ixoomin2+i, iw) = &
335 tmp(ixomin1:ixomax1, ixomin2)
343 do i = ixoomin2, ixoomax2
344 w(ixomin1:ixomax1, i, iw) = &
345 tmp(ixomin1:ixomax1, ixomin2)
356 call mpistop(
"bc_data_set: unknown iB")
395 if (n_bc == -1) cycle
397 tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) =
bc_data_get_3d(n_bc, &
398 x(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3, 2), &
399 x(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3, 3), qt)
406 do i = 0, ixoomax1-ixoomin1
407 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
408 2 * tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) - &
409 w(ix, ixomin2:ixomax2, ixomin3:ixomax3, iw)
413 do i = 0, ixoomax1-ixoomin1
415 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
416 4 * tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) - &
417 3*w(ix, ixomin2:ixomax2, ixomin3:ixomax3, iw)
419 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
420 2 * tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) - &
421 w(ix, ixomin2:ixomax2, ixomin3:ixomax3, iw)
423 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
424 tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3)
429 do i = 0, ixoomax1-ixoomin1
430 if (i==ixoomax1-ixoomin1)
then
431 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
432 4 * tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) - &
433 3*w(ix, ixomin2:ixomax2, ixomin3:ixomax3, iw)
434 elseif (i==ixoomax1-ixoomin1-1)
then
435 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
436 2 * tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3) - &
437 w(ix, ixomin2:ixomax2, ixomin3:ixomax3, iw)
439 w(ixoomin1+i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
440 tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3)
448 do i = ixoomin1,ixoomax1
449 w(i, ixomin2:ixomax2, ixomin3:ixomax3, iw) = &
450 tmp(ixomin1, ixomin2:ixomax2, ixomin3:ixomax3)
493 if (n_bc == -1) cycle
495 tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) =
bc_data_get_3d(n_bc, &
496 x(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3, 1), &
497 x(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3, 3), qt)
504 do i = 0, ixoomax2-ixoomin2
505 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
506 2 * tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) - &
507 w(ixomin1:ixomax1, ix, ixomin3:ixomax3, iw)
511 do i = 0, ixoomax2-ixoomin2
513 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
514 4 * tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) - &
515 3* w(ixomin1:ixomax1, ix, ixomin3:ixomax3, iw)
517 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
518 2 * tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) - &
519 w(ixomin1:ixomax1, ix, ixomin3:ixomax3, iw)
521 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
522 tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3)
527 do i = 0, ixoomax2-ixoomin2
528 if (i==ixoomax2-ixoomin2)
then
529 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
530 4 * tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) - &
531 3* w(ixomin1:ixomax1, ix, ixomin3:ixomax3, iw)
532 elseif (i==ixoomax2-ixoomin2-1)
then
533 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
534 2 * tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3) - &
535 w(ixomin1:ixomax1, ix, ixomin3:ixomax3, iw)
537 w(ixomin1:ixomax1, ixoomin2+i, ixomin3:ixomax3, iw) = &
538 tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3)
546 do i = ixoomin2,ixoomax2
547 w(ixomin1:ixomax1, i, ixomin3:ixomax3, iw) = &
548 tmp(ixomin1:ixomax1, ixomin2, ixomin3:ixomax3)
590 if (n_bc == -1) cycle
592 tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) =
bc_data_get_3d(n_bc, &
593 x(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3, 1), &
594 x(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3, 2), qt)
601 do i = 0, ixoomax3-ixoomin3
602 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
603 2 * tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) - &
604 w(ixomin1:ixomax1, ixomin2:ixomax2, ix, iw)
608 do i = 0, ixoomax3-ixoomin3
610 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
611 4 * tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) - &
612 3 * w(ixomin1:ixomax1, ixomin2:ixomax2, ix, iw)
614 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
615 2 * tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) - &
616 w(ixomin1:ixomax1, ixomin2:ixomax2, ix, iw)
618 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
619 tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3)
624 do i = 0, ixoomax3-ixoomin3
625 if (i==ixoomax3-ixoomin3)
then
626 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
627 4 * tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) - &
628 3 * w(ixomin1:ixomax1, ixomin2:ixomax2, ix, iw)
629 elseif (i==ixoomax3-ixoomin3-1)
then
630 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
631 2 * tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3) - &
632 w(ixomin1:ixomax1, ixomin2:ixomax2, ix, iw)
634 w(ixomin1:ixomax1, ixomin2:ixomax2, ixoomin3+i, iw) = &
635 tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3)
643 do i = ixoomin3,ixoomax3
644 w(ixomin1:ixomax1, ixomin2:ixomax2, i, iw) = &
645 tmp(ixomin1:ixomax1, ixomin2:ixomax2, ixomin3)
655 call mpistop(
"bc_data_set: unknown iB")
666 character(len=*),
intent(in) :: fname
667 type(bc_data_t),
intent(out) :: bc
668 double precision,
allocatable :: tmp_data(:, :, :, :)
669 integer,
parameter :: max_variables = 10
670 character(len=40) :: tmp_names(max_variables)
671 character(len=256) :: line
672 character(len=40) :: word, typename
673 integer,
parameter :: my_unit = 123
674 integer :: n, n_points_total
675 integer :: n_components
677 open(my_unit, file=trim(fname), status=
"old", action=
"read")
680 read(my_unit,
"(A)") line
683 read(my_unit,
"(A)") line
686 read(my_unit,
"(A)") line
688 if (line /=
"ASCII")
then
689 print *,
"line: ", trim(line)
690 error stop
"read_vtk: not an ASCII file"
694 read(my_unit,
"(A)") line
696 if (line /=
"DATASET STRUCTURED_POINTS")
then
697 print *,
"line: ", trim(line)
698 error stop
"read_vtk must have: DATASET STRUCTURED_POINTS"
702 read(my_unit,
"(A)") line
703 read(line, *) word, bc%n_points
705 if (word /=
"DIMENSIONS")
then
706 print *,
"line: ", trim(line)
707 error stop
"read_vtk expects: DIMENSIONS"
711 read(my_unit, *) word, bc%dx
713 if (word /=
"SPACING")
then
714 print *,
"line: ", trim(line)
715 error stop
"read_vtk expects: SPACING"
719 read(my_unit, *) word, bc%origin
720 if (word /=
"ORIGIN")
then
721 print *,
"line: ", trim(line)
722 error stop
"read_vtk expects: ORIGIN"
726 read(my_unit, *) word, n_points_total
728 if (word /=
"POINT_DATA")
then
729 print *,
"line: ", trim(line)
730 error stop
"read_vtk expects: POINT_DATA n_points"
733 if (n_points_total /= product(bc%n_points)) &
734 error stop
"read_vtk: n_points not equal to NX*NY*NZ"
736 allocate(tmp_data(bc%n_points(1), bc%n_points(2), bc%n_points(3), &
740 do n = 1, max_variables
743 read(my_unit, *,
end=900) word, tmp_names(n), typename, n_components
745 if (word /=
"SCALARS")
then
746 print *,
"line: ", trim(line)
747 error stop
"read_vtk expects: SCALARS name type ncomponents"
750 if (n_components /= 1) error stop
"read_vtk: ncomponents should be 1"
753 read(my_unit, *) word, typename
755 if (word /=
"LOOKUP_TABLE")
then
756 print *,
"line: ", trim(line)
757 error stop
"read_vtk expects: LOOKUP_TABLE name"
761 read(my_unit, *) tmp_data(:, :, :, n)
769 if (n == max_variables + 1) &
770 error stop
"read_vtk: increase max_variables"
774 bc%values = tmp_data(:, :, :, 1:n-1)
775 bc%names = tmp_names(1:n-1)
Module to set boundary conditions from user data.
logical, public, protected interp_phy_first_row_same
subroutine read_vtk_structured_points(fname, bc)
character(len=std_len), public, protected boundary_data_file_name
data file name
elemental double precision function, public bc_data_get_2d(n_bc, x1, qt)
logical, public, protected bc_phy_first_row
subroutine bc_read_params(files)
Read this module"s parameters from a file.
logical, public, protected boundary_data_primitive
elemental double precision function, public bc_data_get_3d(n_bc, x1, x2, qt)
subroutine, public bc_data_set(qt, ixIL, ixOL, iB, w, x)
Set boundary conditions according to user data.
subroutine, public bc_data_init()
integer, dimension(:, :), allocatable, public, protected bc_data_ix
Integer array for indexing lookup tables per variable per direction.
logical, public, protected bc_data_time_varying
Whether boundary condition data is time varying.
logical, public, protected interp_phy_first_row
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter unitpar
file handle for IO
integer, dimension(:, :), allocatable typeboundary
Array indicating the type of boundary condition per variable and per physical boundary.
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer, parameter bc_data
character(len=std_len), dimension(:), allocatable par_files
Which par files are used as input.
integer, parameter bc_icarus
A Fortran 90 module for creating 1D and 2D lookup tables. These tables can be used to efficiently int...
type(lt2_t) function, public lt2_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
type(lt_t) function, public lt_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
type(lt3_t) function, public lt3_create_from_data(x_min, x_max, spaced_data)
This function returns a new lookup table from regularly spaced data.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_convert), pointer phys_to_primitive
procedure(sub_convert), pointer phys_to_conserved