New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial topography plugin prm polygon #1099
Conversation
45d68e2
to
0eba453
Compare
I added a function to utilities which computes if a point falls within a 2d polygon. I added it there because I noticed that it is a function I use a lot in my plugins, especially for initial conditions. So I thought it might be useful for other people as well. |
/** | ||
* The polygons and their points are stored in this vector. | ||
*/ | ||
std::vector<std::vector<std::vector<double> > > point_lists; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you know the size of the inner vector, can you change the inner vector to Point<dim>
or Point<dim-1>
or whatever is the appropriate type?
Nice addition. I think it would be nice to have a test as well. |
0eba453
to
c693ef1
Compare
I hope this addresses all comments :) |
{ | ||
value = topography_values[i]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous comments on this code have been erased during renaming of the function, but to rehash: I said that this is inefficient because it has to go through all of the point lists, and then takes the value of the last polygon that matches. You said that this is the intended behavior.
I think I don't understand your use case where you have multiple polygons, and more than one of them actually has the given point inside. If that's the case, why take the last polygon's value, rather than the first? Taking the first has the advantage that you can just exit the function at this point, rather than having to search through all following polygons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right it is inefficient. My point was mainly that the last one should be chosen. It is more a conceptual thing for me, that you go through the list and 'paint over' in every polygon. I have made it more efficient now, in the sense that I turned around the for loop and put the return inside the if statement.
Although it currently has my preference that the last one is the final one, but I do not feel very strongly about it. So if you really prefer it to be the other way around I am fine with it.
c693ef1
to
427704f
Compare
"The next topography height > the next point list describing a polygon.\" " | ||
"The format for the point list describing the polygon is \"x1,y1;x2,y2\". " | ||
"For example for two triangular areas of 100 and -100 meters high set: " | ||
"'100 > 0,0;5,5;0,10 & -100 > 10,10;10,15;20,15'. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, this won't render correctly in latex. I think you need to write $>$
or maybe better, \textgreater
.
I was going to merge, but then I saw the issue with Thinking about it, you probably also want to add an entry to the Otherwise ready to merge. |
/run-tests |
{ | ||
if (aspect::Utilities::polygon_contains_point<dim>(point_lists[i-1],p1)) | ||
{ | ||
return topography_values[i-1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This order of the loop works for me. You may want to add a comment explaining why this is the order in which you go through the loop this way.
427704f
to
80f6fa9
Compare
I must say that it currently still is not usable, because no geometry model has implemented the initial topography yet. But that will be the next step :) About the squashing, I normally squash (fixup actually) all changes in one source and include pair in one commit, and each test in one commit. Is this what you meant, or do you want everything into one commit which contains everything? Furthermore, I noticed that before adding the last set of changes (after which the tester ran again), the tester failed because three melt tests where taking to long. For now it is fine, but maybe the allowed time per test should be extended a bit, or the tests should be simplified a bit in the future? |
Yes, one for code changes, one for changelog, one for tests is totally fine. That's how I often do it as well. Regarding tester time, that's @tjhei 's call. But I haven't seen this problem before, so I suspect that it doesn't happen very often and in fact only happens if something else is happening in the background. |
@@ -6,6 +6,12 @@ | |||
* | |||
* <ol> | |||
* | |||
* <li> New: There is now an initial topography plugin which reads | |||
* from the prm file polygon definitons and set the initial topography |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> definitions
I was going to merge, because the structure with the 4 commits is also just fine -- in fact, it's a nice way of doing it this way because the function that tests whether a point is inside a polygon is a self-contained addition that can certainly be in its own commit. But I saw that you have two typos in the changelog. Can you still fix them? (Logically, btw, the second commit with |
c61c37a
to
b2736bd
Compare
Thanks! Your are right, that order makes more sense. I also noticed that there where still two comments in prm_polygon.h incorrect, so I fixed them (hopefully didn't introduce more spelling mistakes :P ) |
Please do not merge yet, I found a possible mistake somewhere. I want to check it first. |
OK. Let us know when you have it fixed :-) |
b2736bd
to
6663c29
Compare
I found that the name was not of the subsection was not consistent with the interface, and that is now fixed. At the same time I was making the implementation of this in the ellipsoidal chunk geometry model, and I found some weird behaviour. But I am now quite sure that doesn't have to do with this part of the code, but with what happens when you use a very course grid with a very large topography. But that is something we might discuss in that pull request. In short, if the tester is fine with this, I think it is ready to merge :) |
This adds an initial topography plugin which defines the initial topography by defining 2d polygons on the surface and setting it to the desired elevation. After this I will update the ellipsoidal chunk and make a test out of this. Or should I do this within this pull request?