[petsc-users] Question about DMDA BOUNDARY_CONDITION set

Barry Smith bsmith at mcs.anl.gov
Tue Apr 4 13:59:39 CDT 2017


> On Apr 4, 2017, at 1:24 AM, Wenbo Zhao <zhaowenbo.npic at gmail.com> wrote:
> 
> Barry,
> 
> Thanks.
> 
> It is my fault. I should not mix the VecScatter and MatSetValues.
> 
> 1. Matrix assemble
> There are only two options matrix for case with rotation boundary.
> The first is using "MatSetoption(A,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_FALSE)".
> The second is to create matrix by hand.
> Is it correct?

  Yes

> 
> 2. VecScatter
> It will be used to get the values on ghosted cell.
> My case is neutron diffusion equation which is like below:
> \( -\nabla \cdot D_g \nabla \phi_g + \Sigma_{r,g}\phi_g - \sum_{g' \neq g} \Sigma_{s,g'\to g} \phi_{g'} = \frac{1}{Keff} \chi_g \sum_{g' = 1, G} \nu\Sigma_{f,g'}\phi_{g'}  \)
> where g denotes energy group, G is the number of energy groups, \(D_g\) is the diffusion coefficient of group g, \(\Sigma_{r,g}\) is the removal cross section of group g,
> \(\Sigma_{s,g'\to g}\) is the scatter cross section from group g' to group g, \(chi_g\) is the fission spectral of group g, \(\nu\Sigma_{f,g'}\) is the fission production cross section,
> \(\phi_g\) is neutron flux and eigenvector, Keff is the eigenvalue.
> The diffusion coefficients and other cross sections varied in the region and are distributed on procs. 
> If I use mesh-centerd seven point finite difference method for 3D, the degree of freedom is G and \(D_g\) need comunication.
> 
> I get the \(D_g\) of the ghost cell through VecScatter and insert values to matrix.

   I don't understand what you are getting at here. Why would you ever take values from a vector and put them in a matrix. In PETSc vectors contain field variables and matrices contain operators on fields. Or do you mean by "matrix" a multidimensional array used to represent a field? The actual matrix operator for the equation above is very complicated if you fully compute the entries in the operator.

> Is it correct?
> 
> BEST,
> 
> Wenbo



More information about the petsc-users mailing list