yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00921
Re: be carefully with python console and postProcessAttributes
> postProcessingAttributes used to initialize attributes
> _after_ serialization / deserialization a object, but not to initialize the object after it
> original creation. This is due to the fact that when
> python-console was lacking, and used only C++ preprocessors, after
> creation a model in the preprocessor it saved to a file, after which the file
> loaded in SimulationController, and the simulation runs. Thus, this mechanism allows
> to initialize the attributes after initial creation an object in the preprocessor.
> However, with the advent of python-console this save/load step is omited.
> Therefore, objects that require initialization after its creation,
> initialized noncorrectly, so for such objects must explicitly call
> postProcessingAttributes (or do save/load model before run a simulation).
>
Hi, I was aware of this problem, for example utils.facet calls
explicitly postProcessAttributes(). Most objects do not do anything
substantial in this initialization, but it has to be watched out and I
don't know if there is possibly a general solution for that.
There is a function to save simulation to a in-memory XML using
O.saveTmp('init') and load it immediately afterwards with O.loadTmp('init').
> Or is a bad idea to use postProcessingAttributes() to initialize, and better to use the mechanism of action() first call?
>
That's what I do in UniaxialStrainer: there is a non-serializable
attribute bool needsInit, which is set to true in the constructor. In
action then: if(needsInit) init(); (which sets needsInit=false).
Vaclav
Follow ups
References