Skip to content

Commit

Permalink
Fixing pymeshloader bug involving unsorted BDF files (#192)
Browse files Browse the repository at this point in the history
* Fixing bug in pymeshloader involoving unsorted bdf files

* Modifying test to use unsorted node numbering

* modifying element ordering in test

* Fixing more sorting issues

* Converting another bdf test to use unsorted IDs

* swapping out `sorted` for `max` function
  • Loading branch information
timryanb authored Mar 14, 2023
1 parent d30a585 commit 0c26129
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
22 changes: 13 additions & 9 deletions tacs/pymeshloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ def scanBdfFile(self, fileName):

# Try to get the node x,y,z locations from bdf file
try:
self.bdfXpts = self.bdfInfo.get_xyz_in_coord()
self.bdfXpts = self.bdfInfo.get_xyz_in_coord(
fdtype=self.dtype, sort_ids=False
)
# If this fails, the file may reference multiple coordinate systems
# and will have to be cross-referenced to work
except:
self.bdfInfo.cross_reference()
self.bdfInfo.is_xrefed = True
self.bdfXpts = self.bdfInfo.get_xyz_in_coord()
self.bdfXpts = self.bdfInfo.get_xyz_in_coord(
fdtype=self.dtype, sort_ids=False
)

# element card contained within each property group (may contain multiple per group)
# Each entry will eventually have its own tacs element object assigned to it
Expand Down Expand Up @@ -643,7 +647,7 @@ def createTACSAssembler(self, varsPerNode, massDVs):
self.creator.setBoundaryConditions(bcnodes, bcptr, bcdofs, bcvals)

# Set node locations
Xpts = self.bdfInfo.get_xyz_in_coord().astype(self.dtype)
Xpts = self.bdfInfo.get_xyz_in_coord(fdtype=self.dtype, sort_ids=False)
self.creator.setNodes(Xpts.flatten())

# Set the elements for each component
Expand Down Expand Up @@ -702,16 +706,16 @@ def _addTACSRBE2(self, rbeInfo, varsPerNode):
depConstrainedDOFs.extend(dofsAsList)
# add dummy nodes for all lagrange multiplier
dummyNodeNum = (
list(self.bdfInfo.node_ids)[-1] + 1
max(self.bdfInfo.node_ids) + 1
) # Next available nastran node number
# Add the dummy node coincident to the dependent node in x,y,z
self.bdfInfo.add_grid(dummyNodeNum, self.bdfInfo.nodes[node].xyz)
# Update Nastran to TACS ID mapping dicts, since we just added new nodes to model
self.nastranToTACSNodeIDDict[dummyNodeNum] = self.bdfInfo.nnodes - 1
dummyNodes.append(dummyNodeNum)

conn = indepNode + depNodes + dummyNodes
nTotalNodes = len(conn)
# Update Nastran to TACS ID mapping dicts, since we just added new nodes to model
self._updateNastranToTACSDicts()
# Add dummy nodes to lagrange multiplier node list
self.numMultiplierNodes += len(dummyNodes)
tacsIDs = self.idMap(dummyNodes, self.nastranToTACSNodeIDDict)
Expand All @@ -737,12 +741,12 @@ def _addTACSRBE3(self, rbeInfo, varsPerNode):
depConstrainedDOFs = self.isDOFInString(rbeInfo.refc, varsPerNode)

# add dummy node for lagrange multipliers
dummyNodeNum = list(self.bdfInfo.node_ids)[-1] + 1 # Next available node number
dummyNodeNum = max(self.bdfInfo.node_ids) + 1 # Next available node number
# Add the dummy node coincident to the dependent node in x,y,z
self.bdfInfo.add_grid(dummyNodeNum, self.bdfInfo.nodes[depNode[0]].xyz)
dummyNodes = [dummyNodeNum]
# Update Nastran to TACS ID mapping dicts, since we just added new nodes to model
self._updateNastranToTACSDicts()
self.nastranToTACSNodeIDDict[dummyNodeNum] = self.bdfInfo.nnodes - 1
dummyNodes = [dummyNodeNum]
# Add dummy node to lagrange multiplier node list
self.numMultiplierNodes += len(dummyNodes)
tacsIDs = self.idMap(dummyNodes, self.nastranToTACSNodeIDDict)
Expand Down
10 changes: 5 additions & 5 deletions tests/integration_tests/input_files/I_beam.bdf
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ SPC1 1 123456 27
SPC1 1 123456 28
SPC1 1 123456 29
SPC1 1 123456 30
$ Femap Property 1 : Web
PSHELL 1 1 .1 1 1 0.
$ Femap Property 2 : Flange
PROD 2 1 .05 0. 0. 0.
$ Femap Property 1 : Web
PSHELL 1 1 .1 1 1 0.
$ Femap Material 1 : Aluminum
MAT1 1 7.+10 .3 2700. 0. 0. +
+ 2.7+8
Expand Down Expand Up @@ -113,8 +113,8 @@ GRID 62 0 5. .8 0. 0
GRID 63 0 6. .8 0. 0
GRID 64 0 7. .8 0. 0
GRID 65 0 8. .8 0. 0
GRID 66 0 9. .8 0. 0
GRID 89 0 10. .5 0. 0
GRID 66 0 9. .8 0. 0
CQUAD4 1 1 1 2 31 30
CQUAD4 2 1 2 3 32 31
CQUAD4 3 1 3 4 33 32
Expand Down Expand Up @@ -164,8 +164,8 @@ CQUAD4 46 1 62 63 20 21
CQUAD4 47 1 63 64 19 20
CQUAD4 48 1 64 65 18 19
CQUAD4 49 1 65 66 17 18
CQUAD4 50 1 66 15 16 17
CROD 51 2 16 17
CQUAD4 50 1 66 15 16 17
CROD 52 2 17 18
CROD 53 2 18 19
CROD 54 2 19 20
Expand All @@ -183,8 +183,8 @@ CROD 65 2 5 6
CROD 66 2 6 7
CROD 67 2 7 8
CROD 68 2 8 9
CROD 69 2 9 10
CROD 70 2 10 11
CROD 69 2 9 10
RBE3 71 89 123456 1. 123456 16 15+
+ 14 13 12 11
DESVAR 1 FEMAP1 0.1 0.01 0.5
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/input_files/rbe_test.bdf
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ CQUAD4 27 1 38 39 44 43
CQUAD4 28 1 39 40 45 44
CQUAD4 29 1 41 42 47 46
CQUAD4 30 1 42 43 48 47
CQUAD4 31 1 43 44 49 48
CQUAD4 32 1 44 45 50 49
CQUAD4 31 1 43 44 49 48
$
MAT1 1 7.+10 .3 2700. 0. 0. +
+ 2.7+8
$
RBE2 33 1000 123456 5 10 15 20 25 + A
+ A 26 31 36 41 46
$
GRID 1000 15. 5. 0.
GRID 1 0. 0. 0.
GRID 2 2.5 0. 0.
GRID 3 5. 0. 0.
Expand Down Expand Up @@ -99,9 +100,8 @@ GRID 45 30. 7.5 0.
GRID 46 20. 10. 0.
GRID 47 22.5 10. 0.
GRID 48 25. 10. 0.
GRID 49 27.5 10. 0.
GRID 50 30. 10. 0.
GRID 1000 15. 5. 0.
GRID 49 27.5 10. 0.
$
SPC1 1 123456 1 6 11 16 21 30 + B
+ B 35 40 45 50
Expand Down

0 comments on commit 0c26129

Please sign in to comment.