[petsc-users] DMPlexProjectFunction and Boundary Conditions

Matthew Knepley knepley at gmail.com
Wed Apr 3 15:31:52 CDT 2013


On Thu, Apr 4, 2013 at 3:09 AM, Dharmendar Reddy <dharmareddy84 at gmail.com>wrote:

>
>
>
> On Wed, Apr 3, 2013 at 10:41 AM, Matthew Knepley <knepley at gmail.com>wrote:
>
>> On Wed, Apr 3, 2013 at 11:04 PM, Dharmendar Reddy <
>> dharmareddy84 at gmail.com> wrote:
>>
>>> Hello,
>>>         I see that in DMPlexComputeResidualFEM boundary conditions are
>>> applied using DMPlexProjectFunctionLocal. I was wondering why is there a
>>> loop over all local vertex Ids and a call to
>>> evaluation function on line 241 below. If i am not wrong, i can see that
>>> VecSetValuesSection is only to the points indicated as boundary points in
>>> DMPlexCreatSection.  Should one call lines 235:242 only if v is constrained
>>> node ? Also, should the user provide functions for all components of all
>>> fields, is there a way to update add value of only the field that is
>>> constrained ?
>>>
>>> 234:   for (v = vStart; v < vEnd; ++v) {235:     PetscInt <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/PetscInt.html#PetscInt> dof, off;
>>> 237:     PetscSectionGetDof <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/IS/PetscSectionGetDof.html#PetscSectionGetDof>(cSection, v, &dof);238:     PetscSectionGetOffset <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/IS/PetscSectionGetOffset.html#PetscSectionGetOffset>(cSection, v, &off);239:     if (dof > dim) SETERRQ2 <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/SETERRQ2.html#SETERRQ2>(PetscObjectComm <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/PetscObjectComm.html#PetscObjectComm>((PetscObject <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Sys/PetscObject.html#PetscObject>)dm), PETSC_ERR_ARG_WRONG, "Cannot have more coordinates %d then dimensions %d", dof, dim);240:     for (d = 0; d < dof; ++d) coords[d] = PetscRealPart(cArray[off+d]);241:     for (c = 0; c < numComp; ++c) values[c] = (*funcs[c])(coords);242:     VecSetValuesSection <http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Vec/VecSetValuesSection.html#VecSetValuesSection>(localX, section, v, values, mode);243:   }
>>>
>>> ProjectFunction() just implements \int_\Omega v f(x). If you really
>> don't want to add a no-op function, I can
>>  check for NULL, but I think that is slower in the inner loop.
>>
>> Hello,
>
> I do not know how to pass Array of functions in Fortran. At this point i
> am not that worried about performance, but my understanding was that
>

We have just redone the way function pointers are handled in PETSc. I was
waiting to code this until someone asked.


> ProjectFunctionLocal along with fem.bcFuns was used set boundary
> conditions in DMPlexComputeResidualFEM.
>

Yes that is right.


> I think i miss understood the code then. How do i use the bcFields and
> bcPoints information used to create defualtSection to set boundary
> conditions ?
>

There are several ways to do BC, and the DMPlex stuff should support them
all. However, the one I am using here is to eliminate
the constrained dofs from the global system, but not the local system. So,
first constrained dofs are marked in the default PetscSection
for the DM. In ProjectFunction() the INSERT_BC_VALUES makes sure only
marked dofs get values. You are correct that I could
optimize the loop to run over only points with constrained dofs, however
this is a < 10% optimization which I am ignoring now.


> I was thinking VecSetValuesSection with mode=Insert_BC_values was updating
> the field values on the points indicated as boundary.
>

Yes, that is right.

   Thanks,

       Matt


>    Matt
>>
>>
>>
>>> --
>>> -----------------------------------------------------
>>> Dharmendar Reddy Palle
>>> Graduate Student
>>> Microelectronics Research center,
>>> University of Texas at Austin,
>>> 10100 Burnet Road, Bldg. 160
>>> MER 2.608F, TX 78758-4445
>>> e-mail: dharmareddy84 at gmail.com
>>> Phone: +1-512-350-9082
>>> United States of America.
>>> Homepage: https://webspace.utexas.edu/~dpr342
>>>
>>
>>
>>
>> --
>> 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
>>
>
>
>
> --
> -----------------------------------------------------
> Dharmendar Reddy Palle
> Graduate Student
> Microelectronics Research center,
> University of Texas at Austin,
> 10100 Burnet Road, Bldg. 160
> MER 2.608F, TX 78758-4445
> e-mail: dharmareddy84 at gmail.com
> Phone: +1-512-350-9082
> United States of America.
> Homepage: https://webspace.utexas.edu/~dpr342
>



-- 
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-users/attachments/20130404/436953c5/attachment.html>


More information about the petsc-users mailing list