Re: suggestions for DSMC particle storage needed



<phaccount@xxxxxxxxxxxx> wrote:

>I think my question translates into: what is a good memory management
>scheme for Monte-Carlo type simulations where I will have a decent
>turn-over of particles? I am very new to this area, and pointers to
>literature will be appreciated.

Do you know beforehand how many particles there can be at any time?
If so, my advice would be to allocate enough space once, at the start
of the program.

For each particle, keep a logical flag determining wether this
particular particle exists or not.

Something like this:

type particle
real :: x, y, z
integer :: charge
logical :: exists
end type particle

type(particle), allocatable :: p(:)

Alternatively, you could use

real, allocatable :: x(:), y(:), z(:)
integer, allocatable :: charge(:)
logical, allocatable :: exists(:)

This should be fairly straightforward to implement.
.



Relevant Pages