CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   Surface aligned mesh (

rpasiok November 27, 2006 09:02

Hello FOAMers, inspired by
Hello FOAMers,

inspired by hftga2foam I thought about an utility for stretching a mesh or align it with a surface.
I use OpenFOAM to simulate flows around various hydraulic structures with scoured irregular bed and the bottom mesh always cause my headakes.

I tried to code such an utility and here is what it does:
  • reads an initial mesh
  • reads 2 surface files, i.e new bottom and top of the mesh (supported extensions are '.ftr', '.stl', '.stlb', '.gts', '.obj', '.ac', '.off' and '.tri');
  • moves mesh points in the Z direction so that the bottom and top faces are aligned with the surfaces - internal mesh points keep their relative distance between bottom and top faces during the transformation;
  • writes the new mesh to the next time step directory.
Sources and examples of the utility can be found on the wiki page:

Shortcomings of the code:
  • both surfaces must cover original mesh in the XY-plane - it crashes if there's no surface point to read for any of mesh point t move
  • curently it moves the mesh only in the Z direction
I'm still looking for reasonable free (GPL-ed) surface generator. Usually I start with a grid of points or isolines and there's need for a non-linear interpolation / smoothing.
If you use or know about such tool, please, let me know.


Radoslaw Pasiok

hjasak November 27, 2006 11:22

Why don't you just use the aut
Why don't you just use the automatic mesh motion solver - that will allow you to move all boundaries in any way you like and allow you to control the mesh grading etc.


rpasiok November 28, 2006 05:55

Thank you Hrvoje for suggestio
Thank you Hrvoje for suggestion!
I would love to use the solver and I will in the future. Meanwhile I didn't want to jump into the dynamic mesh stuff as I regarded it to much complicated for my static problem. Maybe that was wrong impression...

I should know already that in the OpenFOAM I should check twice for ready to use solutions before I try to do something myself :-/

Radoslaw Pasiok

hjasak November 28, 2006 06:33

Have a look at the moveMesh ap
Have a look at the moveMesh application: there is a field called motionU, you specify the motion of the boundary, run moveMesh and... you're done!


rpasiok November 29, 2006 12:01

Thank you Hrvoje once again, I
Thank you Hrvoje once again, I had a look at the moveMesh & friends and it looks really great.

But still the main problem is to specify motionU. Please keep in mind that, in general, my surface is irregular.
What is the most elegant way of finding motionU if a patch is going to change its shape? More precisely, I want all patch points to move in a common direction but various distances.

In the alignMeshSurf the direction is assumed and the hitPoint of triSurfaceSearch is used to find the distance at each mesh point. Here I would need hitPoint only for patch points to know their distance to the surface. Then I would write the distances to motionU in similiar manner as it is done with motionDiff in setMotionMovingCone (newMovingCone case of icoDyMFoam).
Or is there something better? Thank you in advance for any suggestions.

Radoslaw Pasiok

hjasak November 29, 2006 13:58

Have a look at the PrimitivePa
Have a look at the PrimitivePatch class and projectPoints:

//- Project vertices of patch onto another patch
template <class>
List<objecthit> projectPoints
const ToPatch& targetPatch,
const vectorField& projectionDirection,
const intersection::algorithm alg = intersection::FULL_RAY,
const intersection::direction dir = intersection::VECTOR
) const;

objectHit gives you both the distance and location of projected point.



maka January 7, 2008 06:55

related thread
related thread

All times are GMT -4. The time now is 15:08.