Closed wave46 closed 2 years ago
Hi @wave46. The best way to do this is to use a proper 3D mesh object of your PFC if you're truly interested in 3D effects. For other submodules like the JET, AUG and MAST-U ones we've actually extracted the relevant data from the master CAD model of these machines and stored it as a collection of mesh files. The axisymmetric_mesh_from_polygon
function is useful for interfacing with 2D-only data as a rough approximation, but it sounds like you have better data than that already.
That said, it shouldn't be too hard to add a new function toroidal_mesh_from_polygon
, which does the same thing but takes a toroidal_extent
argument in degrees and uses that instead of the 360 degrees the axisymmetric version does.
In private communication @wave46 told me that the proper CAD model is on the way. But for now they have only the model from the ToFu package, which is a set of 2D polygons with given toroidal position and extension. Interestingly, I suggested exactly the same name for the function: toroidal_mesh_from_polygon
. The axisymmetric_mesh_from_polygon
will be a special case of toroidal_mesh_from_polygon
then.
Thank you, @jacklovell. The problem is the axisymmetric_mesh_from_polygon
function closes the last extented polygon to the first one, so the whole figure becomes closed.
In case of given toroidal_extent
the mesh of the 2D polygon should be made to close the extension from the ends. In case of complex concave polygons, can it be made with the help of cherab or some others python libraries? I've tried some solutions, but didn't succeed yet
Hello @wave46,
do I understand correctly, that you want to be able to generate some toroidally discrete parts of in vessel components from their poloidal cross-section definded as a polygon? An example of such component could be the outer wall limiter we have in Generomak? I would say that this is a slightly different problem. The axisymmetric_mesh_from_polygon
generates just a shell, what you want is a watertight object, correct? In this case I think it should not be a problem to get, but I have my doubts it will be that useful in many cases and that it should be added as a tool. axisymmetric_mesh_from_polygon
was added, because most of the equilibrium codes deliver also first wall contour. In your case, this is only a temporary solution, until you get proper meshes.
I would suggest to poke the responsible people to export your drawings into a step file and then use salome to do the meshing. This is what I do for COMPASS/COMPASS Upgrade. The advantage is you can control the number triangles. Also, most of the time, there is a limited number of plasma facing component types (e.g. inner wall limiters). You have to mesh every type of tile just once and then you can instantiate it in raysect and move around, to get your PFC design. This is what I use and it saves a lot of time during loading, plus some memory.
Thank you, @Mateasek
Yes, that's the problem. And now I see that your suggestion is a better way to proceed. Thanks a lot to everyone for quick responses.
Just an argument for implementing toroidal_mesh_from_polygon
, if we do that it will allow other wall meshes from ToFu to be imported to Cherab as well. This would be useful for benchmarking and would also make it easier for users to switch between the two packages.
Are we talking here about extending a general shape, specified only by vertices, from 2D to 3D by adding vertices with toroidal rotation? Because if we do, then I'm bit afraid it is impossible to correctly triangulate the faces aiming in the poloidal direction. If you really want this functionality, then I would suggest making it a function, which has both 2D vertices and triangles as parameters,and extending it into 3D in the same way as toroidal_mesh_from_polygon
.
Because if we do, then I'm bit afraid it is impossible to correctly triangulate the faces aiming in the poloidal direction.
I think, triangulate2d
from raysect.core.math.polygon
should give a nice result. I've never used it before, but the algorithm looks fine.
Yes, for very specific shapes it does, but you can run into problems. triangulate2d
can raise exceptions for various shapes, when it thinks it is not a single ear polygon and that happens quite often, at least to me. If you have in mind triangulating simple shapes, then this is ok, but why should we have a tool for a task, which can be done by a user with a few lines of code? Wouldn't it be better to have a demo instead of a function?
I don't think we should be engaging in problems of meshing at all. I don't think we should care about how ToFu defines its data and first wall elements. I think that vertices and triangles is a very common and actually standard input requirement and that we don't have to do all the heavy lifting, especially when it is tricky to be made general. I think that providing the functionality I proposed is more than enough.
If you really want this functionality, then I would suggest making it a function, which has both 2D vertices and triangles as parameters,and extending it into 3D in the same way as toroidal_mesh_from_polygon.
I agree, but let's make the triangles optional. If not provided, the function will try to triangulate a given polygon with triangulate2d
. We will clarify in the docstring that triangulate2d
does not work for all polygons.
@Mateasek if triangulate2d is failing it is because the vertices are not spatially clockwise/anticlockwise ordering. If the polygon is drawn by connecting each vertex in sequence and any lines cross - then it will fail. In all other situations the algorithm should work reliably. It is a widely used triangulation algorithm in 3d graphics.
Fixed in #365
I am Kudashev Ivan, a PhD student from Aix-Marseille University from M2P2 laboratory under the supervision of Eric Serre and Anna Medvedeva. We are going to develop a cherab-submodule for WEST tokamak. It seemed useful to modify or have a similar to
axisymmetric_mesh_from_polygon()
function which can work with not fully axisymmetric plasma-facing components. For example, if I have some PFC with given toroidal position and extension (in degrees) and I don't want to rotate it for all 360 degrees. Thank you!