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