10-17-2017 05:50 PM
Hi,
So I've successfully used a series of commands to generate a native solid hexahedral mesh (nodes and elements) by first creating nodes and then using Mesh->Between(F11) to define connectivity and generate the elements. However then when trying to automate the process with as an API, I get stuck at the element generation. I have entered all the required inputs for the feMeshBetween() method and get no errors, but nothing happens, the code just executes and I am left with a bunch of nodes with no elements. I am then left to manually use the Mesh->Between user interface, where I can enter all the inputs in the dialog box and the elements get generated just fine.
I also found it strange that in the user interface dialog, if you choose elements only, the requirement to enter corner coordinates goes away (logically since you have already put the nodes there and are referencing their IDs), however the last argument for the method in the API is not listed as optional/dependent in the documentation. I have tried both options (generating only elements vs generating both nodes and elements) and neither works (for me) in the API.
Anyone else encounter this or is familiar with this method?
10-18-2017 08:43 AM
Would you mind posting your code?
10-18-2017 09:41 AM
Here is an example:
Sub Main Dim App As femap.model Set App = feFemap() Dim numNodes(2) As Variant, bias(2) As Variant, nodeINC(2) As Variant, corner(23) As Variant GenerationMode = 2 'Nodes and Elements shape = 4 'Quad rightsplit = True alternate = True allQuad = True logSpacing = False numCorners = 4 ' planar elements numNodes(0) = 10 : numNodes(1) = 10 ' : numNodes(2) = 0 bias(0) = 1.0 : bias(1) = 1.0 ' : bias(2) = 1.0 nodeINC(0) = 0 : nodeINC(1) = 0 corner(0) = 0 : corner(1) = 0 : corner(2) = 0 'Corner 1: X = 0, Y = 0, Z = 0 corner(3) = 10 : corner(4) = 0 : corner(5) = 0 'Corner 2: X = 10, Y = 0, Z = 0 corner(6) = 10 : corner(7) = 10 : corner(8) = 0 'Corner 3: X = 10, Y = 10, Z = 0 corner(9) = 0 : corner(10) = 10 : corner(11) = 0 'Corner 4: X = 0, Y = 10, Z = 0 rc = App.feMeshBetween(1,GenerationMode,shape,rightSplit,alternate, _ +allQuad,logSpacing,numCorners,numNodes,bias,nodeINC,corner) End Sub
10-18-2017 10:31 AM
Here is a 10x10x10 cube example:
Sub Main Dim App As femap.model Set App = feFemap() Dim numNodes(2) As Variant, bias(2) As Variant, nodeINC(2) As Variant, corner(23) As Variant GenerationMode = 2 'Nodes and Elements shape = 8 'Brick rightsplit = True alternate = True allQuad = True logSpacing = False numCorners = 8 ' solid elements numNodes(0) = 10 : numNodes(1) = 10 : numNodes(2) = 10 bias(0) = 1.0 : bias(1) = 1.0 : bias(2) = 1.0 nodeINC(0) = 0 : nodeINC(1) = 0 corner(0) = 0 : corner(1) = 0 : corner(2) = 0 'Corner 1: X = 0, Y = 0, Z = 0 corner(3) = 10 : corner(4) = 0 : corner(5) = 0 'Corner 2: X = 10, Y = 0, Z = 0 corner(6) = 10 : corner(7) = 10 : corner(8) = 0 'Corner 3: X = 10, Y = 10, Z = 0 corner(9) = 0 : corner(10) = 10 : corner(11) = 0 'Corner 4: X = 0, Y = 10, Z = 0 corner(12) = 0 : corner(13) = 0 : corner(14) = 10 'Corner 5: X = 0, Y = 0, Z = 10 corner(15) = 10 : corner(16) = 0 : corner(17) = 10 'Corner 6: X = 10, Y = 0, Z = 10 corner(18) = 10 : corner(19) = 10 : corner(20) = 10 'Corner 7: X = 10, Y = 10, Z = 10 corner(21) = 0 : corner(22) = 10 : corner(23) = 10 'Corner 8: X = 0, Y = 10, Z = 10 rc = App.feMeshBetween(1,GenerationMode,shape,rightSplit,alternate, _ +allQuad,logSpacing,numCorners,numNodes,bias,nodeINC,corner) End Sub
10-18-2017 11:36 AM
Many thanks for the demo and sample code!
Through cross-referencing my code against yours the only meaningful difference I could see was in declaring the array variables. I was declaring them as Double rather than Variant, which I guess was causing the issue. I am not familiar enough with coding to know why this would be an issue, especially since I am working directly in the FEMAP API window.
Here is my code in case someone finds it useful.
Sub Main
Dim App As femap.model
Set App = feFemap()
Dim length As Double, w As Double, t As Double, ri As Double
Dim nElemRow As Integer, nElemCol As Integer, nLong As Integer, layDir As Integer
Dim entitySet As Object
Dim copyVect(2) As Double
Dim axisLoc(2) As Variant
Dim axisVect(2) As Variant
Dim numNodes(2) As Variant
Dim nodeBias(2) As Variant
Dim nodeInc(2) As Variant
Dim nodeCoords(23) As Variant
Dim layerID As Integer
Dim nodeID As Integer
Dim wireNode As Object
Dim wireElem As Object
length = 1.0
w = 0.020
t = 0.004
ri = 0.300
nElemCol = 5
nElemRow = 3
nLong = 100
'Define Dependent Variables
nNodeRow =nElemRow + 1
nNodeCol = nElemCol + 1
'Coding To Generate Nodes and Elements
numNodes(0) = nNodeCol
numNodes(1) = nLong+1
numNodes(2) = nNodeRow
nodeBias(0) = 1.0
nodeBias(1) = 1.0
nodeBias(2) = 1.0
nodeInc(0) = 1+ nodeIDoffset
nodeInc(1) = nSect
nodeInc(2) = nNodeCol
'Corner 1
nodeCoords(0) = -length/2 : nodeCoords(1) = ri : nodeCoords(2) = -w/2
'Corner 2
nodeCoords(3) = -length/2 : nodeCoords(4) = ri : nodeCoords(5) = w/2
'Corner 3
nodeCoords(6) = length/2 : nodeCoords(7) = ri : nodeCoords(8) = w/2
'Corner 4
nodeCoords(9) = length/2 : nodeCoords(10) =ri : nodeCoords(11) = -w/2
'Corner 5
nodeCoords(12) = -length/2 : nodeCoords(13) = ri + t : nodeCoords(14) = -w/2
'Corner 6a
nodeCoords(15) = -length/2 : nodeCoords(16) = ri + t : nodeCoords(17) = w/2
'Corner 7
nodeCoords(18) = length/2 : nodeCoords(19) = ri + t : nodeCoords(20) = w/2
'Corner 8
nodeCoords(21) = length/2 : nodeCoords(22) = ri + t : nodeCoords(23) = -w/2
rc = App.feMeshBetween(1,2,8,True,True,True,False,8,numNodes,nodeBias,nodeInc,nodeCoords)
End Sub