I am trying to create a SURF152 surface on nodes using NDSURF.
When using
mapdl.ndsurf('SRF_N','FL1_E',3)
The surface elements are not created.
But if I copy the macro NDSURF.mac (from C:\Program Files\ANSYS Inc\v222\ansys\apdl\NDSURF.mac) to the working directory it works as expected by calling:
mapdl.use("'NDSURF.mac','SRF_N','FL1_E',3") # Works fine ?!
Any ideas?
Also if you do mapdl.nplot() then mapdl.eplot() at the end, it will crash mapdl.
📝 Steps to reproduce
Main script:
from ansys.mapdl.core import launch_mapdl
import os
curdir = os.getcwd()
mapdl = launch_mapdl(override=True, run_location=curdir, verbose=True,
cleanup_on_exit=True)
mapdl.clear()
mapdl.prep7()
mapdl.shpp('on')
# Create fluid line type
mapdl.et(1,'FLUID116',1,1)
mapdl.type(1)
# Create start finish for line
mapdl.k(0,0,0,1)
mapdl.k(0,1,0,1)
mapdl.klist()
# Create real constant for fluid1516
mapdl.r(1,1,1,1)
mapdl.rmore(0,0,'',1,'',)
mapdl.rmore('')
mapdl.rmore('',0,1)
mapdl.real(1)
# Create line and mesh
mapdl.l(1,2)
mapdl.lmesh(1)
mapdl.esll()
mapdl.cm('FL1_E','ELEM')
# Create solid87 elem type
mapdl.et(2, 87)
mapdl.r(2)
mapdl.real(2)
mapdl.type(2)
# Create keypoints for surface
mapdl.k(10,0,-0.5,0)
mapdl.k(11,0,0.5,0)
mapdl.k(12,1,0.5,0)
mapdl.k(13,1,-0.5,0)
# Create area from keypoints
mapdl.a(10,11,12,13)
mapdl.alist()
# Create volume downwards and mesh
mapdl.vext(1, dz=-0.5)
mapdl.vlist()
mapdl.vmesh(1)
# Select initial surface and get nodes
mapdl.alist()
mapdl.asel('S','AREA','',1)
mapdl.nsla('s',1)
mapdl.cm('SRF_N','NODE')
# Create SURF152 element type with 1 extra node
# kopt5 - extra nodes - 1 See 3 lines below
# One extra node (optional if KEYOPT (8) > 1; required if KEYOPT (9) > 0). Valid for convection and
# radiation calculations. Use this option if the bulk temperature is unknown. The extra node gets
# the bulk temperature from a FLUID116 (p. 350) element.
# kopt6 - use bulk temp for kopt5 - 0 Extra node temperature used as bulk temperature
# kopt8 - heat flux / conv loads - 4 Evaluate hf at fluid bulk temperature, TB
mapdl.et(3,'SURF152',2,0,2,1,1,0)
mapdl.keyopt(3,8,4)
mapdl.type(3)
mapdl.etlist()
# Add real constants
mapdl.r(3,1,1e-9,'',0,1,0)
mapdl.rmore(0,0,0,0,)
mapdl.rmore('',1,1)
mapdl.real(3)
# BUG: NDSURF DOES NOT WORK
# Copying C:\Program Files\ANSYS Inc\v222\ansys\apdl\NDSURF.mac to local dir
# And running NDSURF.mac using the *use command works fine
# mapdl.ndsurf('SRF_N','FL1_E',3) # Will not create a surface
mapdl.use("'NDSURF.mac','SRF_N','FL1_E',3") # Works fine ?!
# Get surface and create component
mapdl.cmsel('S','SRF_N')
mapdl.esln("s",1,'corner')
mapdl.esel('r','ename','',152)
mapdl.cm('SRF_E','ELEM')
mapdl.elist()
mapdl.nsle()
mapdl.nplot() # This works
mapdl.eplot() # This crashes mapdl
mapdl.exit()
NDSURF.mac (created by Ansys) :
! ANSYS $RCSfile: NDSURF.MAC,v $
! Modified on $Date$
! Source ID = $Revision$
/nopr
! ndsurf.mac
! Macro to mesh surface effect elements with extra nodes
! arg1 = Component of nodes to be meshed with surface effect elements
! arg2 = Component of target fluid elements
! arg3 = Model dimensionality, must be 2 or 3.
!
*get,_rout,active,,rout
*get,_mnu,active,,menu
*if,_rout,ne,17,then
finish
/prep7
*endif
_arg1=arg1
*get,_cchk,parm,_arg1,type
*if,_cchk,eq,0,then
_ok=1
*if,_mnu,eq,1,then
*msg,warn
Component name containing nodes must be input
*else
*msg,warn
Component name must be input (and enclosed in single quotes)
*endif
*endif
*if,_cchk,ge,3,then
_snode=arg1
*elseif,_arg1,ne,0,then
*msg,warn
The Component name must consist of valid character string
_ok=1
*endif
*if,_ok,ne,1,then
_arg2=arg2
*get,_cchk,parm,_arg2,type
*if,_cchk,eq,0,then
_ok=1
*if,_mnu,eq,1,then
*msg,warn
Component name containing fluid elements must be input
*else
*msg,warn
Component name must be input (and enclosed in single quotes)
*endif
*endif
*if,_cchk,ge,3,then
_telem=arg2
*elseif,_arg2,ne,0,then
*msg,warn
The Component name must consist of valid character string
_ok=1
*endif
_arg3=arg3
*get,_cchk,parm,_arg3,type ! obtain type of parameter
*if,_cchk,ne,0,then
*msg,error
Input value for model dimensionality must be numeric
_ok=1
*endif
_dimn=arg3
*if,arg3,ne,3,then
*if,arg3,ne,2,then
*msg,error
Input value for model dimensionality must be 2 or 3 only.
_ok=1
*endif
*endif
*endif
*if,_ok,ne,1,then
cm,_lines,line ! store existing selected sets of entities
cm,_nodes,node ! store existing selected sets of entities
cm,_elems,elem ! store existing selected sets of entities
*get,_csys,active,,csys
*get,_stype,comp,_snode,type
*if,_stype,ne,1,then
*msg,error,_snode
The component %c contains no nodes
_ok=1
*else
cmsel,s,_snode
*endif
esln
cm,_selem,elem
*get,_ttype,comp,_telem,type
*if,_ttype,ne,2,then
*msg,error,_telem
The component %c contains no elements
_ok=1
*else
cmsel,s,_telem
*get,_num2,elem,,count
*endif
cm,_areas,area
cmsel,s,_elems
cmsel,s,_nodes
cmsel,s,_lines
*endif
*get,_etnum,active,,type
*get,_etkop,etyp,_etnum,attr,kop4 ! 2D 3/4 node or 3D 4/8 option
*get,_etxn,etyp,_etnum,attr,kop5 ! extra node option
*get,_etaw,etyp,_etnum,attr,kop6 ! extra node option
*if,_ok,ne,1,then ! process
*if,_etkop,eq,1,then
*if,_dimn,eq,2,then
_maxnod = 3
*else
_maxnod = 5
*endif
*elseif,_etkop,eq,0,then
*if,_dimn,eq,2,then
_maxnod = 4
*else
_maxnod = 9
*endif
*endif
type,_etnum
keyopt,_etnum,6,0
keyopt,_etnum,5,0
cmsel,s,_snode
cmsel,s,_selem
cmsel,s,_lines
esurf ! ESURF surface elements
*if,_status,ge,2,then
*msg,error
Some surfaces were not meshed, check model
_ok=1
*endif
esln,s,1
esel,r,type,,_etnum
*get,_noelm,elem,,count ! number of meshed surface elements
cm,_surfe,elem ! meshed surface elements
cmsel,s,_nodes
cmsel,s,_elems
cmsel,s,_lines
cmsel,s,_areas
keyopt,_etnum,5,1
keyopt,_etnum,6,_etaw
*endif
*if,_ok,ne,1,then
*dim,_nodelm,array,_maxnod
cmsel,s,_telem
nsle,s ! get nodes from elements TELEM
csys,0
cmsel,s,_surfe
*get,_elmin,elem,,num,min
*get,_elmax,elem,,num,max
*do,_j,_elmin,_elmax
*if,esel(_j),ne,1,cycle
*vget,_nodelm(1),elem,_j,node,1,,,4
*get,_cx,elem,_j,cent,x
*get,_cy,elem,_j,cent,y
*get,_cz,elem,_j,cent,z
_nodelm(_maxnod) = node(_cx,_cy,_cz)
*if,_maxnod,eq,4,then
en,_j,_nodelm(1),_nodelm(2),_nodelm(3),_nodelm(4)
*elseif,_maxnod,eq,3,then
en,_j,_nodelm(1),_nodelm(2),_nodelm(3)
*elseif,_maxnod,eq,9,then
en,_j,_nodelm(1),_nodelm(2),_nodelm(3),_nodelm(4),_nodelm(5),_nodelm(6),_nodelm(7),_nodelm(8)
emore,_nodelm(9)
*elseif,_maxnod,eq,5,then
en,_j,_nodelm(1),_nodelm(2),_nodelm(3),_nodelm(4),_nodelm(5)
*endif
*enddo
esel,s,ename,,116
esel,a,ename,,66
*if,_dimn,eq,2,then
esel,a,ename,,19
esel,a,ename,,151
*else
esel,a,ename,,21
esel,a,ename,,152
*endif
nsle,s
eplot
cmsel,s,_lines
cmsel,s,_nodes
cmsel,s,_elems
esel,a,type,,_etnum
csys,_csys
*if,_etxn,ne,1,then
*msg,note,_etnum
Element type %i extra node option was reset (Keyopt(5)=1)
*endif
*endif
*if,_ok,ne,1,then
/out,ndsurf,out
*msg,info
%/_________________________ NDSURF RESULTS_____________________________
*vwrite,_noelm
(/,4x,'NUMBER OF SURFACE ELEMENTS CREATED = ', f5.0)
*msg,info
%/_____________________________________________________________________
/out
*endif
*if,_ok,ne,1,then ! no error
*if,_mnu,ne,1,then ! menu off
*list,ndsurf,out ! batch listing
*else
*list,ndsurf,out ! batch listing
! *uilist,ndsurf,out ! interactive listing
*endif
*endif
cmdele,_lines
cmdele,_nodes
cmdele,_elem
cmdele,_surfe
cmdele,_areas
_ok= $_rout= $_cchk= $_arg1= $_mnu= $_arg2= $_telem= $_snode=
_csys= $_num2= $_etnum= $_etkop= $_etxn= $_etaw=
_ntot= $_type= $_etyp= $_maxnod= $_nodelm=
_count= $_elmin= $_i= $_j= $_cx= $_cy= $_cz=
_noelm= $_stype= $_ttype= $_dimn= $_arg3=
🔍 Before submitting the issue
🐞 Description of the bug
Hello,
I am trying to create a SURF152 surface on nodes using NDSURF.
When using
The surface elements are not created.
But if I copy the macro NDSURF.mac (from C:\Program Files\ANSYS Inc\v222\ansys\apdl\NDSURF.mac) to the working directory it works as expected by calling:
Any ideas?
Also if you do mapdl.nplot() then mapdl.eplot() at the end, it will crash mapdl.
📝 Steps to reproduce
Main script:
NDSURF.mac (created by Ansys) :
💻 Which operating system are you using?
Windows
🐍 Which Python version are you using?
3.10
📦 Installed packages