📄 main3line.c
字号:
/* last edit: Ilja Schmelzer -------------- 11-OCT-1994 17:19:59.12 */
/************************************************************************/
/* */
/* <<< 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") */
/* */
/************************************************************************/
/*
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 creates the intersection of two cylindrical objects. This shows the
principal possibility to compute boundary lines, but also the current state
of the program (local errors around the boundary line).
*/
#include <stdio.h>
#include "ibg.h"
#include "ibgd.h"
#include "ibgg.h"
#include "ibgapplication.h"
/* a trivial 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.008) 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];
return 0.25 - yy*yy - xx*xx; /* - 0.1*zz;*/
}
ibgFloat region3(ibgPtObject This, ibgPoint *n)
{ibgFloat *rx = ibgpX(*n), xx = rx[0], yy = rx[1], zz = rx[2];
return 0.25 - zz*zz - (yy-0.2)*(yy-0.2);
}
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.01);
g0 = ibgdSplitRegion(g0,3,1,region3,0,0.01);
ibggDmin[0] = ibggDmin[1] = ibggDmin[2] = 0.05;
/* 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. */
/* 1,z,0, for the 2D variant only 1 value in z direction */
2,z,3, /* alternative: for the 3D variant 2 values in z direction */
/* refinement criteria: */
refineRegion,ibgNULL, /* isotropical refinement */
ibggDefaultRefineFace,ibgNULL,
ibggDefaultRefineLine,ibgNULL,
ibggDefaultRefineNode,ibgNULL,
refineEdge,ibgNULL); /* anisotropical refinement */
/* end of program: */
ibgNameFile = "test3line";
ibgOutput(grid);
return ibgdQuit();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -