[petsc-users] Advice on setting BCs in a PLEX
Matthew Knepley
knepley at gmail.com
Mon Nov 4 17:20:27 CST 2024
On Mon, Nov 4, 2024 at 7:10 PM Aldo Bonfiglioli <aldo.bonfiglioli at unibas.it>
wrote:
> Dear users,
>
> I have been using petsc's KSP for over 20 years and I am considering using
> DMPLEX to replace my own data structure in a mixed FEM/FVM CFD code.
>
> To do so, I am trying to understand DMPLEX by writing a 1D code that
> solves u_t = u_xx using PSEUDOTS.
>
> In order to prescribe Dirichlet BCs at the endpoints of the 1D box, I use
> PetscSectionSetConstraintDof when building the PetscSection.
>
> A global vector is missing both the shared dofs which are not owned by
> this process, as well as *constrained* dofs. These constraints represent
> essential (Dirichlet) boundary conditions. They are dofs that have a given
> fixed value, so they are present in local vectors for assembly purposes,
> but absent from global vectors since they are never solved for during
> algebraic solves.
>
>
>
> My global Vec has indeed two entries less than the local one.
>
> When initializing the solution or evaluating the rhs function I transfer
> data from the global to local representation, do the calculation, then
> transfer back.
>
> I am doing something wrong, though, which shows up in the attached log
> file.
>
> My simple code is also attached.
>
> Hi Aldo,
I think we are very close to working. The PetscSection only care about the
sizes of things, like vectors, and it seems
like that is right. Now you want the boundary values to be put in your
vectors (I think). There needs to be a routine
to stick in the boundary values, which is DMPlexInsertBoundaryValues().
You can change this function by calling
PetscObjectFunctionCompose() for "DMPlexInsertBoundaryValues_C".
Does that make sense?
Thanks,
Matt
> Thank you for your advice.
>
> Aldo
>
> --
> Dr. Aldo Bonfiglioli
> Associate professor of Fluid Machines
> Scuola di Ingegneria
> Universita' della Basilicata
> V.le dell'Ateneo lucano, 10 85100 Potenza ITALY
> tel:+39.0971.205203 fax:+39.0971.205215
> web: https://urldefense.us/v3/__http://docenti.unibas.it/site/home/docente.html?m=002423__;!!G_uCfscf7eWS!Yef4Gll06T0STqTT9tclyiR99EATrA8nCwlcq7LOmCo4TPWg3fYGMZS0Ohp-XcuAHGtnTiIEQOhfmV77lCcX$ <https://urldefense.us/v3/__http://docenti.unibas.it/site/home/docente.html?m=002423__;!!G_uCfscf7eWS!cWgDpzKW9KGEkqxu775gDU488CBQ5itLl2l_HUsDKcPstbcuSm0_bZPHkMciXajTi3539fuMPe8TD1YZuirDfmSBMSXXxrQZWns$>
>
>
--
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
https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Yef4Gll06T0STqTT9tclyiR99EATrA8nCwlcq7LOmCo4TPWg3fYGMZS0Ohp-XcuAHGtnTiIEQOhfmSraytgu$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Yef4Gll06T0STqTT9tclyiR99EATrA8nCwlcq7LOmCo4TPWg3fYGMZS0Ohp-XcuAHGtnTiIEQOhfmf3oD6xM$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241105/5585c0e9/attachment.html>
More information about the petsc-users
mailing list