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

[snappyHexMesh] Fixing boundary coordinates snappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 22, 2019, 07:16
Default Fixing boundary coordinates snappyHexMesh
  #1
New Member
 
Tim
Join Date: Jul 2019
Posts: 7
Rep Power: 7
botman is on a distinguished road
Hi

I am attempting a meshing strategy that involves
  1. directional refinement of the blockMesh using topoSet and refineMesh, where the refined mesh does not satisfy the requirements for snappyHexMesh
  2. separation of the refined blockMesh into an "inner" and "outer" region, where the inner region satisfies the requirements for snappyHexMesh (quads).
  3. snappyHexMesh of the inner region around an STL geometry which resides at the center of the inner mesh
  4. recombination of the inner and outer mesh using stitchMesh (perfect).

Defining the interface patches that were created in step 2 as outerMesh_innerBoundary and innerMesh_outerBoundary, what appears to happen is that during the snapping phase of step 3, the boundary coordinates of the "innerMesh_outerBoundary" patch seem to move a little, which means I can't get stitchMesh "perfect" to work when I try to recombine the patch with the "outerMesh_innerBoundary" patch in step 4. I was hoping someone might know if there was a quick trick to fix/constrain the "innerMesh_outerBoundary" coordinates during snapping?

The number of faces on "innerMesh_outerBoundary" patch has not changed during snapping, but it seems that snapping process relaxes the coordinates of the whole mesh. The interface patches are not smooth and have lots of "kinks" (like a castellated mesh); so, I don't think that the other stitchMesh options will work for this mesh (or at least I haven't managed to get them to work with a toleranceDict).

I know I could try the directional refinement now available in snappyHexMesh, but I would rather not go back to the drawing board if there was quick fix to constrain the coordinates.

Thanks in advance for any assistance.

Last edited by botman; July 24, 2019 at 11:04.
botman is offline   Reply With Quote

Old   July 23, 2019, 03:26
Default
  #2
New Member
 
Tim
Join Date: Jul 2019
Posts: 7
Rep Power: 7
botman is on a distinguished road
In the off chance this is of use to others, below is the workaround I am adopting using the python package Ofpp. The script just shifts the points of the innerMesh_outerBoundary patch to match those of outerMesh_innerBoundary. I can then use stitchMesh perfect. Note that I have merged the meshes before running the script, and the script only works if the interfacing patches are almost perfect.

Code:
import numpy as np
import Ofpp 

mesh = Ofpp.FoamMesh('.')
bi = mesh.boundary[b'innerMesh_outerBoundary']
bo = mesh.boundary[b'outerMesh_innerBoundary']
fList_i = np.array(range(bi.start, bi.start + bi.num))
fList_o = np.array(range(bo.start, bo.start + bo.num))
mpts_i = np.zeros((len(fList_i), 3))  
mpts_o = np.zeros((len(fList_o), 3))

# Compute the mid-points of the boundary faces
for k in range(len(fList_i)):
        mpts_i[k] = np.average(
            mesh.points[np.ix_(mesh.faces[fList_i[k]])], axis=0)
        mpts_o[k] = np.average(
            mesh.points[np.ix_(mesh.faces[fList_o[k]])], axis=0)

# Set the points on the inner patch to match the outer patch
for i, mi in enumerate(mpts_i):
        j = np.argmin(np.linalg.norm(mpts_o-mi, axis=1))
        point_i = mesh.points[mesh.faces[fList_i[i]]]
        point_o = mesh.points[mesh.faces[fList_o[j]]]
        point_o2i = point_o[[np.argmin(np.linalg.norm(
            point_o-pi, axis=1)) for pi in point_i]]
        mesh.points[mesh.faces[fList_i[i]]] = point_o2i

# ... then you just export the updated points matrix to constant/polyMesh and then "stitchMesh -perfect" should run ok

Last edited by botman; July 24, 2019 at 11:04.
botman 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
Wind turbine simulation Saturn CFX 60 July 17, 2024 06:45
Out File does not show Imbalance in % Mmaragann CFX 5 January 20, 2017 11:20
Multiphase flow - incorrect velocity on inlet Mike_Tom CFX 6 September 29, 2016 02:27
Velocity vector in impeller passage ngoc_tran_bao CFX 24 May 3, 2016 22:16
Waterwheel shaped turbine inside a pipe simulation problem mshahed91 CFX 3 January 10, 2015 12:19


All times are GMT -4. The time now is 21:29.