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

📄 mainpix.c

📁 有限元学习研究用源代码(老外的),供科研人员参考
💻 C
字号:
/* last edit: Ilja Schmelzer -------------- 12-OCT-1994 01:23:30.82	*/
/************************************************************************/
/*                                                                      */
/*  <<< 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")	*/
/*                                                                      */
/************************************************************************/
/*

This is an example for a main program. It is  creating a geometry description
using a pixmap.

It also shows the ability of IBG to handle a great number of thin layers. We
have a topology consisting of 50 thin regions. The resulting topology see
picpix.ps, the grid picpix_1.ps. The requirements of topology lead to a
relative fine grid. Here no application-defined refinement has been used, so
with trivial geometry there will be only 4 points.

So, the coarse boundary approximation in the lower right corner is in
aggreement with the refinement criteria used here. The uncertainty in the
boundary computation is caused by the resolution of the pixmap.

*/

#include <stdio.h>
#include "ibg.h"
#include "ibgd.h"
#include "ibgg.h"
#include "ibgapplication.h"
#include "ibgdpixmap.h"

/* trivial isotropical refinement: */

static void refineRegion(ibgPtObject This, ibgPoint *n, ibgFloat *length)
{
 *length = 1000.0;
}

/* trivial anisotropical refinement: */

static int refineEdge(ibgPtObject This, ibgPoint *x1, ibgPoint *x2)
{ibgDouble dx,dy;
 int u1,u2;
 if((u1=ibgpSegment(*x1))==(u2=ibgpSegment(*x2))) return ibgFalse;
 dx = ibgpX(*x1)[0]-ibgpX(*x2)[0];
 dy = ibgpX(*x1)[1]-ibgpX(*x2)[1];
/* here we refine an edge near the boundary */
 if(ibgMaterial[u1] == ibgMaterial[u2]){
	if(dx*dx+dy*dy < 2.0) return ibgFalse; else return ibgTrue;
 }else{
	if(dx*dx+dy*dy < 0.04) return ibgFalse; else return ibgTrue;
 }
}

int main()
{int t;
/* the data of the pixmap border */
 ibgFloat xp[2] = {0.0,80.0},
	  yp[2] = {0.0,80.0};
/* the data of the coarse grid - cuboid */
 ibgFloat xc[2] = {0.0,80.0},
	  yc[2] = {0.0,80.0},
	  zc[2] = {0.0,1.0};
 ibgPixmap p;
 int ix,iy,k;
 ibGeometry g0;
 ibGrid	*grid;
 int colors;

 ibgApplicationInit();	/* calls also ibgdInit and ibGridInit */

/* initialization of the pixmap:
*/
 colors = ibgSMAX-1;
 if(ibgColDefaultRegion+colors > ibgColorMAX)
	colors = ibgColorMAX - ibgColDefaultRegion - 1;

/* reading the map of Ruegen: */
 ibgdPixmapRead(&p,&colors,&ibgColorOf[ibgColDefaultRegion],"test.ppm");

/* renaming standard materials for a map: */
#define ibgMWater 	ibgMConductor
#define ibgMLand	ibgMIsolator
 for(t=1;t<colors;t++){
	ibgColRegion[t] = ibgColDefaultRegion+t;
	if(ibgColorOf[ibgColRegion[t]].b > 0.8*ibgColOn) /* very blue */
	    	ibgMaterial[t] = ibgMWater;
	else
	    	ibgMaterial[t] = ibgMLand;
 }

/* creating the geometry description defined by the picture: */
 g0 = ibgdPixmap(&p,xp[0],xp[1],yp[0],yp[1]);

/* grid generator call. */
 grid=ibGridGenerate(g0,  	/* geometry description */
	10000,	/* approx. point number (for malloc to minimize realloc) */
	2,xc,10, /* coarse grid data */
	2,yc,10, /* 2 values in x and y data field */
	1,zc,0,	/* 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 = "testpix";
 ibgOutput(grid);
 return ibgdQuit();
}

⌨️ 快捷键说明

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