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

Mesh macro

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexHorlock

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 6, 2010, 23:29
Default Mesh macro
  #1
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 17
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, 22:53
Default Parametric and Persistent
  #2
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,663
Blog Entries: 1
Rep Power: 47
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, 01:32
Default
  #3
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 17
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, 01:55
Default
  #4
New Member
 
Karan Anand
Join Date: Feb 2010
Posts: 23
Rep Power: 16
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, 02:19
Default Ahead of the curve.
  #5
Senior Member
 
PSYMN's Avatar
 
Simon Pereira
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 2,663
Blog Entries: 1
Rep Power: 47
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, 03:50
Default Thanks
  #6
New Member
 
Hannow
Join Date: Nov 2009
Posts: 6
Rep Power: 17
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: 15
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, 18:18
Default
  #8
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
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, 12:58
Default
  #9
New Member
 
Rohit Vasudevan
Join Date: Feb 2011
Location: Southampton
Posts: 9
Rep Power: 15
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, 14:18
Default
  #10
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
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, 08:15
Default
  #11
ICS
New Member
 
Join Date: Aug 2013
Posts: 12
Rep Power: 13
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, 08:29
Default
  #12
New Member
 
Join Date: Sep 2012
Posts: 26
Rep Power: 14
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 http://www.cfd-online.com/Forums/ans...ia-script.html

Greets Nigirim
Nigirim is offline   Reply With Quote

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

Old   September 30, 2014, 15: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: Melbourne
Posts: 584
Rep Power: 14
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

Old   October 8, 2015, 14:33
Default
  #17
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 11
USER1234 is on a distinguished road
Hi,

does anybody know how to change the transiition in Workbench mechanical/Mesh into "slow"? I tried this one, but I think the problem is the name of the "transition" feature:

Code:
var SelMesh = DS.Tree.FirstActiveBranch.MeshControlGroup;
DS.Script.changeActiveObject(SelMesh.ID);
SelMesh.TransitionSF.ItemValue = "Slow";
I also habe trouble to select the type of Bias in the Sizing feature:

Code:
DS.Script.doInsertMeshSize();
ListView.ActivateItem("Bias Type");
ListView.ItemValue = "3";
The problem is, that I don#t know how to select the 3rd item in the list/the 3rd type of bias.

I hope somebody can help me out!

Best regards
Max
USER1234 is offline   Reply With Quote

Old   November 15, 2015, 20:50
Default
  #18
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

this will work! in quotes it means the value, without quotes pick the (listno - 1) to get desired list number.
Code:
DS.Script.doInsertMeshSize();
ListView.ActivateItem("Bias Type");
ListView.ItemValue = 2;
Cheers
Kapi
Kapi is offline   Reply With Quote

Reply


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 Off
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 14: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 13:21
Y - pipe mesh gene. macro? Anne Rasmussen Main CFD Forum 0 June 14, 2002 09:21


All times are GMT -4. The time now is 20:14.