Hi Giuseppe,
I used the “addXYZFile” function to add Fluid and Wall particles to my model. For example, I used the following lines:
"
GeometryID fluid =addXYZFile(GT_FLUID, Point(0,0,0), “Fluid.txt”, NULL);
GeometryID wall =addXYZFile(GT_FIXED_BOUNDARY, Point(0,0,0), “Wall.txt”, NULL);
disableCollisions(wall);
"
The fluid particles and wall particles are added correctly, but when I attempt to remove some of these particles using the following commands, they don’t seem to work.
"
GeometryID unfill_body = addBox(GT_FLUID, FT_NOFILL, body1_origin, body1_x, body1_y, body_z+body1_z);
setEraseOperation(unfill_body,ET_ERASE_FLUID);
"
or
"
GeometryID BoxT = addBox(GT_FIXED_BOUNDARY, FT_UNFILL, Point(paddle_origin), 2.0, 2.0, 2.0);
"
Do you know how I can remove the particles that were added using the “addXYZFile” function?
Regards,
Alireza
Hello @AlirezaZarei, I’m afraid you’ve hit one of the limitations of the current object system in GPUSPH. “Particle cloud” object types (XZY, HDF5) require some special handling that currently has as implications that they do not support intersection/erasure with other geometries: they are always imported as-is
One way you can work around this current limitation is to “filter out” unwanted particles by disabling them in an initializeParticles
: this gives you full access to the particle arrays before the simulation begins. In your testcase .h
file declare the override:
void initializeParticles(BufferList &buffers, const uint numParticles);
and in your .cc
file define it to something like this:
void YourTestCaseName::initializeParticles(BufferList &buffers, const uint numParticles)
{
// we use the global position to determine if the particle is wanted or should be clipped
const double4 *pos_global = buffers.getData<BUFFER_POS_GLOBAL>();
// to disable a particle, set its mass (pos.w) to NAN.
// there's a disable_particle() function that does that
float4 *pos = buffers.getData<BUFFER_POS>();
for (int i = 0; i < numParticles; ++i) {
const double4 particle_gpos = pos_global[i];
if ( /* condition on particle_gpos to determine if particle should be removed */ )
disable_particle(pos[i]);
}
}