CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Need help writing .wbjn remesh script file

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 16, 2011, 00:47
Default Need help writing .wbjn remesh script file
  #1
New Member
 
Join Date: Nov 2011
Posts: 5
Rep Power: 15
Rallyeee is on a distinguished road
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:
The External Command performs the remeshing in Workbench using a .wbjn remesh script. The replacement file should be the mesh file in the project directory.
External Command: "C:\Program Files\ANSYS Inc\v130\Framework\bin\Win64\runwb2.bat" -B -R C:\<Path To Remesh Script>\WB_Remesh.wbjn.
Otherwise I'm clueless, so don't be afraid to dumb it right down for me. This simulation will be part of a report that I intend to post up here once completed so hopefully it will save a lot of questions and confusion surrounding such a simulation in the future.
Rallyeee is offline   Reply With Quote

Old   November 16, 2011, 03:22
Default
  #2
New Member
 
Liu Jian
Join Date: Nov 2011
Posts: 3
Rep Power: 15
frank0079 is on a distinguished road
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
frank0079 is offline   Reply With Quote

Old   November 16, 2011, 06:33
Default
  #3
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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
aero_head likes this.
ghorrocks is offline   Reply With Quote

Old   November 17, 2011, 10:32
Default
  #4
New Member
 
Join Date: Nov 2011
Posts: 5
Rep Power: 15
Rallyeee is on a distinguished road
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:
# encoding: utf-8
SetScriptVersion(Version="13.0")
system1 = GetSystem(Name="CFX")
geometry1 = system1.GetContainer(ComponentName="Geometry")
geometry1.SetFile(FilePath="C:/Users/Chris/Desktop/Uni/Geometry_t=0.0014.agdb")
with Transaction():
component1 = system1.GetComponent(Name="Mesh")
component1.Refresh()
mesh1 = system1.GetContainer(ComponentName="Mesh")
mesh1.Edit()
mesh1.Exit()
component1.Update(AllDependencies=True)
component2 = system1.GetComponent(Name="Setup")
component2.Update(AllDependencies=True)
hzhkm1985 likes this.
Rallyeee is offline   Reply With Quote

Old   November 17, 2011, 15:43
Default
  #5
Member
 
anonymous
Join Date: Jun 2011
Posts: 58
Rep Power: 15
Doginal is on a distinguished road
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.
Doginal is offline   Reply With Quote

Old   November 17, 2011, 16:50
Default
  #6
New Member
 
Join Date: Nov 2011
Posts: 5
Rep Power: 15
Rallyeee is on a distinguished road
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?
Rallyeee is offline   Reply With Quote

Old   November 17, 2011, 18:01
Default
  #7
Member
 
anonymous
Join Date: Jun 2011
Posts: 58
Rep Power: 15
Doginal is on a distinguished road
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
Rosen, jdreamer55 and Miladmk like this.
Doginal is offline   Reply With Quote

Old   November 17, 2011, 23:08
Default
  #8
New Member
 
Liu Jian
Join Date: Nov 2011
Posts: 3
Rep Power: 15
frank0079 is on a distinguished road
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)
Miladmk likes this.
frank0079 is offline   Reply With Quote

Old   November 18, 2011, 01:13
Default
  #9
New Member
 
Join Date: Nov 2011
Posts: 5
Rep Power: 15
Rallyeee is on a distinguished road
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.
Rallyeee is offline   Reply With Quote

Old   January 20, 2012, 05:29
Default
  #10
Senior Member
 
Josef Runsten
Join Date: Jul 2010
Location: Gothenburg, Sweden
Posts: 188
Rep Power: 24
jrunsten will become famous soon enough
Send a message via MSN to jrunsten
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)
crevoise and Zubeldia like this.
jrunsten is offline   Reply With Quote

Old   January 22, 2012, 11:14
Default
  #11
New Member
 
claudia
Join Date: Jan 2012
Posts: 11
Rep Power: 14
dclaudia85 is on a distinguished road
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!
dclaudia85 is offline   Reply With Quote

Old   January 27, 2012, 13:10
Default
  #12
New Member
 
Join Date: Nov 2011
Posts: 5
Rep Power: 15
Rallyeee is on a distinguished road
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?
Rallyeee is offline   Reply With Quote

Old   January 29, 2012, 05:56
Default
  #13
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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.
ghorrocks is offline   Reply With Quote

Old   February 2, 2012, 04:54
Default replacement file
  #14
New Member
 
Tom Ou
Join Date: Jan 2012
Posts: 1
Rep Power: 0
ocb00999 is on a distinguished road
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!!!
ocb00999 is offline   Reply With Quote

Old   February 8, 2012, 09:34
Default
  #15
Member
 
Darren Leong
Join Date: Dec 2010
Posts: 64
Rep Power: 16
Darren Leong is on a distinguished road
@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
Darren Leong is offline   Reply With Quote

Old   February 13, 2012, 18:23
Default
  #16
New Member
 
Join Date: Jan 2012
Posts: 1
Rep Power: 0
HeinzBoehm is on a distinguished road
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:
External Command: "C:\Program Files\ANSYS Inc\v130\Framework\bin\Win64\runwb2.bat" -F C:\<Path To Remesh Script>\WB_Remesh.wbjn.
my problem is, that i cannot predict the motion of the valve, because it is effected due to the force of the fluid. i have no rotational velocity given. and i cannot, or i don't know how to monitor a geometry parameter in the solver-manager that gives me the current (exact) position of the valve (which is rotating around an coordinate system i created in cfx pre).

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)
HeinzBoehm is offline   Reply With Quote

Old   February 28, 2012, 12:23
Default
  #17
Member
 
sheth roh
Join Date: Jul 2011
Posts: 56
Rep Power: 15
sheth is on a distinguished road
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)

Quote:
Originally Posted by Darren Leong View Post
@Frank0079: Remeshing using Workbench allows both translational and rotational motions whereas ICEM handles only translation.
sheth is offline   Reply With Quote

Old   October 25, 2012, 21:08
Default
  #18
New Member
 
Anup
Join Date: Feb 2012
Posts: 5
Rep Power: 14
anup is on a distinguished road
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?
Attached Images
File Type: jpg Capture.jpg (41.7 KB, 147 views)
anup is offline   Reply With Quote

Old   November 13, 2012, 00:52
Default
  #19
Member
 
Darren Leong
Join Date: Dec 2010
Posts: 64
Rep Power: 16
Darren Leong is on a distinguished road
Check the location of your rubwb2.bat, e.g. is your ANSYS v130, 32 or 64 bit?

Quote:
Originally Posted by anup View Post
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?
Darren Leong is offline   Reply With Quote

Old   November 13, 2012, 06:53
Default
  #20
Senior Member
 
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22
Lance is on a distinguished road
Quote:
Originally Posted by anup View Post
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?
It seems that you are missing a ":" after C but before \Program
I would also avoid spaces in the path...
Lance is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 09:02.