[petsc-dev] DMSetDefaultSection destroys old sections
Matthew Knepley
knepley at gmail.com
Thu Aug 30 17:12:51 CDT 2012
On Thu, Aug 30, 2012 at 5:10 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Thu, Aug 30, 2012 at 5:06 PM, Chris Eldred <chris.eldred at gmail.com>wrote:
>
>> The code for DMSetDefaultSection is:
>>
>> 3016: PetscSectionDestroy(&dm->defaultSection);
>> 3017: PetscSectionDestroy(&dm->defaultGlobalSection);
>> 3018: dm->defaultSection = section;
>> 3019: return(0);
>>
>
> This code is wrong. It should likely have used
> PetscObjectReference((PetscObject)section) before these lines.
>
Its not wrong. This is the way I wanted it. You set the PetscSection and
give up control. If you
do not want to give up control, then call PetscObjectReference() before
passing it in.
Matt
>
>
>>
>> which destroys the "current" default section before setting the new
>> one. Since my sections are passed by reference in Fortran, the only
>> recourse I can see is to create a copy of the section before it is
>> passed to DMSetDefaultSection. Any other ideas?
>>
>> On Thu, Aug 30, 2012 at 4:03 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>> > I think the bug is not that the old section is destroyed, but that the
>> new
>> > one is not referenced.
>> >
>> >
>> > On Thu, Aug 30, 2012 at 5:00 PM, Chris Eldred <chris.eldred at gmail.com>
>> > wrote:
>> >>
>> >> I am using DMSetDefaultSection and DMCreateLocalVector to create
>> >> vectors in my code, but errors are occurring because
>> >> DMSetDefaultSection destroys old sections. My usage pattern is
>> >>
>> >> for each variable
>> >> call DMSetDefaultSection
>> >> call DMCreateLocalVector
>> >>
>> >> which fails if there is more than one 1 variable that uses the same
>> >> section since the sections are being destroyed when a new one is set.
>> >> Is there a reason for this behavior in DMSetDefaultSection (ie can a
>> >> version of DMSetDefaultSection that does not destroy the old sections
>> >> be provided)?
>> >>
>> >> --
>> >> Chris Eldred
>> >> DOE Computational Science Graduate Fellow
>> >> Graduate Student, Atmospheric Science, Colorado State University
>> >> B.S. Applied Computational Physics, Carnegie Mellon University, 2009
>> >> chris.eldred at gmail.com
>> >
>> >
>>
>>
>>
>> --
>> Chris Eldred
>> DOE Computational Science Graduate Fellow
>> Graduate Student, Atmospheric Science, Colorado State University
>> B.S. Applied Computational Physics, Carnegie Mellon University, 2009
>> chris.eldred at gmail.com
>>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120830/275b6873/attachment.html>
More information about the petsc-dev
mailing list