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

Scripting CFX5

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By mmoelle1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 21, 2018, 13:59
Default Scripting CFX5
  #1
New Member
 
Matthias Möller
Join Date: Oct 2017
Posts: 9
Rep Power: 9
mmoelle1 is on a distinguished road
Dear all,

We are working on an automatized simulation loop that involves CFX5 for the fluid part and a self-written code for the solid part. In essence, we have a fully configured case (from CFX5-pre) that we want to modify by a script. The modifications are as follows: delete the existing mesh and import another mesh that makes use of a self-written user input executable. The outcome of these actions should be saved to a new case file which is then run by the solver. The imported mesh has the same regions, so no problem with boundary conditions should occur.

I have read a lot about CCL but I miss a simple example that demonstrates how to load a case, delete the mesh, and import a new mesh. Or would you suggest another way of scripting CFX5-pre other than CCL? Any help is appreciated.

Kind regards,
Matthias
welaa and shivasluzz like this.
mmoelle1 is offline   Reply With Quote

Old   February 21, 2018, 18:14
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
There are many ways of doing this:
* Use a script to drive CFX-Pre to load the mesh, solve it output the results and update your code for the mesh on the next loop. This is fairly easy to do but will be very slow as it needs to run CFX-Pre and restart simulations many times.
* You can use the user defined mesh option for remeshing in a multiple configuration run. This will be more efficient.
* You can use user fortran to write a new mesh during run time. There used to be an example of this in the CFX tutorials but it got removed many years ago. I suspect CFX support still has access to it. This will be the most efficient way of doing it, but will require some fortran coding and will be trickier to set up.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   February 21, 2018, 18:22
Default
  #3
New Member
 
Matthias Möller
Join Date: Oct 2017
Posts: 9
Rep Power: 9
mmoelle1 is on a distinguished road
Thanks very much for the quick reply.

Do you mean the ImportTemplate.c (and ExportTemplate.c) codes in <CFXROOT>/examples? Based on that, I have written a C++ program that reads in the data from my own simulation programme and "updates" the mesh. To be correct here, it does not write this data to a mesh file but it imports the mesh into CFX5-pre using the cfxImportXYZ functions. Do you know a better way to directly write a mesh file or, even better, to write a "res" file which would contain the solution from the old mesh projected to the new one? The topology of my meshes does not change only the position of vertices changes slightly.

BTW, I can also switch to Fortran if that simplifies the task.
mmoelle1 is offline   Reply With Quote

Old   February 21, 2018, 19:18
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
No, ImportTemplate.c and ExportTemplate.c are for getting meshes into CFX-Pre. There used to be a user fortran example for getting meshes straight into the solver during run time so you could do mesh motion stuff with user defined mesh motion. I have looked at the V19 fortran examples and I can't see it, so I suspect you will need to contact ANSYS support if you want to get it.

As a general comment: in CFX, c++ stuff is only used to get user meshes in and out of CFX-Pre. Fortran stuff is used to add user functions to the solver during a simulation and changing the mesh is one thing you can do here. They are not interchangeable, they act on totally different parts of the CFX workflow. If you want a user function in the solver fortran is your only option (assuming it cannot be done in CEL and CCL).
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   February 22, 2018, 03:27
Default
  #5
New Member
 
Matthias Möller
Join Date: Oct 2017
Posts: 9
Rep Power: 9
mmoelle1 is on a distinguished road
Thanks once more. I will contact the ANSYS support for the deleted Fortran examples you mentioned.

In the meantime, do you have (or can point me to) a simple scripting example that shows how to (1) start CFX-pre, (2) load a case, (3) delete the existing mesh, (4) import another mesh from file, and (5) write the updated case to a file all from the command line, i.e. without user-interaction and GUI starting up?

Concerning your final remark
Quote:
If you want a user function in the solver fortran is your only option (assuming it cannot be done in CEL and CCL).
The only modifications of the mesh between several solver runs are the location of the mesh points (the mesh topology does not change). Is this something that could be done via CEL and/or CCL? If so, I would be very happy if you could also point me to an example.

Thanking you very much in advance.
mmoelle1 is offline   Reply With Quote

Old   February 22, 2018, 05:46
Default
  #6
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
CFX-Pre scripting: Start a session file, record it, and then do the operations you mention. Have a look at the session file and there is your example.

User function: The fortran example used to get called every few time steps to update the mesh. The mesh had the same mesh topology, just the nodal locations moved. This is the user fortran example I mentioned used to be there but got removed several versions of CFX ago.

If you can define a CEL expression which describes your mesh then you can use it. But the expression is almost certainly going to have to call a user fortran function as CEL is a bit limited for complex functions like this.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   February 22, 2018, 13:16
Default
  #7
Senior Member
 
Join Date: Jun 2009
Posts: 1,873
Rep Power: 33
Opaque will become famous soon enough
While recording your session (as Glenn suggested), try using the "Reload Mesh" option. Once you see how the command is stored in the session file, you will learn how is used.

Then, you only need to create a new mesh with the same file name as the previous mesh, i.e. update its contents, execute the CFX-Pre script with the "Reload" command, write definition file, and you should be set.
Opaque is offline   Reply With Quote

Old   February 25, 2018, 11:02
Default
  #8
New Member
 
Matthias Möller
Join Date: Oct 2017
Posts: 9
Rep Power: 9
mmoelle1 is on a distinguished road
Thanks! Recording the session and extracting the relevant parts worked for me.

I have a (hopefully) final question about mesh/file formats. I received two files from a co-worker (case.def and mesh.cfx5). The DEF-file defines the complete case and uses mesh.cfx5 as the mesh file. The CFX5-file is a binary file. I have read that it is an ICEMCFD mesh but the version of ICEMCFD I am using is not able to open it nor to import it as a mesh. I need to rename a 2D region and create another one in that particular file.

Any help is appreciated.
mmoelle1 is offline   Reply With Quote

Old   February 25, 2018, 18:15
Default
  #9
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,854
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
The def file is a full definition for a simulation, it contains the mesh as well. You do not need another file for the mesh. So open the def file in ICEM and you will be able to edit the mesh.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   April 8, 2021, 03:41
Default
  #10
New Member
 
Mohammad_fathi
Join Date: Oct 2020
Posts: 3
Rep Power: 6
Mohammadfba is on a distinguished road
Hi
I want to use remeshing in cfx but I do n't know how to write a script for remeshing. How can I do that?
Best regards
Mohammadfba is offline   Reply With Quote

Reply

Tags
scripting; command line;


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
[ICEM] ICEM Scripting Issues tylerplowright ANSYS Meshing & Geometry 33 September 27, 2021 17:35
Macro scripting in netbeans, importing star libraries laurensvd STAR-CCM+ 3 October 31, 2020 23:06
[ANSYS Meshing] Need help with selection of edges using scripting studentzz ANSYS Meshing & Geometry 1 March 5, 2017 17:49
record actions via scripting Marabelle ANSYS 0 July 31, 2013 12:57
Linking between my own code and CFX5 in Windows Se-Hee CFX 2 May 17, 2007 09:52


All times are GMT -4. The time now is 17:29.