|
[Sponsors] |
October 13, 2016, 04:02 |
Batch Meshing
|
#41 |
New Member
Levente Lázár
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
Hi guys,
in my new workplace I have to use ANSA (only Ansys programs). I've never used this program, in the last 1,5 week I made more tutorials. I have to use in the future the scripts, and I am trying to make some scripts. The help of the sripting in ANSA is very helpful, and with the examples in the help I could make some easy scripts, and they work. But I had a question. I made a small script for the batch meshing. This make a new mesh scenario, and made some filters. It's ok, the program make the scenario and the filters, but don't click on the "Apply" button. (If I open the window, and I click on the "Apply", the filter works.) I found some function to apply something, but don't work, because the object is not right. Code:
import ansa from ansa import batchmesh from ansa import base from ansa import mesh from ansa import guitk What's the problem? def batch_meshing(): mesh.EraseMesh() scenario = batchmesh.GetNewMeshingScenario('Meshing_Scenario', 'PIDS') filter = batchmesh.AddFilterToScenario('Id', 'equals',' 1', scenario, match='any', case_sensitive='yes', filter_name='Szuro') filter = batchmesh.AddFilterToScenario('Id', 'equals',' 6', scenario, match='any', case_sensitive='yes', filter_name='Szuro') filter = batchmesh.AddFilterToScenario('Id', 'equals', '7', scenario, match='any', case_sensitive='yes', filter_name='Szuro') ansa.guitk.BCListViewFilterApply(filter) batchmesh.RunAllMeshingScenarios(60) batch_meshing() Any ideas? Thanks, guys! Levente |
|
October 13, 2016, 06:08 |
Batch Meshing - again
|
#42 |
New Member
Levente Lázár
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
Hallo,
I didn't write, that I use ANSA 17.0.0. Of course I have an other option to mesh with batch. Code:
import ansa from ansa import batchmesh from ansa import base from ansa import mesh from ansa import guitk def batch_meshing(): mesh.EraseMesh() scenario = batchmesh.GetNewMeshingScenario('Meshing_Scenario', 'PIDS') PID1 = base.GetEntity( ansa.constants.FLUENT, "__PROPERTIES__", 6) PID2 = base.GetEntity( ansa.constants.FLUENT, "__PROPERTIES__", 5) PID3 = base.GetEntity( ansa.constants.FLUENT, "__PROPERTIES__", 8) ansa.batchmesh.AddPartToMeshingScenario(PID1, scenario) ansa.batchmesh.AddPartToMeshingScenario(PID2, scenario) ansa.batchmesh.AddPartToMeshingScenario(PID3, scenario) batchmesh.RunAllMeshingScenarios(60) batch_meshing() But if somebody knows the answer for my previous question, I would be happy, if (s)he would tell it. Have a nice scripting! Levente |
|
October 13, 2016, 06:52 |
|
#43 |
Senior Member
Vangelis Skaperdas
Join Date: Mar 2009
Location: Thessaloniki, Greece
Posts: 287
Rep Power: 21 |
Just to mention that in v17 there is a new Tutorial under the CFD category called scripting automation. Have you checked it out?
It may not answer your specific question, but could sure help. |
|
October 13, 2016, 08:03 |
|
#44 |
New Member
Levente Lázár
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
Hi,
thanks for your answer. I have used for help mostly the script help in the v17 Ansa. (Where I can write the scripts, in the "Output window".) I saw also this tutorial (about a drone), what you say. And also the Scripts_Collection_Catalogue.pdf, but they couldn't help me. I found earlier in the folder of Ansa an other folder named "scripts", where there are more folders, and in the folders a lot of scripts. I saw some scripts in the "CFD" and "Mesh" folders, but they couldn't help in this problem. After these I registered here. (Earlier I read only this page for Icem.) So, the second version, that I wrote today, worked in this geometry, but later I will get difficultier geometries (with more 100 faces), and I can't write every PID ID-s, but a filter can be good, if I give the keywords well. (I can choose more faces with one line in the script with a filter.) And an other question. In this line I use "ansa.constants.FLUENT" as deck (?). What's this? Code:
PID1 = base.GetEntity( ansa.constants.FLUENT, "__PROPERTIES__", 6) (I can write other words too instead of FLUENT. Note: I will use Star CCM+.) Thank you! Levente |
|
October 14, 2016, 05:08 |
|
#45 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 12 |
Hi,
After creating your filters in ANSA scripting you can apply them by using the batchmesh.DistributeAllItemsToScenarios() script function. It is the same as clicking the "Autoload" button in the Batch Mesh Manager window. The following code will create the three filters and apply them. Code:
import ansa from ansa import batchmesh from ansa import base from ansa import mesh from ansa import guitk def batch_meshing(): mesh.EraseMesh() scenario = batchmesh.GetNewMeshingScenario('Meshing_Scenario', 'PIDS') filter = batchmesh.AddFilterToScenario('Id', 'equals',' 1', scenario, match='any', case_sensitive='yes', filter_name='Szuro') filter = batchmesh.AddFilterToScenario('Id', 'equals',' 6', scenario, match='any', case_sensitive='yes', filter_name='Szuro') filter = batchmesh.AddFilterToScenario('Id', 'equals', '7', scenario, match='any', case_sensitive='yes', filter_name='Szuro') batchmesh.DistributeAllItemsToScenarios() batchmesh.RunAllMeshingScenarios(60) batch_meshing() Regarding your question about the "ansa.constants.FLUENT" expression. This is used to define the Deck that you will be working on. Each ANSA entity is being identified by a corresponding keyword. For example the keyword for faces is "FACE" and it is common for all decks. However, other entities, such as shell PIDs, have different keywords for different decks. For OpenFOAM, the keyword is "SHELL_PROPERTY", but for Nastran deck for example, the keyword is "PSHELL". As in many functions you need to define this keyword in order to interact with ANSA entities (collect them, manipulate them etc), the deck must also be defined. The important thing is to be consistent throughout your code. If you will be using one deck, you need to make sure that you always use that deck's keywords. ANSA entities' keywords can be found by opening any entity's card (Press F12 to open the database browser, then double click on an entity, e.g. PROPERTY, to open its card, and see the entity's keywords inside brackets). Hope this helps. Please let me know if you face any other issues with your code. Best regards, Grigoris |
|
October 14, 2016, 08:36 |
|
#46 |
New Member
Levente Lázár
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
Hi greg,
thank you for your answer! The script works. I looked for this line. And everything is clear, I understood this "decking". Thanks again! Levente |
|
April 20, 2017, 09:24 |
Does ANSA scripting support Multiprocessing
|
#47 |
New Member
TELANGANA
Join Date: Apr 2017
Posts: 2
Rep Power: 0 |
I have been trying alot ways to get the Multiprocessing code to execute in ansa but no luck; could any help me out how to use multiprocessing module in ansa using python, by which it will help to reduce the execution time a lot ..just for eg. i have a list with 10000 items and i want to divide the list and run the logic further in different processes (Threading will also do)...
|
|
February 21, 2019, 05:09 |
help on scripting
|
#48 |
New Member
Kcm
Join Date: Feb 2019
Posts: 4
Rep Power: 7 |
Hello ;
currently , i have some projects with ANSA, and i am trying to automate some operations using python, I wonder if you have some free script that I can use to fit my needs, and I'll be grateful if you have a script which can read coordinate from an xlsx file and generates SPRING (im working with Deck>PAMCRASH) you can find below the current script, till now i have succeeded to: - read & create POINTS from (csv) file - create NODES and SPRINGS from those nodes but i can't find the link between the two parts ( i need to convert the POINTS from csv file to NODES or Create PRINGS from POINTS directly) ************************************************** ** import ansa from ansa import * def main(): # import csv file and create POINTS file = 'C:/Users/ejjed/Desktop/Scripting/Test.csv' list_points = ansa.base.ImportCSVFileCreatePoints( file ) # create set-NODES vals = {'Name':'new set'} set = base.CreateEntity(constants.NASTRAN, "SET", vals) # create NODES nodes_list = [] for i in range(5): vals = { "X": i*50, "Y": i*50, "Z": i*50 } n = base.CreateEntity(constants.PAMCRASH, "NODE",vals) base.AddToSet(set, nodes_list) # create SPRING from NODES vals_property = {"IDPRT":111, "Name": "new property"} property =base.CreateEntity(constants.PAMCRASH,"PART_SPRING ",vals_property) vals_element = {"M":1,"IPART":111,"N1":1,"N2":5,} SpringEle = base.CreateEntity(constants.PAMCRASH, "SPRING",vals_element) ************************************************** ** cordially |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Script: problems with face names | Maweil | ANSYS Meshing & Geometry | 3 | April 16, 2019 10:10 |
CentFOAM Python Script Installation: Error | socon009 | OpenFOAM Installation | 2 | May 26, 2012 10:36 |
[Commercial meshers] ANSA hexblock mesh to OpenFOAM | yosuu | OpenFOAM Meshing & Mesh Conversion | 7 | October 22, 2011 07:18 |
[Commercial meshers] Output deck from ANSA for OpenFOAM use | Kattie | OpenFOAM Meshing & Mesh Conversion | 10 | February 2, 2011 08:46 |
Perl script for intialisation | pratik mehta | CFX | 2 | September 10, 2008 04:09 |