Closed uljad closed 4 years ago
Hi @uljadberdica1000! The particles2obj
CLI tool assumes the input file is in a binary file format generated by other example apps such as hybrid_liquid_sim
or sph_sim
.
If you want to use your own app to generate compatible files, please take a look at main.cpp
file in hybrid_liquid_sim
example:
void saveParticleAsPos(const ParticleSystemData3Ptr& particles,
const std::string& rootDir, int frameCnt) {
Array1<Vector3D> positions(particles->numberOfParticles());
copyRange1(particles->positions(), particles->numberOfParticles(),
&positions);
char basename[256];
snprintf(basename, sizeof(basename), "frame_%06d.pos", frameCnt);
std::string filename = pystring::os::path::join(rootDir, basename);
std::ofstream file(filename.c_str(), std::ios::binary);
if (file) {
printf("Writing %s...\n", filename.c_str());
std::vector<uint8_t> buffer;
serialize(positions.constAccessor(), &buffer);
file.write(reinterpret_cast<char*>(buffer.data()), buffer.size());
file.close();
}
}
Thank you so much for your help and great work. Is there any way I can generate a partio file (or any particle information saving file format) and most importanly, use it to perform the Zhu-Bridson or the anisotropic algorithms on?
We currently do not support partio format, so you probably should right a converter which both links to Jet Framework and partio library.
tried running : ~/fluid-engine-dev/build/bin$ ./particles2obj -i hybrid_liquid_sim_output/frame_000001.xyz -o out.obj
and I got that there is segmentation error (core dumped). Could you give me an example of how to run the code?
Hi @uljadberdica1000! When running the simulation app, you should pass "--format pos" to export the binary files. By default it will use xyz ASCII format. You can pass -h option to see all the input parameters.
Could you please provide me with an example? I keep getting the error of dumped cores. Do I red the entire folder of the hybrid output? ./particles2obj -i /home/uljad1b/fluid-engine-dev/build/bin/hybrid_liquid_sim_output -o out.obj gave me the following: terminate called after throwing an instance of 'std::__ios_failure' what(): basic_filebuf::underflow error reading the file: iostream error Aborted (core dumped)
Hi @uljadberdica1000!
Sure, so here's an example. You can first run the hybrid_liquid_sim like this:
PS C:\Users\doyub\Codes\fluid-engine-dev> .\build\bin\Release\hybrid_liquid_sim.exe -h
usage:
hybrid_liquid_sim.exe options
where options are:
-r, --resx <resolutionX> grid resolution in x-axis (default is 50)
-f, --frames <numberOfFrames> total number of frames (default is 100)
-p, --fps <fps> frames per second (default is 60.0)
-e, --example <exampleNum> example number (between 1 and 6, default
is 1)
-l, --log <logFilename> log file name (default is
hybrid_liquid_sim.log)
-o, --output <outputDir> output directory name (default is
hybrid_liquid_sim_output)
-m, --format <format> particle output format (xyz or pos.
default is xyz)
PS C:\Users\doyub\Codes\fluid-engine-dev> .\build\bin\Release\hybrid_liquid_sim.exe -f 10 -m pos
Running example 1 (water-drop with FLIP)
Domain: [0.000000, 0.000000, 0.000000] x [1.000000, 2.000000, 1.000000]
Grid spacing: [0.020000, 0.020000, 0.020000]
Writing hybrid_liquid_sim_output\frame_000000.pos...
Writing hybrid_liquid_sim_output\frame_000001.pos...
Writing hybrid_liquid_sim_output\frame_000002.pos...
Writing hybrid_liquid_sim_output\frame_000003.pos...
Writing hybrid_liquid_sim_output\frame_000004.pos...
Writing hybrid_liquid_sim_output\frame_000005.pos...
Writing hybrid_liquid_sim_output\frame_000006.pos...
Writing hybrid_liquid_sim_output\frame_000007.pos...
Writing hybrid_liquid_sim_output\frame_000008.pos...
Writing hybrid_liquid_sim_output\frame_000009.pos...
Then, you can run the particle2obj like this:
PS C:\Users\doyub\Codes\fluid-engine-dev> .\build\bin\Release\particles2obj.exe -i .\hybrid_liquid_sim_output\frame_000000.pos -m zhu_bridson
particles2obj.exe options
where options are:
-?, -h, --help display usage information
-i, --input <inputFilename> input obj file name
-o, --output <outputFilename> output obj file name
-r, --resolution <resolution> grid resolution in CSV format (default
is 100,100,100)
-g, --grid_spacing <gridSpacing> grid spacing in CSV format (default is
0.01,0.01,0.01)
0,0,0)
-m, --method <method> spherical, sph, zhu_bridson, and
anisotropic followed by optional
method-dependent parameters (default is
anisotropic)
-k, --kernel <kernelRadius> interpolation kernel radius (default is
0.2)
PS C:\Users\doyub\Codes\fluid-engine-dev> .\build\bin\Release\particles2obj.exe -i .\hybrid_liquid_sim_output\frame_000000.pos -r 100,200,100 -g 0.01 -k 0.04 -m zhu_bridson -o .\hybrid_liquid_sim_output\frame_000000.obj
Resolution: 100 x 200 x 100
Domain: [0.000000, 0.000000, 0.000000] x [1.000000, 2.000000, 1.000000]
Grid spacing: [0.010000, 0.010000, 0.010000]
Number of particles: 534361
Reconstruction method: zhu_bridson
[INFO] 2020-07-14 01:35:59 [C:\Users\doyub\Codes\fluid-engine-dev\src\jet\point_parallel_hash_grid_searcher3.cpp:141 (build)] Average number of points per non-empty bucket: 428.861
[INFO] 2020-07-14 01:35:59 [C:\Users\doyub\Codes\fluid-engine-dev\src\jet\point_parallel_hash_grid_searcher3.cpp:144 (build)] Max number of points per bucket: 729
[INFO] 2020-07-14 01:35:59 [C:\Users\doyub\Codes\fluid-engine-dev\src\jet\particle_system_data3.cpp:220 (buildNeighborSearcher)] Building neighbor searcher took: 0.05554 seconds
Writing .\hybrid_liquid_sim_output\frame_000000.obj..
Then, you will get results something like:
I'm glad to see this issue. It would be better written the issue step in the README.
Is there any way I could use the xyz file for that? I want to use it as a plugin for something else and need to put the xyz from another simulation.
@uljadberdica1000: you mean you want to generate xyz files externally and use particles2obj to generate mesh, right? Adding xyz support shouldn't be too hard. Let me see what I can do.
Yes thank you so much! I just want to use your work since I will never be able to write a better one anyway! I want to be able to use xyz to generate the mesh with the particles2obj.
@uljadberdica1000: the requested feature is now up for PR. Feel free to test it from the branch (xyz
).
It worked great. Thank you so much. Do you have any literature you could suggest on the trade offs of using each method both computationally and geometrically. I cannot find a proper source! The xyz input works great!
Hi @uljadberdica1000 ,
I would definitely start from Yu and Turk paper (https://www.cc.gatech.edu/~turk/my_papers/particle_surfaces_tog.pdf). I don't know if there are any survey papers on that topic, but that paper should cover most of your questions. The computational cost is something could be reevaluated with modern hardwares including GPUs.
What format should the input file be? Do I have to specify other parameters?