Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

picklinge GridFunction Error

More
3 years 10 months ago - 3 years 10 months ago #2655 by hvwahl
Hi everyone,

im trying to pickle and unpickle GridFunctions in a time dependent problem, in order to restart a computation from the pickled data. However, on writing the data from an unpickled GridFunction into the GridFunction used in the computation
Code:
v1 = GridFunction(V) unpickler = pickle.Unpickler(open("1.dat","rb")) up1, = unpickler.load() v1.vec.data = up1.data
I get the following an error:
Code:
netgen.libngpy._meshing.NgException: Archive error: Polymorphic type ngcomp::S_GridFunction<double> not registered for archive
I have attached an MWE and I on the master branch commit ee5d90c06.

Can anyone help me with this?

Best wishes,
Henry
Attachments:
Last edit: 3 years 10 months ago by hvwahl.
More
3 years 10 months ago #2656 by cwinters
Hi Henry,

you have to use
Code:
v1.vec.data = up1.vec.data
since you can not write a GridFunction on a Basevector.

If I want to save some data for longer times, I usually save the raw data of the vector (just the values in a list and some information the reconstruct the FESpace). There have been quite a lot changes in the pickling interface which caused me some troubles in the past when loading with a newer NGSolve.

Best,
Christoph
More
3 years 10 months ago #2657 by hvwahl
Replied by hvwahl on topic picklinge GridFunction Error
Hi Christoph,

thanks for the quick reply! Sorry I missed that!

Best wishes,
Henry
More
3 years 10 months ago #2658 by hvwahl
Replied by hvwahl on topic picklinge GridFunction Error
On a related Note:

I also need to pickle BitArrays. I have implemented this netgen/libsrc/core/python_ngcore_export.cpp , but would it be possible to get this into the source code? What would be the best way to do this?

Best wishes,
Henry
Time to create page: 0.159 seconds