Skip to content

Commit

Permalink
Factor out dFSBuildSpaceOffsets_Private
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed Apr 12, 2011
1 parent 9ad347d commit df37b11
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
1 change: 1 addition & 0 deletions include/dohpfsimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct _p_dFSRotation {
};

extern dErr dFSCreateLocalToGlobal_Private(dFS fs,dInt n,dInt nc,dInt ngh,dInt *ghidx,dInt rstart);
extern dErr dFSBuildSpaceOffsets_Private(dFS fs,dMeshTag indexTag,const dInt inodes[],dInt rstart,dInt crstart,dInt nents,dMeshEH ents[],dInt *ghstart);
extern dErr DMDestroy_dFS(DM);

dEXTERN_C_END
Expand Down
35 changes: 5 additions & 30 deletions src/fs/impls/cont/cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,38 +355,13 @@ static dErr dFSBuildSpace_Cont(dFS fs)
crstart = rstarts[0] + rstarts[1];
}

{ /* Set offsets (global, closure, local) of first node associated with every entity */
dInt i,scan,nentsExplicit,nentsDirichlet;

/* We assume that orderedSet contains explicitSet+dirichletSet+ghostSet (in that order) */
err = dMeshGetEnts(mesh,fs->set.ordered,dTYPE_ALL,dTOPO_ALL,ents,ents_a,&ents_s);dCHK(err);
err = dMeshGetNumEnts(mesh,fs->set.explicit,dTYPE_ALL,dTOPO_ALL,&nentsExplicit);dCHK(err);
err = dMeshGetNumEnts(mesh,fs->set.dirichlet,dTYPE_ALL,dTOPO_ALL,&nentsDirichlet);dCHK(err);
err = dMeshTagGetData(mesh,ma.indexTag,ents,ents_s,idx,ents_s,dDATA_INT);dCHK(err);

/* global offset */
for (i=0,scan=rstart; i<nentsExplicit; scan+=inodes[idx[i++]])
intdata[i] = scan; /* fill \a intdata with the global offset */
for ( ; i<ents_s; i++) intdata[i] = -1;
err = dMeshTagSetData(mesh,fs->tag.goffset,ents,ents_s,intdata,ents_s,dDATA_INT);dCHK(err);

/* global closure offset */
for (i=0,scan=crstart; i<nentsExplicit+nentsDirichlet; scan+=inodes[idx[i++]])
intdata[i] = scan;
for ( ; i<ents_s; i++) intdata[i] = -1;
err = dMeshTagSetData(mesh,fs->tag.gcoffset,ents,ents_s,intdata,ents_s,dDATA_INT);dCHK(err);

/* local index */
for (i=0,scan=0; i<ents_s; scan+=inodes[idx[i++]])
intdata[i] = scan;
err = dMeshTagSetData(mesh,fs->tag.loffset,ents,ents_s,intdata,ents_s,dDATA_INT);dCHK(err);

/* Set a pointer to the ghost portion, we will work with that next */
ghents = ents + nentsExplicit + nentsDirichlet;
ghents_s = ents_s - nentsExplicit - nentsDirichlet;
{
dInt ghstart;
err = dFSBuildSpaceOffsets_Private(fs,ma.indexTag,inodes,rstart,crstart,ents_s,ents,&ghstart);dCHK(err);
ghents = ents + ghstart;
ghents_s = ents_s - ghstart;
}


/* communicate global and closure offset for ghosts */
err = dMeshTagBcast(mesh,fs->tag.goffset);dCHK(err);
err = dMeshTagBcast(mesh,fs->tag.gcoffset);dCHK(err);
Expand Down
48 changes: 48 additions & 0 deletions src/fs/interface/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,54 @@ dErr dFSBuildSpace(dFS fs)
dFunctionReturn(0);
}

/* Set offsets (global, closure, local) of first node associated with every entity
*
* @param indexTag index into inodes
* @param inodes number of interior nodes associated with each entity inodes[idx[i]]
* @param rstart relative start for global explicit dofs
* @param crstart relative start for global closure dofs
* @param nents size of array to hold entities
* @param ents returns with entities in the proper ordering of the FS
* @param ghstart returns starting offset of ghost entities in ents
*/
dErr dFSBuildSpaceOffsets_Private(dFS fs,dMeshTag indexTag,const dInt inodes[],dInt rstart,dInt crstart,dInt nents,dMeshEH ents[],dInt *ghstart)
{
dInt i,scan,nentsExplicit,nentsDirichlet,*idx,*offset;
dMesh mesh;
dErr err;

dFunctionBegin;
err = dFSGetMesh(fs,&mesh);dCHK(err);
err = dMallocA2(nents,&offset,nents,&idx);dCHK(err);
/* We assume that orderedSet contains explicitSet+dirichletSet+ghostSet (in that order) */
err = dMeshGetEnts(mesh,fs->set.ordered,dTYPE_ALL,dTOPO_ALL,ents,nents,NULL);dCHK(err);
err = dMeshGetNumEnts(mesh,fs->set.explicit,dTYPE_ALL,dTOPO_ALL,&nentsExplicit);dCHK(err);
err = dMeshGetNumEnts(mesh,fs->set.dirichlet,dTYPE_ALL,dTOPO_ALL,&nentsDirichlet);dCHK(err);
err = dMeshTagGetData(mesh,indexTag,ents,nents,idx,nents,dDATA_INT);dCHK(err);

/* global offset */
for (i=0,scan=rstart; i<nentsExplicit; scan+=inodes[idx[i++]])
offset[i] = scan;
for ( ; i<nents; i++) offset[i] = -1;
err = dMeshTagSetData(mesh,fs->tag.goffset,ents,nents,offset,nents,dDATA_INT);dCHK(err);

/* global closure offset */
for (i=0,scan=crstart; i<nentsExplicit+nentsDirichlet; scan+=inodes[idx[i++]])
offset[i] = scan;
for ( ; i<nents; i++) offset[i] = -1;
err = dMeshTagSetData(mesh,fs->tag.gcoffset,ents,nents,offset,nents,dDATA_INT);dCHK(err);

/* local index */
for (i=0,scan=0; i<nents; scan+=inodes[idx[i++]])
offset[i] = scan;
err = dMeshTagSetData(mesh,fs->tag.loffset,ents,nents,offset,nents,dDATA_INT);dCHK(err);

err = dFree2(offset,idx);dCHK(err);
*ghstart = nentsExplicit + nentsDirichlet;
dFunctionReturn(0);
}


dErr dFSCreateExpandedVector(dFS fs,Vec *x)
{
dErr err;
Expand Down

0 comments on commit df37b11

Please sign in to comment.