24小时热门版块排行榜    

查看: 332  |  回复: 0

沉默的海

金虫 (正式写手)

[求助] 求高手编写一个gauss分布的程序

我想编写这样一个程序,在x-z面内有一个圆,圆心坐标为(0,-0.11),半径为0.11,具体见图1.我想在此圆面内定义一个以圆心处y轴为对称轴的gauss分布的值heatflux,示意图如图2(红色越深的代表heatflux值越大) 。简单说就是在圆面内根据x、z的坐标不同定义不同的值heatflux。

图1


图2


下面我自己编了个程序,高手们给看看,因为实在有限元软件中调用此函数,所以基本格式已经定下来了,你可以在* ------------- Program your function below this line  ------------- */   下面编写程序。

#include

#include



#define real double



#ifdef WIN32

#define EXPORT _declspec(dllexport)

EXPORT real func_heatflux(char*, int, real, real, real, real, real, real, int);

#else

real func_heatflux(char*, int, real, real, real, real, real, real, int);

#endif



extern real usertemp1(int);

extern real userfs1(int);

extern real uservx1(int);

extern real uservy1(int);

extern real uservz1(int);

extern int nodNum (real,real,real,int,real*,real*,real* );



/*

*    heat flux coefficient (applied on external surfaces)

*/



real func_heatflux(

  char  prefix[],     /* case name  */

  int   dimension,    /* 2 = 2D ; 3 = 3D */

  real  temp,         /* current temperature */

  real  fs,           /* current fraction of solid */

  real  time,         /* current time */

  real  x_coor,       /* local coordinates: x */

  real  y_coor,       /* local coordinates: y */

  real  z_coor,       /* local coordinates: z */

  int   numBC)        /* boundary condition ID number */

{

/* ------------- Do not change anything above this line ------------- *

* ------------- Program your function below this line  ------------- */

real heatflux;
real power;
real b;
real c;

heatflux=0;
power=1e6;
b=2;
c=-((x_coor)*(x_coor)+(z_coor+0.11)*(z_coor+0.11))/(2*b*b);     



heatflux=(power/(b*2.5))*pow(2.71828183,c);




  return heatflux;

}

希望大家多多帮忙!
回复此楼

» 猜你喜欢

零下一度
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 沉默的海 的主题更新
信息提示
请填处理意见