Closed briandrawert closed 7 years ago
In front of what exactly?
The '.geo' code ends up looking like this:
ll1 = newll;
Line Loop(ll1) = {l21,l1,-l22};
surf1 = news;
Plane Surface(surf1) = {ll1};
Note the negative sign in front of l22
.
Ah, hm, yes. I see now that you needed to insert that as otherwise, the line loop would not consist of "consecutive" lines, i.e., the last point of line k
wouldn't be the first point of line k+1
.
How would you suggest that pygmsh works here? Checking the points of the elements in the line loop, and turn lines around if necessary? I believe that'll be a bit hard since right now, pygmsh doesn't really keep track. If a line is defined, the Gmsh code is written into a string and then forgotten.
Ideally it would be as you describe. One simpler option might be to have the return from the "add_line" function to be an object that extends the string class:
class mystr(str):
def __neg__(self):
return '-'+self
Then, add line loop could use this syntax:
geom.add_line_loop(l1, l2, -l3, -l4)
I thought about this a little bit and I think we shouldn't take make it more complex than necessary. If gmsh requires you to insert a negation -
sign, then pygmsh should too. Making this automatic would certainly be an improvement, but then again so would be many other things, like for example the order of the lines in a line loop.
Keeping things simple make it easier to maintain pygmsh and make it clearer for the user what actually happens.
Now, as for the syntax, there are two options: '-' + l1
and -l1
. (The first one is used in in pygmsh code, e.g., in add_ellipsoid
.) While the second is clearly shorter, the first makes explicit what happens: -
is prepended to the line. Not sure what to prefer here.
Alright, this is now fixed. All objects returned from pygmsh are now class instances, not strings, and you can (and in fact must) now do -my_line
to reverse the line orientation.
I am getting around this by manually entering a
-
sign in front of