MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
mod_initialize_amr.t
Go to the documentation of this file.
2
3 implicit none
4 private
5
6 public :: initlevelone
7 public :: modify_ic
8 public :: initial_condition
10
11
12contains
13
14
15 !> Generate and initialize all grids at the coarsest level (level one)
16 subroutine initlevelone
23
24 integer :: iigrid, igrid{#ifdef evolvingboundary , morton_no}
25
26 levmin=1
27 levmax=1
28
30
31 call getigrids
33
34 ! fill solution space of all root grids
35 do iigrid=1,igridstail; igrid=igrids(iigrid);
36 call alloc_node(igrid)
37 ! in case gradient routine used in initial condition, ensure geometry known
38 call initial_condition(igrid)
39 end do
40 {#IFDEF EVOLVINGBOUNDARY
41 ! mark physical-boundary blocks on space-filling curve
42 do morton_no=morton_start(mype),morton_stop(mype)
43 igrid=sfc_to_igrid(morton_no)
44 if (phyboundblock(igrid)) sfc_phybound(morton_no)=1
45 end do
46 call mpi_allreduce(mpi_in_place,sfc_phybound,nleafs,mpi_integer,&
47 mpi_sum,icomm,ierrmpi)
48 }
49
50 ! update ghost cells
51 call getbc(global_time,0.d0,ps,iwstart,nwgc)
53
54 end subroutine initlevelone
55
56 !> fill in initial condition
57 subroutine initial_condition(igrid)
58 ! Need only to set the mesh values (can leave ghost cells untouched)
61 use mod_comm_lib, only: mpistop
62
63 integer, intent(in) :: igrid
64
65 ! in case gradient routine used in initial condition, ensure geometry known
66 block=>ps(igrid)
67 ^d&dxlevel(^d)=rnode(rpdx^d_,igrid);
68
69 if (.not. associated(usr_init_one_grid)) then
70 call mpistop("usr_init_one_grid not defined")
71 else
72 call usr_init_one_grid(ixg^ll,ixm^ll,ps(igrid)%w,ps(igrid)%x)
73 end if
74
75 end subroutine initial_condition
76
77 !> modify initial condition
78 subroutine modify_ic
81 use mod_comm_lib, only: mpistop
82
83 integer :: iigrid, igrid
84
85 do iigrid=1,igridstail; igrid=igrids(iigrid);
86 block=>ps(igrid)
87 ^d&dxlevel(^d)=rnode(rpdx^d_,igrid);
88
89 if (.not. associated(usr_init_one_grid)) then
90 call mpistop("usr_init_one_grid not defined")
91 else
92 call usr_init_one_grid(ixg^ll,ixm^ll,ps(igrid)%w,ps(igrid)%x)
93 end if
94 end do
95
96 end subroutine modify_ic
97
98 !> improve initial condition after initialization
104 use mod_physics
106
107 logical :: active
108
109 if(associated(usr_improve_initial_condition)) then
111 else if(stagger_grid) then
112 if(associated(usr_init_vector_potential)) then
113 ! re-calculate magnetic field from the vector potential in a
114 ! completely divergency free way for AMR mesh in 3D
115 if(levmax>levmin.and.ndim==3) call recalculateb
116 end if
117 if(slab_uniform.and.associated(phys_clean_divb)) then
118 ! Project out the divB using multigrid poisson solver
119 ! if not initialised from vector potential
120 if(.not.use_multigrid) call mg_setup_multigrid()
121 call phys_clean_divb(global_time,0.d0,active)
122 call getbc(global_time,0.d0,ps,iwstart,nwgc)
123 end if
124 end if
125
126 end subroutine improve_initial_condition
127
128end module mod_initialize_amr
subroutine, public alloc_node(igrid)
allocate arrays on igrid node
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
subroutine recalculateb
re-calculate the magnetic field from the vector potential in a completely divergency free way
Equation of state for AMRVAC, handled through a single eos_container object.
Definition mod_eos.t:30
subroutine, public prepare_eos_w_fields(psx)
Definition mod_eos.t:419
subroutine, public init_forest_root
build root forest
update ghost cells of all blocks including physical boundaries
subroutine getbc(time, qdt, psb, nwstart, nwbc)
do update ghost cells of all blocks including physical boundaries
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
double precision global_time
The global simulation time.
integer, parameter ndim
Number of spatial dimensions for grid variables.
logical stagger_grid
True for using stagger grid.
logical, dimension(:), allocatable phyboundblock
True if a block has any physical boundary.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
integer ixm
the mesh range of a physical block without ghost cells
integer ierrmpi
A global MPI error return code.
double precision, dimension(:), allocatable, parameter d
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
logical use_multigrid
Use multigrid (only available in 2D and 3D).
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
subroutine, public improve_initial_condition()
improve initial condition after initialization
subroutine, public initlevelone
Generate and initialize all grids at the coarsest level (level one).
subroutine, public modify_ic
modify initial condition
subroutine, public initial_condition(igrid)
fill in initial condition
Module to couple the octree-mg library to AMRVAC. This file uses the VACPP preprocessor,...
subroutine mg_setup_multigrid()
Setup multigrid for usage.
This module defines the procedures of a physics module. It contains function pointers for the various...
Definition mod_physics.t:4
procedure(sub_clean_divb), pointer phys_clean_divb
Definition mod_physics.t:92
Module with all the methods that users can customize in AMRVAC.
procedure(p_no_args), pointer usr_improve_initial_condition
procedure(init_one_grid), pointer usr_init_one_grid
Initialize earch grid block data.
procedure(init_vector_potential), pointer usr_init_vector_potential