In our lab, we use Cubit to generate the mesh, and imported it into an electromagnetic solver called JMAG, which accepts a degenerated hexahedrons with four identical nodes instead of a pyramid.
To perform this conversion on the exported nastran file, we apply the following simple Python script. This script is not elegant, but at least it is a solution: is there any way to convert a pyramid to a degenerate hexahedron using the classic Cubit commands?
import re
from numpy import *
SrcFileName = 'scr.bdf'
DstFileName = 'dst.bdf'
fid = open(SrcFileName,'r', encoding='UTF-8')
strLines = fid.readlines()
for n in range(len(strLines)):
sline = re.split(r"\s+|\n$",strLines[n])
if (sline[0] == 'CPYRAM'):
eid = strLines[n][ 8:16]
pid = strLines[n][16:24]
g1 = strLines[n][24:32]
g2 = strLines[n][32:40]
g3 = strLines[n][40:48]
g4 = strLines[n][48:56]
g5 = strLines[n][56:64]
strLines[n] = 'CHEXA ' + eid + pid + g1 + g2 + g3 + g4 + g5 + g5 + '+\n+ ' + g5 + g5 + '\n'
fid.close()
fid = open(DstFileName,'w')
for n in range(len(strLines)):
fid.write(strLines[n])
fid.close()