CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Combining mesh motion and refinement

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By wyldckat
  • 2 Post By mturcios777
  • 1 Post By wyldckat
  • 2 Post By mturcios777

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2014, 15:04
Default Combining mesh motion and refinement
  #1
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Hello everyone,

I am currently working on on a mesh class the combines dynamicRefineFvMesh and dynamicMotionSolverFvMesh. A bit of history to bring you up to speed.

Back in 2.1.x, it was easy enough; I copied the motion calls and velocity boundary correction from dynamicMotionSolverFvMesh and put them in the update() function which also has the refinement from dynamicRefineFVMesh. This worked masterfully on a case based on aachenBomb with a moving boundary and refinement on the C7H16 field.

In 2.2.x, I tried using this mesh for a case with some non-hexahedral cells, and the refinement failed on these cells. They weren't being added to the protectedCells list as they should have. This was fixed with the following commit:
https://github.com/OpenFOAM/OpenFOAM...f842e027a0694e

I've been trying in both 2.2.x and 2.3.x to get them combining, but can't seem to get meshPhi to be properly updated at refinement. This causes a problem as meshPhi is required for updating the velocity boundary conditions after mesh motion.

I posted a bug report here: http://www.openfoam.org/mantisbt/view.php?id=1195, which solved another issue but hasn't quite allowed me to do what I want. Does anyone know how I can get these two mechanisms to "play nice"?

Many thanks to you all!
mturcios777 is offline   Reply With Quote

Old   May 26, 2014, 18:27
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Marco,

Although you did give a good summary of the changes you've made and tried, it feels a bit like flying blind here, as there is no clear indication of where you tried to change what exactly.

I did however find this piece of lost code in OpenFOAM 2.3.x, in the file "src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C", a bit lost in the methods "refine":
Quote:
Code:
    // Move mesh
    /*
    pointField newPoints;
    if (map().hasMotionPoints())
    {
        newPoints = map().preMotionPoints();
    }
    else
    {
        newPoints = points();
    }
    movePoints(newPoints);
    */
It does give the idea that this is the right place to use something like:
Code:
newPoints = motionPtr_->newPoints()
Although it feels that the right thing to do would be to somehow load up the point motion to be done onto the "meshMod" variable, as it seemed to be hinted in the comments above it:
Code:
    // Change mesh and generate map.
    //autoPtr<mapPolyMesh> map = meshMod.changeMesh(*this, true);
Although the "true" argument is only for setting "syncParallel" to true.

You could try:
Code:
meshMod.movePoints(newPoints);
but it clearly states in its comments that:
Quote:
Move all points. Incompatible with other topology changes.
which might not allow the other topology changes to occur...

Either way, from the small experience I have with mesh manipulation (mostly from creating a variant of stitchMesh, named stitchMeshMultiPatch), it seems to be better to perform all mesh manipulations by a single operator (in my case, using a single instance of "polyTopoChanger"), rather then using 2 consecutive operators.

Best regards,
Bruno
hua1015 likes this.
__________________
wyldckat is offline   Reply With Quote

Old   May 26, 2014, 18:55
Default
  #3
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Thanks for the reply Bruno. What I had done back in 2.1.x was add the call for
Code:
dynamicFvMesh::movePoints(motionPtr->newPoints())
before the refine/unrefine calls. What is interesting is that the motion and refinement work fine, its the subsequent call to meshPhi (either in correctBoundaryConditions or correctPhi) that fails.

I've put up a new bug report, which may or may not help better understand:
http://www.openfoam.org/mantisbt/view.php?id=1305

If I turn off correctPhi in system/fvSolution and use fixedValue boundary condition on the moving wall the case runs, though the velocity near the wall is wrong unless I explicitly setting it as the value. This works for the very simple case I made for the bug report, but may not be for engine cases or similar.

At any rate, its only the call to meshPhi that crashes things, which makes it feel like it dissapears during the refinement. I will try moving the mesh movement to where you mentioned and see what happens. Expect a report!

EDIT: Tried moving the mesh motion to commented out code and the same result was obtained.
wyldckat and hua1015 like this.
mturcios777 is offline   Reply With Quote

Old   May 27, 2014, 18:31
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by mturcios777 View Post
EDIT: Tried moving the mesh motion to commented out code and the same result was obtained.
At the risk of sending you on a very wild goose chase into dynamic meshing, a good/advanced source code for dynamic meshing is "dynamicTopoFvMesh", for which the port for 2.2.x is available here: https://github.com/smenon/dynamicTop...ree/Port-2.2.x
It essentially does point motion, re-meshing and motion optimization with Mesquite... or at least it's my interpretation of it.
It only works with tetrahedral cells, but the way it handles the mesh manipulation is different from how OpenFOAM does it, which is why I do think this might come in handy for you. I say this because re-meshing is conceptually similar to mesh refinement and this library also handles motion driven by outside forces.

My memory is very fuzzy from when I looked into it last year, so I don't remember much about what I learned from that source code. Nonetheless, a few memory breadcrumbs are registered on this thread: http://www.cfd-online.com/Forums/ope...opofvmesh.html - On that thread, the initial case discussed (which had some issues running) was a ball floating inside a tube.
hua1015 likes this.
wyldckat is offline   Reply With Quote

Old   June 6, 2014, 16:37
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Marco,

I remembered to come back to this issue to leave a comment for other forum readers.
The fix was eerily simple and it didn't needed any change in "dynamicRefineFvMesh":
Quote:
https://github.com/OpenFOAM/OpenFOAM...641733c8cc7e2a

