Uploading .txt files for particle placement

I am wondering if there is a way to upload a .txt file that defines the particle placement? I know this is possible with a .h5sph file (like in CompleteSaExample), but I’m not sure about a .txt file. And if so, what format does the .txt have to be in? I have an object in the middle of my domain and when I try to fill the domain with fluid particles using the built-in geometries I get extremely large particle velocities at the first time step which results in a crash. So I created a grid of particles in Matlab to start the fluid around the object to avoid these high velocities, but I don’t know how to implement it in the input file.

Thank you for your help.

The XProblem interface offers a addXYZFile() method with this purpose. The particles can be fluid or boundary. Please note that no resampling is performed, so the displacement resolution should roughly match the deltap of the problem.

Hello @brittlyd, and thanks for your interest in GPUPSH.

To expand on @narcolessico’s answer, the file format supported by addXYZFile is a simple list of coordinates (x, y, z), one point per line. The first parameter to addXYZFile defines the type of the geometry (and thus the type of the particles): use GT_FLUID if the point cloud is for the fluid, GT_FIXED_BOUNDARY for a wall, etc. The second parameter is the offset to use for the STL in case the XYZ file has an associated mesh (just use Point(0, 0, 0) otherwise). The third parameter is the file name to load.

For what it’s worth, the fact that filling the domain using the built-in geometries leads to extremely large particle velocities is most likely an indication of the fact that some particles are overlapping, which means that something is not being removed correctly. Could you share with us the source file for the test case that is giving you this issue? It could help us debug the issue.

Hi @giuseppe.bilotta,

Yeah I had a feeling that overlapping was what was causing the large particle velocities, and I found the setEraseOperation function to fix that. I am still interested in uploading .txt files to define particle location for fixed and floating bodies. I created a .txt file with my particle locations in (x y z) format and used the addXYZFile method to try to create a simple cube in the domain (just as a text). Specifically, I wrote

GeometryID fixed_cube = addXYZFile(GT_FIXED_BOUNDARY, Point(0, 0, 0), 

and I recieved an error:

Reading particle data from the input: ./data_files/WaveTankWASIRFBOX/text.txt
FATAL: std::bad_alloc
Makefile:1227: recipe for target 'test' failed
make: *** [test] Error 1

I’m not exactly sure what this error is telling me or how to fix it. I’m pretty new to both GPUSPH and C++ so any advice would be greatly appreciated. I assume it is something wrong with my .txt file specifically, but I’m not quite sure. I uploaded a picture of part of my .txt file as reference.

Hello @brittlyd,

bad_alloc errors generally indicate an out-of-memory condition or something similar. While this can happen when trying to load very large files on a system with low memory condition, it may also indicate some bug in the code (trying to allocate space for way more particles than necessary). If you can share the full example (sources and data file), I can have a look to see where the problem lies.