CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (http://www.cfd-online.com/Forums/ansys-meshing/)
-   -   Mesh macro (http://www.cfd-online.com/Forums/ansys-meshing/77886-mesh-macro.html)

hannow July 6, 2010 22:29

Mesh macro
 
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

PSYMN July 15, 2010 21:53

Parametric and Persistent
 
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 July 16, 2010 00:32

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 (Post 267572)
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.


karananand July 16, 2010 00:55

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!!

PSYMN July 16, 2010 01:19

Ahead of the curve.
 
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

hannow July 16, 2010 02:50

Thanks
 
Thanks guys for the info :)

rohit_8481 March 19, 2011 06:37

@Hannow
 
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...

ICS August 17, 2013 17:18

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??

rohit_8481 August 18, 2013 11:58

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 !

ICS August 18, 2013 13:18

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 August 19, 2013 07:15

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")

Nigirim August 29, 2013 07:29

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

ICS September 8, 2013 19:40

Thanks for your help Nigirim !!!

icyking06 September 30, 2014 14:23

New to ansys meshing
 
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.

Kapi November 6, 2014 23:56

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

AlexHorlock November 10, 2014 15:52

AutoMeshing in ANSYS WorkBench
 
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

USER1234 October 8, 2015 13:33

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

Kapi November 15, 2015 20:50

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


All times are GMT -4. The time now is 17:41.