dear Xingsheng, if you are used to commandline you can modify my awk-script to fit your needs.
to format the mesh file use the following command: awk -f pretty_print_msh.awk input.msh > output.msh the awk-script is attached best regards, Winfried On Thu, 19 Mar 2020, Xingsheng Sun wrote:
Hello All, I am using Gmsh to generate the mesh file for Ls-dyna. The problem is that in the key-format file generated by Gmsh, the coordinates of nodes have too many digits. For instance, in the node information: *NODE 22, 0, 0.012499999999976, -0.001 23, 0, 0.02499999999995, -0.001 24, 0, 0.037499999999926, -0.001 25, 0, 0.049999999999907, -0.001 the y-coordinates of nodes 22-25 have 15 digits that cannot be read by Ls-dyna. So could any people shed light on how to reduce the number of digits in Gmsh? I am using command lines, not GUI. Thank you so much in advance. Best regards, Xingsheng
______________________________________________________________________ / | Winfried Boxleitner | Scientist | AIT Austrian Institute of Technology GmbH \______________________________________________________________________
#======================================================================#
# #
# (c) AIT 2013, all rights reserved #
# #
# Author: Winfried Boxleitner #
# #
#======================================================================#
#
# remove unnecessary entries which are near 0
#
BEGIN{
filter=0
nodes=0
limit=1.0e-20
}
### program loop ###
{
### for gmsh files:
if($1 ~ /\$[A-Z][a-z]/) {filter=1}
if($1 ~ /\$Node/) {nodes=1}
if($1 ~ /\$End[A-Z]/) {filter=0; nodes=0}
### for other blocked text-output:
if($1 ~ /#{/) {filter=1; nodes=1}
if($1 ~ /#}/) {filter=0; nodes=0}
###
if(filter == 1)
{ if($1 ~ "[0-9]")
{ if($1 ~ "\"" )
{ ### treat strings tags in gmsh files correctly, if they contain numbers
print $0
}else{
printf "%5g ", $1
}
for(i=2;i<=NF;i++)
if(nodes > 0)
{ if(($i*$i)<limit)
printf "%+12.6g ", 0
else
printf "%+12.6g ", $i
}
else
{
printf "%5g ", $i
}
printf "\n"
} else {
print $0
}
}
else
{
print $0
}
}
signature.asc
Description: Digital Signature
_______________________________________________ gmsh mailing list [email protected] http://onelab.info/mailman/listinfo/gmsh
