Mesh Motion and Refinement in 2.1.x
Hello Forum-lurkers!
I was wondering if anyone had any experience with combining diferent dynamicFvMesh features togther to form new libraries. With the recent fix of the lagrangian cloud mapping, I was looking to find a way to combine mesh motion and refinement. I tried something simple first: 1. Create a new class dynamicMotionSolverRefineFvMesh. I basically took the dynamicMotionSolverFvMesh, copied it over and declared it dynamicRefineFvMesh. 2. Change the dynamicMotionSolverRefineFvMesh to do the following: Code:
00062 bool Foam::dynamicMotionSolverRefineFvMesh::update() Code:
Selected 9 cells for refinement out of 3025. |
Are you sure it compiles, dline 73 has a ; missing, that should give an error? Did you try this with only the call to the update() of dynamicRefineFvMesh and does it work?
|
Thanks for looking Bernhard; the missing semicolon is present in the actual code, I just made an error in transcription. Calling the motionsolver by itself works, calling the refinement causes the program to hang at spray evolution. Perhaps I didn't fully initialize the dynamicRefineFvMesh?
|
I think I'm closer to the solution, just not quite sure how to implement it. Turning on some of the debug features, I see that the code is getting stuck in the tracking rescues. When Andy fixed the lagrangian spray code to include mapping, he needed clear the tets used by the tracking algorithm. Maybe the tets aren't being cleared properly and thus the tracking algorithm is getting stuck.
In other words, the approach I have should work for cases that don't use lagrangian particles. I'm going to give this a quick try without the spray and see what happens and report back. EDIT: So I tried the same library in a case without lagrangian spray (but still with motion and refinement) and was able to do one iteration with the mesh motion before the refinement. Once the second iteration starts I get the same type of error the case with refinement before motion. Digging deeper I found that the exact line the crash occurs at is Code:
pointMotionU_.boundaryField().updateCoeffs(); |
Hi Marco,
If I understand you correctly, you have a dynamic mesh that is refined and then moved, and/or vice-versa. And from the last comment/result you've got, it looks to me like the "pointMotionU_" field has to be reconstructed/remapped before the coefficients can be updated! Otherwise the field is thinking of a mesh that no longer exists... Unfortunately I'm not very familiar with this part of OpenFOAM (as many other parts), so my question back to you is this: how are all other fields being properly kept between each stage (move/refine)? Another detail to keep in mind is this (probably you already know this): refining a mesh in the wrong place may lead to an unmovable mesh ;) I hope your test case has enough space for both refining and moving! As a last note, I took a quick look at how interDyMFoam refined the "damBreakWithObstacle" case and it looked like the mesh was gradually refined and then unrefined as needed... which could provide with some additional ideas for your implementation ;) Best regards, Bruno |
Hey Bruno,
From what I can tell, mapPolyMesh generates the mapping that is used in a host of other calls to map the fields. The mapping itself is done in $FOAM_SRC/OpenFOAM/fields/DimensionedFields/DimensionedField/MapDimensionedFields.H by the function MapDimensionedFields. The pointScalarField pointMotionU_ is not being mapped, even though the volScalarFields are all mapped as well as some surfaceScalarFields. I don't know if pointMotionU_ is not being added to the object registry, or if it is impossible to map a pointScalarField like this. There shouldn't be any issues for this mesh, its a simple box with a single moving boundary (huge abstraction to what I will eventually need) with a very large cell size to start (this dies on the first timestep when the mesh boundaries have barely moved). I'll upload the test case and some libraries that allow you to edit some of the functionality without "contaminating" the base install. I'm quickly finding out that dynamic meshes are a whole new level of voodoo in OF... |
Quote:
Code:
void Foam::fvMesh::mapFields(const mapPolyMesh& meshMap) I'm not sure how to implement this. What would be the proper template parameters to handle pointScalarFields? I'm thinking something like Code:
MapDimensionedFields<scalar, fvMeshMapper, X>(mapper) |
Hi Marco,
"pointMesh" seems to be the answer... better yet, it already has a dedicated class and methods for this: http://foam.sourceforge.net/docs/cpp/a06760_source.html -> "src/OpenFOAM/meshes/pointMesh/pointMesh.C" Quote:
Among the methods listed in that file, you'll also find "movePoints" and "updateMesh". It almost seems like "pointMotionU_" should be able to update itself, if you can use it properly... |
Thanks Bruno! That function does look promising, so long as I can figure out how to access it through the dynamicFvMesh (as I only want to do this when there is a topology change).
If I continue to get stumped I'll upload what I have so the group mind can have a look. EDIT: Some progress. Since I need access to the mapPolyMesh objects generated at refinement, I copied over the dynamicFvRefineMesh classs and added a motionSolver to it in a similar manner to dynamicFvMotionSolver. In the refine() and unrefine() member function, I added the following code right after the meshCutter and polyTopoChange have refined/unrefined the mesh: Code:
pointMesh motionUpdate(*this); Code:
00118 if (&field.mesh() == &mapper.mesh()) |
Hi Marco,
Since you didn't share the code and test case, I can't tinker with this myself :rolleyes: My guesses are:
Bruno |
2 Attachment(s)
Well, I was only going to upload when I was stumped or if I had a working version for the benefit of others. Unfortunately its the first one, so here you go (there isn't really much there except the addition of a mesh motion solver to the dynamicRefineFv class)
I currently have motion before refinement as that helped my determine what the issue was, but they could just as easily be switched so long as the pointMotionU field is mapped properly. I'm curious about the destroy/create option you mentioned, as doing that is something I've pondered for some time. Would that work with a change of topology? Isn't that pretty much the same thing as mapping? EDIT: While doing a search of the forums, I noticed this thread: http://www.cfd-online.com/Forums/ope...time-step.html Would this be an option? Doing topology changes I would need to supply the old and new meshes, and I'm not sure how to do that... |
Quote:
OK, I'm going to try and play with this neat example :) Let's see how much of OpenFOAM/C++ voodoo I can conjure up :D |
Quote:
|
1 Attachment(s)
:eek: This is somewhat heavy... OK, the case you've provided requires a couple more libraries, but that's just adding too much entropy to the mix.
I've started creating a case based on the tutorial "mesh/moveDynamicMesh/simpleHarmonicMotion", but I stopped when I noticed that a field is needed on which it bases for refinement. Attached is where I stopped. This is still going to require a call to setFields and a way to forcefully load the "T" field into memory :rolleyes: That and probably it also needs flux correction, even if the field is basically static. Nonetheless, this case seems the simplest for isolating how each component works in action. |
Hi Marco,
Unfortunately I'm unable to do everything I want to do... and although this is an interesting subject I would like to get to understand better, I'm completely out of time to look into this and it's probably over my head experience-wise :( I noticed you kept going forward, specially with this bug report: http://www.openfoam.org/mantisbt/view.php?id=638 Good luck! Bruno |
Hey everyone!
Just to update the thread; turns out the pointer to the pointMesh was getting deleted before the mapping, and was thus not registered to be mapped in the polyMesh::updateMesh function. The latest version from git should be working now. I have yet to test this with lagrangian sprays. Stay tuned... EDIT: So it appears to work with lagrangian clouds. I'm going to play with this shiny new toy. Just so people don't get frustrated if their attempts don't work right off the bat, I had to modify the thermodynamics and turbulence libraries to have them work with dynamic meshes. |
mesh movement + refinement
Dear All
Seems that no one has posted here for a long time. I am facing a problem for while which I think combining mesh motion and mesh refinement can solve but I am not sure if anyone has found a solution for it yet. I want to simulate to rectangular boxes floating close to each other with small gap in between while the water level is really important for me I need to keep track of bodies motion based on waves hitting them. The problem occurs when I want both at the same time! as I need a really fine mesh in the area between two bodies but this leads to mesh distortion due to high movement levels in just few time steps. I have tried to restrain my bodies movement by designing some springs in between but apparently I should define such high stiffness that makes no sense. I was wondering if anyone can help how I can solve this problem. Can I combine movement of mesh with refinement in this case considering the fact that I have very little knowledge on code writing! |
All times are GMT -4. The time now is 03:59. |