📄 mainhole.c
字号:
/* last edit: Ilja Schmelzer -------------- 12-AUG-1994 11:59:05.36 */
/************************************************************************/
/* */
/* <<< 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") */
/* */
/************************************************************************/
/*
Intersection-Based Grid Generator Version 1.1
author: Ilja Schmelzer, IAAS,
Mohrenst. 39, D-10117 Berlin Germany
e-mail: schmelzer@iaas-berlin.d400.de
Tel: +49 30 20377 567
Fax: +49 30 200 4975
This is an example for a main program. It is creating a geometry description,
defining refinement criteria and calling the grid generator.
It shows the possibility to create regions with nontrivial topology.
*/
#include <stdio.h>
#include <math.h>
#include "ibg.h"
#include "ibgd.h"
#include "ibgdefault.h"
#include "ibgg.h"
#include "ibgapplication.h"
/* an example of an isotropical refinement criterion. This function has to
return the maximal edge length for orthogonal edges around the region point n.
*/
static void refineRegion(ibgPtObject This, ibgPoint *n, ibgFloat *length)
{
*length = 2.0;
}
/* an example of an anisotropical refinement criterion. This function has to
return ibgTrue if the edge from x1 to x2 must be refined. It is possible to
use the coordinates, the segment number and function values of the points
*/
static int refineEdge(ibgPtObject This, ibgPoint *x1, ibgPoint *x2)
{ibgFloat dx,dy,dz,dd;
if(ibgpSegment(*x1)==ibgpSegment(*x2)) return ibgFalse;
dx = ibgpX(*x1)[0]-ibgpX(*x2)[0];
dy = ibgpX(*x1)[1]-ibgpX(*x2)[1];
dz = ibgpX(*x1)[2]-ibgpX(*x2)[2];
/* here we refine an edge near the boundary */
if(dx*dx+dy*dy+dz*dz < 0.004) return ibgFalse; else return ibgTrue;
}
/* An example of the characteristic function which will be used to define
the region 2.
It has to return a value > 0 for region 2, < 0 for region 1,
and has to be approximately linear in the neighbourhood of 0
*/
ibgFloat region2(ibgPtObject This, ibgPoint *n)
{ibgFloat *rx = ibgpX(*n), xx = rx[0], yy = rx[1], zz = rx[2], dd,dw,rr;
xx *= xx; yy *= yy; zz *= zz; dd = xx + yy;
dw = sqrt(dd);
rr = dd - 1.0*dw + zz + 0.155
+ 0.18*rx[0] + 0.15*rx[2] + 0.02*rx[1] - 0.3*xx*xx
+ 0.2*rx[0]*rx[1];
return -rr;
}
/* An example of the characteristic function which will be used to define
the face 5.
It has to return a value > 0 for region 2, < 0 for region 1,
and has to be approximately linear in the neighbourhood of 0
*/
ibgFloat face5(ibgPtObject This, ibgPoint *n)
{ibgFloat *rx = ibgpX(*n), xx = rx[0], yy = rx[1], zz = rx[2];
return yy;
}
int main()
{
/* the data of the coarse grid - cuboid */
ibgFloat x[2] = {-1.0,1.0},
y[2] = {-1.0,1.0},
z[2] = {-1.0,1.0};
ibGeometry g0;
ibGrid *grid;
ibgApplicationInit(); /* calls also ibgdInit and ibGridInit */
g0 = ibgdNew(1); /* start: only one region 1 */
/* now we split the region 1 into two parts - 1 and 2, using the characteristic
function for region 2. (Region numbers must be positive and < ibgSMAX).
*/
g0 = ibgdSplitRegion(g0,2,1,region2,0,0.5);
ibggDefaultLineNormal = 1000.0;
/* grid generator call. */
grid=ibGridGenerate(g0, /* geometry description */
10000, /* approx. point number (for malloc to minimize realloc) */
2,x,3, /* coarse grid data */
2,y,3, /* 2 values in x and y data field, + 3 points by reg. ref. */
2,z,3, /* for the 2D variant only 1 value in z direction */
/* refinement criteria: */
refineRegion,ibgNULL, /* isotropical refinement */
ibggDefaultRefineFace,ibgNULL,
ibggDefaultRefineLine,ibgNULL,
ibggDefaultRefineNode,ibgNULL,
refineEdge,ibgNULL); /* anisotropical refinement */
/* end of program: */
ibgNameFile = "testhole";
ibgOutput(grid);
return ibgdQuit();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -