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

Change onflow condition "on-the-fly" with pysu2 ?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2021, 13:14
Default Change onflow condition "on-the-fly" with pysu2 ?
  #1
New Member
 
Arne Voß
Join Date: Dec 2021
Posts: 13
Rep Power: 4
Arne Voß is on a distinguished road
Hi everyone,



I use the pysu2 interface to launch a CFD computation similar as shown below. I have two questions/problems:
a) Is it possible to change parameters like the angle of attack, sideslip or the grid movement "on-the-fly", without initializing the solver again? For example it is possible to set mesh deformations on-the-fly with pysu2.CSinglezoneDriver.SetMeshDisplacement() but I haven't found a function to change e.g. the onflow condition.

b) Currently, my workaround is to write the new onflow condition into the config file and initialize SU2 again with hte new config file. However, this creates new problems because I found that the memory is not cleared after the post-processing and thus, after a couple of loops, I run out of memory. Note that I use mesh deformation, which uses a lot of memory.




import pysu2
class MySU2Interface(object):
def init_solver(self, para_filename):
self.FluidSolver = pysu2.CSinglezoneDriver(para_filename, 1, self.comm)


def run_solver(self):
# mpi barrier

self.comm.barrier()


# run solver
self.FluidSolver.Preprocess(0)
self.FluidSolver.Run()
self.FluidSolver.Postprocess()


# write outputs and restart file(s)
self.FluidSolver.Monitor(0)
self.FluidSolver.Output(0)
Arne Voß is offline   Reply With Quote

Old   December 14, 2021, 15:26
Default
  #2
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 465
Rep Power: 13
pcg is on a distinguished road
Unfortunately we do not have that capability.
pcg is offline   Reply With Quote

Old   December 15, 2021, 06:36
Default
  #3
New Member
 
Arne Voß
Join Date: Dec 2021
Posts: 13
Rep Power: 4
Arne Voß is on a distinguished road
Hi Pedro,

thank you very much for the fast answer. Do you have any plans to integrate such a functionality in the future?

In the meantime, do your have or do you plan to have a function that clears/releases all memory when SU2 is done? Something like pysu2.CSinglezoneDriver.release_memory() or similar... I believe that would be very helpful for the users that don't use SU2 (only) as a standalone.
I tried to delete the SU2 instance in python, but that didn't do anything to the memory consumption and running the garbage collector manually didn't help neither.

del self.FluidSolver
gc.collect()

Do you have any suggestions how I could/should handle this problem?


Thank you very much for your help,
Arne




Update to question b): After looking into the code, I found that the function that clears/releases memory is called pysu2.CSinglezoneDriver.Postprocessing(). I didn't see it at the beginning, because there is a second function Postprocess(). Looking at the names only, I didn't realize the difference in the underlying function.

Last edited by Arne Voß; December 21, 2021 at 04:12.
Arne Voß is offline   Reply With Quote

Old   December 20, 2021, 19:04
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 475
Rep Power: 17
bigfootedrockmidget is on a distinguished road
For the updating of parameters: At the start of every iteration you could read a file with the updated parameter value in it and update the value that is read from the config file.
bigfootedrockmidget is offline   Reply With Quote

Old   December 21, 2021, 04:05
Default
  #5
New Member
 
Arne Voß
Join Date: Dec 2021
Posts: 13
Rep Power: 4
Arne Voß is on a distinguished road
Hi,

That sound like what I have in mind. However, I am not sure how to do this. Could you give more detailed instructions?
Thank you very much,
Arne
Arne Voß is offline   Reply With Quote

Old   December 22, 2021, 06:41
Default
  #6
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 465
Rep Power: 13
pcg is on a distinguished road
Hi Arne you can have a look at CEulerSolver::SetFarfield_AoA in CEulerSolver.cpp for what needs to be changed to set a different AoA.
I would be careful with changing Mach number because it may be used for nondimensionalization, or as a parameter of some schemes.
pcg is offline   Reply With Quote

Old   December 22, 2021, 07:03
Default
  #7
New Member
 
Arne Voß
Join Date: Dec 2021
Posts: 13
Rep Power: 4
Arne Voß is on a distinguished road
Hi,

I see that I could call SetAoA(alpha) located in the CConfig.cpp. But I believe the CConfig.cpp is not accessible via the python interface, so I have no idea how I could do this. What needs to be done to expose the CConfig.cpp to the python interface? Is it possible at all?

Sorry that I ask questions that might appear simple to you guys, but I am not a software engineer and have no experience with C++.
Thank you for your help,
Arne
Arne Voß is offline   Reply With Quote

Old   December 23, 2021, 13:37
Default
  #8
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 465
Rep Power: 13
pcg is on a distinguished road
It is not enough to set it in the config object because other classes will use the original value to convert that information into something else, for example, the flow solver will use it to compute the farfield velocity.
The function I pointed to above, modifies that velocity.
The typical process to expose functions to python is via the CDriver class, in particular the methods you add to python_wrapper_structure.cpp. In a nutshell you need to add a method to the driver to reach into the lower classes (solvers, etc.)
See e.g. CDriver::SetVertexNormalHeatFlux in that file.
pcg is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Change Boundary Condition type during Transient simulation Achille FLUENT 3 December 29, 2022 11:20
Change Boundary Condition Type From Solver Daveed OpenFOAM Running, Solving & CFD 1 February 8, 2021 06:16
Change of boundary condition value (mole fraction) of species after convergence Anshul7 FLUENT 0 February 6, 2021 07:21
How to change the viscosity of STL-fluid Region in initial condition Tusher FLOW-3D 0 September 23, 2020 10:28
Pressure change after import init. condition file Tony CFX 0 October 18, 2004 23:46


All times are GMT -4. The time now is 13:22.