Representing structures for simulations



Hello. I am planning on programming my own small smooth particle
hydrodynamics code. I have no prior experience with programming such
code, or even other meshed methods. This SPH code will be interfaced
with another program I have written to study hypervelocity impact.

I guess the main question I have at the moment is how I should
represent structures in my code. How is it normally approached, in both
meshless and mesh-free methods?

For example, say you have a 2D plate of material. I could discretise
space and represent the plate in a 2D memory array. The size of my
array would be proportional to the size of the plate, or the level of
discretisation. This method would be a memory hog for large structures
or fine resolutions, but it would be faster (assuming the structure can
be stored in RAM) because you immediately know which elements/particles
are adjacent to one another. You don't need to run adjacency checks to
determine which sections affect which - you can tell just by the array
co-ordinates.

Alternatively, I could store element/particle information in memory in
a manner unrelated to their spatial positions (like representing a 3D
structure in a very long 1D array). Spatial co-ordinates are stored as
entries in the array. This means that I will need to do adjacency
checks, which is CPU intensive.

Suppose you had to represent a cube of material (so no voids). The
amount of information you must store is the same, regardless of which
storage scheme you choose. Therefore the best scheme is to store it in
a 3D array, since you'd be using the same memory (theoretically) in
either case, but losing on CPU costs for the 1D array scheme. However,
if the material has lots of voids, then the best option may be the long
1D array, because it doesn't allocate memory to wastefully defining
voids.

Are there alternative means of storing structures in memory I have not
thought about? What thoughts do you guys have?

Thanks.

.



Relevant Pages

  • Re: Cheap tricks for map data structure
    ... "object oriented programming" that I saw, ... So C structs are a perfectly reasonable basis for implementing ... memory payload, and being locked into using new/delete by having one ... In the absence of padding bytes, the array of structs (or other ...
    (rec.games.roguelike.development)
  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: High Memory Consumption of Classes and Arrays
    ... Only the array itself has overhead. ... memory as a reference type. ... > least consume 40 bytes of memory. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.mfc)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.language)