MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
mod_usr_methods.t
Go to the documentation of this file.
1!> Module with all the methods that users can customize in AMRVAC
2!>
3!> Each procedure pointer can be initialized in a user's mod_usr.t
5
6 implicit none
7 public
8
9 !> Initialize the user's settings (after initializing amrvac)
10 procedure(p_no_args), pointer :: usr_set_parameters => null()
11 !> Initialize earch grid block data
12 procedure(init_one_grid), pointer :: usr_init_one_grid => null()
13
14 ! Boundary condition related
15 procedure(special_bc), pointer :: usr_special_bc => null()
16 procedure(special_prepare_bc), pointer :: usr_prepare_boundary => null()
17 procedure(special_mg_bc), pointer :: usr_special_mg_bc => null()
18
19 procedure(internal_bc), pointer :: usr_internal_bc => null()
20
21 ! Output related
22 procedure(p_no_args), pointer :: usr_print_log => null()
23 procedure(p_no_args), pointer :: usr_write_analysis => null()
24 procedure(transform_w), pointer :: usr_transform_w => null()
25 procedure(aux_output), pointer :: usr_aux_output => null()
26 procedure(add_aux_names), pointer :: usr_add_aux_names => null()
27 procedure(sub_modify_io), pointer :: usr_modify_output => null()
28 procedure(special_convert), pointer :: usr_special_convert => null()
29
30 ! Called at the beginning of every time step (after determining dt)
31 procedure(process_grid), pointer :: usr_process_grid => null()
32 procedure(process_global), pointer :: usr_process_global => null()
33
34 ! Called every time step just after advance (with w^(n+1), it^n, global_time^n)
35 procedure(process_adv_grid), pointer :: usr_process_adv_grid => null()
36 procedure(process_adv_global), pointer :: usr_process_adv_global => null()
37
38 ! Called after initial condition before the start of the simulation
39 procedure(p_no_args), pointer :: usr_improve_initial_condition => null()
40
41 ! Called before the start of the simulation
42 procedure(p_no_args), pointer :: usr_before_main_loop => null()
43
44 ! Source terms
45 procedure(source), pointer :: usr_source => null()
46 procedure(source), pointer :: usr_source_after => null()
47 !> opacity and Planck source for the SC RT when rt_sc_opacity = 'usr'
48 procedure(sub_rt_sc_chib), pointer :: usr_rt_sc_chib => null()
49 procedure(get_dt), pointer :: usr_get_dt => null()
50 procedure(phys_gravity), pointer :: usr_gravity => null()
51 procedure(sub_get_heating), pointer :: usr_get_heating => null()
52
53 ! Usr defined dust drag force
54 procedure(phys_dust_get_dt), pointer :: usr_dust_get_dt => null()
55 procedure(phys_dust_get_3d_dragforce), pointer :: usr_get_3d_dragforce => null()
56
57 ! Usr defined space varying viscosity
58 procedure(set_viscosity), pointer :: usr_set_viscosity => null()
59
60 ! Usr defined thermal pressure for hydro & energy=.False.
61 procedure(hd_pthermal), pointer :: usr_set_pthermal => null()
62
63 ! Refinement related procedures
64 procedure(refine_grid), pointer :: usr_refine_grid => null()
65 procedure(var_for_errest), pointer :: usr_var_for_errest => null()
66 procedure(a_refine_threshold), pointer :: usr_refine_threshold => null()
67 procedure(flag_grid), pointer :: usr_flag_grid => null()
68
69 ! Set time-independent magnetic field for B0 splitting
70 procedure(set_b0), pointer :: usr_set_b0 => null()
71 ! Set time-independent variables for equilibrium splitting, except for B0
72 procedure(set_equi_vars), pointer :: usr_set_equi_vars => null()
73 ! Set time-independent current density for B0 splitting
74 procedure(set_j0), pointer :: usr_set_j0 => null()
75 procedure(special_resistivity), pointer :: usr_special_resistivity => null()
76
77 ! Particle module related
78 procedure(update_payload), pointer :: usr_update_payload => null()
79 procedure(create_particles), pointer :: usr_create_particles => null()
80 procedure(check_particle), pointer :: usr_check_particle => null()
81 procedure(particle_fields), pointer :: usr_particle_fields => null()
82 procedure(particle_analytic), pointer :: usr_particle_analytic => null()
83 procedure(particle_position), pointer :: usr_particle_position => null()
84
85 ! Radiation quantity related
86 procedure(special_opacity), pointer :: usr_special_opacity => null()
87 procedure(special_fluxlimiter), pointer :: usr_special_fluxlimiter => null()
88 procedure(special_diffcoef), pointer :: usr_special_diffcoef => null()
89
90 ! Called after the mesh has been adjuste
91 procedure(after_refine), pointer :: usr_after_refine => null()
92
93 ! initialize vector potential on cell edges for magnetic field
94 procedure(init_vector_potential), pointer :: usr_init_vector_potential => null()
95
96 ! allow user to change inductive electric field, especially for boundary driven applications
97 procedure(set_electric_field), pointer :: usr_set_electric_field => null()
98
99 ! allow user to specify variables at physical boundaries
100 procedure(set_wlr), pointer :: usr_set_wlr => null()
101
102 ! allow user to specify the expansion function for the surface of a cross sectional
103 ! area of a 1D prominence, along with the analytical derivative of that function and its
104 ! primitive shape evaluated in the boundaries \int_(x_i-dx_i/2)^(x_i+dx_i/2) A(s) ds
105 procedure(set_surface), pointer :: usr_set_surface => null()
106
107 ! for tracing field. allow user to specify variables and field
108 procedure(set_field_w), pointer :: usr_set_field_w => null()
109 procedure(set_field), pointer :: usr_set_field => null()
110
111 ! allow user to specify R factor in ideal gas law with partial ionization
112 procedure(rfactor), pointer :: usr_rfactor => null()
113
114 ! allow user to specify adiabatic index and gamma dependent on space
115 procedure(set_adiab), pointer :: usr_set_adiab => null()
116 procedure(set_adiab), pointer :: usr_set_gamma => null()
117
118 !> Optionally provide local UAWSoM closure coefficients. The returned
119 !> thread radius and Alfven correlation length are in code length units.
120 procedure(uawsom_coefficients), pointer :: usr_uawsom_coefficients => null()
121
122 abstract interface
123
124 subroutine uawsom_coefficients(w,x,ixI^L,ixO^L,primitive,zeta,thread_radius,lperp_alfven)
126 integer, intent(in) :: ixI^L, ixO^L
127 double precision, intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
128 logical, intent(in) :: primitive
129 double precision, intent(out):: zeta(ixI^S), thread_radius(ixI^S)
130 double precision, intent(out):: lperp_alfven(ixI^S)
131 end subroutine uawsom_coefficients
132
133 subroutine p_no_args()
134 end subroutine p_no_args
135
136 !> Initialize one grid
137 subroutine init_one_grid(ixI^L,ixO^L,w,x)
139 integer, intent(in) :: ixI^L, ixO^L
140 double precision, intent(in) :: x(ixI^S,1:ndim)
141 double precision, intent(inout) :: w(ixI^S,1:nw)
142 end subroutine init_one_grid
143
144 !> special boundary types, users must assign conservative
145 !> variables in boundaries
146 subroutine special_bc(qdt,qt,ixI^L,ixO^L,iB,w,x)
148 !> Shape of input arrays
149 integer, intent(in) :: ixI^L
150 !> Region where boundary values have to be set
151 integer, intent(in) :: ixO^L
152 !> Integer indicating direction of boundary
153 integer, intent(in) :: iB
154 double precision, intent(in) :: qdt,qt, x(ixI^S,1:ndim)
155 double precision, intent(inout) :: w(ixI^S,1:nw)
156 end subroutine special_bc
157
158 subroutine special_prepare_bc(qt,qdt)
160 double precision, intent(in) :: qt, qdt
161 end subroutine special_prepare_bc
162
163 !> Special boundary type for radiation hydrodynamics module, only used to
164 !> set the boundary conditions for the radiation energy.
165 subroutine special_mg_bc(iB)
167 integer, intent(in) :: iB
168 end subroutine special_mg_bc
169
170 !> internal boundary, user defined
171 !> This subroutine can be used to artificially overwrite ALL conservative
172 !> variables in a user-selected region of the mesh, and thereby act as
173 !> an internal boundary region. It is called just before external (ghost cell)
174 !> boundary regions will be set by the BC selection. Here, you could e.g.
175 !> want to introduce an extra variable (nwextra, to be distinguished from nwaux)
176 !> which can be used to identify the internal boundary region location.
177 !> Its effect should always be local as it acts on the mesh.
178 subroutine internal_bc(level,qt,qdt,ixI^L,ixO^L,w,x)
180 integer, intent(in) :: ixI^L,ixO^L,level
181 double precision, intent(in) :: qt, qdt
182 double precision, intent(inout) :: w(ixI^S,1:nw)
183 double precision, intent(in) :: x(ixI^S,1:ndim)
184 end subroutine internal_bc
185
186 !> this subroutine is ONLY to be used for computing auxiliary variables
187 !> which happen to be non-local (like div v), and are in no way used for
188 !> flux computations. As auxiliaries, they are also not advanced
189 subroutine process_grid(igrid,level,ixI^L,ixO^L,qt,w,x)
191 integer, intent(in) :: igrid,level,ixI^L,ixO^L
192 double precision, intent(in) :: qt,x(ixI^S,1:ndim)
193 double precision, intent(inout) :: w(ixI^S,1:nw)
194 end subroutine process_grid
195
196 !> If defined, this routine is called before writing output, and it can
197 !> set/modify the variables in the w array.
198 subroutine sub_modify_io(ixI^L,ixO^L,qt,w,x)
200 integer, intent(in) :: ixI^L,ixO^L
201 double precision, intent(in) :: qt,x(ixI^S,1:ndim)
202 double precision, intent(inout) :: w(ixI^S,1:nw)
203 end subroutine sub_modify_io
204
205 !> This subroutine is called at the beginning of each time step
206 !> by each processor. No communication is specified, so the user
207 !> has to implement MPI routines if information has to be shared
208 subroutine process_global(iit,qt)
210 integer, intent(in) :: iit
211 double precision, intent(in) :: qt
212 end subroutine process_global
213
214 !> for processing after the advance (PIC-MHD, e.g.)
215 subroutine process_adv_grid(igrid,level,ixI^L,ixO^L,qt,w,x)
217 integer, intent(in) :: igrid,level,ixI^L,ixO^L
218 double precision, intent(in) :: qt,x(ixI^S,1:ndim)
219 double precision, intent(inout) :: w(ixI^S,1:nw)
220 end subroutine process_adv_grid
221
222 !> for processing after the advance (PIC-MHD, e.g.)
223 subroutine process_adv_global(iit,qt)
225 integer, intent(in) :: iit
226 double precision, intent(in) :: qt
227 end subroutine process_adv_global
228
229 !> this subroutine can be used in convert, to add auxiliary variables to the
230 !> converted output file, for further analysis using tecplot, paraview, ....
231 !> these auxiliary values need to be stored in the nw+1:nw+nwauxio slots
232 !
233 !> the array normconv can be filled in the (nw+1:nw+nwauxio) range with
234 !> corresponding normalization values (default value 1)
235 subroutine aux_output(ixI^L,ixO^L,w,x,normconv)
237 integer, intent(in) :: ixI^L,ixO^L
238 double precision, intent(in) :: x(ixI^S,1:ndim)
239 double precision :: w(ixI^S,nw+nwauxio)
240 double precision :: normconv(0:nw+nwauxio)
241 end subroutine aux_output
242
243 !> Add names for the auxiliary variables
244 subroutine add_aux_names(varnames)
246 character(len=*) :: varnames
247 end subroutine add_aux_names
248
249 !> Calculate w(iw)=w(iw)+qdt*SOURCE[wCT,qtC,x] within ixO for all indices
250 !> iw=iwmin...iwmax. wCT is at time qCT
251 subroutine source(qdt,ixI^L,ixO^L,iw^LIM,qtC,wCT,qt,w,x)
253 integer, intent(in) :: ixI^L, ixO^L, iw^LIM
254 double precision, intent(in) :: qdt, qtC, qt
255 double precision, intent(in) :: wCT(ixI^S,1:nw), x(ixI^S,1:ndim)
256 double precision, intent(inout) :: w(ixI^S,1:nw)
257 end subroutine source
258
259 !> Limit "dt" further if necessary, e.g. due to the special source terms.
260 !> The getdt_courant (CFL condition) and the getdt subroutine in the AMRVACPHYS
261 !> module have already been called.
262 subroutine get_dt(w,ixI^L,ixO^L,dtnew,dx^D,x)
264 integer, intent(in) :: ixI^L, ixO^L
265 double precision, intent(in) :: dx^D, x(ixI^S,1:ndim)
266 double precision, intent(in) :: w(ixI^S,1:nw)
267 double precision, intent(inout) :: dtnew
268 end subroutine get_dt
269
270 !> Calculate gravitational acceleration in each dimension
271 subroutine phys_gravity(ixI^L,ixO^L,wCT,x,gravity_field)
273 integer, intent(in) :: ixI^L, ixO^L
274 double precision, intent(in) :: x(ixI^S,1:ndim)
275 double precision, intent(in) :: wCT(ixI^S,1:nw)
276 double precision, intent(out) :: gravity_field(ixI^S,ndim)
277 end subroutine phys_gravity
278
279 !> Calculate the 3d drag force of gas onto dust
280 subroutine phys_dust_get_3d_dragforce(ixI^L, ixO^L, w, x, fdrag, ptherm, vgas,dust_n_species)
282 integer, intent(in) :: ixI^L, ixO^L, dust_n_species
283 double precision, intent(in) :: x(ixI^S, 1:ndim)
284 double precision, intent(in) :: w(ixI^S, 1:nw)
285 double precision, intent(out) :: &
286 fdrag(ixI^S, 1:ndir, 1:dust_n_species)
287 double precision, intent(in) :: ptherm(ixI^S), vgas(ixI^S, ndir)
288 end subroutine phys_dust_get_3d_dragforce
289
290 !> Calculate the time step associated with the usr drag force
291 subroutine phys_dust_get_dt(w, ixI^L, ixO^L, dtdust, dx^D, x, dust_n_species)
293 integer, intent(in) :: ixI^L, ixO^L, dust_n_species
294 double precision, intent(in) :: dx^D, x(ixI^S,1:ndim)
295 double precision, intent(in) :: w(ixI^S,1:nw)
296 double precision, intent(inout) :: dtdust(1:dust_n_species)
297 end subroutine phys_dust_get_dt
298
299 !>Calculation anormal viscosity depending on space
300 subroutine set_viscosity(ixI^L,ixO^L,x,wp,mu)
302 integer, intent(in) :: ixI^L, ixO^L
303 double precision, intent(in) :: x(ixI^S,1:ndim)
304 double precision, intent(in) :: wp(ixI^S,1:nw) ! primitive w
305 double precision, intent(out) :: mu(ixI^S)
306 end subroutine set_viscosity
307
308 !>Calculation anormal pressure for hd & energy=.False.
309 subroutine hd_pthermal(w,x,ixI^L,ixO^L,pth)
311 integer, intent(in) :: ixI^L, ixO^L
312 double precision, intent(in) :: x(ixI^S,1:ndim)
313 double precision, intent(in) :: w(ixI^S,1:nw)
314 double precision, intent(out) :: pth(ixI^S)
315 end subroutine hd_pthermal
316
317 !>Calculation R factor for ideal gas law with partial ionization
318 subroutine rfactor(w,x,ixI^L,ixO^L,pth)
320 integer, intent(in) :: ixI^L, ixO^L
321 double precision, intent(in) :: x(ixI^S,1:ndim)
322 double precision, intent(in) :: w(ixI^S,1:nw)
323 double precision, intent(out) :: pth(ixI^S)
324 end subroutine rfactor
325
326 !>set adiabatic index
327 subroutine set_adiab(w,x,ixI^L,ixO^L,adiab)
329 integer, intent(in) :: ixI^L, ixO^L
330 double precision, intent(in) :: x(ixI^S,1:ndim)
331 double precision, intent(in) :: w(ixI^S,1:nw)
332 double precision, intent(out) :: adiab(ixI^S)
333 end subroutine set_adiab
334
335 !> Set the "eta" array for resistive MHD based on w or the
336 !> "current" variable which has components between idirmin and 3.
337 subroutine special_resistivity(w,ixI^L,ixO^L,idirmin,x,current,eta)
339 integer, intent(in) :: ixI^L, ixO^L, idirmin
340 double precision, intent(in) :: w(ixI^S,nw), x(ixI^S,1:ndim)
341 double precision, intent(in) :: current(ixI^S,7-2*ndir:3)
342 double precision, intent(out) :: eta(ixI^S)
343 end subroutine special_resistivity
344
345
346 !> Set user defined opacity for use in diffusion coeff, heating and cooling, and radiation force
347 subroutine special_opacity(ixI^L,ixO^L,w,x,kappa)
349 integer, intent(in) :: ixI^L, ixO^L
350 double precision, intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
351 double precision, intent(out):: kappa(ixI^S)
352 end subroutine special_opacity
353
354 !> Set user defined FLD flux limiter, lambda
355 subroutine special_fluxlimiter(ixI^L,ixO^L,w,x,fld_lambda,fld_R)
357 integer, intent(in) :: ixI^L, ixO^L
358 double precision, intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
359 double precision, intent(out):: fld_lambda(ixI^S),fld_R(ixI^S)
360 end subroutine special_fluxlimiter
361
362 !> Set user defined FLD diffusion coefficient
363 subroutine special_diffcoef(w, wprim, x, ixI^L, ixO^L)
365 integer, intent(in) :: ixI^L, ixO^L
366 double precision, intent(inout) :: w(ixI^S, 1:nw)
367 double precision, intent(in) :: wprim(ixI^S, 1:nw)
368 double precision, intent(in) :: x(ixI^S, 1:ndim)
369 end subroutine special_diffcoef
370
371 !> Enforce additional refinement or coarsening
372 !> One can use the coordinate info in x and/or time qt=t_n and w(t_n) values w.
373 !> you must set consistent values for integers refine/coarsen:
374 !> refine = -1 enforce to not refine
375 !> refine = 0 doesn't enforce anything
376 !> refine = 1 enforce refinement
377 !> coarsen = -1 enforce to not coarsen
378 !> coarsen = 0 doesn't enforce anything
379 !> coarsen = 1 enforce coarsen
380 !> e.g. refine for negative first coordinate x < 0 as
381 !> if (any(x(ix^S,1) < zero)) refine=1
382 subroutine refine_grid(igrid,level,ixI^L,ixO^L,qt,w,x,refine,coarsen)
384 integer, intent(in) :: igrid, level, ixI^L, ixO^L
385 double precision, intent(in) :: qt, w(ixI^S,1:nw), x(ixI^S,1:ndim)
386 integer, intent(inout) :: refine, coarsen
387 end subroutine refine_grid
388
389 !> this is the place to compute a local auxiliary variable to be used
390 !> as refinement criterion for the Lohner error estimator only
391 !> -->it is then requiring and iflag>nw
392 !> note that ixO=ixI=ixG, hence the term local (gradients need special attention!)
393 subroutine var_for_errest(ixI^L,ixO^L,iflag,w,x,var)
395 integer, intent(in) :: ixI^L,ixO^L,iflag
396 double precision, intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
397 double precision, intent(out) :: var(ixI^S)
398 end subroutine var_for_errest
399
400 !> Here one can add a steady (time-independent) potential background field
401 subroutine set_b0(ixI^L,ixO^L,x,wB0)
403 integer, intent(in) :: ixI^L,ixO^L
404 double precision, intent(in) :: x(ixI^S,1:ndim)
405 double precision, intent(inout) :: wB0(ixI^S,1:ndir)
406 end subroutine set_b0
407
408 !> Here one can add a time-independent background current density
409 subroutine set_j0(ixI^L,ixO^L,x,wJ0)
411 integer, intent(in) :: ixI^L,ixO^L
412 double precision, intent(in) :: x(ixI^S,1:ndim)
413 double precision, intent(inout) :: wJ0(ixI^S,7-2*ndir:ndir)
414 end subroutine set_j0
415
416 !> Here one can add a steady (time-independent) equi vars
417 subroutine set_equi_vars(ixI^L,ixO^L,x,w0)
419 integer, intent(in) :: ixI^L,ixO^L
420 double precision, intent(in) :: x(ixI^S,1:ndim)
421 double precision, intent(inout) :: w0(ixI^S,1:number_equi_vars)
422 end subroutine set_equi_vars
423
424 !> adjust w when restart from dat file with different w variables
425 subroutine transform_w(ixI^L,ixO^L,nw_in,w_in,x,w_out)
427 integer, intent(in) :: ixI^L, ixO^L, nw_in
428 double precision, intent(in) :: w_in(ixI^S,1:nw_in)
429 double precision, intent(in) :: x(ixI^S, 1:ndim)
430 double precision, intent(out) :: w_out(ixI^S,1:nw)
431 end subroutine transform_w
432
433 !> use different threshold in special regions for AMR to
434 !> reduce/increase resolution there where nothing/something interesting happens.
435 subroutine a_refine_threshold(wlocal,xlocal,threshold,qt,level)
437 double precision, intent(in) :: wlocal(1:nw),xlocal(1:ndim),qt
438 double precision, intent(inout) :: threshold
439 integer, intent(in) :: level
440 end subroutine a_refine_threshold
441
442 !> Allow user to use their own data-postprocessing procedures
443 subroutine special_convert(qunitconvert)
445 integer, intent(in) :: qunitconvert
446 character(len=20) :: userconvert_type
447 end subroutine special_convert
448
449 !> flag=-1 : Treat all cells active, omit deactivation (onentry, default)
450 !> flag=0 : Treat as normal domain
451 !> flag=1 : Treat as passive, but reduce by safety belt
452 !> flag=2 : Always treat as passive
453 subroutine flag_grid(qt,ixI^L,ixO^L,w,x,flag)
455 integer, intent(in) :: ixI^L, ixO^L
456 integer, intent(inout) :: flag
457 double precision, intent(in) :: qt
458 double precision, intent(inout) :: w(ixI^S,1:nw)
459 double precision, intent(in) :: x(ixI^S,1:ndim)
460 end subroutine flag_grid
461
462 !> Update payload of particles
463 subroutine update_payload(igrid,x,u,q,m,mypayload,mynpayload,particle_time)
465 integer, intent(in) :: igrid,mynpayload
466 double precision, intent(in) :: x(1:ndir),u(1:ndir),q,m,particle_time
467 double precision, intent(out) :: mypayload(mynpayload)
468 end subroutine update_payload
469
470 !> Create particles
471 subroutine create_particles(n_particles, x, v, q, m, follow)
472 integer, intent(in) :: n_particles
473 double precision, intent(out) :: x(3, n_particles)
474 double precision, intent(out) :: v(3, n_particles)
475 double precision, intent(out) :: q(n_particles)
476 double precision, intent(out) :: m(n_particles)
477 logical, intent(out) :: follow(n_particles)
478 end subroutine create_particles
479
480 !> Check arbitrary particle conditions or modifications
481 subroutine check_particle(igrid,x,v,q,m,follow,check)
483 integer, intent(in) :: igrid
484 double precision, intent(inout) :: x(1:ndir)
485 double precision, intent(inout) :: v(1:ndir),q,m
486 logical, intent(inout) :: follow
487 logical, intent(out) :: check
488 end subroutine check_particle
489
490 !> Associate fields to particle
491 subroutine particle_fields(w, x, E, B)
493 double precision, intent(in) :: w(ixG^T,1:nw)
494 double precision, intent(in) :: x(ixG^T,1:ndim)
495 double precision, intent(out) :: E(ixG^T, ndir)
496 double precision, intent(out) :: B(ixG^T, ndir)
497 end subroutine particle_fields
498
499 subroutine particle_analytic(ix, x, tloc, vec)
501 integer, intent(in) :: ix(ndir) !< Indices in gridvars
502 double precision, intent(in) :: x(ndir)
503 double precision, intent(in) :: tloc
504 double precision, intent(out) :: vec(ndir)
505 end subroutine particle_analytic
506
507 !> User-defined particle movement
508 subroutine particle_position(x, n, tloc, tlocnew)
510 integer, intent(in) :: n
511 double precision, intent(inout) :: x(3)
512 double precision, intent(in) :: tloc, tlocnew
513 end subroutine particle_position
514
515 subroutine after_refine(n_coarsen, n_refine)
516 integer, intent(in) :: n_coarsen
517 integer, intent(in) :: n_refine
518 end subroutine after_refine
519
520 !> initialize vector potential on cell edges for magnetic field
521 subroutine init_vector_potential(ixI^L, ixC^L, xC, A, idir)
523
524 integer, intent(in) :: ixI^L, ixC^L, idir
525 double precision, intent(in) :: xC(ixI^S,1:ndim)
526 double precision, intent(out) :: A(ixI^S)
527
528 end subroutine init_vector_potential
529
530 ! allow user to change inductive electric field, especially for boundary driven applications
531 subroutine set_electric_field(ixI^L,ixO^L,qt,qdt,fE,s)
533 integer, intent(in) :: ixI^L, ixO^L
534 double precision, intent(in) :: qt, qdt
535 type(state) :: s
536 double precision, intent(inout) :: fE(ixI^S,sdim:3)
537
538 !integer :: ixC^L,ixA^L
539 ! For example, to set inductive electric field at bottom boundary in a 3D box for induction equation
540 ! v and b are from observational data for data-driven application
541
542 !associate(w=>s%w,ws=>s%ws)
543
544 !if(s%is_physical_boundary(5)) then
545 ! ixCmin^D=ixOmin^D-1;
546 ! ixCmax^D=ixOmax^D;
547 ! ixAmin^D=ixCmin^D;
548 ! ixAmax^D=ixCmax^D+1;
549 ! fE(nghostcells^%3ixA^S,1)=-ws(nghostcells^%3ixA^S,3)*w(nghostcells^%3ixA^S,mom(2))
550 ! fE(nghostcells^%3ixA^S,2)= ws(nghostcells^%3ixA^S,3)*w(nghostcells^%3ixA^S,mom(1))
551 ! ixAmin^D=ixCmin^D+kr(2,^D);
552 ! ixAmax^D=ixCmax^D+kr(2,^D);
553 ! fE(nghostcells^%3ixC^S,1)=0.5d0*(fE(nghostcells^%3ixC^S,1)+fE(nghostcells^%3ixA^S,1))*&
554 ! qdt*s%dsC(nghostcells^%3ixC^S,1)
555 ! ixAmin^D=ixCmin^D+kr(1,^D);
556 ! ixAmax^D=ixCmax^D+kr(1,^D);
557 ! fE(nghostcells^%3ixC^S,2)=0.5d0*(fE(nghostcells^%3ixC^S,2)+fE(nghostcells^%3ixA^S,2))*&
558 ! qdt*s%dsC(nghostcells^%3ixC^S,2)
559 !end if
560
561 !end associate
562
563 end subroutine set_electric_field
564
565 !> allow user to specify 'variables' left and right state at physical boundaries to control flux through the boundary surface
566 subroutine set_wlr(ixI^L,ixO^L,qt,wLC,wRC,wLp,wRp,s,idir)
568 integer, intent(in) :: ixI^L, ixO^L, idir
569 double precision, intent(in) :: qt
570 double precision, intent(inout) :: wLC(ixI^S,1:nw), wRC(ixI^S,1:nw)
571 double precision, intent(inout) :: wLp(ixI^S,1:nw), wRp(ixI^S,1:nw)
572 type(state) :: s
573
574 !if(s%is_physical_boundary(3).and.idir==2) then
575 ! wLp(ixOmin2^%2ixO^S,mom(1))=1.d0
576 ! wRp(ixOmin2^%2ixO^S,mom(1))=wRp(ixOmin2^%2ixO^S,mom(1))
577 ! wLC(ixOmin2^%2ixO^S,mom(1))=wLp(ixOmin2^%2ixO^S,mom(1))*wLp(ixOmin2^%2ixO^S,rho_)
578 ! wRC(ixOmin2^%2ixO^S,mom(1))=wRp(ixOmin2^%2ixO^S,mom(1))*wRp(ixOmin2^%2ixO^S,rho_)
579 !end if
580 end subroutine set_wlr
581
582 subroutine set_surface(ixI^L,x,delx,exp_factor,del_exp_factor,exp_factor_primitive)
584 integer, intent(in) :: ixI^L
585 double precision, intent(in) :: delx(ixI^S,1:ndim), x(ixI^S,1:ndim)
586 double precision, intent(out) :: exp_factor(ixI^S), del_exp_factor(ixI^S)
587 double precision, intent(out) :: exp_factor_primitive(ixI^S)
588
589 end subroutine set_surface
590
591 subroutine set_field_w(igrid,ip,xf,wP,wL,numP,nwP,nwL,dL,forward,ftype,tcondi)
593 !use mod_point_searching
594
595 integer, intent(in) :: igrid,ip,numP,nwP,nwL
596 double precision, intent(in) :: xf(numP,ndim)
597 double precision, intent(inout) :: wP(numP,nwP),wL(1+nwL)
598 double precision, intent(in) :: dL
599 logical, intent(in) :: forward
600 character(len=std_len), intent(in) :: ftype,tcondi
601
602 !double precision :: xpp(1:ndim),wpp(1:nw)
603
604 !! nwP=2,nwL=0. get rho/T at line
605 !if (tcondi=='user') then
606 ! xpp(1:ndim)=xf(ip,1:ndim)
607 ! call get_point_w_ingrid(igrid,xpp,wpp,'primitive')
608 ! wP(ip,1)=wpp(rho_)
609 ! wP(ip,2)=wpp(p_)/wpp(rho_)
610 !endif
611
612 end subroutine set_field_w
613
614 subroutine set_field(xfn,igrid,field,ftype)
616
617 integer,intent(in) :: igrid
618 double precision, intent(in) :: xfn(ndim)
619 double precision, intent(inout) :: field(ndim)
620 character(len=std_len), intent(in) :: ftype
621
622 !if (ftype='xdir') then
623 ! field(:)=zero
624 ! field(1)=1.d0
625 !endif
626
627 end subroutine set_field
628
629 !> Calculate volumetric heating rate for TRAC broadening
630 subroutine sub_get_heating(Qgrid,ixI^L,ixO^L,w,x)
632 integer, intent(in) :: ixI^L, ixO^L
633 double precision, intent(in) :: x(ixI^S,1:ndim), w(ixI^S,1:nw)
634 double precision, intent(out):: Qgrid(ixI^S)
635 end subroutine sub_get_heating
636
637 !> Opacity chi = kappa rho and Planck source bpl = a_rad T^4 (code units) for the SC RT
638 subroutine sub_rt_sc_chib(ixI^L, ixO^L, w, x, chi, bpl)
640 integer, intent(in) :: ixI^L, ixO^L
641 double precision, intent(in) :: w(ixI^S,1:nw), x(ixI^S,1:ndim)
642 double precision, intent(out):: chi(ixI^S), bpl(ixI^S)
643 end subroutine sub_rt_sc_chib
644
645 end interface
646
647end module mod_usr_methods
use different threshold in special regions for AMR to reduce/increase resolution there where nothing/...
Add names for the auxiliary variables.
this subroutine can be used in convert, to add auxiliary variables to the converted output file,...
Check arbitrary particle conditions or modifications.
flag=-1 : Treat all cells active, omit deactivation (onentry, default) flag=0 : Treat as normal domai...
Limit "dt" further if necessary, e.g. due to the special source terms. The getdt_courant (CFL conditi...
Calculation anormal pressure for hd & energy=.False.
initialize vector potential on cell edges for magnetic field
internal boundary, user defined This subroutine can be used to artificially overwrite ALL conservativ...
Associate fields to particle.
User-defined particle movement.
Calculate the 3d drag force of gas onto dust.
Calculate the time step associated with the usr drag force.
Calculate gravitational acceleration in each dimension.
for processing after the advance (PIC-MHD, e.g.)
for processing after the advance (PIC-MHD, e.g.)
This subroutine is called at the beginning of each time step by each processor. No communication is s...
this subroutine is ONLY to be used for computing auxiliary variables which happen to be non-local (li...
Enforce additional refinement or coarsening One can use the coordinate info in x and/or time qt=t_n a...
Calculation R factor for ideal gas law with partial ionization.
Here one can add a steady (time-independent) potential background field.
Here one can add a steady (time-independent) equi vars.
Here one can add a time-independent background current density.
Calculation anormal viscosity depending on space.
allow user to specify 'variables' left and right state at physical boundaries to control flux through...
Calculate w(iw)=w(iw)+qdt*SOURCE[wCT,qtC,x] within ixO for all indices iw=iwmin......
special boundary types, users must assign conservative variables in boundaries
Allow user to use their own data-postprocessing procedures.
Set user defined FLD diffusion coefficient.
Set user defined FLD flux limiter, lambda.
Special boundary type for radiation hydrodynamics module, only used to set the boundary conditions fo...
Set user defined opacity for use in diffusion coeff, heating and cooling, and radiation force.
Set the "eta" array for resistive MHD based on w or the "current" variable which has components betwe...
Calculate volumetric heating rate for TRAC broadening.
If defined, this routine is called before writing output, and it can set/modify the variables in the ...
Opacity chi = kappa rho and Planck source bpl = a_rad T^4 (code units) for the SC RT.
adjust w when restart from dat file with different w variables
Update payload of particles.
this is the place to compute a local auxiliary variable to be used as refinement criterion for the Lo...
This module contains definitions of global parameters and variables and some generic functions/subrou...
Module with all the methods that users can customize in AMRVAC.
procedure(rfactor), pointer usr_rfactor
procedure(source), pointer usr_source_after
procedure(source), pointer usr_source
procedure(special_resistivity), pointer usr_special_resistivity
procedure(set_adiab), pointer usr_set_adiab
procedure(special_opacity), pointer usr_special_opacity
procedure(set_adiab), pointer usr_set_gamma
procedure(process_grid), pointer usr_process_grid
procedure(sub_get_heating), pointer usr_get_heating
procedure(particle_position), pointer usr_particle_position
procedure(special_prepare_bc), pointer usr_prepare_boundary
procedure(check_particle), pointer usr_check_particle
procedure(p_no_args), pointer usr_improve_initial_condition
procedure(a_refine_threshold), pointer usr_refine_threshold
procedure(set_surface), pointer usr_set_surface
procedure(phys_dust_get_dt), pointer usr_dust_get_dt
procedure(phys_gravity), pointer usr_gravity
procedure(aux_output), pointer usr_aux_output
procedure(p_no_args), pointer usr_print_log
procedure(phys_dust_get_3d_dragforce), pointer usr_get_3d_dragforce
procedure(special_diffcoef), pointer usr_special_diffcoef
procedure(process_adv_grid), pointer usr_process_adv_grid
procedure(particle_analytic), pointer usr_particle_analytic
procedure(set_viscosity), pointer usr_set_viscosity
procedure(uawsom_coefficients), pointer usr_uawsom_coefficients
Optionally provide local UAWSoM closure coefficients. The returned thread radius and Alfven correlati...
procedure(special_convert), pointer usr_special_convert
procedure(create_particles), pointer usr_create_particles
procedure(init_one_grid), pointer usr_init_one_grid
Initialize earch grid block data.
procedure(update_payload), pointer usr_update_payload
procedure(p_no_args), pointer usr_write_analysis
procedure(sub_modify_io), pointer usr_modify_output
procedure(p_no_args), pointer usr_before_main_loop
procedure(special_fluxlimiter), pointer usr_special_fluxlimiter
procedure(set_field_w), pointer usr_set_field_w
procedure(flag_grid), pointer usr_flag_grid
procedure(process_global), pointer usr_process_global
procedure(special_bc), pointer usr_special_bc
procedure(sub_rt_sc_chib), pointer usr_rt_sc_chib
opacity and Planck source for the SC RT when rt_sc_opacity = 'usr'
procedure(process_adv_global), pointer usr_process_adv_global
procedure(internal_bc), pointer usr_internal_bc
procedure(set_equi_vars), pointer usr_set_equi_vars
procedure(special_mg_bc), pointer usr_special_mg_bc
procedure(set_j0), pointer usr_set_j0
procedure(particle_fields), pointer usr_particle_fields
procedure(refine_grid), pointer usr_refine_grid
procedure(hd_pthermal), pointer usr_set_pthermal
procedure(init_vector_potential), pointer usr_init_vector_potential
procedure(p_no_args), pointer usr_set_parameters
Initialize the user's settings (after initializing amrvac).
procedure(var_for_errest), pointer usr_var_for_errest
procedure(set_b0), pointer usr_set_b0
procedure(set_electric_field), pointer usr_set_electric_field
procedure(set_wlr), pointer usr_set_wlr
procedure(transform_w), pointer usr_transform_w
procedure(after_refine), pointer usr_after_refine
procedure(get_dt), pointer usr_get_dt
procedure(set_field), pointer usr_set_field
procedure(add_aux_names), pointer usr_add_aux_names