weymouth / lily-pad

Real-time two-dimensional fluid dynamics simulations in Processing. Initiated by Dr G D Weymouth:
https://github.com/weymouth/
MIT License
162 stars 78 forks source link

Solver must be a power of 2, and seems to be o (n2) in complexity #10

Closed damian-666 closed 8 years ago

damian-666 commented 8 years ago

Sorry if i don't even make any sense or have not read everything you have published, but i have some ideas , questions , or suggestions for the solver..

So, i have tried a few schemes, they are like this. . 64x64 grids. is all i can run in debug. But, when i try see your code, its it the Algebraic MD?, your converges in 2 , not 80 iterations.. that is great. But i cannot fill a sky or half an ocean on a laptop.. with a rough grid. And i think like Molemaker/ Cohen.. it can be fixed with the GPU and IOP .. but .. thats tricky...http://enu.kz/repository/2010/AIAA-2010-523.pdf . This paper mentions FEFLO andLOC - FCT flux corrected transport.. i thought they used IOP and SIMPLE... and Cuda.. anyways.. Cuda is no good for me..since Skylake is a good cpu.

So, i make three grids.. they compiled them. They were all fast.. there was some stuttering , i believe is due to memory being released ..and the GC'd when maybe it shoudnt. I suspect GC as the cause of the stutters, using 3 processing running ( i forgot which , a flow past some circle)

FFT2 pressure solves seems fast even at 1024 x 1024. 1ms... for the fft on cpu.. But I read "periodic boundary conditions.. However, if the window is one period + buffer. to randomize Y. I dont know if periodic boundary conditions means the immerses rockets, creatures, etc.. need to be symmetrical or what?... I think the doing solves.. in a loose coupled way, which may be good enough only for vfx...to solver for pressure, fft back... then move the think and collide with the air, push it away using a the panel method... then fft solves will be super fast,high res...and using stams way.. stable. I would try it on my force if you think its worth a try, even if not for a CFD IB solver.

Also, as i watch my 3 windows,then i wonder.. should i instead try I use Multigrid , Chimera style , overlapping by 2 boxes.. covery all the info form one grid to the next?.. I could use this for a long 2d ocean with wave.. without resorting to mixed methods, or even narrow band flip. For ortho grids , especially ,this seems doable..

agin TLDR....if i don't even make any sense or missed the published plan. I am reading and reading but i haven't make much progress in my coding. Frankly i am overwhelmed with too many schemes and i just want fast /simple /stable/believable, or perhaps, interchangeable. most are edge based..MAC style..

weymouth commented 8 years ago

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

damian-666 commented 8 years ago

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth notifications@github.com wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244692953, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

