MemoryError in saveTmp

Asked by ceguo on 2012-03-31

Hi,

I'm solving a boundary value problem in which the boundary condition is unknown in advance and has to be solved by iterations. Now I use saveTmp(ID) to save the current configuration and then use loadTmp(ID) before each iteration. As in a step marching problem (each step may have tens of iterations), I will encounter this "MemoryError" after several tens of steps.

I suppose this saveTmp(ID) where ID is a tag for the temporary saving, will overwrite each memory since I use the same ID. So how will this error occur? Or if there is a way to delete no-longer-used memory during simulation?

Besides geometry information like particle position and radius, will the kinematic information (translational velocity and angular velocity) also be saved in saveTmp()?

Thanks in advance!
Ning

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2012-06-07
Last reply:
2012-06-07

Hi Ning,

First of all, would you agree to share an example script showing the
method you used finally to encapsulate a simulation and use it in the
python script (https://answers.launchpad.net/yade/+question/182459)? It
can be useful for many people.

For your new questions:
-The parameters declared with the constructors in the YADE_CLASS_*
macros are registered parameters that are saved with the objects.
Velocity is saved, yes.
-For memory, maybe Jan will have an idea why memory is not released? Can
you confirm that you RAM usage tends to 100% before crash?

Bruno

ceguo (hhh-guo) said : #2

Hi Bruno,

Thanks for your reply.
-To encapsulate a simulation and call from python, I use the module `yadeimport` adapted from `yade-trunk`. Actually it is provided by Jan. My previous solution is copying all the libraries to the python lib directory properly, which also works smoothly. Here I show how to use yadeimport:

=====================================================
from yadeimport import *
from yade.wrapper import *
from yade import pack

class simDEM(object):
    def __init__(self,sd=1):
        self.__id='thread'+str(sd)
        self.__O=Omega()
        self.__O.materials.append(FrictMat(young=1e9,poisson=1.,frictionAngle=.3,density=2650))
        self.__sp=pack.SpherePack()
        self.__sp.makeCloud(minCorner=(0,0,0),maxCorner=(20,20,0),rRelFuzz=.5,num=2000,periodic=True,porosity=0.28,seed=sd)
        self.__sp.toSimulation()
        self.__O.cell.hSize=utils.Matrix3(20,0,0, 0,20,0, 0,0,1)
        for p in self.__O.bodies:
            p.state.blockedDOFs='zXY'
        self.__O.dt=.5*utils.PWaveTimeStep()

    def consolidate(self,stress=(-2.e6,-2.e6,0,0,0,0)):
        ...

    def finalize(self):
        self.__O.exitNoBacktrace()

For `yadeimport`, I can send to anyone interested in this method (Jan sent to me). This method is useful for coupled problems as in my case I coupled yade with another FEM code.

-As my test is very time-consuming, I usually run during night. So I didn't monitor the RAM usage. Just when I came back in the morning, I saw the error message.

Ning

Jan Stránský (honzik) said : #3

Hello,

according to Omega.*pp files, the content should be overwritten in the
memory if the same name is passed to O.saveTmp, but I have never worked
with iostreams more tham just on basic level, so I can't say for sure if
the memory is really overwritten..

Could you please send the whole MemoryError? One (not very nice) workarond
would be to save the content into file, not to memory. Could you also run
the simulation without actual running (or run only a few steps) and
save/load it many times so you can see the memory usage?

I will also write to yade-dev abot the yadeimport soltion

Jan

Dne 2. dubna 2012 14:56 ceguo <email address hidden>napsal(a):

> Question #192224 on Yade changed:
> https://answers.launchpad.net/yade/+question/192224
>
> Status: Answered => Open
>
> ceguo is still having a problem:
> Hi Bruno,
>
> Thanks for your reply.
> -To encapsulate a simulation and call from python, I use the module
> `yadeimport` adapted from `yade-trunk`. Actually it is provided by Jan. My
> previous solution is copying all the libraries to the python lib directory
> properly, which also works smoothly. Here I show how to use yadeimport:
>
> =====================================================
> from yadeimport import *
> from yade.wrapper import *
> from yade import pack
>
> class simDEM(object):
> def __init__(self,sd=1):
> self.__id='thread'+str(sd)
> self.__O=Omega()
>
> self.__O.materials.append(FrictMat(young=1e9,poisson=1.,frictionAngle=.3,density=2650))
> self.__sp=pack.SpherePack()
>
> self.__sp.makeCloud(minCorner=(0,0,0),maxCorner=(20,20,0),rRelFuzz=.5,num=2000,periodic=True,porosity=0.28,seed=sd)
> self.__sp.toSimulation()
> self.__O.cell.hSize=utils.Matrix3(20,0,0, 0,20,0, 0,0,1)
> for p in self.__O.bodies:
> p.state.blockedDOFs='zXY'
> self.__O.dt=.5*utils.PWaveTimeStep()
>
> def consolidate(self,stress=(-2.e6,-2.e6,0,0,0,0)):
> ...
>
> def finalize(self):
> self.__O.exitNoBacktrace()
>
> For `yadeimport`, I can send to anyone interested in this method (Jan
> sent to me). This method is useful for coupled problems as in my case I
> coupled yade with another FEM code.
>
> -As my test is very time-consuming, I usually run during night. So I
> didn't monitor the RAM usage. Just when I came back in the morning, I
> saw the error message.
>
> Ning
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

ceguo (hhh-guo) said : #4

Hello,

As I monitored the memory usage during the simulation (system monitor in Ubuntu), I did observe a continuous increase of the memory occupation. I only use O.saveTmp("string") and O.loadTmp("string") in the code with "string" indicating the name of the temporary memory. I suppose the memory could be overwritten since I set the same name. But it may be safer if we have a function like O.releaseTmp("string") to free the memory manually. Anyway I have no knowledge on memory handling in python. Hope someone can kindly offer some suggestions or do some tests on this.

Ning

Anton Gladky (gladky-anton) said : #5

Hi,

please, provide a simple test script and file the bug.

Thanks.

Anton

ceguo (hhh-guo) said : #6

Thanks Anton,

As my case is a bit complicated, I will find a neat script for your reference later.

Now I have another problem. Before I used Dem3DofGeom but now I change to ScGeom following your advice. Then I found stressTensorOfPeriodicCell is no longer workable for ScGeom. I understand I can use getStress instead in this case. But as I did some modification to stressTensorOfPeriodicCell and added my own functions, so I do hope this module applicable to ScGeom. I am wondering what prevents stressTensorOfPeriodicCell functions properly in ScGeom?

Ning

Anton Gladky (gladky-anton) said : #7

Please, open an another question for this topic.

Thanks

Anton

Jan Stránský (honzik) said : #8

Hi Ning,

function stressTensorOfPeriodicCell will be in a few days time replaced by
unified function applicable to both Dem3dofGeom and SCGeom. What
modifications have you done to this function? We can incorporate it to the
new one :-)

Jan
Dne 7.6.2012 11:10 "ceguo" <email address hidden> napsal(a):

> Question #192224 on Yade changed:
> https://answers.launchpad.net/yade/+question/192224
>
> Status: Answered => Open
>
> ceguo is still having a problem:
> Thanks Anton,
>
> As my case is a bit complicated, I will find a neat script for your
> reference later.
>
> Now I have another problem. Before I used Dem3DofGeom but now I change
> to ScGeom following your advice. Then I found stressTensorOfPeriodicCell
> is no longer workable for ScGeom. I understand I can use getStress
> instead in this case. But as I did some modification to
> stressTensorOfPeriodicCell and added my own functions, so I do hope this
> module applicable to ScGeom. I am wondering what prevents
> stressTensorOfPeriodicCell functions properly in ScGeom?
>
> Ning
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

ceguo (hhh-guo) said : #9

Thanks Jan,

As requested by Anton, I'll post a new question on the stress issue and leave this thread for the memory issue:-)

Ning

Can you help with this problem?

Provide an answer of your own, or ask ceguo for more information if necessary.

To post a message you must log in.