I am attempting to set up a python based optimization using OpenFOAM and pythonFlu.
I have quite a bit of experience with CFD-based optimization but I am relatively new to OpenFOAM and pythonFlu. I am running on a multicore linux system with ubuntu 10.04 and OF 2.1.1 and the matching pythonFlu installed from the packages.
What I would like to have is an interactive script that allows me to repeatedly run pythonFlu solutions with slight modifications to the mesh.
At the moment I have two issues:
1 - resetting the flow for repeated solves
2 - updating the volume mesh.
For the first issue I am working with the simpleFlux algorithm. I have sectioned out the solution part of the simpleFlux algorithm:
~~~~~~
ref.ext_Info() << "\nStarting time loop\n" << ref.nl
I would like to be able to call this, reset the flow to the initial conditions and then call it again and reproduce the same results. At the moment, when I call this the second time, the states and solution stay at the final result from the first call, so the second loop exits immediately on a "converged in 0 iterations" message.
I have tried calling:
between successive calls to the solution algorithm, but that doesn't seem to help. Is there an accepted way of resetting the flow to the initial conditions in OpenFOAM/pythonFlu?
For the second issue, what I would like to do be able to do is take a numpy array of points representing the fvMesh points, and update the fvMesh object.
I have tried a couple of different things and I seem to be able to update the points in the following manner:
x = self.mesh.points().component(ref.vector.X)
y = self.mesh.points().component(ref.vector.Y)
z = self.mesh.points().component(ref.vector.Z)
meshSize = self.mesh.points().size()
for i in range(meshSize):
x[i] = Xpts[i,0]
y[i] = Xpts[i,1]
z[i] = Xpts[i,2]
However, this doesn't seem to update the volumes and other geometric parameters in the mesh. Is there a call that can do this? or is there a better way of doing this?
Another way that might work is to create a pointField on the fly from the new points and then use:
self.mesh.movePoints(newPointField)
~~~~~
Is it possible to create a pointField with pythonFlu?
Thank you in advance for any guidance you can offer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am attempting to set up a python based optimization using OpenFOAM and pythonFlu.
I have quite a bit of experience with CFD-based optimization but I am relatively new to OpenFOAM and pythonFlu. I am running on a multicore linux system with ubuntu 10.04 and OF 2.1.1 and the matching pythonFlu installed from the packages.
What I would like to have is an interactive script that allows me to repeatedly run pythonFlu solutions with slight modifications to the mesh.
At the moment I have two issues:
1 - resetting the flow for repeated solves
2 - updating the volume mesh.
For the first issue I am working with the simpleFlux algorithm. I have sectioned out the solution part of the simpleFlux algorithm:
~~~~~~
ref.ext_Info() << "\nStarting time loop\n" << ref.nl
while self.simple.loop():
ref.ext_Info() << "Time = " << self.runTime.timeName() << ref.nl << ref.nl
...
ref.ext_Info() << "End\n" << ref.nl
return os.EX_OK
self.runTime.setTime(self.runTime.startTime(),self.runTime.startTimeIndex())
x = self.mesh.points().component(ref.vector.X)
y = self.mesh.points().component(ref.vector.Y)
z = self.mesh.points().component(ref.vector.Z)
meshSize = self.mesh.points().size()
for i in range(meshSize):
x[i] = Xpts[i,0]
y[i] = Xpts[i,1]
z[i] = Xpts[i,2]
self.mesh.points().replace(ref.vector.X,x)
self.mesh.points().replace(ref.vector.Y,y)
self.mesh.points().replace(ref.vector.Z,z)
self.mesh.movePoints(newPointField)
~~~~~
Is it possible to create a pointField with pythonFlu?
Thank you in advance for any guidance you can offer.