CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   External management of solid motion (using dynamicmesh) (https://www.cfd-online.com/Forums/main/157403-external-management-solid-motion-using-dynamicmesh.html)

 maxou1993 July 28, 2015 12:37

External management of solid motion (using dynamicmesh)

Hi,
Firstly I would like to apologize for the length of the following post (I tried to do it as short as possible) and the number of questions (I couldn't create one thread for each question, because they are linked by the particular context of my study... and being able to handle OpenFOAM in every particular cases require advanced OpenFOAM skills!)
I would like to model the motion of a sphere in a tube (submitted to a longitudinal gradient pressure) surrounded by fluid (no turbulence) with OpenFOAM 2.3. I have two options for that (the first is simpler but certainly less effective):
1) Use snappyhexmesh at a date t. Then solve the fluid motion with simplefoam (using 1 timestep) around the sphere after having specified its position. Then use a simple Matlab (I'm subject to this constraint) script (by using drag forces and lift forces calculated by OpenFOAM) to deduce the new velocity of the sphere (using simple Newton's 2nd law of motion). Then i update time. Then, I use snappyhexmesh again after having updated the sphere position (using the previous deduced velocity). After, i solve the fluid motion again at t+dt etc...
I have to automate (create the previous loop) the simulation using Matlab (I'm also subject to this constraint).
2) Use dynamicmeshdict : its main advantage is to adapt to the sphere motion and so improve the fluid simulation. But it is more complicated to use it with regards to how it was implemented... My idea is, like for the first case, change my initial condition (update the velocity of the sphere here, still using a Matlab external script) and "simulate"(just calculating new pressure and velocity fields at t+dt) the fluid motion for only 1 timestep . Then i update the inital condition (=displacement of the sphere and inform dynamicmesh the new sphere velocity)...etc But, how could i specify my solid motion (using my updated timestep velocity) during my timestep . I tried to understand the wing motion tutorial (that runs on my computer) but when pimpledymfoam is running, I saw in the pointdisplacement files generated, that the wing displacement is of type "calculated". But how is this displacement "calculated" (what is the location of the file where is written the numerical value of this displacement in Openfoam ? Can I find it ?) in the wingmotion case (which uses 6DOF motion solver) ? Why is "internalfield" of "pointDisplacement" (in the wingmotion case) not equal to 0 at each timestep? More generally could you give me, exemple of motion solvers and for which physical situation they are used for? Are they all implemented in the same way in OpenFOAM (is there a common pattern) ?
I found on the internet a lot of documents dealing with dynamicmesh handling (which manages the "mesh motion solving" once the boundary (in my case, the sphere patch) motion has been updated), but is there good documentation about the previous essential stage that consists in managing the boundary (solid) motion ? Is it possible with dynamicmesh, not to have to use a boundary (solid) motion solver (like 6DOF) but just specify at each timestep a calculated (externally with Matlab) boundary velocity (i don't want to use bodysolidmotion because I don't know "in advance" my body motion that can neither be analytical nor included in an array external file) ? Finally, last but not least, between each timestep, the former velocity and pressure fields have to match the new updated mesh, so as to OpenFOAM to be able to calculate the new pressure and velocity fields on the new nodes... but how could I do that with OpenFOAM (is it the role of mapfields ?). For instance, how do "wingmotion case" fix this problem once dynamicmesh programms have updated the mesh ?

Indeed, to sum up, what i want to do is to be able to do the same as the internal OpenFOAM loop for body motion (use my own external boundary motion solver, but still use dynamicmesh), but in an external way using Matlab (it's the constraint I'm subject to). And I would like to know if it is possible to understand how motion solver (one adapted to my case... so I try to find which one, and how to use it) works, without any C++ knowledge (I only have a C background). Finally, I would like to know if it is it is easily feasible (or at the contrary, if it is totally out of reach without advanced level in OpenFOAM) to code my own boundary motion solver (without using Matlab but still using dynamicmesh for mesh motion) by readapting boundary motion solvers like 6DOF.