Skip to content

Commit

Permalink
Cleaner double-reference handling of element assembly matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed Feb 23, 2011
1 parent 34ad3b5 commit 8b483d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/fs/impls/cont/cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ dErr dFSBuildSpace_Cont_CreateElemAssemblyMats(dFS fs,const dInt idx[],const dMe

/* We don't solve systems with these so it will never make sense for them to use a different format */
err = MatCreateSeqAIJ(PETSC_COMM_SELF,xcnt,nloc,1,nnz,&E);dCHK(err);
Ep = E;
if (1) {
Ep = E;
err = PetscObjectReference((PetscObject)Ep);dCHK(err);
}

err = dJacobiAddConstraints(fs->jacobi,fs->nelem,idx,xstart,loffset,deg,ma,E,Ep);dCHK(err);

Expand All @@ -233,11 +236,13 @@ dErr dFSBuildSpace_Cont_CreateElemAssemblyMats(dFS fs,const dInt idx[],const dMe
if (E != Ep) {err = MatAssemblyEnd(Ep,MAT_FINAL_ASSEMBLY);dCHK(err);}

err = MatCreateMAIJ(E,bs,inE);dCHK(err);
if (E == Ep) *inEp = *inE;
else {err = MatCreateMAIJ(Ep,bs,inEp);dCHK(err);}
if (E == Ep) {
*inEp = *inE;
err = PetscObjectReference((PetscObject)*inEp);dCHK(err);
} else {err = MatCreateMAIJ(Ep,bs,inEp);dCHK(err);}

err = MatDestroy(E);dCHK(err);
if (E != Ep) {err = MatDestroy(Ep);dCHK(err);}
err = MatDestroy(Ep);dCHK(err);
dFunctionReturn(0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/fs/interface/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ dErr dFSDestroy(dFS fs)
err = VecDestroy(fs->dcache);dCHK(err);
err = VecScatterDestroy(fs->dscat);dCHK(err);
err = MatDestroy(fs->E);dCHK(err);
if (fs->E != fs->Ep) {err = MatDestroy(fs->Ep);dCHK(err);}
err = MatDestroy(fs->Ep);dCHK(err);
err = ISLocalToGlobalMappingDestroy(fs->bmapping);dCHK(err);
err = ISLocalToGlobalMappingDestroy(fs->mapping);dCHK(err);
err = dFree(fs->off);dCHK(err);
Expand Down

0 comments on commit 8b483d7

Please sign in to comment.