Skip to content

Commit

Permalink
Add guarded accessors for geometry and relations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed Jun 13, 2011
1 parent 5456e73 commit f8793ec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
12 changes: 10 additions & 2 deletions include/dohpmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
#define _DOHPMESH_H

#include <petscsys.h>
#include <stdlib.h>
#include <string.h>
#include <dohptype.h>
#include <dohpjacobi.h>

#ifdef dHAVE_ITAPS_REL
# include <iGeom.h>
# include <iRel.h>
#endif

dEXTERN_C_BEGIN

typedef struct _p_dMeshPacker *dMeshPacker;
Expand Down Expand Up @@ -168,6 +171,11 @@ extern dErr dMeshPartitionOnOwnership(dMesh,dMeshEH[],dInt,dInt*);
extern dErr dMeshMorph(dMesh,void(*morph)(void*,double*),void*);
extern dErr dMeshSetClosure(dMesh,dMeshESH);

#ifdef dHAVE_ITAPS_REL
extern dErr dMeshSetGeometryRelation(dMesh,iGeom_Instance,iRel_Instance);
extern dErr dMeshGetGeometryRelation(dMesh,iGeom_Instance*,iRel_Instance*);
#endif

dEXTERN_C_END

#endif
4 changes: 4 additions & 0 deletions include/dohpmeshimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ struct _p_dMesh {
PETSCHEADER(struct _dMeshOps);
char *infile,*inoptions;
iMesh_Instance mi;
#ifdef dHAVE_ITAPS_REL
iGeom_Instance igeom;
iRel_Instance irel;
#endif
dMeshESH root,emptyset;
dMeshTag senseTag;
MeshListEH v,e,f,r; /* vertices, edges, faces, vertices */
Expand Down
2 changes: 1 addition & 1 deletion include/dohptype.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _DOHPTYPE_H
#define _DOHPTYPE_H

#include "dohpconfig.h"
#include <dohpconfig.h>
#include <petscconf.h>
#include <iMesh.h>
#include <mpi.h>
Expand Down
33 changes: 32 additions & 1 deletion src/fs/mesh/interface/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ dErr dMeshDestroy(dMesh *meshp)
{
dMesh m = *meshp;
dErr err;
dIInt ierr;

dFunctionBegin;
if (!m) dFunctionReturn(0);
Expand All @@ -1120,9 +1121,13 @@ dErr dMeshDestroy(dMesh *meshp)
MeshListFree(m->arf); MeshListFree(m->afe); MeshListFree(m->aev);
MeshListFree(m->orf); MeshListFree(m->ofe);
MeshListFree(m->x);
iMesh_dtor(m->mi,&err);dICHK(m->mi,err);
iMesh_dtor(m->mi,&ierr);dICHK(m->mi,ierr);
err = PetscFree(m->infile);dCHK(err);
err = PetscFree(m->inoptions);dCHK(err);
#ifdef dHAVE_ITAPS_REL
if (m->irel) {iRel_destroy(m->irel,&ierr);dIRCHK(m->irel,ierr);}
if (m->igeom) {iGeom_dtor(m->igeom,&ierr);dIGCHK(m->igeom,ierr);}
#endif
err = PetscHeaderDestroy(meshp);dCHK(err);
dFunctionReturn(0);
}
Expand Down Expand Up @@ -1535,3 +1540,29 @@ dErr dMeshSetClosure(dMesh mesh,dMeshESH set)
ents_a = adj_a = off_a = 0;
dFunctionReturn(0);
}

#ifdef dHAVE_ITAPS_REL
// The mesh takes ownership with this call. ITAPS interfaces do not have reference counting.
dErr dMeshSetGeometryRelation(dMesh mesh,iGeom_Instance geom,iRel_Instance rel)
{
dFunctionBegin;
dValidHeader(mesh,dMESH_CLASSID,1);
if (rel) {
if (mesh->irel && rel != mesh->irel) dERROR(((dObject)mesh)->comm,PETSC_ERR_ARG_WRONGSTATE,"Can only set relation once");
mesh->irel = rel;
}
if (geom) {
if (mesh->igeom && geom != mesh->igeom) dERROR(((dObject)mesh)->comm,PETSC_ERR_ARG_WRONGSTATE,"Can only set geometry once");
mesh->igeom = geom;
}
dFunctionReturn(0);
}
dErr dMeshGetGeometryRelation(dMesh mesh,iGeom_Instance *geom,iRel_Instance *rel)
{
dFunctionBegin;
dValidHeader(mesh,dMESH_CLASSID,1);
if (rel) *rel = mesh->irel;
if (geom) *geom = mesh->igeom;
dFunctionReturn(0);
}
#endif

0 comments on commit f8793ec

Please sign in to comment.