Code:
@@ -107,7 +107,7 @@ void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs()
 
     const fvMesh& mesh = dimensionedInternalField().mesh();
 
-    if (mesh.changing())
+    if (mesh.moving())
     {

         const fvPatch& p = patch();

         const polyPatch& pp = p.patch();
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   June 6, 2014, 17:10
Default
  #6
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Thanks Bruno, I was relieved to see the fix go though and pulled that commit faster than you can say Courant Number.
wyldckat and anothr_acc like this.
mturcios777 is offline   Reply With Quote

Old   April 19, 2018, 04:29
Default
  #7
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Hi Marco,

do you succeeded in generating a new class which combines dynamicRefineFvMesh and dynamicMotionSolverFvMesh?

I'm eager to hear your update.

Best wishes
Q.E.D.
Q.E.D. is offline   Reply With Quote

Old   April 20, 2018, 14:56
Default
  #8
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
I was able to get it to work. The fix above was the answer, and I think I also had to do the move after the refinement.
mturcios777 is offline   Reply With Quote

Old   April 20, 2018, 15:12
Default
  #9
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Great news! I wonder whether you would mind to share your library? I'm currently working on a case where it might prove very useful!

Anyway, I think the community would be glad to see this library in the next release!

Best Wishes
QED
Q.E.D. is offline   Reply With Quote

Old   April 20, 2018, 15:19
Default
  #10
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Unfortunately I can't as it was developed for work with some other functionality. But the basics are reasonably straightforward. Just clone dynamicFvRefinementMesh into a new mesh class and add the motion solver creation in the constructor and the mesh motion calls from dynamicFvMotionSolverMesh in the update() member function.

You will also need to include all the necessary libraries and source files for it to compile. Depending on which version of OF you have and how your pEqn.H file looks, moving the mesh may need to happen before or after refinement. Only testing will tell you for sure.

Good luck!
mturcios777 is offline   Reply With Quote

Old   April 20, 2018, 16:47
Default
  #11
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Ah, I suspected something Like this. Thank you nonetheless Marco for your valueable tips! I will try to implement it myself! I just thought that maybe I don't have to reinvent the wheel. (As we say here in Germany) :-)

Have a nice weekend!
Q.E.D. is offline   Reply With Quote

Old   April 25, 2018, 09:45
Default
  #12
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Hi Marco,

I did as you suggested and the new class compiles well. But I encounter an error which says:

Quote:
Cannot move points: size of given point list smaller than the number of active points.
It happens in the second iteration, because I put the motion part before the refinement. The first iteration is ok, because it moves and then refines correctly. But then the mentioned error comes up. I guess I have to update the internal mesh numbering somehow. I tried to do this, but failed.

Do you have another tip for me?

Best wishes
Q.E.D.
Q.E.D. is offline   Reply With Quote

Old   April 29, 2018, 05:58
Default
  #13
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Hey everyone,

just a small update: I managed to solve the problem. But I used a chalmers report as a basis, where a new class is derived from dynamicRefineFvMesh and a solidBodyMotionFunction is added as the motion solver. With some minor changes the class works well in OpenFOAM-5.x. The change in the movingWallVelocity BC is not necessary anymore.

In the attachment you will find the library and a test case. The test case is Tobis interfaceAndColumnRefine (www.holzmann-cfd.de) which I modified slightly. Thats because I tried to replace the standard dynamicRefineFvMesh by Tobis dynamicInterfaceRefineFvMesh (Since I was interested in the motion and refinement of an InterDyMFoam-Case), but some error occured which I could not resolve due to my lack of C++ skills.

Best wishes,
Q.E.D.
Attached Files
File Type: zip dynamicMotionRefinement.zip (76.7 KB, 31 views)
Q.E.D. is offline   Reply With Quote

Old   April 29, 2018, 17:31
Default
  #14
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
With some small adjustments in Make/options you are able to include Tobis interface refinement library with the motion solver. Have a look at the attached files.
Attached Files
File Type: zip dynamicMotionInterfaceRefinement.zip (28.0 KB, 47 views)
Q.E.D. is offline   Reply With Quote

Old   May 4, 2018, 06:22
Default
  #15
New Member
 
Join Date: Dec 2015
Posts: 16
Rep Power: 11
Q.E.D. is on a distinguished road
Ok, something is still wrong with this library. I was able to stabilize the computation only by setting the frequency of the movement to zero. (Which is equal to no movement obviously)

Now I have no clue at all....
Q.E.D. is offline   Reply With Quote

Old   September 16, 2022, 02:04
Default
  #16
New Member
 
ABG
Join Date: Sep 2021
Posts: 1
Rep Power: 0
agade is on a distinguished road
Hello I have created a video about the procedure of merging two libraries dynamicMotionFvMesh and dynamicRefineFvMesh. Hope it helps all existing and future users.

https://youtu.be/Yq-ySlXE5JQ
agade is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] snappyHexMesh Boundary Layer at Corner panpanzhong OpenFOAM Meshing & Mesh Conversion 5 July 3, 2018 06:53
Automatic Mesh Refinement in OpnFOAM-1.6-ext Daniel_Khazaei OpenFOAM Running, Solving & CFD 0 October 4, 2013 18:48
Mesh Motion and Refinement in 2.1.x mturcios777 OpenFOAM Programming & Development 16 July 3, 2013 00:03
map point Fields in dynamicRefineFvMesh lukasfischer OpenFOAM Running, Solving & CFD 9 October 26, 2012 11:06
Mesh Motion + Refinement Oli OpenFOAM Running, Solving & CFD 0 July 12, 2010 21:35


All times are GMT -4. The time now is 12:00.