CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ANSYS Meshing & Geometry

Mesh macro

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By AlexHorlock

Reply
 
LinkBack Thread Tools Display Modes
Old   July 6, 2010, 22:29
Default Mesh macro
  #1
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 7
hannow is on a distinguished road
Hi there,

I want to create JScript macro for Ansys Meshing [Fluid Flow] V12.1. So, does anyone knows any meshing scripting guidline? I've already generated Workbench journal code to automatically carry out the process of fluid flow simulation with FLUENT. However, this journal coding in Workbench won't record the operations in geometry creation and mesh generation. So, I had to generate JScript code for the geometry and embedded into the journal code. The only code left is for the meshing and have no idea of how to generate the code. So, if anybody have experience on this matter, please share it with us!

Thank you very much for your help

Hannow
hannow is offline   Reply With Quote

Old   July 15, 2010, 21:53
Default Parametric and Persistent
  #2
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,662
Blog Entries: 1
Rep Power: 36
PSYMN has a spectacular aura aboutPSYMN has a spectacular aura about
You can't really script the ANSYS Meshing section... Rather, it is parametric and persistent. If you make a change to the geometry, the mesher will just generate a mesh with the same (persistent) settings on that new geometry and then pass the mesh to the solver.

The question is "what do you want to script?"

If you are making changes to the geometry and want the meshing script to give you a mesh on that, parametric persistence will automatically update without a script. Most gambit users who want to script meshing are better off once they see the benefits of parametric persistence.

At 13.0, the mesh parameters are also parametric and can be changed from the parameter set bar. This means you could use DX to run a refinement study, all without scripting.

There are some things that require mesh scripting, although I can't really think of any right now (maybe if you want to specify the order of meshing steps?), so we are planning to add that sooner or later.
PSYMN is offline   Reply With Quote

Old   July 16, 2010, 00:32
Default
  #3
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 7
hannow is on a distinguished road
Hi PSYMN,

Thank you very much for you reply, really appreciated

Actually there is an option for the meshing application that allows to read macros from outside files like JScript files, which mean that it's possible to run the meshing process using scripts.

My model is very simple, it's a duct with water flowing inside it. The geometrical parameters that need to be tested is the inlet and the outlet diameters. I don't want to go through the whole CFD process to run every single simulation for different diameters which time consuming, and that why I want to use journaling / scripting so that it can be run automatically by running the script after changing the parameters inside the script.

I already manged to code the whole process with some help from ansys documentation except for the meshing. The meshing process I want to script is just renaming boundaries, assigning meshing parameters and then run the mesher. Till now, I'm still stuck at coding the mesh process, so if you have any idea of how to do it, let us know.

Thank you very much for your sharing
Hannow

Quote:
Originally Posted by PSYMN View Post
You can't really script the ANSYS Meshing section... Rather, it is parametric and persistent. If you make a change to the geometry, the mesher will just generate a mesh with the same (persistent) settings on that new geometry and then pass the mesh to the solver.

The question is "what do you want to script?"

If you are making changes to the geometry and want the meshing script to give you a mesh on that, parametric persistence will automatically update without a script. Most gambit users who want to script meshing are better off once they see the benefits of parametric persistence.

At 13.0, the mesh parameters are also parametric and can be changed from the parameter set bar. This means you could use DX to run a refinement study, all without scripting.

There are some things that require mesh scripting, although I can't really think of any right now (maybe if you want to specify the order of meshing steps?), so we are planning to add that sooner or later.
hannow is offline   Reply With Quote

Old   July 16, 2010, 00:55
Default
  #4
New Member
 
Karan Anand
Join Date: Feb 2010
Posts: 23
Rep Power: 7
karananand is on a distinguished road
I don't know much about the workbench mesh-er and creating a macro for that. ICEM CFD can handle meshing with such parametric changes and meshing using replay scripts that you can record and play in batch mode if you want to do design optimization or implement other such routines. BTW macros in ICEM are called replay scripts.. if you go to help file, search for replay script and not macros, otherwise you will waste time just like me!!
karananand is offline   Reply With Quote

