# Re: Error When Deleting Particles

From: Dimitry Ayzenberg <dayzenbe_at_andrew.cmu.edu>
Date: Tue, 10 Nov 2009 00:38:41 -0500

I'm still not sure why this error is occurring. This is the code I have to
check and delete particles if needed. For now it's without any change to
physical parameters and is pretty inefficient. I'm just trying to get
deletion to work right now. I apologize if the code is messy. Can anyone
help me and figure out why the error is coming up?

void collision(void)
{
int i = 0, j = 0;
double dx, dy, dz, ri, rj, d;
double density = 2;
int n = NumPart;

for( i = 0; i < NumPart; i++ )
{
if ( P[i].Type == -1 )
i++;

ri = pow( ( P[i].Mass * All.UnitMass_in_g / density ) / ( 4 / 3 *
3.14159 ), 1.0/3.0 ) / All.UnitLength_in_cm;

for ( j = 0; j < NumPart; j++ )
{
if ( j == i )
j++;

rj = pow( ( P[j].Mass * All.UnitMass_in_g / density ) / ( 4 / 3 *
3.14159 ), 1/3 ) / All.UnitLength_in_cm;
dx = P[i].Pos[0] - P[j].Pos[0];
dy = P[i].Pos[1] - P[j].Pos[1];
dz = P[i].Pos[2] - P[j].Pos[2];
d = sqrt( dx*dx + dy*dy + dz*dz );

if ( d <= ri + rj )
P[j].Type = -1;
}
}

for ( i = 0; i < NumPart; i++ )
{
if ( P[i].Type == -1 )
n--;
}

if ( n != NumPart ) {
Ptemp = malloc(n * sizeof(struct particle_data));

for ( i = 0, j = 0; i < NumPart; i++, j++ )
{
if ( P[i].Type != -1 )
{
Ptemp[j] = P[i];
Ptemp[j].ID = j;
}
}

free(P);
NumPart = n;
All.TotNumPart = NumPart;
P = malloc(n * sizeof(struct particle_data));

for ( i = 0; i < NumPart; i++ )
P[i] = Ptemp[i];

free(Ptemp);
}
}

Thanks,
Dimitry

On Mon, November 9, 2009 05:16, Sander Valcke wrote:
>

> Hi Dimitry,
>
>
> if the error you are getting is really the problem you could try
> increasing PartAllocFactor in your parameter file. If you are not running
> Gadget in parallel I think that it's impossible that the real
> error is the memory bounds, because no domain decomposition has to be done
> for a single process and if you're able to store N particles, you should
> also be able to store N-1. The error should then probably be somewhere in
> either deleting the one particle or in the modifying of the properties of
> the other.
>
> Sander
>
>
> Dimitry Ayzenberg wrote:
>
>> I'm trying to simulate collisions between non-sph particles by deleting
>> one of the colliding particles and changing the properties of the
>> other to keep everything physical. Everything seems to be correct and I
>>
>> All.NumForcesSinceLastDomainDecomp = 1 +
>> All.TreeDomainUpdateFrequency * All.TotNumPart;
>>
>>
>> , which Volker Springel suggested to add for someone else who was doing
>> something similar. I'm now getting an error that says: "No domain
>> decomposition that stays within memory bounds is possible." I tracked
>> this error down and it seems to be caused by something to do with the
>> function domain_findSplit, which checks if it is possible to split up
>> the domain-grid. I have little idea how I would go around fixing this or
>> why it is occurring. I'm running this on my own personal computer so
>>
>> -Dimitry Ayzenberg
>>
>>
>>
>>
>>
>> -----------------------------------------------------------
>>
>>
>> If you wish to unsubscribe from this mailing, send mail to
>> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe
>> gadget-list A web-archive of this mailing list is available here:
>>
>>
>
> --
> --------------------------------------------------
> | Sander Valcke |
> | Sterrenkundig Observatorium, Universiteit Gent |
> | Krijgslaan 281 S9, B-9000 Gent, Belgium |
> | phone +32-9-264-4796 | fax +32-9-264-4989 |
> | https://sourceforge.net/projects/hyplot/ |
> --------------------------------------------------
> Sometimes the best medicine is to stop taking something.
> --------------------------------------------------
>
>
>
>
>
> -----------------------------------------------------------
>
>
> If you wish to unsubscribe from this mailing, send mail to
> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe gadget-list
> A web-archive of this mailing list is available here: