Cancel
Showing results for 
Search instead for 
Did you mean: 

Tet Mesh Solid command fail the Mesh Size

Legend
Legend

Hi,

 

I often found, that the Tet Mesh Solid fail the Mesh Size. For example here is a solid with mesh size:

 

Failed Mesh Size_before.jpg 

 

After running the Tet Mesh Solid command, and immediately Cancel, the Mesh Size will:

 

Failed Mesh Size_after1.jpg

 

When I complete the mesh:

 

Failed Mesh Size_after2.jpg

 

When somebody use Mesh / Mesh Control / Approach on Surface - Link to Surface command, and modified curve is associated to that surface, then Tet Mesh Solid command can be failed too.

I earlier made an API to solve this problem, it works for me:

 

Dim App As femap.model
Dim curveSet As femap.Set
Dim curveSet_Found As femap.Set
Dim cu As femap.Curve
Dim numLoc As Long
Dim cu_ID As Long
Dim meshParam As Variant
Dim msg As String
Dim msg1 As String
Dim i As Integer
Dim k As Integer
Dim n As Integer
Dim n1 As Integer
Dim n2 As Integer
Dim dist() As Double
Dim nBias() As Double
Dim nGeomBias() As Double
Dim lBiased As Boolean
Dim lBiased1 As Boolean
Dim lGeomBiased As Boolean
Dim lGeomBiased1 As Boolean
Dim lSmall As Boolean
Dim lBig As Boolean
Dim feGroup As femap.Group
Dim groupID As Long
Dim meshSize As Double
Dim minLine As Integer
Dim minClosed As Integer
Dim minOther As Integer
Dim spacing As Integer
Dim biasMethod As Integer
Dim bias As Double
Dim biasLoc As Integer
Dim customSize As Boolean

Dim fail As Integer

Sub Main	'Repair failed Mesh Size on Curve
	Begin Dialog UserDialog 100,150,360,189,"Repair failed Mesh Size on Curve",.dlg ' %GRID:10,7,1,1
		OKButton 250,154,90,21,.OKButton
		PushButton 20,14,130,21,"Scanning",.ScanButton
		PushButton 20,77,130,21,"Create new Group",.GroupButton
		PushButton 20,119,130,21,"Repair",.RepairButton
		PushButton 190,77,150,21,"Activate Group",.ActivateGroupButton
		text 70,49,130,14,"Found Curves: 0",.Text_FoundCurve
		text 160,18,110,14,"0 / 0",.Text_Curve,2
		text 160,123,110,14,"0 / 0",.Text_Repaired,2
		PushButton 230,42,110,21,"Show Curves",.btnShowCurves
		PushButton 20,154,130,21,"Rotate Dynamic",.btnRotateDynamic
	End Dialog
	Dim dlg As UserDialog

    Set App = feFemap()
    Set curveSet = App.feSet
	Set curveSet_Found = App.feSet
	Set cu=App.feCurve
	Set feGroup=App.feGroup

	App.feAppMessage( FCM_COMMAND  , "Repair failed Mesh Size on Curve")

	Dialog dlg

End Sub

Rem See DialogFunc help topic for more information.
Private Function dlg(DlgItem$, Action%, SuppValue?) As Boolean
		'Debug.Print "SuppValue="; SuppValue?
		Select Case Action%
		Case 1 ' Dialog box initialization
			DlgEnable "GroupButton",False
			DlgEnable "ActivateGroupButton",False
			DlgEnable "RepairButton",False
			DlgEnable "btnShowCurves",False
		Case 2 ' Value changing or button pressed
				'Debug.Print DlgItem$
				If DlgItem$="ScanButton" Then

					DlgEnable "ScanButton", False
					DlgEnable "OKButton", False
					rc = curveSet.Select( FT_CURVE, True, "Select Curve(s)")
					If rc = FE_CANCEL Or curveSet.Count=0 Then
						App.feViewRegenerate( 0 )
						DlgEnable "ScanButton", True
						dlg = True ' Prevent button press from closing the dialog box
						GoTo Quit
						'Exit Sub
					End If

					k=1
					cu_ID=curveSet.First
					While cu_ID>0
						rc=cu.Get(cu_ID)
						DlgText "Text_Curve", Str(k)+" /"+Str(curveSet.Count)

						rc=cu.GetMeshLoc(numLoc, meshParam)

						'Debug.Clear

						i=0
						n=0
						lBiased=False
						lBiased1=True
						lGeomBiased=False
						lGeomBiased1=True
						lSmall=False
						lBig=False
						If numLoc<325 Or cu.HasCustomMesh Then
							ReDim dist(numLoc)
							ReDim nBias(numLoc)
							ReDim nGeomBias(numLoc)
						Else
							ReDim dist(1)
							ReDim nBias(1)
							ReDim nGeomBias(1)
						End If
Ciklus1:
						If cu.MeshBias(i)<>1 Or cu.MeshElem(i)<>1 Or numLoc<=3 Then GoTo Skip
						msg=Str(i+1) & "," & Str(n+cu.MeshElem(i)) & vbCrLf &vbCrLf
						msg1=Str(i) +": "+ Format(cu.MeshMaxParam(i),"0.000000")
						If i<>0 Then
							dist(i)=cu.MeshMaxParam(i)-cu.MeshMaxParam(i-1)
							nBias(i)=Round(dist(i)-dist(i-1),4)
							nGeomBias(i)=Round(dist(i)/dist(i-1),4)
							If nBias(i)<>0 And nBias(i-1)<>0 Then
								If Abs(nBias(i))=Abs(nBias(i-1)) And lBiased1 Then
									lBiased=True
								Else
									'Debug.Print Str(Abs(nBias(i))) & "   " & Str(Abs(nBias(i-1)))
									lBiased=False
									lBiased1=False
								End If
							End If
							If i>1 And 2*i<>numLoc Then
								If nGeomBias(i)<>1 And nGeomBias(i-1)<>1 Then
									If Abs(nGeomBias(i))=Abs(nGeomBias(i-1)) And lGeomBiased1 Then
										lGeomBiased=True
									Else
										'Debug.Print Str(Abs(nGeomBias(i))) & "   " & Str(Abs(nGeomBias(i-1)))
										lGeomBiased=False
										lGeomBiased1=False
									End If
								End If
							End If
							If i>0 And Abs(nGeomBias(i))<=0.5 Then
								lSmall=True
							End If
							If i>0 And Abs(nGeomBias(i))>=2 Then
								lBig=True
							End If
							msg1=msg1+"   ->  "+ Format(dist(i),"0.000000")+"   ->  "+ Format(nBias(i),"0.000000") _
								+"   ->  "+ Format(nGeomBias(i),"0.000000")+"   ->  " & lBiased & "  " & lBiased1 & "   " &  lGeomBiased & "  " & lGeomBiased1
						Else
							dist(i)=cu.MeshMaxParam(i)
							msg1=msg1+"   ->  "+ Format(dist(i),"0.000000")
						End If
						'Debug.Print msg1

						n=n+cu.MeshElem(i)
						If cu.MeshMaxParam(i)<1 Then
							i=i+1
							GoTo Ciklus1
						End If

						If lBiased Or lGeomBiased Then GoTo Skip
						If Not(lSmall Or lBig) Then GoTo Skip

						If numLoc<>0 And cu.HasCustomMesh Then
							n1=Round(1/cu.MeshMaxParam(0),0)
							n2=Round(1/(cu.MeshMaxParam(i)-cu.MeshMaxParam(i-1)),0)
							If n1>n2 Then
								n1=n2
							End If
							'MsgBox Str(i) & "___" & Str(n1) & "___" & Str(n2)
							If n1<>n Then
								rc=curveSet_Found.Add(cu_ID)
								'MsgBox Str(n1)
							End If
						End If

Skip:
						cu_ID=curveSet.Next
						k=k+1

					Wend

					If curveSet_Found.Count=0 Then
						MsgBox("Curves with failed Mesh Size not found",vbOkOnly,"Mesh Size repair on Curve")
						curveSet.Clear
						DlgEnable "ScanButton",True
						DlgText "Text_Curve", "0 / 0"
						App.feViewRegenerate( 0 )
						dlg = True ' Prevent button press from closing the dialog box
						GoTo Quit
					End If
					DlgEnable "btnShowCurves",True
					App.feAppMessage( FCM_NORMAL, "Found"+Str(curveSet_Found.Count) + " Curves with failed Mesh Size.")
					DlgText "Text_FoundCurve", "Found Curve:"+Str(curveSet_Found.Count)
					DlgEnable "GroupButton", True
					DlgEnable "RepairButton", True
					dlg = True ' Prevent button press from closing the dialog box
					GoTo Quit
				End If

				If DlgItem$="btnRotateDynamic" Then
					App.feRunCommand (2033, True)			'Rotate Dynamic
					dlg =True	' Prevent button press from closing the dialog box
				End If

				If DlgItem$="btnShowCurves" Then
					rc=App.feViewShow(FT_CURVE,curveSet_Found.ID )
					dlg =True	' Prevent button press from closing the dialog box
				End If


				If DlgItem$="GroupButton" Then
					groupID=feGroup.NextEmptyID()
					rc=feGroup.SetAdd(FT_CURVE,curveSet_Found.ID)
					feGroup.title="Mesh Size repair on Curve"
					rc=feGroup.Put(groupID)
					App.feAppMessage( FCM_NORMAL, Str(curveSet_Found.Count) + " Curves with failed Mesh Size added to Group" + Str(groupID))
					DlgText "ActivateGroupButton","Activate Group"+Str(groupID)
					DlgEnable "ActivateGroupButton", True
					dlg = True ' Prevent button press from closing the dialog box
					GoTo Quit
				End If
				If DlgItem$="ActivateGroupButton" Then
					App.Info_ActiveID(FT_GROUP)=groupID
					App.feAppMessage( FCM_NORMAL, "Activating Group" + Str(groupID))

					dlg = True ' Prevent button press from closing the dialog box
					GoTo Quit
				End If

				If DlgItem$="RepairButton" Then

					DlgEnable "OKButton", False

					fail=0
					k=0

					spacing=1
					biasMethod=0 'Equal length spacing
					bias=1
					biasLoc=0
					cu_ID=curveSet_Found.First
					While cu_ID>0
						rc=cu.Get(cu_ID)
						rc=cu.GetMeshLoc(numLoc, meshParam)
						i=numLoc-2
						n1=Round(1/cu.MeshMaxParam(0),0)
						n2=Round(1/(cu.MeshMaxParam(i)-cu.MeshMaxParam(i-1)),0)
						If n1>n2 Then
							n1=n2
						End If
						'MsgBox Str(i) & "___" & Str(n1) & "___" & Str(n2)
						If n1<>n Then
							rc=curveSet_Found.Add(cu_ID)
							'MsgBox Str(n1)
						End If
						customSize=False
						If numLoc<325 Then customSize=True
						rc=App.feMeshSizeCurve(-cu_ID, n1, meshSize, minLine, minClosed, minOther, spacing, biasMethod, bias, biasLoc, customSize)
						If rc=FE_FAIL Then
							fail=fail+1
						Else
							k=k+1
						End If
						DlgText "Text_Repaired", Str(k)+" /"+Str(curveSet_Found.Count)
						cu_ID=curveSet_Found.Next
					Wend
					App.feAppMessage( FCM_NORMAL, Str(curveSet_Found.Count-fail) + " Curves with failed Mesh Size repaired.")
					If fail<>0 Then App.feAppMessage( FCM_NORMAL, Str(fail) + " Curves with failed Mesh Size failed to repair.")
					App.feViewRegenerate( 0 )

					dlg = True ' Prevent button press from closing the dialog box
					GoTo Quit
				End If

Quit:
		DlgEnable "OKButton", True
		Case 3 ' TextBox or ComboBox text changed
		Case 4 ' Focus changed
		Case 5 ' Idle
			Rem Wait .1 : dlg = True ' Continue getting idle actions
		Case 6 ' Function key
	End Select
End Function

 

Best regards,

 

Peter Kaderasz

3 REPLIES

Re: Tet Mesh Solid command fail the Mesh Size

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Dear Peter,

Great job!.. I have observed this problem as well, what I do is to use always command "Geometry > Solid > CleanUp" and apply mesh size on surfaces. In general I try to mesh with HEX8/20 solid elements, but if not remedy to use TET10 elements I tend to do a mesh preview using "Mesh > Geometry > Surface" command to see the quality of the 2-D Mesh and if required to use this 2-D mesh as SEED mesh for the 3-D mesh.

Best regards,

Blas.

 

Blas Molero Hidalgo, Ingeniero Industrial, Director
IBERISA • 48004 BILBAO (SPAIN)
WEB: http://www.iberisa.com
Blog Femap-NX Nastran: http://iberisa.wordpress.com/

Re: Tet Mesh Solid command fail the Mesh Size

Siemens Phenom Siemens Phenom
Siemens Phenom

If possible, please send me this model and we can debug this issue and make this work more smoothly in future versions of FEMAP.

 

sherman dot mark at siemens dot com

 

Mark.

Re: Tet Mesh Solid command fail the Mesh Size

Legend
Legend

Hi Mark,

 

I can't send this model (it has been repaired), but I can send an another model, created with Femap v11.1.2. The failed curves are these:

Failed Mesh Size.jpg

 

Please open this model with Femap v11.1.2, because after translation via neutral file to v11.2 the solid is repaired.

 

I think later I can send from current Femap version too.

 

Best regard,

 

Peter