Old   July 16, 2010, 01:19
Default Ahead of the curve.
  #5
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,662
Blog Entries: 1
Rep Power: 36
PSYMN has a spectacular aura aboutPSYMN has a spectacular aura about
Yea, I am pretty familiar with ICEM CFD scripting, but you are already ahead of me (and most people) if you can script ANSYS Meshing.

The SDK (Software Development Kit) for workbench is due out soon after the R13.0 release. Until then, you are ahead of the curve.

If you have access to tech support (techsupp@ansys.com), they may be able to ask development about your question.

Simon
PSYMN is offline   Reply With Quote

Old   July 16, 2010, 02:50
Default Thanks
  #6
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 7
hannow is on a distinguished road
Thanks guys for the info
hannow is offline   Reply With Quote

Old   March 19, 2011, 06:37
Default @Hannow
  #7
New Member
 
Rohit Vasudevan
Join Date: Feb 2011
Location: Southampton
Posts: 9
Rep Power: 6
rohit_8481 is on a distinguished road
Hey I'm trying to write a script for workbench... I embedded the JScript into the journal.. But I'm having trouble creating surfaces and body operations on the geometry via the script... Could you help me out on that? And did you manage to get the mesher to run using the script?
Thanks for your help...
rohit_8481 is offline   Reply With Quote

Old   August 17, 2013, 17:18
Default
  #8
ICS
New Member
 
Join Date: Aug 2013
Posts: 7
Rep Power: 4
ICS is on a distinguished road
Hi everybody...

I'm facing the same problem. I'm using WB to generate several meshes for Fluent. I've already created a journal file for WB that actualizes the geometry and calls a JScript for DM that selects the bodies and forms a single part. Now I just have to create a JScript for Meshing (or send a command through the WB journal) that exports the .msh file with the name I want... Any ideas of how could I do that??
ICS is offline   Reply With Quote

Old   August 18, 2013, 11:58
Default
  #9
New Member
 
Rohit Vasudevan
Join Date: Feb 2011
Location: Southampton
Posts: 9
Rep Power: 6
rohit_8481 is on a distinguished road
Hey ICS,

I did manage to get it working in the end. Its been a while since I've worked on ansys. I could take a look and see if I find the scripts. I could PM them to you if I do find them. Cheers. Good luck !
rohit_8481 is offline   Reply With Quote

Old   August 18, 2013, 13:18
Default
  #10
ICS
New Member
 
Join Date: Aug 2013
Posts: 7
Rep Power: 4
ICS is on a distinguished road
Thanks a lot rohit_8481.. If you can find the command that exports the .msh file from the Meshing it'll be very helpfull... it's the last command i need...

Here is the WB scripting code I wrote... It opens the DM and the Meshing in the begining, sends the JScript commands to DM (making it change the geometry file, select all bodies and form a single part), and updates the meshing... now I just have to sent the command to Meshing so that it exports the .msh file with the name I want... (the last two blocks of commands will be repeated for each mesh I have to generate)


[CODE]
system1 = GetSystem(Name="FFF")
geometry1 = system1.GetContainer(ComponentName="Geometry")
mesh1 = system1.GetContainer(ComponentName="Mesh")
component1 = system1.GetComponent(Name="Mesh")

geometry1.Edit()
mesh1.Edit()

geometry1.SendCommand(Command="""ag.m.NewSession (1);
ag.gui.CreateImport ("C:............x_t");
agb.regen();
ag.gui.PickFilter(5, true);
ag.gui.SelectAll();
ag.m.FormBodyGroup();""")

component1.Update(AllDependencies=True)
ICS is offline   Reply With Quote

Old   August 19, 2013, 07:15
Default
  #11
ICS
New Member
 
Join Date: Aug 2013
Posts: 7
Rep Power: 4
ICS is on a distinguished road
Finaly I managed to solve my problem... I couldn't find the command "export" for Meshing, but I'm using the phython command "os.rename()" to change the name of the FFF.msh file generated automaticaly when I update the meshing... The final WB script code became:

