Closed BatchDrake closed 1 year ago
Some questions/comments:
I mean this should be plenty fast enough even for large meshes, so the speed improvement should be neglectable ;)
Why did you name the argument "box" instead of e.g. mesh? Could be bit confusing reading the doc?
My bad, somehow I though that that was how you were calling the mesh in other functions, but now that I read them better it is obvious that box is something else. I am changing it.
Why not use lines = mesh.GetLines('x') to get an array and then just np.min(np.diff(lines)) for example?
That was in fact my first approach, but after looking into the implementation, I saw that it called self.thisptr.GetLines
and looped through its output to build the line list. Since the (Python) loop was unavoidable, I though that maybe calling GetLine
was somewhat more direct. But anyways, if the improvement is barely noticeable, I'd also prefer to favor readability.
Would it make sense to have this function in openEMS.pyx
or CSRectGrid.pyx
instead? I've personally never used automesh.py
(as I've been using my own automatic mesh-generation algorithm), and I'm not sure I would expect to find a timestep calculation function in a file whose name hints to be related with automatic meshing.
E.g. if I wanted to simply check the timestep in Simple_Patch_Antenna.py
, it would be a bit more convenient to not have to do another import
.
Not a big deal either way though.
Well no place is ideal, but there it makes most sense? Because the automesh algorithms could use it to check if the generated mesh is within spec for example. Furthermore this should stay pure python code. In any *.pyx it would be compiled cython code where debugging and so on is always much harder... Additionally most user will probably not (and maybe should not) use it, as it is not easy to determine if a time-step is okay or not.
This PR provides
mesh_estimate_cfl_timestep
, a function that accepts aCSRectGrid
mesh and provides a crude estimate of the maximum CFL time step (in seconds), assuming vacuum propagation. Since adding materials with different permittivities / permeabilities will simply slow the propagation of EM waves in the medium, this is actually an underestimation of the true maximum time step.