[petsc-users] MatZeroRows and MATELEMENTAL
Francesco Ballarin
francesco.ballarin at polimi.it
Tue Oct 28 15:30:35 CDT 2014
Thanks Jack, Barry and Matt.
I patched my PETSc 3.5.2 as follows, but I am not really sure that this is
the correct way (for example, I see in MatSetValues_Elemental two calls to
functions P2RO and RO2E for the computation of the local row index but I do
not understand what is their purpose, nor if I should apply them also to
rowInd[s]).
Thanks
======
diff --git a/petsc/src/mat/impls/elemental/matelem.cxx
b/petsc/src/mat/impls/elemental/matelem.cxx
--- a/petsc/src/mat/impls/elemental/matelem.cxx
+++ b/petsc/src/mat/impls/elemental/matelem.cxx
@@ -772,6 +772,36 @@ static PetscErrorCode MatZeroEntries_Elemental(Mat A)
}
#undef __FUNCT__
+#define __FUNCT__ "MatZeroRows_Elemental"
+PetscErrorCode MatZeroRows_Elemental(Mat AA,PetscInt N,const PetscInt
rows[],PetscScalar diag,Vec /*x*/,Vec /*b*/)
+{
+ // TODO: consider also the optional arguments x and b.
+ Mat_Elemental * a( (Mat_Elemental*)AA->data );
+ elem::DistMatrix<PetscElemScalar> * A( a->emat );
+
+ PetscFunctionBegin;
+ std::vector<PetscInt> rowInd(rows,rows+N);
+ const elem::Int localWidth( A->LocalWidth() );
+ for( elem::Int s(0); s < N; ++s )
+ {
+ const elem::Int row = rowInd[s];
+ if( A->IsLocalRow(row) )
+ {
+ const elem::Int iLoc(A->LocalRow(row));
+ for( elem::Int jLoc(0); jLoc < localWidth; ++jLoc )
+ {
+ const elem::Int j(A->GlobalCol(jLoc));
+ if( row == j )
+ A->SetLocal( iLoc, jLoc, diag );
+ else
+ A->SetLocal( iLoc, jLoc, 0. );
+ }
+ }
+ }
+ PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
#define __FUNCT__ "MatGetOwnershipIS_Elemental"
static PetscErrorCode MatGetOwnershipIS_Elemental(Mat A,IS *rows,IS *cols)
{
@@ -957,7 +987,7 @@ static struct _MatOps MatOps_Values = {
MatAssemblyEnd_Elemental,
0, //MatSetOption_Elemental,
MatZeroEntries_Elemental,
-/*24*/ 0,
+/*24*/ MatZeroRows_Elemental,
MatLUFactorSymbolic_Elemental,
MatLUFactorNumeric_Elemental,
MatCholeskyFactorSymbolic_Elemental,
======
On Mon, Oct 27, 2014 at 11:00 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> > On Oct 26, 2014, at 4:32 AM, Francesco Ballarin <
> francesco.ballarin at polimi.it> wrote:
> >
> > Dear PETSc users,
> > I have a code for PETSc 3.3 in which the PLAPACK interface, now
> discontinued, was used. I am trying to update it to PETSc 3.5.2, using the
> Elemental interface.
> >
> > I see that MatZeroRows is not implemented for MATELEMENTAL. What
> function should I use instead? Does it also support the version with
> optional arguments x and b?
>
> Unfortunately due to Elemental’s complicated parallel storage of matrix
> entries we don’t have any routines to do this. (We don’t even have routines
> to generically set values INSERT_VALUES) on other processes. cc:ing
> Elemental’s author to see what he suggests.
>
> Barry
>
> >
> > Thanks,
> > best regards,
> > Francesco
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141028/71ffc814/attachment.html>
More information about the petsc-users
mailing list