Personal tools
You are here: Home Forum Use problem in meshing circular area

problem in meshing circular area

Up to Use

problem in meshing circular area

Posted by sangpil yoon at February 18. 2017

i was playing with a py file from salome help.

i set my own paramerters (transx and transy)

when those are set to zero no problem since it the original case.....

as soon as i set it non-zero, i have a problem with meshing

i think its because of curved in the geometry.

any suggestions on how to overcome the problem?

 

many thanks in advance

 

 

=========================================

# -*- coding: utf-8 -*-

###
### This file is generated automatically by SALOME v7.5.1 with dump python functionality
###

import sys
import salome

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.NoteBook(theStudy)

###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder

import math
import SALOMEDS


geompy = geomBuilder.New(theStudy)

O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)

geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )

height = 10
radius = 100

base = geompy.MakeVertex(0, 0, 0)
cylinder = geompy.MakeCylinder(base, OZ, radius, height)
geompy.addToStudy( cylinder, 'cylinder' )

# build blocks
size = radius/4.0

transx = -10
transy =  10

box_rot  = geompy.MakeBox(-size, -size, 0,  +size, +size, height)
box_axis = geompy.MakeLine(base, OZ)
box_ro0  = geompy.MakeRotation(box_rot, box_axis, math.pi/4)
box_tmp  = geompy.MakeTranslation(box_ro0, transx, transy, 0)

geompy.addToStudy(  box_rot, 'box_rot' )
geompy.addToStudy(  box_tmp, 'box_tmp' )

hole = geompy.MakeCut(cylinder, box_tmp)
geompy.addToStudy(     hole, 'hole' )

##
plane_trim = 2000
plana_0 = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
planb_0 = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
plane_a  = geompy.MakeTranslation(plana_0, transx, transy, 0)
plane_b  = geompy.MakeTranslation(planb_0, transx, transy, 0)
geompy.addToStudy(  plane_a, 'plane_a' )
geompy.addToStudy(  plane_b, 'plane_b' )

blocks_part = geompy.MakePartition([hole], [plane_a, plane_b], [], [], geompy.ShapeType["SOLID"])
geompy.addToStudy(  blocks_part, 'blocks_part' )

blocks_list = [box_tmp] + geompy.SubShapeAll(blocks_part, geompy.ShapeType["SOLID"])

model_blocks_pttnd = geompy.MakePartition(blocks_list)
geompy.addToStudy(model_blocks_pttnd, 'model_blocks_pttnd')


#
# Build geometric groups
# ----------------------

def group(name, shape, type, base=None, direction=None):
    t = geompy.ShapeType[type]
    g = geompy.CreateGroup(shape, t)

    geompy.addToStudy(g, name)
    g.SetName(name)

    if base!=None:
        l = geompy.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, GEOM.ST_ON)
        geompy.UnionIDs(g, l)

    return g

group_a = group("baseA", model_blocks_pttnd, "FACE", base, OZ)
base_b  = geompy.MakeVertex(0, 0, height)
group_b = group("baseB", model_blocks_pttnd, "FACE", base_b, OZ)

group_1 = group("limit", model_blocks_pttnd, "SOLID")
group_1_all = geompy.SubShapeAllIDs(model_blocks_pttnd, geompy.ShapeType["SOLID"])
geompy.UnionIDs(group_1, group_1_all)
group_1_box = geompy.GetBlockNearPoint(model_blocks_pttnd, base)
geompy.DifferenceList(group_1, [group_1_box])


###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)

def discretize(x, y, z,  n, s=model_blocks_pttnd):
    p = geompy.MakeVertex(x, y, z)
    e = geompy.GetEdgeNearPoint(s, p)
    a = hexa.Segment(e)
    a.NumberOfSegments(n)
    a.Propagation()

# mesh for partition
hexa = smesh.Mesh(model_blocks_pttnd)

hexa_1d = hexa.Segment()
hexa_1d.NumberOfSegments(1)

curve=12
line0=10

discretize(transx+radius        , transy+radius,        0,  curve)
discretize(transx-radius        , transy+radius,        0,  curve)
discretize(transx+(radius+size)/2,       transy,        0,  line0)

hexa.Quadrangle()
hexa.Hexahedron()

hexa.Compute()

hexa.Group(group_a)
hexa.Group(group_b)
hexa.Group(group_1)


if salome.sg.hasDesktop():
  salome.sg.updateObjBrowser

=====================================================

Re: problem in meshing circular area

Posted by Saint Michael at February 20. 2017

Hi

The Hexahedral meshing fails because a 2D mesh is not suitable for that. To fix it it's necessary to adjust discretization of edges to get a quadrangular 2D mesh.

St.Michael

Re: problem in meshing circular area

Posted by sangpil yoon at February 22. 2017

Thanks. Saint Michael for your input.

You are right..the problem starts from 2D meshing..

so i attcked 2D meshing issue first...

 

sadly, when parameters (transx,transy) are non-zero, i am having the same problems.

(NO problem when those are zeros !!!!!)

 

i believe the reason is that the outer circle gets 5 segments NOT 4 segments !

I dont know why......

 

any help is appreciated and thanks in advance....

 

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

# -*- coding: utf-8 -*-

###
### This file is generated automatically by SALOME v7.5.1 with dump python functionality
###

import sys
import salome

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.NoteBook(theStudy)

##############################################################################
#                          run this file in Python Console
#
#
#          >>>execfile(r"/home/sangpil.yoon/run_aster/sample16/Study11.py")
#
##############################################################################

###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder

# Dont forget 2 import for various math functions in python
import math
###########################################################
import SALOMEDS


geompy = geomBuilder.New(theStudy)

# define coordinate a system
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)

geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )

# define parameters
height = 10
radius = 100

cntght = 20
cntius =  8

# define translation parameters
transx =  30
transy =  40

base = geompy.MakeVertex(-transx, -transy, 0)
circle = geompy.MakeCircle(base, OZ, radius)
geompy.addToStudy( circle, 'circle' )
geompy.addToStudy(  base, 'base' )

# build blocks
size = radius/4.0

sk = geompy.Sketcher2D()
sk.addPoint(-size, -size)
sk.addSegmentAbsolute(-size, size)
sk.addSegmentAbsolute(size, size)
sk.addSegmentAbsolute(size, -size)
sk.close()
box_tmp = sk.wire()
geompy.addToStudy(  box_tmp, 'box_tmp' )
geompy.Rotate(box_tmp, OZ, math.pi/4)

##
plane_trim = 2000
plana_0 = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
planb_0 = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
plane_a  = geompy.MakeTranslation(plana_0, transx, transy, 0)
plane_b  = geompy.MakeTranslation(planb_0, transx, transy, 0)
geompy.addToStudy(  plane_a, 'plane_a' )
geompy.addToStudy(  plane_b, 'plane_b' )

isPlanarFace = 1
face01 = geompy.MakeFaceWires([circle, box_tmp],isPlanarFace)
geompy.addToStudy(  face01, 'face01' )

blocks_part = geompy.MakePartition([face01], [plane_a, plane_b], [], [], geompy.ShapeType["FACE"])
geompy.addToStudy(  blocks_part, 'blocks_part' )


a1=geompy.MakeVertex( -transx+radius, -transy+radius,        0)
a2=geompy.MakeVertex( -transx-radius, -transy+radius,        0)
a3=geompy.MakeVertex( -transx+radius, -transy-radius,        0)
a4=geompy.MakeVertex( -transx-radius, -transy-radius,        0)
a5=geompy.MakeVertex( +(radius+size)/3,        0,        0)
geompy.addToStudy(a1, 'a1')
geompy.addToStudy(a2, 'a2')
geompy.addToStudy(a3, 'a3')
geompy.addToStudy(a4, 'a4')
geompy.addToStudy(a5, 'a5')

###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)

def discretize(x, y, z,  n, s=blocks_part):
    p = geompy.MakeVertex(x, y, z)
    e = geompy.GetEdgeNearPoint(s, p)
    a = hexa.Segment(e)
    a.NumberOfSegments(n)
    a.Propagation()

# mesh for partition
hexa = smesh.Mesh(blocks_part)

hexa_1d = hexa.Segment()
hexa_1d.NumberOfSegments(1)

curve=12
line0=10

discretize(         -transx+radius,-transy+radius,        0,  curve)
discretize(         -transx-radius,-transy+radius,        0,  curve)
discretize(         -transx+radius,-transy-radius,        0,  curve)
discretize(         -transx-radius,-transy-radius,        0,  curve)
discretize( +(radius+size)/3,        0,        0,  line0)

hexa.Quadrangle()
hexa.Compute()

if salome.sg.hasDesktop():
  salome.sg.updateObjBrowser(1)

++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Re: problem in meshing circular area

Posted by Saint Michael at February 22. 2017

The mesh is not as expected because of an excess vertex on an arc:

To remove that vertex, add blocks_part = geompy.RemoveExtraEdges(blocks_part) after creation of blocks_part.

St.Michael

Attachments

Re: problem in meshing circular area

Posted by sangpil yoon at March 05. 2017

well...I knew soneone here whould answer my question....

thanks very much for your input.

i will go from here...into 3d... thanks again  

Powered by Ploneboard
Document Actions