|
[Sponsors] |
November 16, 2011, 00:47 |
Need help writing .wbjn remesh script file
|
#1 | |
New Member
Join Date: Nov 2011
Posts: 5
Rep Power: 15 |
Hi guys, yet another student here trying to setup a basic flow simulation for an IC engine. I am doing this simulation using Ansys 13 and the default CFX fluid flow analysis template.
I've made it most of the way through the setup now and have run basic simulations to check the mesh motion and deformation is all working correctly. As expected, part way through the simulation, the mesh quality becomes an issue due to the large deformations involved. I'm now trying to setup the user-defined remeshing. I have the interrupt control set to interrupt at a specific time (t>=0.0014s) and I have a mesh file already setup to suit the position of the geometry at that point. It all seems pretty straight forward but where I'm stuck is the "External Command" section in the "Remeshing" tab. This section requires that I write a".wbjn remesh script". I have very little experience when it comes to writing code and no experience with Fortran or anything along those lines. Therefore, I don't even have a basic understanding of how to do this. I have gone through all the tutorials, help files and also searched these forums but there is a bit of a void of information in this area. There are tutorials on how to setup remeshing but they only go into detail for using the auto remeshing (with an ICEM mesh replay file). I'll save you the details of why I don't want to do it that way. I am confident I have everything setup correctly and only need help with this "External Command" section. If anyone could please give me a basic example of how to write this script file, it would be very much appreciated. I don't even know what a wbjn file is so I'm not even sure if this is something I should be writing in part of Ansys or if I need to use an external program. I'm aware that the file paths and such details will be different but I can figure that part out easily enough. The only info I have to go off so far is what's stated in the help files: Quote:
|
||
November 16, 2011, 03:22 |
|
#2 |
New Member
Liu Jian
Join Date: Nov 2011
Posts: 3
Rep Power: 15 |
Using workbench remeshing will waste a lot of time, because open and update workbench is very slow. My English is too poor to help you,if you can speak chinese,you can watch this:
http://blog.sina.com.cn/s/blog_90affd98010112d7.html |
|
November 16, 2011, 06:33 |
|
#3 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144 |
While it does not answer your question this looks like a good post to plug my PhD thesis from long ago: http://hdl.handle.net/2100/248
I have no experience in remeshing with CFX so cannot help your question. But hopefully my thesis is a useful reference and might be able to help you.... and you can always ask the author if you don't understand something, you don't get that with many books |
|
November 17, 2011, 10:32 |
|
#4 | |
New Member
Join Date: Nov 2011
Posts: 5
Rep Power: 15 |
Thanks for the replies. I really need to use the user-defined remeshing so I can have the valves coming to a complete close. Trying to do an auto remesh like that would cause problems, I believe. I also have no experience with ICEM and don't really have enough time left to figure it out before my thesis is due.
Anyway, I made a little progress. I figured out what the .wbjn file is. For future reference: The .wbjn file required in the external command just refers to a journal file that you make in Workbench itself. Just go to File>Scripting>Record Journal and save it whereever. The journal is then recording every action you make in Workbench until you go back and click "Stop Recording Journal". So once you've started the recording, go and load the new geometry file that you wish to use for the remesh, update the remesh and if required, open the meshing program and make adjustments to suit the new geometry position. Once everything is updated,stop the journal recording and the file is saved. Then you can enter the location of the journal file in the external command section (as it is explained in my quote from the help section above). Also, make sure you use the quotation marks around the path to the .bat file that opens Workbench (exactly as it is written in the help file I quoted). This is important because there's a space in the file name "Ansys Inc" so if you don't use quotes, it tries to find a file just named "Ansys" and the remesh fails. Ok, so where I'm stuck now is that I only know how to get it to remesh once and choose one file. I need it to remesh multiple times throughout the simulation, meaning the remesh script needs to find out what point in time the simulation is at and use that info to decide which geometry file to load. Below is my current journal file that can successfully run the first remesh. Can anyone help me with adding the code required to tell it how to select the correct geometry file for each remesh, based on the current simulation time? The simulation needs to remesh at t=0.0028[s] and t=0.004[s]. The names of the geometry files follow the same convention as the file seen in the script below (Geometry_t=0.0028.agdb and Geometry_t=0.004.agdb) Quote:
|
||
November 17, 2011, 15:43 |
|
#5 |
Member
anonymous
Join Date: Jun 2011
Posts: 58
Rep Power: 15 |
Hey Rallyeee
This is a problem i've been trying to deal with for a while. By the looks of it you found the tutorial on how to perform an workbench remesh but have are confused at the same point everyone else is, during the script phase. By the sounds of it, you already have all your meshes made. If that is the case, and i'm not 100% sure on this, I do not believe you need to perform all the same steps as in the workbench remesh tutorial. My understanding is that the point of the "remesh" configuration and how the tutorial works, is it allows you to have workbench create a new mesh based of the latest output of the solver. In essence, in your .wbjn script, you can write it to send the output geometry to workbench, open workbench and read the new geometry then remesh the solution based of the new geometry. I dont think this is what you are really trying to do so you should not have to go through this step. With that being said, I have not figured out how to input a different mesh without using this type of method. If you have found a way for it to apply a new mesh during a single time, then to do it multiple times my simple solution would be to create a new stop criteria and configuration for each stop criteria. Then you could simply point the remesh configuration for each stop to a specified mesh file. How I have solved the .wbjn issue myself in my simulations is to skip the .wbjn step and instead direct the solver to just open my workbench file. From there, instead of having the .wbjn file create my new mesh, i simply do it manually. Once i finish, i just save my file and close workbench and once workbench is closed, the solver reads the new mesh, interpolates the results and continues. It is not the most efficient as it requires you to watch the simulation and manually update things however it gets the job done. If this interests you then feel free to post here again or pm me and i can explain this further. |
|
November 17, 2011, 16:50 |
|
#6 |
New Member
Join Date: Nov 2011
Posts: 5
Rep Power: 15 |
Hi Doginal, thanks for the reply. I think I've already started doing what you mentioned, I'm setting it up to run multiple configs and it has a separate script file for each config. So it can just do one remesh each config and I don't have to figure out any fancy coding.
It's not the most computationally efficient way but it's the most efficient in terms of my time. I'm interested to hear how you do each step manually. If I knew I could do it that way, I would have long ago. I don't mind if I need to come back to the computer every time it needs a remesh. Do I literally just leave the wbjn file out of the external command section? |
|
November 17, 2011, 18:01 |
|
#7 |
Member
anonymous
Join Date: Jun 2011
Posts: 58
Rep Power: 15 |
You dont quite leave off the .wbjn script
The way the code is in the tutorial for the external command External Command: "C:\Program Files\ANSYS Inc\v130\Framework\bin\Win64\runwb2.bat" -B -R C:\<Path To Remesh Script>\WB_Remesh.wbjn. the -B represent, run workbench in batch mode. Batch mode simply means it runs workbench without opening any of the GUI so you dont see it happening. the -R tells it to run a script once workbench has opened (in this case in batch mode) Instead of just deleting that part replace the -B and -R with -F and replace the path to the .wbjn file to your workbench file (.wbpj). -F means to open workbench like normal so it will open your workbench file for you to use. manipulate your geometry and generate your mesh. The geometry manipulation can be simplified by monitoring some point in the solver that tracks any motion and using a parameter in your geometry. This will allow you to edit the geometry without actually opening your geom file. Also i should note, when i do this, i open and run cfx.pre and cfx.solver as standalone application and my workbench contains only the geometry and mesh. To summarize Mesh file is same as tutorial External Command: "C:\Program Files\ANSYS Inc\v130\Framework\bin\Win64\runwb2.bat" -F C:\<Path To Remesh Script>\WB_Remesh.wbpj. Hope this helps and let me know if you have any other questions DM |
|
November 17, 2011, 23:08 |
|
#8 |
New Member
Liu Jian
Join Date: Nov 2011
Posts: 3
Rep Power: 15 |
Maybe this will help you, read it carefully.
# encoding: utf-8 SetScriptVersion(Version="13.0") Open(FilePath="C:/Documents and Settings/jian.liu/Desktop/workbench-remesh/1.wbpj") system1 = GetSystem(Name="Post") results1 = system1.GetContainer(ComponentName="Results") results1.Edit() results1.SendCommand(Command=r"""DATA READER: Clear All Objects = false Append Results = true Edit Case Names = false Open to Compare = false Multi Configuration File Load Option = Last Case Open in New View = true Keep Camera Position = true Load Particle Tracks = true Files to Compare = END DATA READER: Domains to Load= END > load filename=C:\Documents and Settings\jian.liu\Desktop\workbench-remesh\Unnamed_001.dir\res, multifile=append""") results1.SendCommand(Command="""VIEW:View 1 Camera Mode = User Specified CAMERA: Option = Pivot Point and Quaternion Pivot Point = 1.3113e-006, 0, 0.005 Scale = 0.741036 Pan = 0, 0 Rotation Quaternion = 0.279848, -0.364705, -0.115917, 0.880476 END END EXPRESSION EVALUATOR: Evaluated Expression = Angle END > forceupdate EXPRESSION EVALUATOR""") results1.Exit() designPoint1 = Parameters.GetDesignPoint(Name="0") parameter1 = Parameters.GetParameter(Name="P1") designPoint1.SetParameterExpression( Parameter=parameter1, Expression="P2") system2 = GetSystem(Name="SYS") component1 = system2.GetComponent(Name="Mesh") component1.Update(AllDependencies=True) Save( FilePath="C:/Documents and Settings/jian.liu/Desktop/workbench-remesh/1.wbpj", Overwrite=True) |
|
November 18, 2011, 01:13 |
|
#9 |
New Member
Join Date: Nov 2011
Posts: 5
Rep Power: 15 |
Thanks for the help guys, I'll have to mess around some more and see how I go. I'm trying to run this all off a laptop so the sims take a while. I'll no doubt be back with more questions.
|
|
January 20, 2012, 05:29 |
|
#10 |
Senior Member
|
Hi everone. I thought I'd end the confusion about the script file used in EDR's tutorial. The missing wbjn script from http://www.edr.no/blogg/ansys_blogge...nch_cfx_remesh contains the following code:
Code:
import os import string import subprocess ################################################################################ # Get information from CCL file (WB project name) ################################################################################ f=open('ccl','r') lines = f.readlines() f.close # Check for "Replacement Mesh File" in CCL nl =0 allline = '' for line in lines: if (nl > 0): if (string.find(line,"=") == -1 and string.find(line,"END") == -1): allline += line else: nl = 0 if (string.find(line,"Replacement Mesh File =") != -1): allline += line nl += 1 # # Extract project name from replacement mesh file projectfile = allline projectfile = string.replace(projectfile," ","") projectfile = string.replace(projectfile,'\\\n',"") projectfile = string.replace(projectfile,'\n',"") projectfile = string.replace(projectfile,'\\',"/") projectfile = string.replace(projectfile,"ReplacementMeshFile=","") projectfile = string.replace(projectfile,"_files/dp0/global/MECH/SYS.mshdb",".wbpj") print "Project File: ", projectfile print "" ################################################################################ # Extract monitor data from monfile ################################################################################ if (os.path.exists("res")): proc = subprocess.Popen(["cfx5mondata", "-res", "res", "-lastvaluesonly", "-varrule", "CATEGORY = USER POINT"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: print 'ERROR: Result file \"res\" does not exist' sys.exit(0) # Extract monitor data of parameters defined as "ANSYS Paramter *" monitorfile = proc.stdout.readlines() monnames = string.split(string.replace(string.replace(''.join(monitorfile[0]),"USER POINT,",""),"\n",""),",") mondata = string.split(string.replace(monitorfile[1],"\n",""),",") MonValue = {} for name in monnames: monname = string.replace(name,"\"","") MonValue[monname] = mondata[monnames.index(name)] # Control output for mon in MonValue: print "Monitor: ", mon print " Value: ", MonValue[mon] print "" # Error check if (len(MonValue) < 1): print "ERROR: No monitor data available for ANSYS remeshing (name = ANSYS Parameter *" sys.exit(0) ################################################################################ # Run Workbench script ################################################################################ # Open project file SetScriptVersion(Version="13.0") Open(FilePath=projectfile) # Get parameter data currentDP=Parameters.GetFirstDesignPoint() dpProps=Parameters.GetEntityProperties(currentDP) localParameters=dpProps['Parameters'] # Modify Workbench project for param in localParameters: propParam=Parameters.GetEntityProperties(param) print "Parameter: ", propParam['DisplayText'] print " Expression: ", propParam['Expression'] print " Value: ", propParam['Value'] wbMon = propParam['DisplayText'] for mon in MonValue: # Update parameters having names found in CFX monitor data if (wbMon == mon): print " Replaced by value: ", str(MonValue[mon]) currentDP.SetParameterExpression( Parameter=param, Expression=str(MonValue[mon])) # Update Geometry and Meshing system1 = GetSystem(Name="SYS") component1 = system1.GetComponent(Name="Geometry") component1.Update(AllDependencies=True) component2 = system1.GetComponent(Name="Mesh") component2.Update(AllDependencies=True) Save(Overwrite=True) |
|
January 22, 2012, 11:14 |
|
#11 |
New Member
claudia
Join Date: Jan 2012
Posts: 11
Rep Power: 14 |
Hi everybody!
I'm trying to do something like this http://blog.sina.com.cn/s/blog_90affd98010112d7.html but I have to remesh a fluid domain with a solid cylinder rotating in it. I would like to know wich geometrical parameter I should set to create the new mesh! Can somebody help me? Thanks a lot! |
|
January 27, 2012, 13:10 |
|
#12 |
New Member
Join Date: Nov 2011
Posts: 5
Rep Power: 15 |
Hi guys, I'm still slowly picking away at this. I have run many simulations and remeshed many times but have not completed an entire run successfully yet. The main issue is that there are constant license server problems with my University's server. I'm wondering if it's possible to restart a run after it has failed. I have to remesh many times in one simulation and I can never get through them all without the license server dropping out during one of them and causing the solution to fail. Is there any way to process the results files that are left over and start from that point? Or once a solution fails, is the only option to start again from scratch?
|
|
January 29, 2012, 05:56 |
|
#13 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144 |
That sounds like a really hopeless setup. You have to give the IT guys a kick as that is pathetic if they cannot even run a half reasonable licenses server..... I mean - how hard is it? It is just a computer which sits there and does nothing much.
End of soapbox. If you have an unreliable system then all you can do is write frequent full transient results files. Then you can restart from the most recent full results file. But keep a record of how much time you are wasting with this and show it to your professor/supervisor. |
|
February 2, 2012, 04:54 |
replacement file
|
#14 |
New Member
Tom Ou
Join Date: Jan 2012
Posts: 1
Rep Power: 0 |
I am also having problem with the remeshing. I follow your script, and I successfully start the remeshing script.
But the problem is, ANSYS just replaced the old mesh with exactly the same mesh. So I guess I am wroing in setting the replacement file. Does anyone know which file to put in that blank? Thanks so much!!! |
|
February 8, 2012, 09:34 |
|
#15 |
Member
Darren Leong
Join Date: Dec 2010
Posts: 64
Rep Power: 15 |
@Frank0079: Remeshing using Workbench allows both translational and rotational motions whereas ICEM handles only translation.
@Rallyee: Set license preference to use one license for each application instead of sharing. For future runs that crash and generate a result file, you can initialise the run with the res file in order to continue the run. If done correctly, your monitor plot will continue from where it left off. When post-processing, load results as complete history. @ocb00999:refer to the mesh file located in the project dp0 subfolder, e.g. C:\Run\Run_files\dp0\global\MECH\SYS.mshdb. The other thing is to make sure that the name of your data monitors are the same as the parameters in Workbench. @dclaudia85: you might be better off rotating the cylinder and interface it with the outer fluid domain using GGI. Last edited by Darren Leong; February 8, 2012 at 09:44. Reason: added reply to dclaudia85 |
|
February 13, 2012, 18:23 |
|
#16 | |
New Member
Join Date: Jan 2012
Posts: 1
Rep Power: 0 |
hello everybody,
i have a problem with remeshing too. i use ansys 14 to simulate a butterfly valve (rotating around an axis) by using the rigid body solver. due to the motion of the butterfly valve (rigid body) the mesh is deformed in a such way making it impossible to get meaningful results. i somehow need to extract the geometry out of the current results. what i tried to do, is what Doginal suggested. remeshing without a script but doing it manually. Quote:
does anybody know, how to extract the current geometry while the solver is paused? i would be very thankful for any kind of help! (if i would know an angular velocity of 1 degree*s^-1 for example, i could stop after one second set the new angle, create the new mesh and go on) |
||
February 28, 2012, 12:23 |
|
#17 |
Member
sheth roh
Join Date: Jul 2011
Posts: 56
Rep Power: 15 |
Hi,
I am facing similar problems. I need to remesh using user defined functions and I am not expert in coding area. My question is related to the post quoted below, Can we have icem cfd mesh using user defined re meshing setting? I have tried icem reply and it only gave transnational motion. Can you please give some guidelines in resolving this issue. (http://www.cfd-online.com/Forums/cfx...sh-motion.html) |
|
October 25, 2012, 21:08 |
|
#18 |
New Member
Anup
Join Date: Feb 2012
Posts: 5
Rep Power: 14 |
External Command: "C:\Program Files\ANSYS Inc\v130\Framework\bin\Win64\runwb2.bat" -B -R C:\<Path To Remesh Script>\WB_Remesh.wbjn.
Hi, I am trying to do similar problem like the sample tutorial of EDR Blogg with workbench remeshing, but just before remeshing it ended giving a error(attached) indicating there is no batch file exist. Can anyone please help me? |
|
November 13, 2012, 00:52 |
|
#19 | |
Member
Darren Leong
Join Date: Dec 2010
Posts: 64
Rep Power: 15 |
Check the location of your rubwb2.bat, e.g. is your ANSYS v130, 32 or 64 bit?
Quote:
|
||
November 13, 2012, 06:53 |
|
#20 | |
Senior Member
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22 |
Quote:
I would also avoid spaces in the path... |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
2.0.x on Mac OSX | niklas | OpenFOAM Installation | 74 | March 28, 2012 17:46 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
Installation of OpenFOAM-1.6 on Ubuntu 9.10 | marval | OpenFOAM Installation | 2 | March 17, 2010 09:33 |
gcc and executable file from Mac to Linux | simone Marras | Main CFD Forum | 0 | April 8, 2007 16:49 |
Results saving in CFD | hawk | Main CFD Forum | 16 | July 21, 2005 21:51 |