Skip to content

Commit

Permalink
Started the dFS object.
Browse files Browse the repository at this point in the history
This object should handle constraining degrees of freedom and function
spaces on a subdomain of the mesh.  Eventually it will be a full-fledged
PETSc DM object.  For problems with mixed discretization, there will be
a dMFS (multi function space) object.  All fields in a dMFS will need to
be discretized over a dFS and that dFS must share the same dQuotient.
If this property is not satisfied, just use Barry's DMComposite.

Signed-off-by: Jed Brown <jed@59A2.org>
  • Loading branch information
jedbrown committed Sep 7, 2008
1 parent 07ecd2a commit 21795e3
Show file tree
Hide file tree
Showing 24 changed files with 596 additions and 148 deletions.
45 changes: 45 additions & 0 deletions include/dohpfs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef _DOHPFS_H
#define _DOHPFS_H
/**
* @file dohpfs.h
* @author Jed Brown <jed@59A2.org>
* @date Sun Sep 7 17:46:54 2008
*
* @brief The function space object
*
*
*/

#include "dohpmesh.h"
#include "dohpjacobi.h"
#include "dohpquotient.h"
#include "petscpf.h"

PETSC_EXTERN_CXX_BEGIN

typedef struct _p_dFS *dFS;

#define dFSType char *

#define dFSCONT "cont"

extern PetscCookie dFS_COOKIE;

EXTERN dErr dFSCreate(MPI_Comm,dFS*);
EXTERN dErr dFSSetMesh(dFS,dMesh,dMeshESH,dMeshTag); /* mesh, active set, partition tag */
EXTERN dErr dFSSetQuotient(dFS,dQuotient); /* must be defined at least on the active set and boundary facets */
EXTERN dErr dFSSetDegree(dFS,dMeshTag,dJacobi);
EXTERN dErr dFSAddBdy(dFS,const char*,dMeshESH,dMeshTag,dBool,PF); /* name, facets, orientation tag, flip orientation?, normal -> constraints */
EXTERN dErr dFSSetUp(dFS);
EXTERN dErr dFSSetType(dFS,const dFSType);
EXTERN dErr dFSSetFromOptions(dFS);

EXTERN dErr dFSDestroy(dFS);
EXTERN dErr dFSView(dFS,PetscViewer);
#define dFSRegisterDynamic(a,b,c,d) dFSRegister(a,b,c,d)
EXTERN dErr dFSRegister(const char[],const char[],const char[],dErr(*)(dFS));
EXTERN dErr dFSRegisterAll(const char[]);
EXTERN dErr dFSInitializePackage(const char[]);

PETSC_EXTERN_CXX_END
#endif /* _DOHPFS_H */
3 changes: 2 additions & 1 deletion include/dohpjacobi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

PETSC_EXTERN_CXX_BEGIN

extern PetscCookie dJACOBI_COOKIE;

