Questions on dynamicTopoFvMesh
Hi,
I'm trying to understand how to use dynamicTopoFvMesh library to simulate a free moving (6DoF) object into a fluid. I'm following the circCylinder3d tutorial just to understand how to setup my case that will use pimpleDyMFoam and I've got lots of questions... just a couple to start: 1. What is tetFemSolution ? 2. In dynamicMeshDict there are position constrains: Code:
//- Constrain surface mesh-motion on a specified cylinder Code:
boundaryField // angularOscillatingDisplacement // angularOscillatingVelocity // oscillatingDisplacement // oscillatingVelocity // surfaceDisplacement // surfaceSlipDisplacement Is there something similar to the following type ? Code:
oggetto Thanks. |
1 Attachment(s)
Daniele,
Sorry if the whole thing was confusing to you. I'll briefly explain: 1. The tetFemSolution file is for the tetDecompositionMotionSolvers in OpenFOAM-1.6-ext. If you don't use that library, then this file has no effect, since the mesquiteMotionSolver does not use it any way. 2. The motionU file is a way for motionSolvers to input boundary conditions, and again, is not used by the mesquiteMotionSolver, and is input using dynamicMeshDict instead. However, it appears that the fixedValuePatches approach is too simplistic, and using more complicated patch fields like sixDoFRigidBodyDisplacement may not work this way (this particular patch writes the initial position to disk, which is required for solution restarts). I've attached a diff patch which I've tested only briefly with the Port-2.1.x branch of the github repository - for some reason, it doesn't work with OF-1.6-ext. This patch basically points the mesquiteMotionSolver to use the pointDisplacement field (which the fvMotionSolver uses) to calculate 6-DoF properties. 3. Remember to add a libs entry in your controlDict that loads libforces.so (located at $FOAM_SRC/postProcessing/functionObjects/forces, if you're curious), so that the 6DoF stuff is picked up, and those patches become available for run time selection. Hope this helps. |
Hi Sandeep,
many thanks for the clarifications ! I'll try the patch and let you know. |
It give me a strange error:
Code:
/*---------------------------------------------------------------------------*\ Here you can find the case: https://www.box.com/s/9pg0lcuhu20th8cnccfh Thanks for any help. |
1 Attachment(s)
Anyway you could give me a more meaningful stack trace? I you compile with debug symbols, that would be helpful.
I think I might have seen this error before. Perhaps the attached diff would help. Not sure if this is the same problem though. |
Greetings to all!
@Sandeep: Your latest patch "topoMapperTemplates.patch" fixed the problem! Sorry about the nearly meaningless stack trace. I'm the guy responsible for this OpenFOAM port named blueCFD, and this particular version Daniele is using is still a preview version, for which the stack trace is still very flaky. Although it's not necessary but as future reference, on Linux (Ubuntu 12.04 x86_64), the respective stack trace was this (although not using debug symbols): Code:
#0 Foam::error::printStack(Foam::Ostream&) in "/home/user/OpenFOAM/OpenFOAM-2.1.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" Bruno |
1 Attachment(s)
Thanks to both Bruno and Sandeep!
But I still have problems: I cleared all the position BC from dynamicMeshDict and I used the following pointDisplacement dict: Code:
Code:
If I then modified dynamicMeshDict adding the same position BC: Code:
fixedValuePatches Code:
Last question / problem: I made the tests with: edgeRefinement off; I think I don't need it so far. However when I enable the refinement it returns an error (see enclosed file). Any idea or comment ? |
A small update:
@Sandeep: in the first patch you sent me there was an additional flag called "usePointDisplacement". Code:
if (optionsDict.found("usePointDisplacement")) I tried but it returns more or less the same error: Code:
/*---------------------------------------------------------------------------*\ |
Hi!
First note: I don't know how to help Daniele any further on how to set-up this case for having the loose object float away with the flow. I'm only able so far to diagnose why things were crashing. Second note: Just to inform readers that I've already sent an email to Daniele informing about the problems that were happening with this case in particular, at least about the error itself. In summary:
Bruno |
3 Attachment(s)
Hi,
first I want to thank Bruno for the support. Then, just to complete the thread, I enclose some pictures of the mesh. It's a simple two diameter pipe, with a sphere inside of the bigger diameter part. In order to mesh it using just tet elements I used Netgen. Everything was fine for checkmesh (skew and not-orto) but I hadn't check the small-determinant cells. I don't know why normally these faulty cells are not so important...or maybe they are and they are the hidden cause of lots of crashes... or maybe it's just me that I'm stick to Windows. However the main problem is that I don't know how to refine the mesh in order to avoid them. You can see their position in the last picture (white coloured). I neither don't know what caused them. The geometry is quite simple and I cannot understand how Netgen can create such cells in those (simple) position. I googled a little but there's not so many information avaible on the topic. BTW I tried: Netgen itself: mesh resolution seems to have no correlation with the number of null-determinant cells. GMsh, Engrid: Windows version are too instables. MeshLab: Still studying it. Help needed Salome: I wanted to locally refine the edges but it crash immediately. Anyway I'll leave this thread,for now, and I'll create another in the right meshing forum to try to solve this problem. I'll come back asap. But if you have any idea post it wherever you want !! :) |
Daniele,
If I vaguely recall, I remember having trouble with objects falling under gravity using pimpleDyMFoam as well, and that using interDyMFoam (with a bogus alpha field of all fluid) seemed to fix the problem. Again, this is a little weird since gravity is supposed to be picked up from the boundary condition in pimpleDyMFoam, and there's some funky settings where a registered gravity field is sometimes used instead. You may want to also check if pressure is being dealt with in a consistent manner for both situations. Your 'cells with small determinants' seems okay to me from a visual observation, and if checkMesh gives you a decent non-orthogonality, you should be good on that front. I've run meshes with far worse and still succeeded. |
Thanks for your support Sandeep.
I will definitely try interDyMFoam but so far the main problem seems caused by the 0-det cells. Bruno made a deep analysis of the issue that, I want to confirm, happens just on this Windows porting. In few words, it brings to an out-of-range array access. Linux manages better than Windows this kind of problems. I'm still looking for a way to get rid of this cells but, as you said, normally OF can manage worse meshes without problems: I don't know if I'm going to find the right tool. Thanks. |
Greetings to all!
I've finally managed to figure out what's wrong! And I don't have enough experience to fix this :(. It's not a problem with cell determinant being null or very small... It's the first patch on this thread that's broken! The problem is this part of the patch: Code:
@@ -3583,6 +3604,14 @@ void mesquiteMotionSolver::applyFixedValuePatches() Code:
#0 Foam::error::printStack(Foam::Ostream&) in "/home/user/OpenFOAM/OpenFOAM-2.1.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" Simply run: Code:
pimpleDyMFoam Best regards, Bruno |
Bruno,
Is this after a topology change? If so, could you check if the patch field is being mapped after topo-changes? If not, perhaps the pointMesh mapper is being incorrectly called (or maybe not at all). Thanks |
Hi Sandeep,
I think there are topology changes and some mapping seems to occur... but not for the second iteration, if I understand it correctly. I've used the following debug flags to turn on some more reports on what OpenFOAM does (placed inside the file "~/.OpenFOAM/2.1.x/controlDict"): Code:
DebugSwitches Code:
Create time Bruno |
1 Attachment(s)
Greetings to all!
@Sandeep: any chance you can (help us) figure out what's missing here? Because after roughly 5h of studying dynamic meshing, studying the "mesquiteMotionSolver" and doing several trial-and-errors... I haven't managed to fix this problem. Attached is a patch with the code where I stopped trying to fix this. In essence, my findings are as follows:
Bruno |
I think I might know why things are not being mapped. The boundaryConditions_ member is instantiated using a pointMesh::New function, which may not be registering itself correctly for all subsequent pointField mapping.
I say this because the only field that is currently being mapped (from your logs) is the volTensorField grad(U). It would be helpful to ensure that the pointMesh exists during the mapping process (in MapGeometricFields.H), so that all pointFields associated with it are mapped accordingly as well. Another possibility is to have the boundaryConditions_ pointVectorField mapped during the mesquiteMotionSolver::update(const mapPolyMesh& mpm) call. I think a pointMapper will need to be instantiated for this, but I can't remember off the top of my head - perhaps you could take a cue from other parts of OpenFOAM, like the fvMotionSolver::updateMesh() functions. |
Hi Sandeep,
Many thanks! I'll look into this further. Best regards, Bruno |
1 Attachment(s)
Hi Sandeep,
Unfortunately, I'm unable to figure out how to do the point mapping. All of my tests seem to indicate that "boundaryConditions_()" no longer has enough information when it is working inside "void mesquiteMotionSolver::update(const mapPolyMesh& mpm)". Attached is a hack that seems to work, although it has to resort to the file system for storing the "pointDisplacement" field. It's applied on top of your two patches, if I'm not mistaken. It's a (very) sub-optimal solution, but it gets the job done... or at least I hope so. edit: after several iterations, it looks like the sphere is starting to get deformed... I can only guess that it's because there are points that are being erased/added, which are not mapped out with this hack... :( Best regards, Bruno |
Bruno,
I'm willing to bet that the points on the sphere correspond to un-mapped points. Can you add a noModificationPatches / noSwapPatches entry in dynamicMeshDict with your "sphere" patch, and see if the deformations still happen? If you look at the Foam:: polyMesh::updateMesh(const mapPolyMesh& mpm) function in polyMeshUpdate.C, you'll see this bit: Code:
if (thisDb().foundObject<pointMesh>(pointMesh::typeName)) |
Hi Sandeep,
Many thanks for the feedback! I should have posted the several tests I've made so far, because I did try several different ways of mapping the "pointDisplacement" field and respective mesh. That one in particular I think didn't work, although it's possible that I didn't manage to define the proper usage of each object and respective methods. Later today I'll post the attempts I've made at mapping the field. In the mean time, the problem is also hat I did further (re)searching on this topic, which lead me to thinking that I would need several more complex hacks that I found in OpenFOAM's source code, specifically the ones in:
Best regards, Bruno |
2 Attachment(s)
Hi Sandeep,
OK, I've got mixed results... First for the partially-good news: While using the hack to use the file system and by adding the sphere (named "oggetto") to the "noModificationPatches" and "noSwapPatches", it does allow to keep the sphere's surface in perfect condition while it moves.The bad news: I still haven't been able to make the proper update to work. I've tried to use the following code, but without success (this is the patch for the code):Other attempts I did in the past were, both in "mesquiteMotionSolver::update(...)":
Best regards, Bruno |
Bruno,
You could have the smoother work a little harder at each time step, and see if the simulation goes further. Specify a higher cpuTime value for tcInner and see if that helps. Also, you have edgeRefinement set to 'no', which means that cells cannot be collapsed, and that probably explains why you see negative volumes. You can play around with the growth factor to coarsen the mesh away from the 'oggetto' patch (not too agressive, otherwise you'll get too many collapses, which you can restrict using the maxModifications entry). I'll look into the mapping when I have some time on my hands. Sandeep |
Hi Sandeep,
Many thanks for the hints! Unfortunately, by removing the cells that were in the way, the saved "pointDisplacement" of the internal field has a different number of cells, which leads the solver stopping to complain about the different array sizes. Nonetheless, this does give me (again) the idea for adopting a hack similar to the strategy used for "fixedValuePatches"... Best regards, Bruno |
Bruno,
Can you give me a test case that I can use? Also, you'll have to list out the details of how to reproduce the problem. Sandeep |
Hi Sandeep,
Many thanks! Although I'll only be able to provide a clean/smaller case and more explicit instructions in about 5 hours from now :( In the mean time, the case is the one mentioned in post #13, namely: https://www.dropbox.com/s/bs3ehwn6xq...topo_v2.tar.gz Unpack and simply run pimpleDyMFoam. It should crash as soon as "boundaryConditions_().correctBoundaryConditions() " is called the second time around, if I'm not mistaken. moveDynamicMesh is not enough, due to the need for forces to work, which depend on "U" and "p"... This is assuming that the whole "dynamicTopoFvMesh" code only has the first two source code patches you provided on this thread, for using with OpenFOAM 2.1.x. Unless you prefer the hack I tried to use, relying on the file system, for which the "pointDisplacement" file was placed in the "constant" folder; the source code patch is on post #19. Best regards, Bruno |
Bruno,
I've committed a fix and your case seems to be running with point fields mapped. I haven't tried extensively with edgeRefinement on, so you might want to test it out. Unfortunately, since your length scales vary quite drastically across the 'wall' patch, the algorithm has a hard time trying to figure out what the optimal length scale is, and so you tend to get excessive bisections / collapses. You have a length scale for 'oggetto' specified as 0.2, while the paraview ruler tells me it's 0.002 - so you may want to check that. Until I have a more general solution, one workaround is to limit the number at each time-step using the maxModifications entry, or perhaps you could split up the patch into several smaller ones with a uniform length scale for each. Thanks for the bug-report. |
Hi Sandeep,
You're very welcome about the bug report! And many thanks for the fix and for the suggestions! And no wonder I couldn't figure it out... I was only looking at the source code for "mesquiteMotionSolver" :rolleyes: Best regards, Bruno |
patch motion with dynamicTopoFvMesh
Hi Sandeep,
I wonder if there is a difference between the implementation of patch motion between dynamicTopoFvMesh and dynamicMotionSolverFvMesh?. I am trying to do a simple oscillating body simulation by using both libraries and the output of the patch motion is totally different (about an order of magnitude in amplitude). Using dynamicMotionSolverFvMesh i set the moving patch in pointDisplacement as follows: Code:
wing Using dynamicTopoFvMesh/mesquite I set the moving patch in dynamicMeshDict exactly in the same way, by just adding Code:
wing Any clue?, jg |
I see that both your entries are the same, but how different is "totally different"? What was your output? If you post your entire dynamicMeshDict file, that would be helpful.
|
patch motion with dynamicTopoFvMesh
Hi,
Ok, this is the entry where i set the patch motion Code:
solver mesquiteMotionSolver; Even if I set the entry usePointDisplacement yes, and use the pointDisplacement dictionary (same one as the one used with dynamicMotionSolverFvMesh), the patch motion of both libraries are different. |
And what's the output?
|
The simulation runs fine (I am using moveDynamicMesh), the smoothing works fine, the remeshing works fine. But, nevertheless the fact that I am using the same patch motion for both dynamic meshing classes (libdynamicTopoFvMesh and dynamicMotionSolverFvMesh), I think the motion I am getting with libdynamicTopoFvMesh is not the right one, the amplitude is like one order of magnitude higher compare to the output of dynamicMotionSolverFvMesh.
|
Ah... I know what the problem is:
It appears that the oscillatingDisplacement patchField provides an absolute value of displacement (from the mean), while the applyFixedValuePatches() function in mesquiteMotionSolver expects an incremental displacement vector for each time-step. You see the acceleration because the displacement is continuously updated as: refPoints_ += dPointField; in mesquiteMotionSolver.C You could write a new boundary condition similar to oscillatingDisplacement which provides displacement increments, or alternatively, I also provide a timeVaryingDisplacement patchField in the repository that uses an interpolation table from file, which might be easier. I would have to look into a fix for the absolute vs. incremental confusion. Can you try changing the "+=" operator in applyFixedValuePatches to simply "=" and see if that makes a difference? |
It crash immediately.
Let's see if I can write the bc, in anycase I am not in a hurry, so probably you will come with a solution first. Does this affect the behavior of the 6DOF solver? it is safe to use? Have a nice day, joel |
Can you post a test case with dynamicMeshDict entries for both solver types?
|
1 Attachment(s)
Hi Sandeep,
You can use the ballTranslation tutorial from the last openfoam workshop. Use the attached files to run the case using dynamicMotionSolverFvMesh. I tested everything and runs fine. Running this two cases you clearly see the difference in the patch motion between the two solvers. Have a nice day, joel |
joel,
Can you try the angularOscillating variant with zero angular velocity and see if there's a difference between both solvers? Thanks |
Hi Sandeep,
Same problem with angularOscillatingDisplacement. Joel |
Hi Sandeep,
Any update regarding this issue? |
All times are GMT -4. The time now is 11:07. |