|
[Sponsors] |
February 20, 2015, 04:30 |
Script for Ansys meshing
|
#1 |
New Member
Riadh
Join Date: Feb 2015
Posts: 3
Rep Power: 11 |
Hi
I am working on the optimization of a heat transfer system. I will couple an optimization code (developed in matlab) with a heat transfer system model (developed in ansys workbench). I have already developed a Workbench journal code to automatically carry out the process of fluid flow simulation with FLUENT. However, the Ansys meshing is not accessible through the Workbench journal code. I have to develop a jScript code to modify the mesh parameters (sizing, inflation), but i didn't find any information in Ansys meshing guide. Could you help me please to develop this JScript code. Could you send me an exemple if you have? Best Regards |
|
February 22, 2015, 21:00 |
|
#2 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Riadh,
Welcome to forum. You have to create a .JS file for mesh which you can access from the .WBJN file. In that .js file you can make function for sizing or inflation like this... For sizing: Code:
ds.Script.doInsertMeshSize(); // command for adding new Sizing Function ListView.ActivateItem("Scoping Method"); ListView.ItemValue = "Named Selection"; ListView.ActivateItem("Named Selection"); ListView.ItemValue = "All_EDGE_Name"; ListView.ActivateItem("Type"); ListView.ItemValue = "Element Size"; ListView.ActivateItem("Element Size"); ListView.ItemValue = "0.0003"; ListView.ActivateItem("Behavior"); ListView.ItemValue = "Hard"; ListView.ActivateItem("Bias Type"); ListView.ItemValue = "No Bias"; the function and its parameters can be accessed my "Listview" once you have the function by which it is called. In this case it was "DoInsertMeshSize()" Similarly For Inflation you have the below function and you can add its parameters by "Listview" just like above depending upon your requirement. Code:
ds.Script.doInsertInflation(); You can search CFDonline and check Ansys Portal as well for such codes. Hope it helps Cheers KAPI |
|
February 23, 2015, 08:54 |
|
#3 |
New Member
Riadh
Join Date: Feb 2015
Posts: 3
Rep Power: 11 |
Dear Kapi
Thank you for your reply, it is very helpful!! I am looking if there is a command to expand the Sizing group of controls (clicking the “+” sign to the left of the word Sizing) and change for example the Curvature Normal Angle (see attached figure). I tried ListView.ActivateItem("Sizing") but i didn't work. Best Regards! |
|
February 23, 2015, 18:58 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Riadh,
What you are asking is global Sizing under mesh. What I told you in previous post is actually Sizing function which you can get by right click mesh and it will open up different functions which you can add to your geometry like Sizing, methods, inflation and things ( Mesh>Insert>Sizing) If you are looking for localized sizing function then please insert sizing function rather than changing the global sizing and use the code which I gave you. ps: to get into Mesh global setting you cannot use Listview, you need different function. Cheers KAPI |
|
February 23, 2015, 20:00 |
|
#5 |
New Member
Riadh
Join Date: Feb 2015
Posts: 3
Rep Power: 11 |
Dear Kapi
I agree with you, actually I am looking for the function which changes the global sizing (not the localized sizing function). Do you know this function, it's the last command i need. Riadh |
|
February 24, 2015, 18:12 |
|
#6 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Riadh,
Yes I can help you with global function as well. Basically for global changes, you need to function called "meshGroup" It helps in listing all the global properties of mesh. The below code changes global mesh minimum sizing and Maximum sizing. Code:
meshGroup.MinSizeSF = 0.01; meshGroup.MaxSizeSF = 0.25; Hope it helps complete your project. Have a good one! Cheers KAPI |
|
April 4, 2016, 12:17 |
|
#7 |
New Member
Join Date: Apr 2016
Posts: 1
Rep Power: 0 |
I know this thread is over a year old but I did find a way in 16.1 to use ListView for setting global mesh parameters. By searching through various .js files and Ans.Common.ControlsCOM.dll, I found that you need to select the group first and then use the 'Expand' property. Then you can just use ListView.ActivateItem and ListView.ItemValue like usual.
In this example I changed the Physics Preference, Relevance Center, Max Face Size, and Growth Rate options. It looks like ListView.FindGroup(n) returns the groups in the order that they appear ('Display' first, 'Defaults' second, 'Sizing' third, and so on). I hope this can be of help to someone. Code:
//Get DesignSpace object var DS = WB.AppletList.Applet("DSApplet").App; //Get 'Mesh' control group var Mesh_Mod = DS.Tree.FirstActiveBranch.MeshControlGroup; //Get the ListView object so we can change the setting for the mesh sizing var ListView = DS.Script.lv; //Select 'Mesh' from the tree DS.Script.SelectItems(""+Mesh_Mod.ID); //Set global mesh options //Set options in 'Defaults' group var lGroupDefaults = ListView.FindGroup(2); //Get the 'Defaults' group lGroupDefaults.Expand = 1; //Expand group ListView.ActivateItem("Physics Preference"); //Set 'Physics Preference' option to 'CFD' ListView.ItemValue = "CFD"; lGroupDefaults.Expand = 0; //Collapse group //Set options in 'Sizing' group var lGroupSizing = ListView.FindGroup(3); lGroupSizing.Expand = 1; //Expand //Set sizing options ListView.ActivateItem("Relevance Center"); ListView.ItemValue = "Fine"; ListView.ActivateItem("Max Face Size"); ListView.ItemValue = "1e-04"; ListView.ActivateItem("Growth Rate"); ListView.ItemValue = "1.05"; lGroupSizing.Expand = 0; //Collapse |
|
November 30, 2016, 04:40 |
mesh a geometry via script sizing and worksheet for multizone
|
#8 |
New Member
giosue giacoppo
Join Date: Sep 2012
Posts: 9
Rep Power: 14 |
Dear All
Due to your knowledge in anys and scripting I suppose you are the right person to ask this question... I'm trying to automate the meshing of a geometry by using a conformal mesh. To do so manually, I sliced the domain into several blocks. 1)Defined several named selection 'via worksheet options" 2)defined several sizing controls referred to previuos defined named selection. 3)Applied Multizone Method to all bodies 4) Defined a worksheet for meshing in precise order Any suggestion on how to do the same via scripting? Kind regards |
|
January 4, 2018, 11:43 |
|
#9 |
Member
Join Date: Jan 2018
Posts: 34
Rep Power: 8 |
Does anyone know how to get all the functions that can be added after Ds.Script?
|
|
March 21, 2018, 12:03 |
|
#10 |
New Member
Krishna praveen
Join Date: Mar 2018
Posts: 6
Rep Power: 8 |
||
September 11, 2018, 13:06 |
Calling Js File from Workbench file
|
#11 |
New Member
Andrew M
Join Date: Apr 2018
Location: Toronto
Posts: 18
Rep Power: 8 |
Once you have developed the .JS file for controlling your meshing parameter how do I call it from the workbench file or the ANSYS command window?
Does anyone have an example of there workbench code? |
|
January 9, 2019, 18:06 |
|
#12 |
New Member
Andrew M
Join Date: Apr 2018
Location: Toronto
Posts: 18
Rep Power: 8 |
I know this post is old but did you ever work out this process ?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Workbench] SCRIPT for geometry / meshing | Kapi | ANSYS Meshing & Geometry | 12 | April 16, 2015 19:48 |
[ICEM] Problem with ICEM Script Meshing | asal | ANSYS Meshing & Geometry | 2 | March 23, 2013 20:11 |
[ICEM] script for cylinder hexa meshing in ICEM | Far | ANSYS Meshing & Geometry | 0 | May 25, 2012 08:55 |
Volume Meshing & Face Meshing? singularity of grid | ken | FLUENT | 0 | September 4, 2003 12:08 |