system1 = GetSystem(Name="FFF")
geometry1 = system1.GetContainer(ComponentName="Geometry")
mesh1 = system1.GetContainer(ComponentName="Mesh")
component1 = system1.GetComponent(Name="Mesh")

import os

geometry1.Edit()
mesh1.Edit()

geometry1.SendCommand(Command="""ag.m.NewSession (1);
ag.gui.CreateImport ("C:/...................x_t");
agb.regen();
ag.gui.PickFilter(5, true);
ag.gui.SelectAll();
ag.m.FormBodyGroup();""")

component1.Update(AllDependencies=True)
os.rename("C:/................/dp0/FFF/MECH/FFF.msh","C:/............msh")
ICS is offline   Reply With Quote

Old   August 29, 2013, 07:29
Default
  #12
New Member
 
Join Date: Sep 2012
Posts: 26
Rep Power: 4
Nigirim is on a distinguished road
Hello ICS and others,

I have found a way to export the mesh per script in any given format ansys meshing can export. You can take a look here to see what i have found Export fluent mesh via script

Greets Nigirim
Nigirim is offline   Reply With Quote

Old   September 8, 2013, 19:40
Default
  #13
ICS
New Member
 
Join Date: Aug 2013
Posts: 7
Rep Power: 4
ICS is on a distinguished road
Thanks for your help Nigirim !!!
ICS is offline   Reply With Quote

Old   September 30, 2014, 14:23
Default New to ansys meshing
  #14
New Member
 
Bing Wang
Join Date: Sep 2014
Posts: 2
Rep Power: 0
icyking06 is on a distinguished road
Hi everyone

I have a similar problem that seems already solved by you guys. Does anyone want to share some clues?

My problem is how to operate meshing by script. Basically I wonder how can I select faces and set sizing number and mesh in the end.

It seems that we can do it with JScript instead of journal. If so, where can I find documentation about JScript for Meshing?

Thank you all.
icyking06 is offline   Reply With Quote

Old   November 6, 2014, 23:56
Default
  #15
Senior Member
 
Join Date: Apr 2014
Location: On holidays till mid Oct'15!
Posts: 278
Rep Power: 4
Kapi is on a distinguished road
Hi IcyKing06,

You have to first find out Partid and topoid and then use forceselect to select faces

Quote:
SM.ForceSelect(partID[i], aTopoId)
sizing can be scripted by this

Quote:
ds.Script.doInsertMeshSize()
and meshing can be done like this

Quote:
ds.Script.doModelPreviewMesh()
Hope this helps in your scripting!



Cheers
Kapi
Kapi is offline   Reply With Quote

Old   November 10, 2014, 15:52
Smile AutoMeshing in ANSYS WorkBench
  #16
New Member
 
Alex Horlock
Join Date: Nov 2014
Posts: 1
Rep Power: 0
AlexHorlock is on a distinguished road
Dear All,

We are a pair of university students who have spent a bit of time on this subject and also found the lack of documentation disappointing. The good news is it is certainly possible and easy(ish) once you know how, but just difficult to get the syntax right... A good starting point is this Thesis by
Bhanoday Reddy and Rainel González Brioso
http://liu.diva-portal.org/smash/get...162/FULLTEXT01

Their Appendix 2 pretty much covers the process. Watch out for the semi-colons which we don't think do anything/ stop the program running. Thanks for all the help from above, hope this adds to the knowledge.

Cheers
namsivag likes this.
AlexHorlock is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
engrid -> save as .stl with boundarie codes Zymon enGrid 31 August 29, 2011 13:40
[ICEM] Hexa Mesh Smoothing Jules ANSYS Meshing & Geometry 6 December 4, 2010 19:00
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
basic of mesh refinement arya CFX 4 June 19, 2007 12:21
Y - pipe mesh gene. macro? Anne Rasmussen Main CFD Forum 0 June 14, 2002 08:21


All times are GMT -4. The time now is 09:04.