Skip to content

Commit

Permalink
Factor dFSCreateLocalToGlobal_Private() out of dFSBuildSpace_Cont()
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed Nov 29, 2009
1 parent 53df545 commit bf8923b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
2 changes: 2 additions & 0 deletions include/dohpfsimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ struct _p_dFSRotation {
Vec strong; /**< Values for all strongly enforced dofs */
};

extern dErr dFSCreateLocalToGlobal_Private(dFS fs,dInt n,dInt nc,dInt ngh,dInt *ghidx,dInt rstart);

PETSC_EXTERN_CXX_END

#endif
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ list (APPEND Dohp_SRCS
# ADD_SUBDIRECTORY (fs)
list (APPEND Dohp_SRCS
fs/interface/fs.c
fs/interface/fsbuild.c
fs/interface/fsreg.c
fs/interface/fsrot.c
fs/interface/fsgeom.c
Expand Down
42 changes: 2 additions & 40 deletions src/fs/impls/cont/cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,46 +346,8 @@ static dErr dFSBuildSpace_Cont(dFS fs)
err = VecCreateDohp(((dObject)fs)->comm,bs,n,nc,ngh,ghidx,&fs->gvec);dCHK(err);
}

/* Create block local to global mapping */
{
Vec g,gc,lf;
dInt i,*globals;
dScalar *a;
err = dFSCreateGlobalVector(fs,&g);dCHK(err);
err = VecDohpGetClosure(g,&gc);dCHK(err);
err = VecSet(gc,-1);dCHK(err);
err = VecSet(g,1);dCHK(err);
err = VecGhostUpdateBegin(gc,INSERT_VALUES,SCATTER_FORWARD);dCHK(err);
err = VecGhostUpdateEnd(gc,INSERT_VALUES,SCATTER_FORWARD);dCHK(err);
err = VecGhostGetLocalForm(gc,&lf);dCHK(err);
err = dMallocA(nc+ngh,&globals);dCHK(err);
err = VecGetArray(lf,&a);dCHK(err);
/* \a a is a mask determining whether a value is represented in the global system (1) or not (-1) */
for (i=0; i<n; i++) {
if (a[i*bs] != 1) dERROR(1,"should not happen");
globals[i] = rstart+i;
}
for ( ; i<nc; i++) {
if (a[i*bs] != -1) dERROR(1,"should not happen");
globals[i] = -(rstart + i);
}
for ( ; i<nc+ngh; i++) {
globals[i] = signbit(a[i*bs]) * ghidx[i-nc];
}
err = VecRestoreArray(lf,&a);dCHK(err);
err = VecGhostRestoreLocalForm(gc,&lf);dCHK(err);
err = VecDohpRestoreClosure(g,&gc);dCHK(err);
err = VecDestroy(g);dCHK(err);
err = ISLocalToGlobalMappingCreateNC(((dObject)fs)->comm,nc+ngh,globals,&fs->bmapping);dCHK(err);
/* Don't free \a globals because we used the no-copy variant, so the IS takes ownership. */
{
dInt *sglobals; /* Scalar globals */
err = dMallocA((nc+ngh)*bs,&sglobals);dCHK(err);
for (i=0; i<(nc+ngh)*bs; i++) sglobals[i] = globals[i/bs]*bs + i%bs;
err = ISLocalToGlobalMappingCreateNC(((dObject)fs)->comm,(nc+ngh)*bs,sglobals,&fs->mapping);dCHK(err);
/* Don't free \a sglobals because we used the no-copy variant, so the IS takes ownership. */
}
}
/* Create fs->bmapping and fs->mapping */
err = dFSCreateLocalToGlobal_Private(fs,n,nc,ngh,ghidx,rstart);dCHK(err);

/* Create a cache for Dirichlet part of closure vector, this could be local but it doesn't cost anything to make it global */
{
Expand Down

0 comments on commit bf8923b

Please sign in to comment.