# Coloring Drainage Simulation - help

Hey everyone,

I have a drainage simulation (see grasshopper file below). Now I want to color that in different colors. That means, there shall be different colors dependent on how much “water” there is. Can anyone help please? I have absolutely no idea how I should do that.

Thanks!
DrainageSimWithoutColor.gh (6.1 KB)

Hello
I am not a specialist but such algoritm must work.

For each point of the mesh
Weight on point =0;
For each curve find closest distance between the curve and the mesh point
Weight = Weight + Kernel(distance)
End For
End For

Kernel could be
if (distance < threshold)
result =1
else
result =0

It gives that

1 Like

Hi,

thank you, that gives me an idea how I could start. Just one question: what is weight on point?

Oh, that looks exactly what I need!

Weight allow you to measure the number of pipes is passing near the point.

Kernel could be square or has a bell shape

I can say that the drainage code you use seems pretty bad. It uses mesh vertices. If your mesh vertices are equally spaced en XY plane it is OK, if not it is not good !!!
Each departure of flow represent the rain droplet so it is better to have an uniform distribution.

Okay, so I’ll have a try on another one. And then to get color into that thing.

Here a Grasshopper version, it is not very fast. It is far faster in C#.

drainage_analyse_rainflow.gh (1.2 MB)

2 Likes

Thank you so much! I learned more from your help and examples today than all the last days I sat there on my own. Now I will get it working I think

It looks like it should be colored expensive.

I continued to look to this subject. There are others ways to get the color that could be fastest. I think of using a bitmap or a 2D array to do that. This will remove the need for using closest point sot it could become more fast. What is strange is that there are not a lot of good tool to do that, but as it is not my domain I surely have missed something.

Another thing is the coloring. There are others metrics than debit. There is also the velocity (~slope).

I also discovered this marvelous website to get STL of terrain.
http://jthatch.com/Terrain2STL/
Mont Blanc

3 Likes

Did something similar during my master’s at the A.A. let me know if you need any help

2 Likes

@laurent_delrieu,
Are you familiar with Gismo? Terrain2STL is using 80-90m terrain resolution, while Gismo is using 20-30m. This is the same Mont Blanc peak with 4x4km

1 Like

Thanks @djordje I didn’t know Gismo, GIS is not my domain.
@djordje do you know a tool to make the drainage coloring ?
I have to discover GIS a bit at the moment. I implemented a GeoJSON reader because for my needs I needs some maps (country, marine domain …). I also need to calculate area (on the earth) and make boolean operation on surface on earth. For that I use Clipper…

Gismo seems very useful. For @Nine.Jates here is the link Drainage is included in Gismo.

1 Like

Hi @laurent_delrieu,
At the moment Gismo does not support drainage coloring. But @Nine.Jates can use your upper Grasshopper definition and Gismo’s “Terrain Generator” to get the terrain surface by defining latitude/longitude and radius.
As for your tasks, Gismo can generate underwater terrain as well, if this is what you meant with marine domain?

1 Like

Tognatta, this looks very interesting!! Thank you for sharing the youtube video.

1 Like

For the maritime I mean that

For my use Rhinoceros or Grasshopper are not usable. I have make a standalone application so I use Rhino3dmIO, Clipper, … and many standard .NET library.

Thank you everyone, I will have a look at that tomorrow!

Re @djordje, I don’t know if I used well Gismo Flow Path but it seems a bit long. 1 minute for 5000 points on a mesh. My C# component is doing 7.7 s with 20 000 points.
I don’t like to put bad program (no comments no optimization …) like that, but it seems it could be useful

1 Like

Hi @laurent_delrieu,
No need for apology.
Gismo’s component was created 3 years ago, and it hasn’t been optimized since then. As you just showed there is plenty of room for that.
In Gismo’ case we could probably use generators instead of lists. Increase the tolerance for stopping the flow path. I see you also use RTree, which is something that Gismo should implement as well.

In any case, thank you for sharing the comparison results and sharing your code.
As always they are truly valuable!

No problem,
What I do is going face to face and using Mesh topology. I developed that for Geodesic curve. So it doesn’t use closest Point or things like that. It sticks to the faces and edges. But it seems that I forgot some cases for the drainage. Cases that were difficult for geodesic. So use it with caution. I will try to make a more usable and tested tool.
RTree is no use for drainage, it is used for coloring.

1 Like