Hi @Bruno.

In this case the Triangulation is created inside a class called ProbGeom1D, 
and the DoFHandler is in another class called State1D, created later and 
that uses an instance of ProbGeom1D as an input. 

geo = pygeom.ProbGeom1D(inp) 
state = pystate.State1D(inp, geo);

If I finish my script there there is not exception raised. 

I believed that the ownership should be preserved by python (python 
instances owned by other instances follow same rules as c++), but I guess I 
am missing something.
If I delete the python classes manually I do not get the exception:

#!/usr/bin/python
import pyinput
import pygeom
import pystate
import pyeqfactory
import pyeigenprobfactory
import pyeigensolver
import pypostprocessing

inp = pyinput.Input("heter1d/1d1g_heter")
geo = pygeom.ProbGeom1D(inp)
state = pystate.State1D(inp, geo);
equation = pyeqfactory.EqFactory1D.New(state)
eigenprob = pyeigenprobfactory.EigenProbFactory1D.New(state, equation)
solver = pyeigensolver.EigenSolver1D(state, eigenprob)
solver.solve_eigenproblem()
print state.get_keff()
out = pypostprocessing.PostProcessing1D(state)

del out 
del solver
del eigenprob
del equation
del state
del geo
del inp

I do not know why this happens, because I do not wrap the interface for 
Subscriptor (it is called internally inside the c++ classes, whithout 
python knowing about its existence). I will try to ask for this behaviour 
somewhere else and I will try to report whatever I will get here, in case 
anyone else face the same problem.

Thanks, Sebas.



El martes, 14 de febrero de 2017, 15:08:00 (UTC+1), Bruno Turcksin escribió:
>
> Hi,
>
> most of time this problem happens because the DoFHandler was declared 
> before the Triangulation. In the destructor, the Triangulation will be 
> destroyed before the DoFHandler.
>
> Best,
>
> Bruno
>
> On Tuesday, February 14, 2017 at 8:35:10 AM UTC-5, 
> Sebastian.Gonzalez-Pintor wrote:
>>
>>
>>
>> Hello! I am using swig to parse some code that I have wrote, and this 
>> code uses dealii. When I run the code with python, I get an error raised by 
>> Subscriptor as follows
>>
>> --------------------------------------------------------
>> An error occurred in line <114> of file </home/segonpin/lib/dealii/source
>> /base/subscriptor.cc> in function
>>     virtual dealii::Subscriptor::~Subscriptor()
>> The violated condition was: 
>>     counter == 0
>> The name and call sequence of the exception was:
>>     ExcInUse (counter, object_info->name(), infostring)
>> Additional Information: 
>> Object of class N6dealii13TriangulationILi1ELi1EEE is still used by 1 
>> other objects.
>>
>>
>> (Additional information: <none>)
>>
>>
>> See the entry in the Frequently Asked Questions of deal.II (linked to 
>> from http://www.dealii.org/) for a lot more information on what this 
>> error means and how to fix programs in which it happens.
>>
>>
>> Stacktrace:
>> -----------
>> #0  /home/segonpin/lib/dealii-8.4.bin/lib/libdeal_II.g.so.8.4.2: 
>> dealii::Subscriptor::~Subscriptor()
>> #1  /home/segonpin/lib/dealii-8.4.bin/lib/libdeal_II.g.so.8.4.2: 
>> dealii::Triangulation<1, 1>::~Triangulation()
>> #2  /home/segonpin/codessebas/dealii-neutron-transport/python/_pygeom.so: 
>> Forest::ProbGeom<1>::~ProbGeom()
>> #3  /home/segonpin/codessebas/dealii-neutron-transport/python/_pygeom.so: 
>> #4  python: PyObject_Call
>> #5  python: PyObject_CallFunctionObjArgs
>> #6  /home/segonpin/codessebas/dealii-neutron-transport/python/_pygeom.so: 
>> #7  python: ) [0x4fd4e6]
>> #8  python: PyDict_SetItem
>> #9  python: _PyModule_Clear
>> #10  python: PyImport_Cleanup
>> #11  python: Py_Finalize
>> #12  python: Py_Main
>> #13  /lib/x86_64-linux-gnu/libc.so.6: __libc_start_main
>> #14  python: _start
>> --------------------------------------------------------
>>
>> I know that this problem is because I am destroying an instance of an 
>> object that is still owned by someone else. My question is, how can I get 
>> the information of who is owning?
>>
>> Extra info: The same code runs well when calling things in the same order 
>> in python. I think that something is going wrong when using wrappers with 
>> std::shared_ptr, but swig is prepared for this and then I do not think this 
>> should be a problem. I was thinking that identifying who increased the 
>> counter in Subscriptor without decreasing it later can give me extra hints 
>> for fixing the problem. For extra information, the python file is
>>
>> #!/usr/bin/python
>> import pyinput
>> import pygeom
>> import pystate
>> import pyeqfactory
>> import pyeigenprobfactory
>>
>> inp = pyinput.Input("heter1d/1d1g_heter")
>> geo = pygeom.ProbGeom1D(inp) # This is the element that will raise the 
>> exception later
>> state = pystate.State1D(inp, geo);
>> equation = pyeqfactory.EqFactory1D.New(state)
>> # commenting the following line there is no exception raised.
>> eigenprob = pyeigenprobfactory.EigenProbFactory1D.New(state, equation) 
>>
>>
>>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to