On Thu, Aug 30, 2012 at 5:10 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div class="im">On Thu, Aug 30, 2012 at 5:06 PM, Chris Eldred <span dir="ltr"><<a href="mailto:chris.eldred@gmail.com" target="_blank">chris.eldred@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The code for DMSetDefaultSection is:<br>
<br>
3016:   PetscSectionDestroy(&dm->defaultSection);<br>
3017:   PetscSectionDestroy(&dm->defaultGlobalSection);<br>
3018:   dm->defaultSection = section;<br>
3019:   return(0);<br></blockquote><div><br></div></div><div>This code is wrong. It should likely have used PetscObjectReference((PetscObject)section) before these lines.</div></div></blockquote><div><br></div><div>Its not wrong. This is the way I wanted it. You set the PetscSection and give up control. If you</div>
<div>do not want to give up control, then call PetscObjectReference() before passing it in.</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div> </div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
which destroys the "current" default section before setting the new<br>
one. Since my sections are passed by reference in Fortran, the only<br>
recourse I can see is to create a copy of the section before it is<br>
passed to DMSetDefaultSection. Any other ideas?<br>
<div><div><br>
On Thu, Aug 30, 2012 at 4:03 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>> wrote:<br>
> I think the bug is not that the old section is destroyed, but that the new<br>
> one is not referenced.<br>
><br>
><br>
> On Thu, Aug 30, 2012 at 5:00 PM, Chris Eldred <<a href="mailto:chris.eldred@gmail.com" target="_blank">chris.eldred@gmail.com</a>><br>
> wrote:<br>
>><br>
>> I am using DMSetDefaultSection and DMCreateLocalVector to create<br>
>> vectors in my code, but errors are occurring because<br>
>> DMSetDefaultSection destroys old sections. My usage pattern is<br>
>><br>
>> for each variable<br>
>> call DMSetDefaultSection<br>
>> call DMCreateLocalVector<br>
>><br>
>> which fails if there is more than one 1 variable that uses the same<br>
>> section since the sections are being destroyed when a new one is set.<br>
>> Is there a reason for this behavior in DMSetDefaultSection (ie can a<br>
>> version of DMSetDefaultSection that does not destroy the old sections<br>
>> be provided)?<br>
>><br>
>> --<br>
>> Chris Eldred<br>
>> DOE Computational Science Graduate Fellow<br>
>> Graduate Student, Atmospheric Science, Colorado State University<br>
>> B.S. Applied Computational Physics, Carnegie Mellon University, 2009<br>
>> <a href="mailto:chris.eldred@gmail.com" target="_blank">chris.eldred@gmail.com</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
Chris Eldred<br>
DOE Computational Science Graduate Fellow<br>
Graduate Student, Atmospheric Science, Colorado State University<br>
B.S. Applied Computational Physics, Carnegie Mellon University, 2009<br>
<a href="mailto:chris.eldred@gmail.com" target="_blank">chris.eldred@gmail.com</a><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>