📄 ibgg.h
字号:
/* last edit: Ilja Schmelzer -------------- 17-OCT-1994 19:39:02.26 */
/************************************************************************/
/* */
/* <<< I B G >>> - Intersection - Based Grid generation package */
/* */
/* Version 1.1 by Ilja Schmelzer schmelzer@iaas-berlin.d400.de */
/* */
/* to be distributed under IBG license conditions (see "readme.ibg") */
/* */
/************************************************************************/
/* <<< IBGG >>> - Intersection-Based Grid Generation - Grid Format */
#ifndef IBGG_H
#define IBGG_H
#ifndef IBG_H
#include "ibg.h"
#endif
#ifndef IBGC_H
#include "ibgc.h"
#endif
#ifndef IBGT_H
#include "ibgt.h"
#endif
/*........ grid package initialization: */
void ibGridInit();
/*........ grid generation: */
ibGrid *ibGridGenerate(ibGeometry g,
unsigned nmax,
unsigned nx, ibgFloat *x, unsigned fx,
unsigned ny, ibgFloat *y, unsigned fy,
unsigned nz, ibgFloat *z, unsigned fz,
void (*RefineRegion)(ibgPtObject This, ibgPoint *point,
ibgFloat *length),
ibgPtObject pRefineRegion,
void (*RefineFace)(ibgPtObject This, ibgPoint *point,
ibgFloat *normal, ibgFloat *tangential),
ibgPtObject pRefineFace,
void (*RefineLine)(ibgPtObject This, ibgPoint *point,
ibgFloat *normal, ibgFloat *tangential),
ibgPtObject pRefineLine,
void (*RefineNode)(ibgPtObject This, ibgPoint *point,
ibgFloat *length),
ibgPtObject pRefineNode,
ibgBoolean (*RefineEdge) (ibgPtObject This,
ibgPoint *n1, ibgPoint *n2),
ibgPtObject pRefineEdge
);
/* refinement parameter described in the documentation: */
extern ibgFloat ibggDmin[ibgDIM];
extern ibgFloat ibggDefaultRegionLength,ibggDefaultNodeLength;
extern ibgFloat ibggDefaultFaceNormal,ibggDefaultFaceTangential;
extern ibgFloat ibggDefaultLineNormal,ibggDefaultLineTangential;
void ibggDefaultRefineRegion(ibgPtObject This, ibgPoint *point,
ibgFloat *length);
void ibggDefaultRefineFace(ibgPtObject This, ibgPoint *point,
ibgFloat *normal, ibgFloat *tangential);
void ibggDefaultRefineLine(ibgPtObject This, ibgPoint *point,
ibgFloat *normal, ibgFloat *tangential);
void ibggDefaultRefineNode(ibgPtObject This, ibgPoint *point,
ibgFloat *length);
ibgBoolean ibggDefaultRefineEdge (ibgPtObject This,
ibgPoint *n1, ibgPoint *n2);
/* other refinement parameter: */
extern ibgFloat ibggDelaunayBig, ibggDelaunayEps;
extern ibgFloat ibggBV;
extern ibgFloat ibggBLWait,ibggBLHalf,ibggBLObtuse,ibggBctg;
extern ibgFloat ibggOref,ibggOref2,ibggOinv,ibggOmax;
extern ibgFloat ibggPref;
extern int ibggPrefL;
/*........ copy the grid: */
ibGrid *ibGridCopy(ibGrid *grid);
/*........ delete the grid: */
ibGrid *ibGridFree(ibGrid *gg);
/*........ initialize a floating point component by a function: */
void ibGridFunction(ibGrid *gg, int fnum,
ibgFloat (*func)(ibgPtObject fThis, ibgPoint *x),
ibgPtObject fThis);
/*........ dimension data: */
#define ibgridGDIM(g) ((g).gridDimension)
#define ibgridXDIM(g) ((g).spaceDimension)
/*........ flags: */
/*........ point data ( n = ibgridFirstPoint(g), ..., ibgridLastPoint(g) ) :*/
#define ibgridFirstPoint(g) ((g).firstPoint) /* first point */
#define ibgridLastPoint(g) ((g).lastPoint) /* last point */
#define ibgridPoint(g,n) (*((ibgPoint *)((char *)((g).Point) + IBGPOINTSIZE*(n))))
/*........ point -> a cell containing the point. This field may be not defined */
#define ibgridPointCell(g,n) ((g).PointCell[n])
#define ibgridHasPointCell(g) ((g).PointCell)
/*........ cell data ( c = ibgridFirstCell(g), ..., ibgridLastCell(g) ) :*/
#define ibgridFirstCell(g) ((g).firstCell) /* first cell */
#define ibgridLastCell(g) ((g).lastCell) /* last cell */
#define ibgridCellType(g,c) ((g).CellType[c]) /* cf. ibgCellType */
#define ibgridCellSegment(g,c) ((g).CellSegment[c]) /* > 0: number of geom. segment */
/* containing the cell; */
/* == 0: cell is outside; */
/* < 0: not a cell; */
/*............. point list for cells: */
/* c = ibgridFirstCell(g), ..., ibgridLastCell(g) */
/* n = 0, ..., ibgcPoints(ibgridCellType(g,c))-1 */
#define ibgridCellPoint(g,c,n) ((g).CPoint[(g).CPointFirst[c]+n])
#define ibgridCPointList(g,c) ((int*)((g).CPoint + (g).CPointFirst[c]))
/*............. neighbour cell list for cells: */
/* c = ibgridFirstCell(g), ..., ibgridLastCell(g) */
/* s = 0, ..., ibgcSides(ibgridCellType(g,c)) -1 */
#define ibgridHasSides(g) ((g).CSide)
#define ibgridCellSide(g,c,s) ((g).CSide[(g).CSideFirst[c]+s])
#define ibgridCSideList(g,c) ((int*)((g).CSide + (g).CSideFirst[c]))
/*............. "outside" neighbours for cells with codim = 1: */
#define ibgridCellLeft(g,c,t) ((g).CSide[(g).CSideFirst[c]+ibgcSExtL(t)])
#define ibgridCellRight(g,c,t) ((g).CSide[(g).CSideFirst[c]+ibgcSExtR(t)])
/*............. list of "outside" neighbours for cells with codim > 1: */
#define ibgridHasOutsides(g) ((g).COutside)
#define ibgridLastCOut(g) ((g).lastCOut)
#define ibgridCOutFirst(g,c,t) ((g).CSide[(g).CSideFirst[c]+ibgcSExtF(t)])
#define ibgridCOutNext(g,o) ((g).COutNext[o])
#define ibgridCOutside(g,o) ((g).COutside[o])
/*........ begin and end for every geometrical type (codimension) */
#define ibgridFirstRegionCell(g) ((g).firstRegion)
#define ibgridLastRegionCell(g) ((g).lastRegion)
#define ibgridFirstFaceCell(g) ((g).firstFace)
#define ibgridLastFaceCell(g) ((g).lastFace)
#define ibgridFirstLineCell(g) ((g).firstLine)
#define ibgridLastLineCell(g) ((g).lastLine)
#define ibgridFirstNodeCell(g) ((g).firstNode)
#define ibgridLastNodeCell(g) ((g).lastNode)
/*........ coordinates of the window for creating a geometry from the grid: */
#define ibgridXMin(g,i) ((g).xmin[i])
#define ibgridXMax(g,i) ((g).xmax[i])
/*........ other data fields: */
#define ibgridHasCellData(g) ((g).CellData)
#define ibgridHasPointData(g) ((g).PointData)
#define ibgridPointData(g,n) ((char *)((g).PointData) + (g).NDataSize*(n))
#define ibgridCellData(g,c) ((char *)((g).CellData) + (g).CDataSize*(c))
/*............ creating new points and cells: */
int ibgridCNew(ibGrid *g, ibgCellType t);
/*....... int ibgridNNew (ibGrid *g); */
/*....... int ibgridCONew(ibGrid *g); */
int ibgridNRealloc(ibGrid*g); /* to be used only in: */
#define ibgridNNew(g) ((g)->lastPoint<(g)->maxPoint ? ++(g)->lastPoint :\
(ibgridNRealloc(g) ? ++(g)->lastPoint : 0))
int ibgridCORealloc(); /* to be used only in: */
#define ibgridCONew(g) ((g)->lastCOut<(g)->maxCOut ? ++(g)->lastCOut :\
(ibgridCORealloc(g) ? ++(g)->lastCOut : 0))
/*............ some parts of grid generation process: */
void ibgridMakeRegions(ibGrid *gg, ibGeometry g);
/* creating the boundary faces of the grid: */
void ibgridMakeFaces(ibGrid *gg, ibGeometry g);
/* creating the boundary lines of the grid: */
void ibgridMakeLines(ibGrid *gg, ibGeometry g);
/* creating the boundary nodes of the grid: */
void ibgridMakeNodes(ibGrid *gg, ibGeometry g);
/*............ cycle over all points of a grid g:
parameter: n - point number, t - type, u - segment, point - point data (gPoint*)
*/
#define foribgPoints(g,in,t,u,point) \
for(in=ibgridFirstPoint(g); in<=ibgridLastPoint(g); in++){\
point = &ibgridPoint(g,in);\
u = ibgpSegment(*point);\
t = ibgpType(*point);\
if((t == ibgSRegion) && (u <= 0)) continue;
#define endibgPoints(g,in,t,u,point) }
/*............ cycle over cells of a grid g:
parameter: ic - cell number, u - segment of the cell, t - type of the cell
*/
#define foribgCells(g,ic,t,u)\
for(ic=ibgridFirstCell(g);ic<=ibgridLastCell(g);ic++)\
if(t=ibgridCellType(g,ic),(u=ibgridCellSegment(g,ic))>0)
#define endibgCells(g,ic,t,u)
#define foribgRegionCells(g,ic,t,u) \
for(ic=ibgridFirstRegionCell(g);ic<=ibgridLastRegionCell(g);ic++)\
if(ibgcCODIM(t=ibgridCellType(g,ic))==ibgSRegion)\
if((u=ibgridCellSegment(g,ic))>0)
#define endibgRegionCells(g,ic,t,u)
#define foribgFaceCells(g,ic,t,u) \
for(ic=ibgridFirstFaceCell(g);ic<=ibgridLastFaceCell(g);ic++)\
if(ibgcCODIM(t=ibgridCellType(g,ic))==ibgSFace)\
if((u=ibgridCellSegment(g,ic))>0)
#define endibgFaceCells(g,ic,t,u)
#define foribgLineCells(g,ic,t,u) \
for(ic=ibgridFirstLineCell(g);ic<=ibgridLastLineCell(g);ic++)\
if(ibgcCODIM(t=ibgridCellType(g,ic))==ibgSLine)\
if((u=ibgridCellSegment(g,ic))>0)
#define endibgLineCells(g,ic,t,u)
#define foribgNodeCells(g,ic,t,u) \
for(ic=ibgridFirstNodeCell(g);ic<=ibgridLastNodeCell(g);ic++)\
if(ibgcCODIM(t=ibgridCellType(g,ic))==ibgSNode)\
if((u=ibgridCellSegment(g,ic))>0)
#define endibgNodeCells(g,ic,t,u)
/* private part: */
struct ibgPoints0{
int spaceDimension;
int firstPoint,lastPoint,maxPoint;
ibgPoint *Point;
int *Near;
};
extern ibgPoints ibggExternalPoints;
int ibgAppendPoint(ibgPoints *list, ibgPoint *p);
int ibgAppendPoints(ibgPoints *list, ibgPoints *rest);
struct _ibGrid0{
/* dimension data */
int gridDimension,spaceDimension;
/* point data */
int firstPoint,lastPoint,maxPoint;
ibgPoint *Point;
/* cell data */
int firstCell,lastCell,maxCell;
/* begin and end for every geometrical type (codimension): */
int firstRegion,lastRegion;
int firstFace,lastFace;
int firstLine,lastLine;
int firstNode,lastNode;
/* type of a cell (includes form of the cell and it's codimension in the grid)*/
ibgCellType *CellType;
/* geometrical segment of a cell */
ibgSegment *CellSegment;
/* > 0: number of the geometrical segment containing the cell;
== 0: cell is outside;
< 0: not a cell;
*/
/* point list for cells: */
int freeCPoint,maxCPoint;
int *CPointFirst,*CPoint;
/* neighbour cell list for cells: */
int freeCSide,maxCSide;
int *CSideFirst,*CSide;
/* list of higher dimensional "outside" cells (for codimension > 1): */
int lastCOut,maxCOut;
int *COutNext,*COutside;
/* coordinates of the window for creating a geometry from the grid: */
ibgFloat xmin[ibgDIM],xmax[ibgDIM];
ibgTopologyRec Topology;
/* list containing one of the cells containing a given point: */
int *PointCell;
/* other point data (data type is hidden): */
int NDataSize;
void *PointData;
/* other cell data (data type is hidden): */
int CDataSize;
void *CellData;
/* first free cell for a given type: */
int CFree[IBGCTMAX];
/* first free point: */
int NFree;
};
extern ibGrid ibgg; /* current grid for new-operations: */
int ibgridCNew(ibGrid *g, ibgCellType t);
/* ......... macros connected with the CFree-field: */
#define ibgridNoCell 123456789
#define ibgridCFree(g,c) \
(ibgridCellSegment(g,c) = -(g).CFree[ibgridCellType(g,c)],\
(g).CFree[ibgridCellType(g,c)] = c,\
ibgridCellType(g,c) = ibgc0Nothing)
#define ibgridCGet(g,c,t) \
((*(c)=(g).CFree[t])!=ibgridNoCell )?( \
(g).CFree[t] = - ibgridCellSegment(g,*(c)), \
ibgridCellType(g,*(c)) = (t), \
ibgridCellSegment(g,*(c)) = 0 \
):( *(c) = ibgridCNew(&(g),t) \
)
/* ......... macros connected with the NFree-field: */
#define ibgridNoPoint 12345678
#define ibgridNFree(g,n) \
(ibgridPointCell(g,n) = -(g).NFree,\
(g).NFree = (n))
#define ibgridNGet(g,n) \
(((n)=(g).NFree)!=ibgridNoPoint)?( \
(g).NFree = - ibgridPointCell(g,(n)) \
):( (n) = ibgridNNew(&(g)) \
)
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -