dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #03750
Re: Periodic BC's
Great that it's working, even if it's not very fast yet.
Are you using PETSc (--enable-petsc)? Also, are you manipulating many
terms in each row, or just two (adding just -1 and 1)? If you are adding
just -1 and 1 at two positions, this should be OK with uBlas. Use
ident(..) to zero the row and then add your terms using set(..).
getRow() is unlikely to work as it returns a copy of the row, so you
won't be able to get your information back into the matrix. It's
difficult to get a reference to a row through GenericMatrix as the
different linear algebra backends have different data structures.
If you need more, I would recommend deriving class from FEM and adding a
function to do what you need and use uBlas matrices and vectors rather
than Generic*. uBlas matrices are very good for this they are the
default if you don't enable PETSc. Make something like
class MyFEM : FEM
{
static void applyPeridocBC(uBlasSparseMatrix& A, uBlasVector& b,
Mesh& mesh, FiniteElement& element, BoundaryCondition& bc);
};
With uBlas, you can get the a matrix to return a vector reference to a
particular row.
Garth
Ivo Conradi wrote:
> Thanks for the responses. I added some periodicity data to the mesh
> object and got the FEM to manipulate the matrix and vector (with
> GenericMatrix::get/set) to apply the periodic bc's. This works, but
> unfortunately this is not very fast, because I don't use any sparsity
> information.
>
> This is why I would like to know if it is possible to add a getRow()
> function to GenericMatrix. As far as I know the derived classes
> support it and it would help me speed up things, but I have been unable
> to get it working.
>
> Any comments would be highly appreciated.
>
> regards,
>
> Ivo
>
> On Mon, Nov 13, 2006 at 09:28:07AM +0100, Johan Hoffman wrote:
>> You may for example apply your periodic bc by identifying "master and
>> slave" dofs on the two (if periodic in one direction) periodic boundaries;
>> so that when assembling, all contribution to the slave dofs are added to
>> the corresponding master dofs, and the slave dofs are then identified with
>> the master dofs (in the simplest way by using 1 and -1 in the rows of the
>> slave dofs; maybe not that pretty, but it works in many cases...).
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
References