/**
* Handle for manipulating EFS objects. Since these are actually stored in arrays, the handle is the actual object
* rather than just a pointer. This means that a certain amount of library code (dFS) will have to be able to see the
Expand Down Expand Up @@ -65,7 +67,6 @@ EXTERN dErr dJacobiCreate(MPI_Comm,dJacobi*);
EXTERN dErr dJacobiSetType(dJacobi,dJacobiType);
EXTERN dErr dJacobiSetFromOptions(dJacobi);
EXTERN dErr dJacobiSetUp(dJacobi);
EXTERN dErr dJacobiSetFromOptions(dJacobi);
EXTERN dErr dJacobiDestroy(dJacobi);
EXTERN dErr dJacobiView(dJacobi,PetscViewer);
#define dJacobiRegisterDynamic(a,b,c,d) dJacobiRegister(a,b,c,d)
Expand Down
40 changes: 22 additions & 18 deletions include/dohpmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

PETSC_EXTERN_CXX_BEGIN

typedef int MeshInt;
typedef double MeshReal;
typedef iBase_EntityHandle DohpEH;
typedef iBase_TagHandle DohpTag;
typedef iBase_EntitySetHandle DohpESH;
typedef int dMeshInt;
typedef double dMeshReal;
typedef iBase_EntityHandle dMeshEH;
typedef iBase_TagHandle dMeshTag;
typedef iBase_EntitySetHandle dMeshESH;

extern PetscCookie dMESH_COOKIE;

EXTERN const char *const iBase_ErrorString[];
EXTERN const char *const iMesh_TopologyName[];
Expand All @@ -23,6 +25,7 @@ EXTERN const char *const iBase_TagValueTypeName[];
// #define ICHKERRQ(n) if (n) { dERROR(1,"ITAPS error: %s", iBase_ErrorString[n]); }

/* Unfortunately the explicit `mesh' is necessary to get a useful error string */
#define dICHK(m,e) ICHKERRQ((m),(e))
#define ICHKERRQ(mesh,err) \
if (err) { \
dErr _l_ret = err; \
Expand All @@ -49,31 +52,31 @@ typedef unsigned short DohpOrient;

typedef struct {
char *v;
MeshInt a,s;
dMeshInt a,s;
} MeshListData;

typedef struct {
MeshReal *v;
MeshInt a, s;
dMeshReal *v;
dMeshInt a, s;
} MeshListReal;

typedef struct {
MeshInt *v, a, s;
dMeshInt *v, a, s;
} MeshListInt;

typedef struct {
DohpEH *v;
MeshInt a, s;
dMeshEH *v;
dMeshInt a, s;
} MeshListEH;

typedef struct {
DohpESH *v;
MeshInt a,s;
dMeshESH *v;
dMeshInt a,s;
} MeshListESH;

typedef struct {
DohpTag *v;
MeshInt a,s;
dMeshTag *v;
dMeshInt a,s;
} MeshListTag;

/* Use this macro to zero a MeshListXXX, i.e. MeshListInt a=MLZ; */
Expand Down Expand Up @@ -113,21 +116,22 @@ static const int DohpHexQuad[6][4] = {{0,1,5,4}, {1,2,6,5}, {2,3,7,6}, {3,0,4,7}
* */
static const int DohpQuadLine[4][2] = {{0,1},{1,2},{2,3},{3,4}};

EXTERN dErr MeshListIntView(MeshListInt *,const char *);
EXTERN dErr MeshListIntView(MeshListInt*,const char*);
EXTERN dErr MeshListEHView(MeshListEH*,const char*);
EXTERN dErr DohpOrientFindPerm_HexQuad(const iBase_EntityHandle *,const iBase_EntityHandle *,dInt,DohpOrient*);
EXTERN dErr DohpOrientFindPerm_QuadLine(const iBase_EntityHandle *,const iBase_EntityHandle *,dInt,DohpOrient*);

typedef struct p_dMesh *dMesh;

EXTERN dErr dMeshGetLocalNodeNumbering(dMesh,dInt,dInt*,dInt*);
EXTERN dErr dMeshGetTagName(dMesh m,DohpTag tag,char **name);
EXTERN dErr dMeshGetTagName(dMesh m,dMeshTag tag,char **name);
EXTERN dErr dMeshLoad(dMesh m,const char fname[],const char opt[]);
EXTERN dErr dMeshCreate(MPI_Comm comm,dMesh *inm);
EXTERN dErr dMeshOrientFacets(dMesh m);
EXTERN dErr dMeshDestroy(dMesh);
EXTERN dErr dMeshView(dMesh,PetscViewer);
EXTERN dErr dMeshRegisterAll(const char path[]);
EXTERN dErr dMeshGetEntSetName(dMesh m,DohpESH set,char **str);
EXTERN dErr dMeshGetEntSetName(dMesh m,dMeshESH set,char **str);

PETSC_EXTERN_CXX_END
#endif
6 changes: 5 additions & 1 deletion include/dohpquotient.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _DOHPQUOTIENT_H

#include "dohpmesh.h"
#include "dohpjacobi.h"

PETSC_EXTERN_CXX_BEGIN

Expand All @@ -15,10 +16,12 @@ typedef dErr (*dQuotientSetDegreeFunc)(dQuotient,void*,dInt,dInt[]);
#define dQuotientGauss "gauss"

EXTERN dErr dQuotientUpdate(dQuotient);
EXTERN dErr dQuotientCreate(dMesh m,DohpESH loc,DohpTag qsizetag,dQuotient *inq);
EXTERN dErr dQuotientCreate(dMesh m,dMeshESH loc,dMeshTag qsizetag,dQuotient *inq);
EXTERN dErr dQuotientSetType(dQuotient q,const dQuotientType type);
EXTERN dErr dQuotientSetFromOptions(dQuotient q);
EXTERN dErr dQuotientSetUp(dQuotient q);
EXTERN dErr dQuotientGetMesh(dQuotient,dMesh*);

EXTERN dErr dQuotientDestroy(dQuotient q);
EXTERN dErr dQuotientRegister(const char sname[],const char path[],const char name[],dErr (*function)(dQuotient));
EXTERN dErr dQuotientRegisterAll(const char path[]);
Expand All @@ -27,6 +30,7 @@ EXTERN dErr dQuotientView(dQuotient q,PetscViewer viewer);
EXTERN dErr dQuotientInitializePackage(const char path[]);
EXTERN dErr dQuotientSetSetDegree(dQuotient q,dQuotientSetDegreeFunc func,void *ctx);
EXTERN dErr dQuotientSetDegreeConst(dQuotient q,void *vval,dInt n,dInt *degree);
EXTERN dErr dQuotientGetArrRule(dQuotient q,dInt,dMeshEH[],dRule**);

PETSC_EXTERN_CXX_END

Expand Down
2 changes: 1 addition & 1 deletion include/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CFLAGS =
FFLAGS =
SOURCEC =
SOURCEF =
SOURCEH = dohptype.h dohp.h private/dohpimpl.h dohpmesh.h dohpbase.h dohpquotient.h dohpjacobi.h uthash.h
SOURCEH = dohptype.h dohp.h private/dohpimpl.h dohpmesh.h dohpbase.h dohpquotient.h dohpjacobi.h uthash.h dohpfs.h
OBJSC =
OBJSF =
LIBBASE = libdohp
Expand Down
6 changes: 3 additions & 3 deletions include/private/dohpimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "dohp.h"
#include "src/dm/dmimpl.h"
// #include "private/fsimpl.h"
// #include "private/jacimpl.h"

PetscCookie dDM_COOKIE;
PetscLogEvent dLOG_MatMult, dLOG_FunctionEval, dLOG_JacobianEval;
Expand Down Expand Up @@ -168,8 +168,8 @@ struct _dQuotientOps {
struct p_dQuotient {
PETSCHEADER(struct _dQuotientOps);
dMesh mesh;
DohpTag qsizetag;
DohpESH loc;
dMeshTag qsizetag;
dMeshESH loc;
dInt nelems;
dInt *degree;
void **quad; // element quadrature context for locally owned elements
Expand Down
98 changes: 23 additions & 75 deletions include/private/fsimpl.h
Original file line number Diff line number Diff line change
@@ -1,91 +1,39 @@
#ifndef _FSIMPL_H
#define _FSIMPL_H

#include "dohpjacobi.h"
#include "dohpfs.h"
#include "src/dm/dmimpl.h"

PETSC_EXTERN_CXX_BEGIN

/**
* There is exactly one #dRule on each element. The ops table is normally shared across the domain.
*
*/
struct v_dRuleOps {
dErr (*view)(dRule,PetscViewer);
dErr (*getSize)(dRule,dInt*,dInt*); /**< topological dimension of the space, total number of nodes */
dErr (*getNodeWeight)(dRule,dReal[],dReal[]); /**< nodes and weights in interlaced ordering, arrays must be large enough */
dErr (*getTensorNodeWeight)(dRule,dInt*,dInt[],const dReal**,const dReal**); /**< topological dimension, number of
* nodes in each direction, weights in
* each direction. Does not copy, may not
* be implemented. */
};

#define dRuleHEADER \
struct v_dRuleOps *ops

struct p_dRule {
dRuleHEADER;
};
extern PetscLogEvent dLOG_FSConstrain;

/**
* Operations required for an EFS. Defined here so that these function calls can be inlined.
*
*/
struct v_dEFSOps {
dErr (*view)(dEFS,PetscViewer);
dErr (*getSizes)(dEFS,dInt*,dInt*,dInt*); /**< topological dimension, number of interior nodes, total number of nodes */
dErr (*getTensorNodes)(dEFS,dInt*,dInt*,dReal**);
dErr (*apply)(dEFS,dInt,dInt*,dScalar**restrict,const dScalar[],dScalar[],dApplyMode,InsertMode);
/**< dofs/node, work length, work, modal values, nodal values */
dErr (*scatterInt)(dEFS,dInt,dInt,const dScalar[],dScalar[],InsertMode,ScatterMode); /**< dofs/node, offset of interior dofs, array, local array */
/**
* @bug It's not yet clear to me how to implement this.
*
*/
dErr (*scatterFacet)(dEFS,dEFS,dInt*,dScalar**restrict,const dScalar[],dScalar[],InsertMode,ScatterMode);
struct dFSBoundary {
PF constrain;
char *name;
dMeshESH facets;
dMeshTag orient;
dBool fliporient;
struct dFSBoundary *next;
};

/**
* This is held once for every function space on every element. This part of the implementation is not really private.
*
*/
#define dEFSHEADER \
struct v_dEFSOps *ops; \
dRule rule

struct p_dEFS {
dEFSHEADER;
};

/**
* Generic operations provided by a #dJacobi implementation.
*
*/
struct _dJacobiOps {
dErr (*setup)(dJacobi);
dErr (*setfromoptions)(dJacobi);
dErr (*destroy)(dJacobi);
dErr (*view)(dJacobi,PetscViewer);
//dErr (*getrule)(dJacobi,dInt,const dInt[],dRule*,dInt*); /**< put a dRule into the output buffer */
//dErr (*getefs)(dJacobi,dInt,const dInt[],const dInt[],dEFS*,dInt*); /**< put a dEFS into the output buffer */
dErr (*getrulesize)(dJacobi,dTopology,dInt*);
dErr (*getrule)(dJacobi jac,dTopology top,const dInt rsize[],dRule *rule,void **base,dInt *index);
dErr (*getefs)(dJacobi jac,dTopology top,const dInt bsize[],dRule rule,dEFS *efs,void **base,dInt *index);
struct _dFSOps {
DMOPS(dFS)
dErr (*setfromoptions)(dFS);
};

/**
* Private Jacobi table context.
*
*/
struct p_dJacobi {
PETSCHEADER(struct _dJacobiOps);
dInt basisdegree; /**< the maximum degree basis functions to be supported */
dInt ruleexcess; /**< the amount of over-integration to be supported */
dBool setupcalled;
void *impl; /**< private implementation context */
struct _p_dFS {
PETSCHEADER(struct _dFSOps);
dMesh mesh;
dMeshTag partition,degree;
dMeshESH active;
struct dFSBoundary *bdy_start;
dQuotient quotient;
dJacobi jacobi;
dBool setupcalled;
void *data;
};

EXTERN dErr dJacobiCreate_Tensor(dJacobi); /* should really only be visible to dJacobiInitializePackage */

PETSC_EXTERN_CXX_END

#endif

0 comments on commit 21795e3

Please sign in to comment.