Afivo 0.3
All Classes Namespaces Functions Variables Pages
computational_domain.f90

Example showing how create different types of computational domains.

Example showing how create different types of computational domains

1#include "../src/cpp_macros.h"
2!> \example computational_domain.f90
3!> Example showing how create different types of computational domains
4program computational_domain
5 use m_af_all
6
7 implicit none
8
9 integer :: n_cell = 4 ! Boxes contain n_cell^dim cells
10 type(af_t) :: tree ! Will contain the quad/octree grid
11 integer :: grid_size(NDIM)
12 real(dp) :: domain_size(NDIM)
13 logical :: periodic(NDIM)
14
15 ! Create mesh 1: two boxes along x-direction
16 grid_size(:) = n_cell
17 grid_size(1) = 2 * n_cell
18 domain_size = 1.0_dp * grid_size
19
20 call af_add_cc_variable(tree, "phi")
21 call af_init(tree, n_cell, domain_size, grid_size, mem_limit_gb=0.1_dp)
22 call af_write_silo(tree, "output/computational_domain_" // dimname // "_1")
23 call af_destroy(tree)
24
25 ! Create mesh 2: two boxes along y-direction
26 grid_size(:) = n_cell
27#if NDIM > 1
28 grid_size(2) = 2 * n_cell
29#endif
30 domain_size = 1.0_dp * grid_size
31
32 call af_add_cc_variable(tree, "phi")
33 call af_init(tree, n_cell, domain_size, grid_size, mem_limit_gb=0.1_dp)
34 call af_write_silo(tree, "output/computational_domain_" // dimname // "_2")
35 call af_destroy(tree)
36
37 ! Create mesh 3: Two boxes along x-direction that are fully periodic
38 grid_size(:) = n_cell
39 grid_size(1) = 2 * n_cell
40 periodic(:) = .true.
41 domain_size = 1.0_dp * grid_size
42
43 call af_add_cc_variable(tree, "phi")
44 call af_init(tree, n_cell, domain_size, grid_size, mem_limit_gb=0.1_dp)
45 call af_write_silo(tree, "output/computational_domain_" // dimname // "_3")
46 call af_destroy(tree)
47
48end program computational_domain
Module which contains all Afivo modules, so that a user does not have to include them separately.
Definition: m_af_all.f90:3