[petsc-users] Advice on setting Dirichlet bcs in DMPlex

Aldo Bonfiglioli aldo.bonfiglioli at unibas.it
Thu Dec 19 11:39:02 CST 2024


Dear all,

I am using TS to solve the PDE

u_t + c * u_c = eps * u_xx in 1D i.e. smthg. similar to 
https://urldefense.us/v3/__https://petsc.org/release/src/ts/tutorials/ex4.c.html__;!!G_uCfscf7eWS!eeErx_FNg50N1eRlD9eyfoEp8I0llTQmVFpPWoz5_LQhL8K6uOId5zbgle0ghE71NJmon8T_vwwfN3LnEbf4cTUXtlkWJRflikU$ 

except that I am using DMPlex, instead of a structured grid.

Since the problem is linear, I tried smthg. like:

>    PetscCall(RHSMatrixHeat(ts,0.0,u,A,A,&appctx));
>    PetscCall(TSSetRHSFunction(ts,NULL,TSComputeRHSFunctionLinear,&appctx)); 
>
>    PetscCall(TSSetRHSJacobian(ts,A,A,TSComputeRHSJacobianConstant,&appctx));
>
My problem is that the A matrix (as well as the global vector) is 
missing the rows/cols corresponding to the endpoints where Dirichlet 
boundary conditions are prescribed;

> 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.

therefore, A*u = f(u) except in the two vertices adjacent to the 
endpoints, i.e. first and last entries of the global vector.

The code is attached; when the flag -use_jacobian is set, f(u) is 
computed as A*u, if it is not set, f(u) is computed in FormRHSFunction.

The latter approach works, the former does not.

Regards,

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!eeErx_FNg50N1eRlD9eyfoEp8I0llTQmVFpPWoz5_LQhL8K6uOId5zbgle0ghE71NJmon8T_vwwfN3LnEbf4cTUXtlkWzhmq6Yg$ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241219/aaf2de11/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex15f90.F90
Type: text/x-fortran
Size: 28898 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241219/aaf2de11/attachment-0001.bin>
-------------- next part --------------
-dm_plex_dim 1 
-Peclet 50
-dm_plex_shape box 
-dm_plex_box_faces 30 
-dm_plex_simplex true
-dm_plex_interpolate 
-dm_plex_check_all
-dm_petscsection_view
-ts_max_steps 5000
-options_left


More information about the petsc-users mailing list