On Jun 21, 2012, at 7:42 AM, Matthew Knepley wrote:
On Wed, Jun 20, 2012 at 8:40 PM, Blaise Bourdin <bourdin@lsu.edu> wrote:
Hi,
I want to change the way I handle boundary conditions in my finite elements code:
Right now, I skip the rows and columns during the matrices assembly, using a flag (a SectionInt). Using an IS denoting all dof with a BC and MatZeroRowsColumns, MatZeroRowsColumnsIS or MatZeroRowsColumnsLocal would make much more sense.
The difficulty comes up when applying a Dirichlet boundary condition on only one of the dof associated with a vertex (roller boundary conditions in elasticity, for instance). What I can easily get from Sieve is the point number associated with a vertex, for instance, from which I can obtain the _local_ index of the dof associated with a given component of a field at this point. For vectors, I can then set values on the local Vec or the Section. For matrices, though I can't just use MatGetLocalSubMatrix since I need also to modify the out of diagonal block terms.
I guess I need the LocalToGlobalMapping or to renumber the IS describing my BC and convert it to global indices. I am sure that this information is somewhere in Sieve (in the overlap, I guess), but I was thinking that since getting a Local to Global scatter is trivial, there may be a way to obtain the mapping or renumbering the IS from the scatter.
Now that I think about it more, the right way is most likely to get the information I need from Sieve.
Yes, in the new version there is jsut a LocalToGlobalMapping. In C++, you can use the GlobalNumbering,
numbering->getIndex(point) + dof offset
And for the record, in the old version, where a DMMesh can be associated with several data layout, the following seems to work (adapted from DMCreateLocalToGlobalMapping_Mesh):
Obj<PETSC_MESH_TYPE::real_section_type> s;
ALE::Obj<PETSC_MESH_TYPE> m;
ierr = DMMeshGetMesh(dm, m);CHKERRQ(ierr);
ierr = SectionRealGetSection(vsec,s);CHKERRQ(ierr);
const ALE::Obj<PETSC_MESH_TYPE::order_type>& globalOrder = m->getFactory()->getGlobalOrder(m, s->getName(), s);
offset = globalOrder->getIndex(point) + dof ;
Blaise
--