⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main3surf.c

📁 有限元学习研究用源代码(老外的),供科研人员参考
💻 C
字号:
/* last edit: Ilja Schmelzer -------------- 10-JUN-1994 17:51:30.74	*/
/************************************************************************/
/*                                                                      */
/*  <<< 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 3D grid generator.

The geometry consists of two regions (1 and 2) with a simple third order
boundary face between them. It contains 5017 points and 34663 cells.

It shows the possibility to create 3D grids and surface grids.
*/

#include <stdio.h>
#include "ibg.h"
#include "ibgd.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

   Here it is a simple third order function.
*/

ibgFloat region2(ibgPtObject This, ibgPoint *n)
{ibgFloat *rx = ibgpX(*n), xx = rx[0], yy = rx[1], zz = rx[2];
 return yy - 1.5*zz*zz - 1.4*xx*xx*(xx-0.67);
}

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);

/* grid generator call. */
 grid=ibGridGenerate(g0,  	/* geometry description */
	10000,	/* approx. point number (for first 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,
/* refinement criteria: */
	refineRegion,ibgNULL,			/* isotropical refinement */
	ibggDefaultRefineFace,ibgNULL,
	ibggDefaultRefineLine,ibgNULL,
	ibggDefaultRefineNode,ibgNULL,
	refineEdge,ibgNULL);			/* anisotropical refinement */
/* end of program: */
 ibgOSSpecial[ibgRSpace]	= ibgFalse;
 ibgNameFile = "test3surf";
 ibgOutput(grid);
 return ibgdQuit();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -