ProjectPhysX / FluidX3D

The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs via OpenCL. Free for non-commercial use.
https://youtube.com/@ProjectPhysX
Other
3.48k stars 281 forks source link

Applying a force during simulation to simulate main line water pressure #197

Closed mikehnta00 closed 2 weeks ago

mikehnta00 commented 2 weeks ago

Starting with the "periodic faucet mass conservation test;" I am trying to add a force to the water as it comes out of the z = Nz plane.

Is there a feature or an easy way to add a layer of cells that applies a certain force to the water during simulation?

It seems when you use the SURFACE define it enables UPDATE_FIELDS so rho, u, T are updated in every LBM step.

This might be overriding my attempt, or more likely, I'm not even be accessing the correct data with my additional code in setup.cpp Here is my attempt to add a force to the water: }); // ############################# run simulation, export images and data ################################### lbm.graphics.visualization_modes = VIS_FLAG_LATTICE|VIS_PHI_RASTERIZE; lbm.run(); const uint D = max(Nx, Nz), R = D / 6; const ulong n = lbm.get_N(); uint x = 0u, y = 0u, z = 0u; lbm.coordinates(n, x, y, z); while (true) { //if inside the force circle, for (int i= 0; i< n; i++) { if (y == Nx/2u+2u*R+5u && sq(x-Nx/2u)+sq(z-(Nz-R))>sq(R)) lbm.u.y[n] = lbm.u.y[n]+0.9f; // add force to the water }; }

mikehnta00 commented 2 weeks ago

Actually I see now that just using "lbm.u.z[n] = 0.75f; " or something does exactly what I was looking for Hope this helps someone!

ProjectPhysX commented 2 weeks ago

Hi @mikehnta00,

there is a very convenient and also physically correct way in place to do this:

No need to pull out and modify the velocity. The TYPE_E boundaries are only for fixed-velocity boundary conditions.

Kind regards, Moritz