Save internally generated mesh to file #389
-
Hi Capytaine users, This is my first question. I'm new to capytaine, fluid modelling, meshing and programming in general. I'm studying the interaction between a liquid surface and an array of vertically standing prisms (cylindrical, square, whatever). I'm currently trying to build the array using the tools inside capytaine by sequentially adding prisms to an array. This gets slooow.. and I need to run multiple simulations on an array. I thought I could save time by dumping the array out into a file so I can load it in for multiple simulations. I'm trying to use the pickle package to do this. It is not working. It can't find the relevant variable in the global dictionary (though I know it is there), and I think this might be because the variable names in python are just aliases for something that's happening at a lower level, so it's simply not valid to try and extract the mesh this way. But as I said, I'm no programmer and I don't know how it all works. Can this be done? That is, is there a way to export a mesh generated internally in Capytaine so it can be loaded for future simulations? Thanks in advance! Joe |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @joesmerdon, Are you sure the mesh manipulation is what is slowing you down? |
Beta Was this translation helpful? Give feedback.
-
Hi @mancellin, Thanks for your reply! I'm creating the array by making a cylinder and then adding a cylinder to that cylinder in a for loop, so each time I am adding a cylinder to the pre-existing array with the += operator. The documentation says to use the join_bodies command if one is adding more than two bodies together, but I can't figure that out right now, as each cylinder would need its own variable name. So even before I get to running the simulation, I'm adding cylinders one by one to an array, and this is taking a long time. Hope this illustrates my problem. Just fyi, I am simultaneously investigating ways to generate the array as a single mesh by drawing an svg file and extruding it, which may be easier in the long run, but I am trying to get to the point where I can just batch run simulations and get some initial results. The simulations do of course take much longer than generating the mesh does -- it's just that an obvious place to optimise is to avoid re-generating the same mesh for every run. Thanks! Joe |
Beta Was this translation helpful? Give feedback.
I see.
The canonical way to save a mesh is to use the standard file formats for meshes as found in the
capytaine.io.mesh_writers
. See the example in the code below.However you will lose the information about the degrees of freedom. I tried pickles in the example code below. It seems to work, but does not seem faster than recreating the body from scratch.