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/)
-   -   Automating the Named Selctions in WorkBench (http://www.cfd-online.com/Forums/ansys-meshing/89583-automating-named-selctions-workbench.html)

Mostapha June 16, 2011 21:37

Automating the Named Selctions in WorkBench
 
Hi,

I'm trying to automate the process of importing, meshing and running a CFD simulation for a parametric study. In an iterative process, geometry is continuously being updated, re-generated, and re-tested. So far I am able to create the *.sat file, but need to name the inlet and outlet and set the boundary conditions. The whole process must be automated.

The problem is that I cannot name the selections in the right way yet. As far as I understand there is no way to do NamedSelections using the WorkBench commands. I was able to use a .js code to name the surfaces by their area, but this has limitations. I need one more properties such as Face Normal or Face Starting Coordinates to recognize between the inlet and outlet which has the same areas. I've tried Normal, SurfaceNormal, SurfaceAzimuth, etc but Ansys gives me the undefined error!

This is part of the .js file in which I am trying to collect face normals and areas and name them based on these two variables. I don’t know what to use in this line to get the normal: face_normal.push(faces(h).??????);
Here is the part of the java script:




var part = SM.PartMgr.PartById(part_id);
var brep = part.BRep;
body = brep.Cell(topo_id);

var face_ids = new Array();
var faces = body.Faces;
for (var f = 1; f <= faces.Count; f++) {
face_ids.push(faces(f).Id);
}

face_id_map[i - 1] = new Array(2);
face_id_map[i - 1][0] = part_id;
face_id_map[i - 1][1] =
face_ids.slice(0, face_ids.length);

var face_normal = new Array();
var faces = body.Faces;
for (var h = 1; h <= faces.Count; h++) {
face_normal.push(faces(h).?????);
}

var face_area = new Array();
var faces = body.Faces;
for (var j = 1; j <= faces.Count; j++) {
face_area.push(faces(j).Area);
}
}
SM.Clear();
var name = null;
var inletarea = 400
for (var i = 0; i < face_id_map.length; i++) {
var part_id = face_id_map[i][0];
var face_ids = face_id_map[i][1];
for (var j = 0; j < face_ids.length; j++) {
if (Math.abs(inletarea-face_area[j]) < 22)
{
SM.Clear();
name = face_normal[j] + '_' + face_area[j].toString();
SM.AddToSelection(part_id, face_ids[j], false);
SC.addNamedSelection(false, name, SC.id_NS_UnknownMultiCriterion);
}
}

Thanks in advance,

Mostapha

sac June 17, 2011 04:46

"As far as I understand there is no way to do NamedSelections using the WorkBench commands."

There is a way...

If your using version v13.0 you can do named selections via criteria.

e.g.

  • You can define an x,y,z location of an entity to pick it.
  • You can define a explicit size or a range of sizes to pick the entity (edges, faces, bodies, verts)
As well as many other ways of doing things.

You can also say ok I have this group - please add or take away entities from this group for example.

To try this out when creating a named selection in meshing choose worksheet instead of geometry in the details window.

Mostapha June 17, 2011 11:18

Thank you so much Sac.

I'm using V.12. I want to do all of these using the command line. Is it possible ri work with the worksheet by command line? I'm not sure if I can select work sheets when I import a .sat geometry. It's available when you use design modeler to make your model.

I do like your other suggestion. I removed other entities based on their areas. So the question is how to select between inlet and outlet which are two surfaces with the same area using a java script code? (I gues it should be their coordinates or their normal?)

Mostapha

sac June 17, 2011 12:38

Quote:

Originally Posted by Mostapha (Post 312489)
Thank you so much Sac.

I'm using V.12. I want to do all of these using the command line. Is it possible ri work with the worksheet by command line?

Before we go any further - Where are you generating your initial geometry?

In a CAD system? In Design Modeler?

Mostapha June 17, 2011 14:39

Hi Sac... In a CAD system: Rhino.

sac June 17, 2011 16:46

OK then there are three ways you could approach this.

The first is to move to v13.0 and use named selections via criteria to do exactly what your doing with the javascript code.

The second is to carry on with the javascript code to replicate what is there by default in v13.0 in v12.0.

In both case I'd be using a range of x,y,z (so basic between a and b) to make up for the change is inlet and outlet size as you "parameterise" your model.

The other way is to buy ANSYS spaceclaim direct Modeler use it to make the modifications. The reason I'd recommend this over Design Modeler in this case is because its good at making changes from "static" cad files (i.e. static files such as .sat or .iges files). DM could also do the job if you let it re-make the parts of that make up your inlet or outlet (or similar methodology).

Mostapha June 17, 2011 16:56

Thanks... The first option is impossible now!

I want to do the second one but I don't know how I should write the .js code to define the range of x,y and z. Lack of knowledge in Javascriptig!! However hopefully I can figure it out if you can guide me to an example.

The third option sounds interesting. I will try it if I cannot solve it with the second strategy... Again thank you so much for your help!

Mostapha June 19, 2011 18:42

Fluid/Solid
 
So the third suggestion was so helpful. The only problem left is to change the body from Solid to Fluid using WB scripting... I looked both in WorkBench Scripting Guide and Scripting API in DesignModeler documents but I couldn't find the command...

Thanks in advance!

sac June 20, 2011 10:44

Quote:

Originally Posted by Mostapha (Post 312661)
So the third suggestion was so helpful. The only problem left is to change the body from Solid to Fluid using WB scripting... I looked both in WorkBench Scripting Guide and Scripting API in DesignModeler documents but I couldn't find the command...

Thanks in advance!

I don't have time currently to look into it for you. Sorry :(

However...

Read this blog:

http://www.padtinc.com/blog/post/201...TO-Part-1.aspx

There are five parts and this is just the link to the first. If a scripting command exists in the meshing or DM applications this should help you find it.

Mostapha June 20, 2011 14:06

Hi Sac,

I've read this blog when I had the previous problem. Since I haven't administrative account I cannot change anything on the C drive so I couldn't use the cool "debugger" concept. I will try to try other way to implement the idea anyway.

I should add I tried the ID_* and I know it is "ID_Phase" but I couldn't find the do*command for that...

Thanks again for your help. I really appreciate it!

Mostapha

Mostapha June 20, 2011 21:45

An update
 
So I've tried ID_Fluid and ID_FluidSolid as well but still I cannot find any "do*" command in any file in all the Ansys folders!!! :(:(:(

icyking06 August 11, 2015 16:27

Hi. Does anyone solve this problem now? I have the same difficulty in naming the surfaces with vertices, hopefully.


All times are GMT -4. The time now is 21:25.