Skip to content

Commit

Permalink
Merge branch 'knepley/fix-plex-closure-index' into next
Browse files Browse the repository at this point in the history
* knepley/fix-plex-closure-index:
  PetscSection: Change clIndices member to clPoints - Added some docs
  • Loading branch information
knepley committed Jan 2, 2014
2 parents a652896 + 2a50d0e commit 9c16e23
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/petsc-private/isimpl.h
Expand Up @@ -73,9 +73,9 @@ struct _p_PetscSection {
PetscInt *numFieldComponents; /* The number of components in each field */
PetscSection *field; /* A section describing the layout and constraints for each field */

PetscObject clObj; /* Key forthe closure (right now we only have one) */
PetscSection clSection; /* Section for the closure index */
IS clIndices; /* Indices for the closure index */
PetscObject clObj; /* Key for the closure (right now we only have one) */
PetscSection clSection; /* Section giving the number of points in each closure */
IS clPoints; /* Points in each closure */
};


Expand Down
48 changes: 40 additions & 8 deletions src/vec/is/utils/vsectionis.c
Expand Up @@ -59,7 +59,7 @@ PetscErrorCode PetscSectionCreate(MPI_Comm comm, PetscSection *s)
(*s)->field = NULL;
(*s)->clObj = NULL;
(*s)->clSection = NULL;
(*s)->clIndices = NULL;
(*s)->clPoints = NULL;
PetscFunctionReturn(0);
}

Expand Down Expand Up @@ -1479,7 +1479,7 @@ PetscErrorCode PetscSectionReset(PetscSection s)
ierr = PetscFree(s->bcIndices);CHKERRQ(ierr);
ierr = PetscFree2(s->atlasDof, s->atlasOff);CHKERRQ(ierr);
ierr = PetscSectionDestroy(&s->clSection);CHKERRQ(ierr);
ierr = ISDestroy(&s->clIndices);CHKERRQ(ierr);
ierr = ISDestroy(&s->clPoints);CHKERRQ(ierr);

s->atlasLayout.pStart = -1;
s->atlasLayout.pEnd = -1;
Expand Down Expand Up @@ -1987,30 +1987,62 @@ PetscErrorCode PetscSFCreateSectionSF(PetscSF sf, PetscSection rootSection, Pets

#undef __FUNCT__
#define __FUNCT__ "PetscSectionSetClosureIndex"
PetscErrorCode PetscSectionSetClosureIndex(PetscSection section, PetscObject obj, PetscSection clSection, IS clIndices)
/*@
PetscSectionSetClosureIndex - Set a cache of points in the closure of each point in the section
Input Parameters:
+ section - The PetscSection
. obj - A PetscObject which serves as the key for this index
. clSection - Section giving the size of the closure of each point
- clPoints - IS giving the points in each closure
Note: We compress out closure points with no dofs in this section
Level: intermediate
.seealso: PetscSectionGetClosureIndex(), DMPlexCreateClosureIndex()
@*/
PetscErrorCode PetscSectionSetClosureIndex(PetscSection section, PetscObject obj, PetscSection clSection, IS clPoints)
{
PetscErrorCode ierr;

PetscFunctionBegin;
section->clObj = obj;
ierr = PetscSectionDestroy(&section->clSection);CHKERRQ(ierr);
ierr = ISDestroy(&section->clIndices);CHKERRQ(ierr);
ierr = ISDestroy(&section->clPoints);CHKERRQ(ierr);
section->clSection = clSection;
section->clIndices = clIndices;
section->clPoints = clPoints;
PetscFunctionReturn(0);
}

#undef __FUNCT__
#define __FUNCT__ "PetscSectionGetClosureIndex"
PetscErrorCode PetscSectionGetClosureIndex(PetscSection section, PetscObject obj, PetscSection *clSection, IS *clIndices)
/*@
PetscSectionGetClosureIndex - Get the cache of points in the closure of each point in the section
Input Parameters:
+ section - The PetscSection
- obj - A PetscObject which serves as the key for this index
Output Parameters:
+ clSection - Section giving the size of the closure of each point
- clPoints - IS giving the points in each closure
Note: We compress out closure points with no dofs in this section
Level: intermediate
.seealso: PetscSectionSetClosureIndex(), DMPlexCreateClosureIndex()
@*/
PetscErrorCode PetscSectionGetClosureIndex(PetscSection section, PetscObject obj, PetscSection *clSection, IS *clPoints)
{
PetscFunctionBegin;
if (section->clObj == obj) {
if (clSection) *clSection = section->clSection;
if (clIndices) *clIndices = section->clIndices;
if (clPoints) *clPoints = section->clPoints;
} else {
if (clSection) *clSection = NULL;
if (clIndices) *clIndices = NULL;
if (clPoints) *clPoints = NULL;
}
PetscFunctionReturn(0);
}

0 comments on commit 9c16e23

Please sign in to comment.