damian-666 commented 8 years ago

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction (

onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer <damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth notifications@github.com wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244692953, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

weymouth commented 8 years ago

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth notifications@github.com wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment-244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244922808, or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PSienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9 .

damian-666 commented 8 years ago

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth notifications@github.com wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth notifications@github.com wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244922808, or mute the thread https://github.com/notifications/unsubscribe-auth/ AAclJ08PSienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244941714, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS-aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

damian-666 commented 8 years ago

Hello again,

i think made a little progress on the two phase "wave tank"....I hope i didnt miss anything, but i think the two phase sloshing with bubbles works, but is often unstable and thats the cause of the stalling, slowness, and leaking processing modules. I tried the simplest two- phase i could make, set the air to water ratio to 1/10, and got some decent sloshing with tuning of the MG smoother iterations and other params.

but for my simulations even with 1/10 density and a small immersed boundary, I can't get a stable solve without a lucky tuning. And three of teh papers explain that is expected. So they use MG as a preconditioner for a Conjugate Gradient solve . So i think the two- phase is not stable enough and that is the main cause of the stalling. The papers all show nicely deformed bubbles and details.

i hope to try it because it looks good when it works , but . , in the papers, they examine all the boundaries inside, consider the types. they reuse the buffers , work in parallel when possible, and this one claims to handle 800 to 1 density. " A parallel multigrid Poisson solver for fluids simulation on large grids" -Disney, McAdams.

if I find a robust solver i can port to java and switch in i will try.. but I am running out of time and might not be able to do it ( if you think it is the right plan). Here is what i dug up..

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457.5625&rep=rep1&type=pdf

https://wissrech.ins.uni-bonn.de/research/projects/amg/ Project C2: Adaptive and robust multigrid methods for space time discretizations http://sfb611.iam.uni-bonn.de/subproject.php?id=25&lang=enDevelopment of CFD Code NaSt3DGP http://wissrech.ins.uni-bonn.de/research/projects/NaSt3DGP/index.htmHigh-Performance Parallel Computing http://wissrech.ins.uni-bonn.de/research/himalaya/index.html

code licenses are ok....

http://www.prace-ri.eu/IMG/pdf/scalable-tools-for-fem-applications.pdf

BoomerAMG of HYPRE code of the Laurence Livermore National Laboratory (LLNL), USA http://computation.llnl.gov/sites/default/files/public/hypre-2.11.1_ref_manual.pdf

I use a c++ to c# converter.. there probably is one for java... i found one AMR poison solvers in Chombo but it is commented out.. s

also , i find papers that say FFT pressure solves can work with immersed boundaries if the ends are periodic ( or one can put dampers or boundaries, unseen in the margins so that stuff doesnt wrap around ..or move the Y , or use IB as boundaries) STAM fft 01 autodesk paper , a method like that.. But solving the poisson in these papers with a MG.+ CG. similar to what is there, seems better and can be just as fast.

my code was last like this but i feel its unstable more often than not.... unless i missed a piece..

FloodPlot flood;

Body body;

// flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0);

TwoPhase flow;

void setup() { int n=(int)pow(2, 6)*2;

int m=(int)pow(2, 5)*1;

// size ( 400, 300);

Window view = new Window(n,n/2); float L = n/8.;

body = new CircleBody(n/3, m/2, L/2, view); // define geom

flow = new TwoPhase(n,m,2,0.05); flow.f.eq(0.8,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0.02,0);

// length-scale in grid units //body = new CircleBody(n/3,n/2,L,view); // define geom

}

/ TwoPhase( int n, int m, float dt, Body body, float nu, boolean QUICK, float g, float gamma ){ super( n, m, dt, body, nu, QUICK); f = new FreeInterface( this.n, this.m, gamma ); f0 = new FreeInterface( this.n, this.m, gamma ); this.g.y = g; } TwoPhase( int n, int m, float dt, float g ){ this( n, m, dt, new CircleBody(-10.,-10.,0.,new Window()), 0, false, g, 0.1); }; /

void draw() {

body.follow();                             // update the body

flow.update(body); //flow.update();

flow.update2(); flow.f.display(0.1,1); body.display();

// flood.display(flow.u.curl());

}

/*** void setup(){ int n=(int)pow(2,7), m=(int)pow(2,6); flow = new TwoPhase(n,m,2,0.01); flow.f.eq(0,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0,0); }

void draw(){ flow.update(); flow.update2(); flow.f.display(); } **/

void settings() { size(600, 150); }

On Tue, Sep 6, 2016 at 9:58 PM, Damian Hallbauer <damian.hallbauer@gmail.com

wrote:

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth notifications@github.com wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth <notifications@github.com

wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment-244922808 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PS ienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244941714, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS-aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

damian-666 commented 8 years ago

hello again, sorry to bug you bug im runny out of time, need guidance on LilyPad.. two phase and free boundary.

I read in your wikik that the iVof and the two phase is still under development. But is anyone actively doing so?

But my focus is on swimmers and walkers in 2d... I dont know if a volcano will explode or the flying wing will be driver to the water... take in water ... sink while emitting bubbles. so i need unconditionally stable. I don't need compressible or shocks. For an interactive simulation it must be pretty stable under most conditions.

Incremental fluids" code on github has given me multi density , dust in the air...stratified... One phase.

But in a port of that ot java, I found a solver for CG in Java... it is preconditioned by incomplete Cholesky preconditioner... not AMG ..

here is a java version of the CG solver but with a different preconditioner. I dont know if AMG and this would be right or the fastest way to get the two phase code stable.

https://github.com/noSoulApophis/incremental-fluids-java/blob/master/src/ physics/EulerianFluids/ExplicitFluid3conjugateGradients.java

I dont konw if i am qualified to fix the two phase in Lilypad. i am self taught in CFD.. just a newbie. My focus for 5 years. has been creature locomotion and balance.. they walk on boards with thin hulls... I can add that to air eating overturning two phase model, my demo will be incredible,.... creatures walking on boats using just muscle and bone power.

but unless you prescribe me a plan of action or proper test cases. for waves crashing on a reef. and a body i can slosh around.. .. it, dont want to risktime to work on this i need to return to America or to German or Canada, i have 3 citizenships. This island with its waves and creatures , currents , reefs, and total freedom to research , has taught me alot but i think i need to go after 5 years.

I might try the Nast2d code, but i dont konw if i can put a fish in that...

thanks, Damian Hallbauer , CEO and Sole Proprietor, Puppet Army Faction.

On Wed, Sep 7, 2016 at 7:47 AM, Damian Hallbauer <damian.hallbauer@gmail.com

wrote:

Hello again,

i think made a little progress on the two phase "wave tank"....I hope i didnt miss anything, but i think the two phase sloshing with bubbles works, but is often unstable and thats the cause of the stalling, slowness, and leaking processing modules. I tried the simplest two- phase i could make, set the air to water ratio to 1/10, and got some decent sloshing with tuning of the MG smoother iterations and other params.

but for my simulations even with 1/10 density and a small immersed boundary, I can't get a stable solve without a lucky tuning. And three of teh papers explain that is expected. So they use MG as a preconditioner for a Conjugate Gradient solve . So i think the two- phase is not stable enough and that is the main cause of the stalling. The papers all show nicely deformed bubbles and details.

i hope to try it because it looks good when it works , but . , in the papers, they examine all the boundaries inside, consider the types. they reuse the buffers , work in parallel when possible, and this one claims to handle 800 to 1 density. " A parallel multigrid Poisson solver for fluids simulation on large grids" -Disney, McAdams.

if I find a robust solver i can port to java and switch in i will try.. but I am running out of time and might not be able to do it ( if you think it is the right plan). Here is what i dug up..

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457 .5625&rep=rep1&type=pdf

https://wissrech.ins.uni-bonn.de/research/projects/amg/ Project C2: Adaptive and robust multigrid methods for space time discretizations http://sfb611.iam.uni-bonn.de/subproject.php?id=25&lang=enDevelopment of CFD Code NaSt3DGP http://wissrech.ins.uni-bonn.de/research/projects/NaSt3DGP/index.htmHigh-Performance Parallel Computing http://wissrech.ins.uni-bonn.de/research/himalaya/index.html

code licenses are ok....

http://www.prace-ri.eu/IMG/pdf/scalable-tools-for-fem-applications.pdf

BoomerAMG of HYPRE code of the Laurence Livermore National Laboratory (LLNL), USA http://computation.llnl.gov/sites/default/files/public/hypre -2.11.1_ref_manual.pdf

I use a c++ to c# converter.. there probably is one for java... i found one AMR poison solvers in Chombo but it is commented out.. s

also , i find papers that say FFT pressure solves can work with immersed boundaries if the ends are periodic ( or one can put dampers or boundaries, unseen in the margins so that stuff doesnt wrap around ..or move the Y , or use IB as boundaries) STAM fft 01 autodesk paper , a method like that.. But solving the poisson in these papers with a MG.+ CG. similar to what is there, seems better and can be just as fast.

my code was last like this but i feel its unstable more often than not.... unless i missed a piece..

FloodPlot flood;

Body body;

// flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0);

TwoPhase flow;

void setup() { int n=(int)pow(2, 6)*2;

int m=(int)pow(2, 5)*1;

// size ( 400, 300);

Window view = new Window(n,n/2); float L = n/8.;

body = new CircleBody(n/3, m/2, L/2, view); // define geom

flow = new TwoPhase(n,m,2,0.05); flow.f.eq(0.8,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0.02,0);

// length-scale in grid units //body = new CircleBody(n/3,n/2,L,view); // define geom

}

/ TwoPhase( int n, int m, float dt, Body body, float nu, boolean QUICK, float g, float gamma ){ super( n, m, dt, body, nu, QUICK); f = new FreeInterface( this.n, this.m, gamma ); f0 = new FreeInterface( this.n, this.m, gamma ); this.g.y = g; } TwoPhase( int n, int m, float dt, float g ){ this( n, m, dt, new CircleBody(-10.,-10.,0.,new Window()), 0, false, g, 0.1); }; /

void draw() {

body.follow();                             // update the body

flow.update(body); //flow.update();

flow.update2(); flow.f.display(0.1,1); body.display();

// flood.display(flow.u.curl());

}

/*** void setup(){ int n=(int)pow(2,7), m=(int)pow(2,6); flow = new TwoPhase(n,m,2,0.01); flow.f.eq(0,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0,0); }

void draw(){ flow.update(); flow.update2(); flow.f.display(); } **/

void settings() { size(600, 150); }

On Tue, Sep 6, 2016 at 9:58 PM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth notifications@github.com wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth < notifications@github.com> wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment-244922808 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PS ienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-244941714, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS-aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

weymouth commented 8 years ago

What's the problem with the current two phase implantation? Can you describe it concretely in two sentences and send me a minimal example that replicates the problem?

On Sep 8, 2016 19:42, "damian-666" notifications@github.com wrote:

hello again, sorry to bug you bug im runny out of time, need guidance on LilyPad.. two phase and free boundary.

I read in your wikik that the iVof and the two phase is still under development. But is anyone actively doing so?

But my focus is on swimmers and walkers in 2d... I dont know if a volcano will explode or the flying wing will be driver to the water... take in water ... sink while emitting bubbles. so i need unconditionally stable. I don't need compressible or shocks. For an interactive simulation it must be pretty stable under most conditions.

Incremental fluids" code on github has given me multi density , dust in the air...stratified... One phase.

But in a port of that ot java, I found a solver for CG in Java... it is preconditioned by incomplete Cholesky preconditioner... not AMG ..

here is a java version of the CG solver but with a different preconditioner. I dont know if AMG and this would be right or the fastest way to get the two phase code stable.

https://github.com/noSoulApophis/incremental-fluids-java/blob/master/src/ physics/EulerianFluids/ExplicitFluid3conjugateGradients.java

I dont konw if i am qualified to fix the two phase in Lilypad. i am self taught in CFD.. just a newbie. My focus for 5 years. has been creature locomotion and balance.. they walk on boards with thin hulls... I can add that to air eating overturning two phase model, my demo will be incredible,.... creatures walking on boats using just muscle and bone power.

but unless you prescribe me a plan of action or proper test cases. for waves crashing on a reef. and a body i can slosh around.. .. it, dont want to risktime to work on this i need to return to America or to German or Canada, i have 3 citizenships. This island with its waves and creatures , currents , reefs, and total freedom to research , has taught me alot but i think i need to go after 5 years.

I might try the Nast2d code, but i dont konw if i can put a fish in that...

thanks, Damian Hallbauer , CEO and Sole Proprietor, Puppet Army Faction.

On Wed, Sep 7, 2016 at 7:47 AM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Hello again,

i think made a little progress on the two phase "wave tank"....I hope i didnt miss anything, but i think the two phase sloshing with bubbles works, but is often unstable and thats the cause of the stalling, slowness, and leaking processing modules. I tried the simplest two- phase i could make, set the air to water ratio to 1/10, and got some decent sloshing with tuning of the MG smoother iterations and other params.

but for my simulations even with 1/10 density and a small immersed boundary, I can't get a stable solve without a lucky tuning. And three of teh papers explain that is expected. So they use MG as a preconditioner for a Conjugate Gradient solve . So i think the two- phase is not stable enough and that is the main cause of the stalling. The papers all show nicely deformed bubbles and details.

i hope to try it because it looks good when it works , but . , in the papers, they examine all the boundaries inside, consider the types. they reuse the buffers , work in parallel when possible, and this one claims to handle 800 to 1 density. " A parallel multigrid Poisson solver for fluids simulation on large grids" -Disney, McAdams.

if I find a robust solver i can port to java and switch in i will try.. but I am running out of time and might not be able to do it ( if you think it is the right plan). Here is what i dug up..

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457 .5625&rep=rep1&type=pdf

https://wissrech.ins.uni-bonn.de/research/projects/amg/ Project C2: Adaptive and robust multigrid methods for space time discretizations http://sfb611.iam.uni-bonn.de/subproject.php?id=25&lang=enDevelopment of CFD Code NaSt3DGP <http://wissrech.ins.uni-bonn.de/research/projects/NaSt3DGP/index.htm High-Performance Parallel Computing http://wissrech.ins.uni-bonn.de/research/himalaya/index.html

code licenses are ok....

http://www.prace-ri.eu/IMG/pdf/scalable-tools-for-fem-applications.pdf

BoomerAMG of HYPRE code of the Laurence Livermore National Laboratory (LLNL), USA http://computation.llnl.gov/sites/default/files/public/hypre -2.11.1_ref_manual.pdf

I use a c++ to c# converter.. there probably is one for java... i found one AMR poison solvers in Chombo but it is commented out.. s

also , i find papers that say FFT pressure solves can work with immersed boundaries if the ends are periodic ( or one can put dampers or boundaries, unseen in the margins so that stuff doesnt wrap around ..or move the Y , or use IB as boundaries) STAM fft 01 autodesk paper , a method like that.. But solving the poisson in these papers with a MG.+ CG. similar to what is there, seems better and can be just as fast.

my code was last like this but i feel its unstable more often than not.... unless i missed a piece..

FloodPlot flood;

Body body;

// flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0);

TwoPhase flow;

void setup() { int n=(int)pow(2, 6)*2;

int m=(int)pow(2, 5)*1;

// size ( 400, 300);

Window view = new Window(n,n/2); float L = n/8.;

body = new CircleBody(n/3, m/2, L/2, view); // define geom

flow = new TwoPhase(n,m,2,0.05); flow.f.eq(0.8,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0.02,0);

// length-scale in grid units //body = new CircleBody(n/3,n/2,L,view); // define geom

}

/ TwoPhase( int n, int m, float dt, Body body, float nu, boolean QUICK, float g, float gamma ){ super( n, m, dt, body, nu, QUICK); f = new FreeInterface( this.n, this.m, gamma ); f0 = new FreeInterface( this.n, this.m, gamma ); this.g.y = g; } TwoPhase( int n, int m, float dt, float g ){ this( n, m, dt, new CircleBody(-10.,-10.,0.,new Window()), 0, false, g, 0.1); }; /

void draw() {

body.follow(); // update the body flow.update(body); //flow.update();

flow.update2(); flow.f.display(0.1,1); body.display();

// flood.display(flow.u.curl());

}

/*** void setup(){ int n=(int)pow(2,7), m=(int)pow(2,6); flow = new TwoPhase(n,m,2,0.01); flow.f.eq(0,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0,0); }

void draw(){ flow.update(); flow.update2(); flow.f.display(); } **/

void settings() { size(600, 150); }

On Tue, Sep 6, 2016 at 9:58 PM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth notifications@github.com wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth < notifications@github.com> wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10# issuecomment-244922808 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PS ienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment-244941714 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS- aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245571919, or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ89TdAt5JdUEAIBpPqi4jlfrgWwSks5qn_SbgaJpZM4JwAR9 .

damian-666 commented 8 years ago

Thanks.. yes. I will do this now. the sample code is there at the bottom of the email before last, but i will double check it. starting from scratch. I did get one "wave tank" to work but trying to buld a wave maker, or using a large circles, using a paddle, was unstable. both papers reported instability in two- phase with AMG only for a solver. We can make this state of the art just by integrating this and its from Los Alamos... no license issues. it is very exiting stuff....

warning: the crashed processing sessions, leak, under Win 10, and under various names which i will provide ( processing bug) .. cleaning them is important during test.

On Thu, Sep 8, 2016 at 8:38 PM, Dr Weymouth notifications@github.com wrote:

What's the problem with the current two phase implantation? Can you describe it concretely in two sentences and send me a minimal example that replicates the problem?

On Sep 8, 2016 19:42, "damian-666" notifications@github.com wrote:

hello again, sorry to bug you bug im runny out of time, need guidance on LilyPad.. two phase and free boundary.

I read in your wikik that the iVof and the two phase is still under development. But is anyone actively doing so?

But my focus is on swimmers and walkers in 2d... I dont know if a volcano will explode or the flying wing will be driver to the water... take in water ... sink while emitting bubbles. so i need unconditionally stable. I don't need compressible or shocks. For an interactive simulation it must be pretty stable under most conditions.

Incremental fluids" code on github has given me multi density , dust in the air...stratified... One phase.

But in a port of that ot java, I found a solver for CG in Java... it is preconditioned by incomplete Cholesky preconditioner... not AMG ..

here is a java version of the CG solver but with a different preconditioner. I dont know if AMG and this would be right or the fastest way to get the two phase code stable.

https://github.com/noSoulApophis/incremental- fluids-java/blob/master/src/ physics/EulerianFluids/ExplicitFluid3conjugateGradients.java

I dont konw if i am qualified to fix the two phase in Lilypad. i am self taught in CFD.. just a newbie. My focus for 5 years. has been creature locomotion and balance.. they walk on boards with thin hulls... I can add that to air eating overturning two phase model, my demo will be incredible,.... creatures walking on boats using just muscle and bone power.

but unless you prescribe me a plan of action or proper test cases. for waves crashing on a reef. and a body i can slosh around.. .. it, dont want to risktime to work on this i need to return to America or to German or Canada, i have 3 citizenships. This island with its waves and creatures , currents , reefs, and total freedom to research , has taught me alot but i think i need to go after 5 years.

I might try the Nast2d code, but i dont konw if i can put a fish in that...

thanks, Damian Hallbauer , CEO and Sole Proprietor, Puppet Army Faction.

On Wed, Sep 7, 2016 at 7:47 AM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Hello again,

i think made a little progress on the two phase "wave tank"....I hope i didnt miss anything, but i think the two phase sloshing with bubbles works, but is often unstable and thats the cause of the stalling, slowness, and leaking processing modules. I tried the simplest two- phase i could make, set the air to water ratio to 1/10, and got some decent sloshing with tuning of the MG smoother iterations and other params.

but for my simulations even with 1/10 density and a small immersed boundary, I can't get a stable solve without a lucky tuning. And three of teh papers explain that is expected. So they use MG as a preconditioner for a Conjugate Gradient solve . So i think the two- phase is not stable enough and that is the main cause of the stalling. The papers all show nicely deformed bubbles and details.

i hope to try it because it looks good when it works , but . , in the papers, they examine all the boundaries inside, consider the types. they reuse the buffers , work in parallel when possible, and this one claims to handle 800 to 1 density. " A parallel multigrid Poisson solver for fluids simulation on large grids" -Disney, McAdams.

if I find a robust solver i can port to java and switch in i will try.. but I am running out of time and might not be able to do it ( if you think it is the right plan). Here is what i dug up..

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457 .5625&rep=rep1&type=pdf

https://wissrech.ins.uni-bonn.de/research/projects/amg/ Project C2: Adaptive and robust multigrid methods for space time discretizations <http://sfb611.iam.uni-bonn.de/subproject.php?id=25&lang=en Development of CFD Code NaSt3DGP <http://wissrech.ins.uni-bonn.de/research/projects/NaSt3DGP/index.htm High-Performance Parallel Computing http://wissrech.ins.uni-bonn.de/research/himalaya/index.html

code licenses are ok....

http://www.prace-ri.eu/IMG/pdf/scalable-tools-for-fem-applications.pdf

BoomerAMG of HYPRE code of the Laurence Livermore National Laboratory (LLNL), USA http://computation.llnl.gov/sites/default/files/public/hypre -2.11.1_ref_manual.pdf

I use a c++ to c# converter.. there probably is one for java... i found one AMR poison solvers in Chombo but it is commented out.. s

also , i find papers that say FFT pressure solves can work with immersed boundaries if the ends are periodic ( or one can put dampers or boundaries, unseen in the margins so that stuff doesnt wrap around ..or move the Y , or use IB as boundaries) STAM fft 01 autodesk paper , a method like that.. But solving the poisson in these papers with a MG.+ CG. similar to what is there, seems better and can be just as fast.

my code was last like this but i feel its unstable more often than not.... unless i missed a piece..

FloodPlot flood;

Body body;

// flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0);

TwoPhase flow;

void setup() { int n=(int)pow(2, 6)*2;

int m=(int)pow(2, 5)*1;

// size ( 400, 300);

Window view = new Window(n,n/2); float L = n/8.;

body = new CircleBody(n/3, m/2, L/2, view); // define geom

flow = new TwoPhase(n,m,2,0.05); flow.f.eq(0.8,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0.02,0);

// length-scale in grid units //body = new CircleBody(n/3,n/2,L,view); // define geom

}

/ TwoPhase( int n, int m, float dt, Body body, float nu, boolean QUICK, float g, float gamma ){ super( n, m, dt, body, nu, QUICK); f = new FreeInterface( this.n, this.m, gamma ); f0 = new FreeInterface( this.n, this.m, gamma ); this.g.y = g; } TwoPhase( int n, int m, float dt, float g ){ this( n, m, dt, new CircleBody(-10.,-10.,0.,new Window()), 0, false, g, 0.1); }; /

void draw() {

body.follow(); // update the body flow.update(body); //flow.update();

flow.update2(); flow.f.display(0.1,1); body.display();

// flood.display(flow.u.curl());

}

/*** void setup(){ int n=(int)pow(2,7), m=(int)pow(2,6); flow = new TwoPhase(n,m,2,0.01); flow.f.eq(0,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0,0); }

void draw(){ flow.update(); flow.update2(); flow.f.display(); } **/

void settings() { size(600, 150); }

On Tue, Sep 6, 2016 at 9:58 PM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting

parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth <notifications@github.com

wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth < notifications@github.com> wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10# issuecomment-244922808 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PS ienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10# issuecomment-244941714 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS- aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245571919, or mute the thread https://github.com/notifications/unsubscribe-auth/ AAclJ89TdAt5JdUEAIBpPqi4jlfrgWwSks5qn_SbgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245583642, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbfOYjDhlt0n7ruG6Xkimjykl4Y_ks5qoAG6gaJpZM4JwAR9 .

damian-666 commented 8 years ago

Hello Dr:

here is the minimum code to show the instability in two phase.. Almost everything i try is unstable after 20 sec or less... I took code from Twophase flow and pasted to Main Window . file called LilyPad

changes: -your sample + the circle so I can make sloshes and waves.

TOO START FROM SCRATCH .. TAKE THE TWO PHASE CODE , CHANGE THE SETUP AND DRAW IN LILY PAD. THEN PUT THE CIRCLE IN TO DO SOME SLOSHING. I MIGHT HAVE DON THIS WRONG.

TODO : RESHAPE TO GET MORE OF A TANK LIKE LONGER RECTANGLE. SET THE RATIO TO BE LIKE WATER AN AIR WITH BUBBLES. TRY TO MAKE WAVES. TRY TO PUT A REEF OR SLOW SO THAT WAVES BREAK. ADD WINDS GOING LEFT AND RIGHT. INTEGRAT WITH THE FLOOD VIEW..

MY TEST CODE, JUST REPLACE ALL IN LILYPAD FILE.

/*****

Click the "Run" button to Run the simulation.

Change the geometry, flow conditions, numercial parameters visualizations and measurments from this window.

This screen has an example. Other examples are found at the top of each tab. Copy/paste them here to run, but you can only have one setup & run at a time.

*****/ // Circle that can be dragged by the mouse TwoPhase flow; Body body; FloodPlot flood;

//void setup(){ // int n=(int)pow(2,7), m=(int)pow(2,6); size(800,400); // flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0); //}

void setup(){

_// int n=(int)pow(2,6)_6 , m=(int)pow(2,6) ; *

// flood = new FloodPlot(view); // intialize a flood plot...TODO now sure how to get this working // flood.setLegend("vorticity",-.5,.5); // and its legend . I wish this code to be legend when used with my creatures }

//the sample /* void draw(){

/ for reference* class TwoPhase extends BDIM{

*/

void mousePressed(){body.mousePressed();} // user mouse... void mouseReleased(){body.mouseReleased();} // interaction methods void mouseWheel(MouseEvent event){body.mouseWheel(event);}

NOTES ON BREAKING WAVES AND BUBBLES

A good sample for numerical wave take would be nice so i can see the potential of this code. I have no phd, i'm a hacker with the CFD just starting to understand .. but I have read up to STAR 2016 though and adaptive meshing is now "IT". The two papers I read say MG is not stable with two phase. MG as a preconditioner for Conjugate gradient is used, and along with such an overhaul, an adoption of adaptive grid might come along free. Code is widely available from multiple c++ sources. I have done ports using a machine xlate from c++ to c#.

NOTES: on hang up sessions, processes leak.. i use cntl alt delete or a reboot to start fresh after 20 minuts. but you can see when it gets slow and bogged

names of the processes.. in Processing , that leak.. if you have lots of ram , no problem.

java platform SE binary. vshub application frame host

On Thu, Sep 8, 2016 at 10:35 PM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

Thanks.. yes. I will do this now. the sample code is there at the bottom of the email before last, but i will double check it. starting from scratch. I did get one "wave tank" to work but trying to buld a wave maker, or using a large circles, using a paddle, was unstable. both papers reported instability in two- phase with AMG only for a solver. We can make this state of the art just by integrating this and its from Los Alamos... no license issues. it is very exiting stuff....

warning: the crashed processing sessions, leak, under Win 10, and under various names which i will provide ( processing bug) .. cleaning them is important during test.

On Thu, Sep 8, 2016 at 8:38 PM, Dr Weymouth notifications@github.com wrote:

What's the problem with the current two phase implantation? Can you describe it concretely in two sentences and send me a minimal example that replicates the problem?

On Sep 8, 2016 19:42, "damian-666" notifications@github.com wrote:

hello again, sorry to bug you bug im runny out of time, need guidance on LilyPad.. two phase and free boundary.

I read in your wikik that the iVof and the two phase is still under development. But is anyone actively doing so?

But my focus is on swimmers and walkers in 2d... I dont know if a volcano will explode or the flying wing will be driver to the water... take in water ... sink while emitting bubbles. so i need unconditionally stable. I don't need compressible or shocks. For an interactive simulation it must be pretty stable under most conditions.

Incremental fluids" code on github has given me multi density , dust in the air...stratified... One phase.

But in a port of that ot java, I found a solver for CG in Java... it is preconditioned by incomplete Cholesky preconditioner... not AMG ..

here is a java version of the CG solver but with a different preconditioner. I dont know if AMG and this would be right or the fastest way to get the two phase code stable.

https://github.com/noSoulApophis/incremental-fluids-java/ blob/master/src/ physics/EulerianFluids/ExplicitFluid3conjugateGradients.java

I dont konw if i am qualified to fix the two phase in Lilypad. i am self taught in CFD.. just a newbie. My focus for 5 years. has been creature locomotion and balance.. they walk on boards with thin hulls... I can add that to air eating overturning two phase model, my demo will be incredible,.... creatures walking on boats using just muscle and bone power.

but unless you prescribe me a plan of action or proper test cases. for waves crashing on a reef. and a body i can slosh around.. .. it, dont want to risktime to work on this i need to return to America or to German or Canada, i have 3 citizenships. This island with its waves and creatures , currents , reefs, and total freedom to research , has taught me alot but i think i need to go after 5 years.

I might try the Nast2d code, but i dont konw if i can put a fish in that...

thanks, Damian Hallbauer , CEO and Sole Proprietor, Puppet Army Faction.

On Wed, Sep 7, 2016 at 7:47 AM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Hello again,

i think made a little progress on the two phase "wave tank"....I hope i didnt miss anything, but i think the two phase sloshing with bubbles works, but is often unstable and thats the cause of the stalling, slowness, and leaking processing modules. I tried the simplest two- phase i could make, set the air to water ratio to 1/10, and got some decent sloshing with tuning of the MG smoother iterations and other params.

but for my simulations even with 1/10 density and a small immersed boundary, I can't get a stable solve without a lucky tuning. And three of teh papers explain that is expected. So they use MG as a preconditioner for a Conjugate Gradient solve . So i think the two- phase is not stable enough and that is the main cause of the stalling. The papers all show nicely deformed bubbles and details.

i hope to try it because it looks good when it works , but . , in the papers, they examine all the boundaries inside, consider the types. they reuse the buffers , work in parallel when possible, and this one claims to handle 800 to 1 density. " A parallel multigrid Poisson solver for fluids simulation on large grids" -Disney, McAdams.

if I find a robust solver i can port to java and switch in i will try.. but I am running out of time and might not be able to do it ( if you think it is the right plan). Here is what i dug up..

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457 .5625&rep=rep1&type=pdf

https://wissrech.ins.uni-bonn.de/research/projects/amg/ Project C2: Adaptive and robust multigrid methods for space time discretizations http://sfb611.iam.uni-bonn.de/subproject.php?id=25&lang=en Development of CFD Code NaSt3DGP <http://wissrech.ins.uni-bonn.de/research/projects/NaSt3DGP/index.htm High-Performance Parallel Computing http://wissrech.ins.uni-bonn.de/research/himalaya/index.html

code licenses are ok....

http://www.prace-ri.eu/IMG/pdf/scalable-tools-for-fem-applic ations.pdf

BoomerAMG of HYPRE code of the Laurence Livermore National Laboratory (LLNL), USA http://computation.llnl.gov/sites/default/files/public/hypre -2.11.1_ref_manual.pdf

I use a c++ to c# converter.. there probably is one for java... i found one AMR poison solvers in Chombo but it is commented out.. s

also , i find papers that say FFT pressure solves can work with immersed boundaries if the ends are periodic ( or one can put dampers or boundaries, unseen in the margins so that stuff doesnt wrap around ..or move the Y , or use IB as boundaries) STAM fft 01 autodesk paper , a method like that.. But solving the poisson in these papers with a MG.+ CG. similar to what is there, seems better and can be just as fast.

my code was last like this but i feel its unstable more often than not.... unless i missed a piece..

FloodPlot flood;

Body body;

// flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0);

TwoPhase flow;

void setup() { int n=(int)pow(2, 6)*2;

int m=(int)pow(2, 5)*1;

// size ( 400, 300);

Window view = new Window(n,n/2); float L = n/8.;

body = new CircleBody(n/3, m/2, L/2, view); // define geom

flow = new TwoPhase(n,m,2,0.05); flow.f.eq(0.8,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0.02,0);

// length-scale in grid units //body = new CircleBody(n/3,n/2,L,view); // define geom

}

/ TwoPhase( int n, int m, float dt, Body body, float nu, boolean QUICK, float g, float gamma ){ super( n, m, dt, body, nu, QUICK); f = new FreeInterface( this.n, this.m, gamma ); f0 = new FreeInterface( this.n, this.m, gamma ); this.g.y = g; } TwoPhase( int n, int m, float dt, float g ){ this( n, m, dt, new CircleBody(-10.,-10.,0.,new Window()), 0, false, g, 0.1); }; /

void draw() {

body.follow(); // update the body flow.update(body); //flow.update();

flow.update2(); flow.f.display(0.1,1); body.display();

// flood.display(flow.u.curl());

}

/*** void setup(){ int n=(int)pow(2,7), m=(int)pow(2,6); flow = new TwoPhase(n,m,2,0.01); flow.f.eq(0,m,n+2,0,m+2); flow.u = new VectorField(n+2,m+2,0,0); }

void draw(){ flow.update(); flow.update2(); flow.f.display(); } **/

void settings() { size(600, 150); }

On Tue, Sep 6, 2016 at 9:58 PM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

op, i just pulled up my processing to try another scheme and see that all the sessions i made were still running. as leaked process, when it didn't solve, . so the latest processing leaks it, i have to use task manager to close them. . so now i close them all and i get a decent performance boost.

out of the box, this code does more and is organized better than the other ones ive looked at.. Most of which i cannot even get to compile

But reusing those buffers i always have optimized first, pretty sure that would be worth it.

and thinking about SIMD is something, flattening the buffers to 1d, i learned from this CFD code research.

i can try to do it but my project is 2 years overdue and it might get closed down for a while. but do you think this code is right for making a breaking wave? with winds on it? if there is a test case please let me know And if there is no sample i can figure out most of it ... i ame guessing to make a union of stuff to put on the bottom.. and then make a wave pusher thing to generate the waves....

But if you can point me to how to set

viscosity , fluid density, gravity direction, ( or general acceleration) , bouyancy, ( for two phase)... i was adjusting

parameters but without really knowing .. i can figure it all out if it in there somewhere.

Adding heat is not hard... but I had to hack to figure out how to adjust the density ratio.

Im learning python, processing, fortran90. java, shaders opencl,.. all for this CFD because it fits so well with my creatures.. Emergent stuff like weather comes from heat so i want to do alot with the Air Field.

My project is 2 years overdue and I think i have read over 300 papers. i might just need to ask general stuff sometimes. I can probably figure it out but I don't understand Algebraic multgrid, nor an easy way to make it adaptive, but i probably have the paper somewhere.

thanks for makeing this code available., it might be my best water solution and have several dust schemes that can work..

On Tue, Sep 6, 2016 at 8:58 PM, Dr Weymouth < notifications@github.com> wrote:

My role in this open source project is to help people use and update lily pad.

If you have a bug, or usage question, then I'll try to help fix/answer it. If you can put some time into optimising the memory allocation, that would be great. I'm not a computer scientist, so I could use help with that. If you make a change and send a pull request then everyone else will benefit from your work on it. Same for multi-threading (which I am about to start working on myself). Same for adaptive mesh refinement.

This is my understanding of how open source works.

So, if you're interested in making lily pad better for everyone, then pick one item and make it better. That would be great.

On Sep 6, 2016 19:28, "damian-666" notifications@github.com wrote:

Hello again.. maybe the last email was all over the place but I have some well defined issues now .

I got the two phase to work but I am not sure if it is working as well as it could. The main issue is performance. for first pass , I noticed that the MG solver is reallocating the MG solver instance, and its arrays every call. There is a lot of that and for every field with the whole grid...as well. For the solver , i think it could have one instance of the solver, and a buffer PoissonMatrix A and a buffer B for the fields passed in. A hash table or map could associate the field with data if needed... I am trying a quick use of static.. so that the data is kept in place, not moved around and reallocated, which , in a loop can be fragmenting memory and require garbage collecting and compacting. I noticed when i put 3 grids in a row like a chimera that the GC was stuttering.. that was the first hint of buffer issues.

static class MG{ PoissonMatrix A; static Field r, x;

SIMD processing : the arrays could be made to 1d ( not sure if that matters) , but to take advantage of SIMD some care has to be taken with rows and columns of arrays should be as laid out in memory. so i think columns on the outer loop for 2d array.. one or the other. I have seen big boosts with code that has SIMD friendly loops without branches

t when I move the circle near the surface, it is very slow... Even an stutter and hang up.. not explode, but stall..

i loaded http://www.lagers.org.uk/jasmine/ but i see no difference.. nothing compelling about it..

If there is parallelization to be done, i think that could be next, but i am not sure with Algebraic MG?. adaptive methods that use smaller squares near entopy or the interface, would be best.. some use it in deep water.

-I noticed the line seg object could not break the bubbles. I think the circle did pushes them. I like how I could stir the bottom and slosh the whole thing.

-But for a numerical wave take with some length , it seems it needs plenty of speed up. I see new ways to get find surface detail from coarse grids. and for vortons, it would nee to treat rollups with a fine mesh or perhaps using vorton particles, or blobs of them.

-the bubbles could be compressible, that would be a nice look if resolved.

-I would love to see a sample of a breaking , overturning , air gulping wave. I can now have the wind blow on way or the other and see the effect :)

-toward the breaker should make a barrel, in the wave direction ( onshore) , should make a mess.. ( i can see the wind blow on the water).

I could not figure out how to change the density ratio, or any buoyancy parameters .. 10 might be enough , 100 or 1000 is the reality.. but a buoyancy factor would be enough.

  • The functions did not have enough comment so i could find how to set the gravity direction, or strength, the viscosity, the density ..

-would it be hard to add temperature? I would think that just advects simply, with the fluid, diffuses, also.. then, adds to the buoyancy if the air is hotter than the water.

-adaptive features such as grid refinement would give the most reward.. probably..

I am still not sure if this code is the right path for me, I like the idea of a flapping bird in air and this method is the most complete. I use a simple drag / flux model, for fish locomotion, and it worked fine. But the IB is supposed to be the best way to react to the reef contours, hillsides, and the AMG method one of the fastest. But i am no expert i am reading papers every day and never feel like I know enough.

I installed Jasmine to processing, didnt notice much of a difference... ( on PC, windows 10 , latest processing,) the ball does move the bubbles, they do go up. I would like a 100 to 1 density ratio ( is that close to water /air?)... the air could be compressible... should be.. 10 to 1 would be enough.. But i think i need to added gravity.

is there a less frendly and more performant code I could look at? I though i saw some code that calculated the breaking bow waves on a vessel from your team.. at MIT ? should i try the MarineHydro/lessons/? is it true the code is 1st order accurate, you stated long ago.. but i saw some notes on RK and I see plenty of vorticity, almost too much.

I now found some new flip code that is adaptive both with the size of the mesh and the sph particles, using a tetrahedron grid, but it is only one phase. I can clearly see the wind blowing on the surface here and i think i don't want to do without that...

If i see a nice breaking wave demo, maybe i can fix some of this stuff... but i dont konw java, c# in not much different though.

CBatty's variational cut cell method promises a coupling. it is using a complex conjugate..

I tried compling the java, so i think the main issue is the buffers, and something else...

i am gong to give a quick try to this: reuse the buffers by making classes static. A map might need to be implemented but heap churn in the loop and allocations are expensive so im sure it worth it. If worker threading, each thread can have its own buffers, mapped by thread id...

static class MG{ PoissonMatrix A; static Field r, x;

int iter=0;

float tol=1e-5;

MG( PoissonMatrix pA, Field X, Field B ){ A = pA; x = X; r = new Field(x.n,x.m,0,tol); tol = r.inner(r); r = A.residual(b,x); }

[image: Inline image 2]

air is to thin, water not dense enoug.....

I am only 5 month into CFL ,[image: Inline image 1] so i am hoping ot find code that matches since my project focus is an walking creatures, and walking on boats now..

But runing at 2^ 6 2,^ 5 gives me barely interactive speeds.

for 2d i was hoping to do the full NS... not using some hacks..

i still dont understand "periodic" boundary conditions, if there is only one period in the window... with buffers on the margins... because the FFT pressure solve scales the best ..

On Mon, Sep 5, 2016 at 9:33 PM, Damian Hallbauer < damian.hallbauer@gmail.com

wrote:

Thanks. I dont think its a bug. I think its an issue of rendering, or maybe an additional feature like adaptive methods , cells of different sizes, near the high entropy area, would help. I wrote an enormous email describing what i would like to use the code for ( breaking waves, thin paneled boats , and surfer-eating fishes) for an educational and entertaining simulation game for disabled kids that cant go surfing outside. I hope you don't mind it.

i am looking all over the internet.. ShadowFax uses a moving grid, and another scheme based on VOF uses a triangle grid has some advantages over the voronoi one.

On Mon, Sep 5, 2016 at 4:49 PM, Dr Weymouth < notifications@github.com> wrote:

I'm sorry, what exactly is the issue you are reporting? The only issues I see are in your title.

The first issue in the title is that the solver must be a power of 2, but this is not quite right. The number of point in each direction needs to be proportional to a large power of 2. This is because the multi-grid solver interactively "restricts" the domain by a factor of two in each direction. It will be much more efficient if the solver can do that at least three times, and more is better.

As for the second issue in the title: If n is the total number of points, the the fluid routines in the code are O(n) except for the multi-grid solver which is O(n log n). However, if you double the points in both x and y, then this is increasing n by a factor of 4. In addition, if you double the resolution then running a certain simulation (say two cycles of bluff body shedding) will require (about) twice as many time steps.

Hope that helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244692953 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_ LmTEPVm6vYGR0C38dtqSdNzmVqZdhks5qm9eagaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10# issuecomment-244922808 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ08PS ienC_VMAPiybqmbto02xiXdks5qnU5HgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment -244941714 , or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbbeHrfDeVS- aqAyoFAgQIk8OekAks5qnWNfgaJpZM4JwAR9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/weymouth/lily-pad/issues/10#issuecomment-245571919 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAclJ89Td At5JdUEAIBpPqi4jlfrgWwSks5qn_SbgaJpZM4JwAR9

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245583642, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmbfOYjDhlt0n7ruG6Xkimjykl4Y_ks5qoAG6gaJpZM4JwAR9 .

weymouth commented 8 years ago

I'm sorry, but that doesn't work because of all the little stars and weird tab stuff you've introduced. Can you please clean that up and put it in as a code block or attach as a single LilyPad.pde file?

damian-666 commented 8 years ago

Thanks, I will find the Pde file and send. meanwhile, this might work after this line, to copy and replace to the replace everything below in the File LilyPad.pde. I am using win 10, using the blessed "Everything" tool as a start menu. I found java AMG->CG solvers that might work, if you want it let me know.

// Circle that can be dragged by the mouse TwoPhase flow; Body body; FloodPlot flood;

//void setup(){ // sample test code given // int n=(int)pow(2,7), m=(int)pow(2,6); size(800,400); // flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0); //}

void setup(){

// int n=(int)pow(2,6)*6 , m=(int)pow(2,6) ; //tried this.. not sure if one phase must be 2x the other, hints welcome int n=(int)pow(2,7) , m=(int)pow(2,6);

size(1200,500); // display window size , trying for numerical wave tank

float L = n/8.; // length-scale in grid units Window view = new Window(n,m);

// body = new CircleBody(n/18,n/14,L/2,view); body = new CircleBody(n/18,n/14,L,view); //BIGGER circle, more stalling

flow = new TwoPhase(n,m,2,0.01); // flow = new TwoPhase( n, m, 0, body, 0.1,true,10, 0.1 ); //not stable either

flow.f.eq(0,m,n+2,0,m+2);
flow.u = new VectorField(n+2,m+2,0.2,0);

// flow.u = new VectorField(n+2,m+2,0.2,0); //breeze to the right at 0.2 vel x? WI how to do a slight wind in the air phase.

// flood = new FloodPlot(view); // intialize a flood plot...TODO now sure how to get this working // flood.setLegend("vorticity",-.5,.5); // and its legend . I wish this code to be legend when used with my creatures }

// sample test code given / void draw(){ flow.update(); flow.update2(); flow.f.display(); } /

void draw(){

body.follow(); // update the body flow.update(body); flow.update2(); // 2-step fluid update // flood.display(flow.u.curl());

flow.f.display(); body.display(); }

void mousePressed(){body.mousePressed();} // user mouse... void mouseReleased(){body.mouseReleased();} // interaction methods void mouseWheel(MouseEvent event){body.mouseWheel(event);}

//WISH: WOULD LOVE TO HAVE A WITH NUMERICAL WAVE TANK... A MOVEABLE reef object. //a sloping beach or a wall. //a way to controll the wind direction left or right. //a moveable paddle used to generate waves pulses

On Fri, Sep 9, 2016 at 10:40 AM, Dr Weymouth notifications@github.com wrote:

I'm sorry, but that doesn't work because of all the little stars and weird tab stuff you've introduced. Can you please clean that up and put it in as a code block or attach as a single LilyPad.pde file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245802734, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmZCdM5LVkcyKdr86wRczNd9i0eH6ks5qoMcLgaJpZM4JwAR9 .

damian-666 commented 8 years ago

Sorry, to drop off the grid...​ ran out of 4g credits just as i was sending this, had to go to buy some. Here is the file.

Maybe you can tune it properly, see what i did wrong , I am certain i could have done better setting up a wave or fuel slosh tank, the flood window, parameters, etc. But those two papers told me two phase using just AMG was unstable for them. so i hunted for some pretty simple java AMG/CG code... but the c++ i sent before is top notch ..and looks more like the solver you have. If you prescribe that it should indeed be changed , i may be able to find time to porting it this week,., with guidance..

I'm not too concerned about fluid mass conservation for the wave, i can correct it and attribute changes to tides. For a fuel /slosh tank I would need it to conserve.., with maybe kind of correction scheme for the VOF. Maybe i can bring attention to this on the CFG group and recruit some workers to bring it to its maximum potential. Python is not friendly or fast, and version-bundled, CFD, is hard enough. So lilypad could be the most rewarding one for the noobs.. and also potentially applicable to real projects, Fish races.. boat eating solitons...

Thx..

On Fri, Sep 9, 2016 at 11:35 AM, Damian Hallbauer < damian.hallbauer@gmail.com> wrote:

Thanks, I will find the Pde file and send. meanwhile, this might work after this line, to copy and replace to the replace everything below in the File LilyPad.pde. I am using win 10, using the blessed "Everything" tool as a start menu. I found java AMG->CG solvers that might work, if you want it let me know.

// Circle that can be dragged by the mouse TwoPhase flow; Body body; FloodPlot flood;

//void setup(){ // sample test code given // int n=(int)pow(2,7), m=(int)pow(2,6); size(800,400); // flow = new TwoPhase(n,m,2,0.01); // flow.f.eq(0,m,n+2,0,m+2); // flow.u = new VectorField(n+2,m+2,0,0); //}

void setup(){

// int n=(int)pow(2,6)*6 , m=(int)pow(2,6) ; //tried this.. not sure if one phase must be 2x the other, hints welcome int n=(int)pow(2,7) , m=(int)pow(2,6);

size(1200,500); // display window size , trying for numerical wave tank

float L = n/8.; // length-scale in grid units Window view = new Window(n,m);

// body = new CircleBody(n/18,n/14,L/2,view); body = new CircleBody(n/18,n/14,L,view); //BIGGER circle, more stalling

flow = new TwoPhase(n,m,2,0.01); // flow = new TwoPhase( n, m, 0, body, 0.1,true,10, 0.1 ); //not stable either

flow.f.eq(0,m,n+2,0,m+2);
flow.u = new VectorField(n+2,m+2,0.2,0);

// flow.u = new VectorField(n+2,m+2,0.2,0); //breeze to the right at 0.2 vel x? WI how to do a slight wind in the air phase.

// flood = new FloodPlot(view); // intialize a flood plot...TODO now sure how to get this working // flood.setLegend("vorticity",-.5,.5); // and its legend . I wish this code to be legend when used with my creatures }

// sample test code given / void draw(){ flow.update(); flow.update2(); flow.f.display(); } /

void draw(){

body.follow(); // update the body flow.update(body); flow.update2(); // 2-step fluid update // flood.display(flow.u.curl());

flow.f.display(); body.display(); }

void mousePressed(){body.mousePressed();} // user mouse... void mouseReleased(){body.mouseReleased();} // interaction methods void mouseWheel(MouseEvent event){body.mouseWheel(event);}

//WISH: WOULD LOVE TO HAVE A WITH NUMERICAL WAVE TANK... A MOVEABLE reef object. //a sloping beach or a wall. //a way to controll the wind direction left or right. //a moveable paddle used to generate waves pulses

On Fri, Sep 9, 2016 at 10:40 AM, Dr Weymouth notifications@github.com wrote:

I'm sorry, but that doesn't work because of all the little stars and weird tab stuff you've introduced. Can you please clean that up and put it in as a code block or attach as a single LilyPad.pde file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-245802734, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmZCdM5LVkcyKdr86wRczNd9i0eH6ks5qoMcLgaJpZM4JwAR9 .

weymouth commented 8 years ago

I've reproduced the issue and migrated to a new issue with a clear title focused just on this topic.

damian-666 commented 8 years ago

sounds good Doctor, thank s for looking at it right away. sorry, but i cant put this in a tweet .too tired to be concise.. i tried to put in bold the important points...

i must say, LilyPad is the only tool i found that give an interesting useful result in 5 seconds. CFD and python and fortran, for a biologist.. is wayyy too much.

Yes, I see that the QUICK is stable, but .. using it at 64 x 32 is interactive on my modest quad core. I would need to clean the view... i could try the stream view , vorticity or some particles or isolines... I would look for ways to add sub grid detail... perhaps anisotropic turbulence.. or particles or vortons. But.. i feel evenQUICK is not that robust... as in... if i put the density ratio at 1/100...and

flow = new TwoPhase(n, m, 0, body, L/10.0, true, 0.01, 0.001); //QUICK changed viscosity or gamma to 0.001. from 0.1.. air enters water stops..... this could be an issue if heat is added... 0.001 for apparent viscousity is a common starting value ive read....anyways...

and if go back to the stable quick with the moving ball, and i use 1/100 for density ratio. its ok.. but the waster is too thick to be watery...

changing the last two params will stall it...

flow = new TwoPhase(n, m, 0, body, L/10.0, true, 0.01, 0.1); //QUICK...

if I had heat, this would not be predictable.

if it were stable , some parallelisation , trivial.. as described in A parallel multigrid Poisson solver for fluids simulation on large grids

im still convinced its the pressure solve because of my parameter testing, and the iterations and smoothing set at 20.. so i put together some papers.. i cant draw conclusions from them i hope you can . the code is not too hard to find.

here in this paper looks very promising:

Here is says the approach allows for 800 to 1 density with bubbles that change shape since they focus only on areas of interest:

An Adaptive Level Set Approach for Incompressible Two-Phase Flows1 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457.5625&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.457.5625&rep=rep1&type=pdf

flow = new TwoPhase(n, m, 0, body, L/10.0, true, 0.01, 0.001); //QUICK changed viscosity to 0.001... air enters water... this could be an issue if heat is added...

these researches love AMG for mud flows. and everything. while others say that AMG is suitable as a preconditioner, for two phase air/ waer. https://info.ngwa.org/GWOL/pdf/021573551.pdf

i think if it is lagging.. then the code can change to AMG->CG... many of the optimizations are just trivial parallelizations.

in c# we have Parallel.ForEach loops...

https://www.math.ucla.edu/~jteran/papers/MST10.pdf

A parallel multigrid Poisson solver for fluids simulation on large grids

https://wissrech.ins.uni-bonn.de/research/projects/amg/

Multigrid Methods on Adaptively Refined Grids

my next step is to use MAC cut cell scheme to do multi density soot that i hope will stratify. But, i will need water and I might skip ahead to 2 phase if I will get all that anyways.. and help with Lilypad... I would love to see if work with that code i sent before

- is there buoyancy?.. i search for bubbles and i find no explicit code.. bubbles are not in FLIP.... normally.. I have a 2d man and a 2d flying wing.. if we crashes into the sea.. i hope water leaks in... and it sinks... maybe even implodes from pressure at depth.... and burpees out bubbles ...

-should i try convex, air containing shapes , are they supported? seems they would work.. and float... i am not able to set the ball free to float or sink...

i might be able to prototype faster with processing ( but the leaks are annoying) than with my setup. in that case i could maybe improve lilypad since my code often comes as java ro c++ first. my plan Now my main priority is to get "tunabrains" adaptive fluids to java port, to c#, mult-density single phase dust integrated with my c# tool as a plugin... and see some stratified air i hope, that interacts with temperature gradients and with my 2d bipedal creatures. If they can roll vortices from their arms, that would be ideal. ( Im building a 2d dimension universe simulation). An educational but fun physics game.. But, i will need waves, and if I can use a fork for this.. sharing back the general purpose, perhaps this can be my air, water, and solids, as c# and java are so similar.

Or more. I would port it to c#... apply trivial parallelization.. to loops i use parallel.foreach...

On Sat, Sep 10, 2016 at 10:00 AM, Dr Weymouth notifications@github.com wrote:

I've reproduced the issue and migrated to a new issue with a clear title focused just on this topic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weymouth/lily-pad/issues/10#issuecomment-246081405, or mute the thread https://github.com/notifications/unsubscribe-auth/AP_LmWGYGzZ16Il-K9uHHzt4KHBbtZreks5qog9EgaJpZM4JwAR9 .

damian-666 commented 8 years ago

found some speedups for java.. .net has better tools but MSFT hasnt pushed it as mush as the community has..

rendering.. using p2d or p3d makes a big difference.

size(1400,700,P2D);

https://blog.jooq.org/2015/02/05/top-10-easy-performance- optimisations-in-java/

http://stackoverflow.com/questions/5686200/parallelizing-a-for-loop

memory leaks... they go by alot of names... soits hard to clear them... log out log in...

people even fix the source ...