Afivo  0.3
computational_domain_3d.f90
1 
4 program computational_domain_3d
5  use m_a3_all
6 
7  implicit none
8 
9  integer :: n_cell = 4 ! Boxes contain n_cell^dim cells
10  real(dp) :: dr = 1.0_dp ! Coarse grid spacing
11  integer :: n_var_cc = 1 ! Number of cell-centered variables
12  integer :: n_var_fc = 0 ! Number of face-centered variables
13  type(a3_t) :: tree ! Will contain the quad/octree grid
14 
15  integer, parameter :: n_boxes = 2 ! How many boxes to add
16  integer :: ix_list(3, n_boxes) ! Spatial indices of boxes
17  integer :: nb_list(a3_num_neighbors, n_boxes) ! Neighbor information
18 
19  ! Create mesh 1: two boxes along x-direction
20  ix_list(:, 1) = [1, 1, 1] ! Box 1 at [1, 1, 1]
21  ix_list(:, 2) = [2, 1, 1] ! Box 2 at [2, 1, 1]
22 
23  call a3_init(tree, n_cell, n_var_cc, n_var_fc, dr)
24  call a3_set_base(tree, n_boxes, ix_list)
25  call a3_write_vtk(tree, "computational_domain_3d_1", dir="output")
26  call a3_destroy(tree)
27 
28  ! Create mesh 2: two boxes along y-direction
29  ix_list(:, 1) = [1, 1, 1] ! Box 1 at [1, 1, 1]
30  ix_list(:, 2) = [1, 2, 1] ! Box 2 at [1, 2, 1]
31 
32  call a3_init(tree, n_cell, n_var_cc, n_var_fc, dr)
33  call a3_set_base(tree, n_boxes, ix_list)
34  call a3_write_vtk(tree, "computational_domain_3d_2", dir="output")
35  call a3_destroy(tree)
36 
37  ! Create mesh 3: Two boxes along x-direction that are fully periodic
38  ix_list(:, 1) = [1, 1, 1] ! Box 1 at [1, 1, 1]
39  ix_list(:, 2) = [2, 1, 1] ! Box 2 at [2, 1, 1]
40 
41  nb_list(:, :) = af_no_box ! Start with default value
42  nb_list(a3_neighb_lowx, 1) = 2 ! Box 1's lower x-neighbor is box 2
43  nb_list(a3_neighb_lowy, 1) = 1 ! Box 1 is periodic in y-direction
44  nb_list(a3_neighb_lowy, 2) = 2 ! Box 2 is periodic in y-direction
45  nb_list(a3_neighb_lowz, 1) = 1
46  nb_list(a3_neighb_lowz, 2) = 2
47 
48  call a3_init(tree, n_cell, n_var_cc, n_var_fc, dr)
49  call a3_set_base(tree, n_boxes, ix_list, nb_list)
50  call a3_write_vtk(tree, "computational_domain_3d_3", dir="output")
51  call a3_destroy(tree)
52 
53 end program computational_domain_3d
Module which contains all Afivo modules, so that a user does not have to include them separately...
Definition: m_a3_all.f90:4