?? user.c
字號:
/*
* user.c : user program of the SIMPLE
*/
/*
* 注意C與FORTRAN的差別:
* 1. C中的數組下標是從0開始的,而FORTRAN則是從1開始的
* 因此本程序中的一些量(如L1,L2,L3,M1,M2,M3,NFMAX,nGam,nP,nRho,IPref,JPref)比FORTRAN程序中的小1
* 所有數組的下標從0開始,程序中數組下標中出現的數字比FORTRAN中的小1
* 2. C的數組是按行優先讀的,而FORTRAN的則是按列讀的
* 因此本程序中的F的定義不同,是F[NFMAX][I][J]
* 3. C用指針來實現FORTRAN的EQUIVALENCE功能。
* 如定義double (*U)[NSIZE],U=F[0],則U[i][j]等同于F[0][i][j];
*/
#include "staincl.h"
#include "extern.h"
/*global variable for user */
double (*T)[NSIZE];
double htc;
double Q;
double Tf;
double Gam1;
double gy;
short method;
/*******************************************************************************
* functon name: fnGrid
* description: in this file you should do:
* --initialize variable you defined
* --set the filename of the output file, the step can be ignored
* --set the title of the variable that will be calculated
* --set which variable will be calc and print
* --set axis mode-nMode: 1-cartesian, 2-axisymmetric, 3-polar
* --set the number of steps
* --set the number of grids
* --devide grids
********************************************************************************/
void fnGrid()
{
T=F[4];
method=1;
htc=5;
Q=50;
Tf=100;
Gam1=1;
szTitle[4]="temprature";
szTitle[12]="conductor";
bSolve[4]=TRUE;
bPrint[4]=TRUE;
bPrint[12]=TRUE;
iLast=50;
nMode=2;
XL=2.0;
YL=1.0;
R[0]=1;
L1=6;//
M1=6;//
fnUGrid();
}
/*******************************************************************************
* functon name: fnStart
* description: in this file you should do:
* --initialize the
********************************************************************************/
void fnStart()
{
int i,j;
for(i=0;i<=L1;i++)
{
for(j=0;j<=M1;j++)
{
T[i][j]=200;
if(i==0)
T[i][j]=100*(1+Y[j]);
}
}
}
/*******************************************************************************
* functon name: fnDense
* description: in this file you should do:
* --calc the density if needed
********************************************************************************/
void fnDense()
{
}
/*******************************************************************************
* functon name: fnbound
* description: in this file you should do:
* --calc the boundary
********************************************************************************/
void fnBound()
{
int i,j;
for(i=1;i<=L2;i++)
{
T[i][M1]=T[i][M2];
T[i][0]=T[i][1]+Q*YDif[1]/Gam1;
}
gy=Gam1/XDif[L1];
for(j=1;j<=M2;j++)
T[L1][j]=(htc*Tf+gy*T[L2][j])/(htc+gy);
}
/*******************************************************************************
* functon name: fnOutput
* description: in this file you should do:
* --print calc info to terminal or write to file
********************************************************************************/
void fnOutPut()
{
if(iIter==0)
{
fprintf(pFileOut,"\n Method=%d",method);
fprintf(pFileOut,"\n Iter T[4][5] T[5][3]");
}
fprintf(pFileOut,"\n %4d %12.8f %12.8f ",iIter,T[3][4],T[4][2]);
if(iIter==iLast)
fnPrint();
}
/*******************************************************************************
* functon name: fnGamsor
* description: in this file you should do:
* --set the gam
* --set the sc,sp
********************************************************************************/
void fnGamSor()
{
int i,j;
double res,ares;
for(i=0;i<=L1;i++)
for(j=0;j<=M1;j++)
Gam[i][j]=Gam1;
for(i=3;i<=4;i++)
for(j=3;j<=6;j++)
Gam[i][j]=0.2*(1+T[i][j]/100);
for(i=1;i<=L2;i++)
{
for(j=1;j<=M2;j++)
{
Con[i][j]=100;
AP[i][j]=-0.5;
}
}
if(method==2)
{
for(i=1;i<=L2;i++)
{
Gam[i][M1]=0;
Gam[i][0]=0;
Con[i][1]+=Q*R[0]/ARX[1];
}
res=1/htc+1/gy;
ares=1/(res*XCV[L2]);
for(j=1;j<=M2;j++)
{
Gam[L1][j]=0;
Con[L2][j]+=ares*Tf;
AP[L2][j]-=ares;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -