CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Need help writing .wbjn remesh script file (https://www.cfd-online.com/Forums/cfx/94434-need-help-writing-wbjn-remesh-script-file.html)

Rallyeee November 15, 2011 23:47

Need help writing .wbjn remesh script file
 
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.

frank0079 November 16, 2011 02:22

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

ghorrocks November 16, 2011 05:33

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 :)

Rallyeee November 17, 2011 09:32

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)

Doginal November 17, 2011 14:43

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.

Rallyeee November 17, 2011 15:50

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?

Doginal November 17, 2011 17:01

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

frank0079 November 17, 2011 22:08

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)

Rallyeee November 18, 2011 00:13

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.

jrunsten January 20, 2012 04:29

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)


dclaudia85 January 22, 2012 10: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!

Rallyeee January 27, 2012 12:10

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?

ghorrocks January 29, 2012 04:56

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.

ocb00999 February 2, 2012 03:54

replacement file
 
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!!!

Darren Leong February 8, 2012 08:34

@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.

HeinzBoehm February 13, 2012 17:23

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?:confused::confused::confused::confused: 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)

sheth February 28, 2012 11:23

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 (Post 343355)
@Frank0079: Remeshing using Workbench allows both translational and rotational motions whereas ICEM handles only translation.


anup October 25, 2012 20:08

1 Attachment(s)
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 November 12, 2012 23:52

Check the location of your rubwb2.bat, e.g. is your ANSYS v130, 32 or 64 bit?

Quote:

Originally Posted by anup (Post 388585)
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?


Lance November 13, 2012 05:53

Quote:

Originally Posted by anup (Post 388585)
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...

Charu September 1, 2014 06:31

Pls answer me
 
I know this is the one, which is used to execute script for Fluent..
But at end of execution, it shut down the fluent software.
I need to display fluent.. So can u pls help me for this?

"C:\Program Files\ANSYS Inc\v150\Framework\bin\Win64\runwb2.bat" -B -R C:\Users\admin\Desktop\newWbjn.wbpj..

abubakarizhar July 18, 2016 02:18

Please guide.
 
Quote:

Originally Posted by Doginal (Post 332586)
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

hi doginal
i know this reply is little older but can you please tell me how to load the latest geometry for remeshing in workbench. do i have to redraw the geometry or is there any way i can load the latest geometry from the cfx results files. i am simulating vortex induced vibrations of cylinders in cfx rigid body solver.
please reply.

filo87 December 14, 2016 06:46

Problem with Remeshing
 
Hi everybody. I'm doing my first moving mesh and remeshing simulation on a check valve but I have a problem that I'm not able to solve.
I set the transient simulation in order to have a moving mesh. It runs for a while but at a certain point the displacements are too big and the simulation fails.
So I started to work on remeshing. However I don't have ICEM (because of license purchasing issue) and i don't know how to generate the new geometry, when the displacements of the original mesh become too big, in order to make a new mesh on it.

Can anyone please help me? Thanks a lot!

ghorrocks December 14, 2016 16:35

FAQ: https://www.cfd-online.com/Wiki/Ansy..._went_wrong.3F

afef February 25, 2020 04:27

from gambit to ansys
 
Is it possible to import external geometry file in ansys workbench from gambit to remesh it?
help plz:confused::confused::confused:

Gert-Jan February 25, 2020 05:41

Aren't you able to export the geometry in Gambit through Iges, STEP or parasolid?

Alternatively, you can import the fluent mesh in ICEM, delete all volume elements and build a new mesh from the remaining surface elements.


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