Created
November 19, 2017 07:02
-
-
Save zhulianhua/847c65158fd589ec9d3436550ca48ffe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void data2D(int mm_, double* T_, double* qx_,double* qy_,double* xcoord_, double* ycoord_, double* dx_, double* dy_, int NumMeshx_, int NumMeshy_ ) | |
{ | |
FILE *fp; | |
char fname[1000]; | |
int m1,i,j; | |
int nodes,elements; | |
int index[M][N]; | |
nodes=0; | |
elements=0; | |
for(i=0;i<(NumMeshx_-1);i++) | |
{ | |
for(j=0;j<(NumMeshy_-1);j++) | |
{ | |
if(i>aM && i<cM && j>bN && j<dN) | |
{ | |
} | |
else | |
{ | |
nodes++; | |
} | |
} | |
} | |
printf("nodes =%d \n", nodes); | |
for(i=1;i<(NumMeshx_-1);i++) | |
{ | |
for(j=1;j<(NumMeshy_-1);j++) | |
{ | |
if(i>aM && i<=cM && j>bN && j<=dN) | |
{ | |
} | |
else | |
{ | |
elements++; | |
} | |
} | |
} | |
printf("elements =%d \n",elements); | |
/* | |
ofstream stream("Mesh.dat"); | |
stream << "VARIABLES = X,Y" << endl; | |
stream << "ZONE T = Time" << endl; | |
stream << "Nodes=" << nNodes << ", Elements=" << nElements << ", ZONETYPE=FEQuadrilateral" << endl; | |
stream << "DATAPACKING=BLOCK" << endl; | |
stream << "VarLocation=([1-2]=NODAL)" << endl; //,[3-9]=CellCentered | |
stream << "VARIABLES = X,Y,Rho,u,v,T,Tr,Tt,qtx,qty,qrx,qry" << endl; | |
stream << "ZONE T = Time" << endl; | |
stream << "Nodes=" << nNodes << ", Elements=" << nElements << ", ZONETYPE=FEQuadrilateral" << endl; | |
stream << "DATAPACKING=BLOCK" << endl; | |
stream << "VarLocation=([1-2]=NODAL,[3-12]=CellCentered)" << endl; // | |
*/ | |
sprintf(fname,"%s%d%s%.1f%s%.2f%s","nanoporous_2D",mm_,"L",(log(L)/log(10)),"T",T_ref,".dat"); | |
if( ( fp=fopen(fname,"w"))==NULL) {printf(" File Open Error\n");exit(1);} | |
fprintf(fp,"TITLE=%s\n","Square_nonogray2D"); | |
fprintf(fp,"Variables= %s, %s, %s, %s, %s \n","X","Y","T","qx","qy"); | |
fprintf(fp,"ZONE T = Time \n "); | |
fprintf(fp,"NODES=%d, ELEMENTS=%d , ZONETYPE=FEQuadrilateral \n ",nodes,elements); | |
fprintf(fp,"DATAPACKING=BLOCK \n "); | |
fprintf(fp,"VarLocation=([1-2]=NODAL,[3-12]=CellCentered)\n "); | |
m1=0; | |
for(i=0;i<(NumMeshx_-1);i++) | |
{ | |
for(j=0;j<(NumMeshy_-1);j++) | |
{ | |
if(i>aM && i<cM && j>bN && j<dN) | |
{ | |
} | |
else | |
{ | |
m1++; | |
index[i][j]=m1; | |
fprintf(fp, "%e \t",(xcoord_[i]+dx_[i]/2.0)); | |
} | |
// fprintf(fp, "%e \t",(L/(NumMeshx_-2)*i)); | |
if(m1%10==0) | |
{ | |
fprintf(fp," \n"); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
m1=0; | |
for(i=0;i<(NumMeshx_-1);i++) | |
{ | |
for(j=0;j<(NumMeshy_-1);j++) | |
{ | |
m1++; | |
if(i>aM && i<cM && j>bN && j<dN) | |
{ | |
} | |
else | |
{ | |
fprintf(fp, "%e \t",(ycoord_[j]+dy_[j]/2.0)); | |
} | |
if(m1%10==0) | |
{ | |
fprintf(fp," \n"); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
m1=0; | |
for(i=1;i<(NumMeshx_-1);i++) | |
{ | |
for(j=1;j<(NumMeshy_-1);j++) | |
{ | |
m1++; | |
if(flag[GID(i,j)] ==0) | |
{ | |
} | |
else | |
{ | |
fprintf(fp, "%e \t",T_[GID(i,j)]); | |
} | |
if(m1%10==0) | |
{ | |
fprintf(fp," \n"); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
m1=0; | |
for(i=1;i<(NumMeshx_-1);i++) | |
{ | |
for(j=1;j<(NumMeshy_-1);j++) | |
{ | |
m1++; | |
if(flag[GID(i,j)] ==0) | |
{ | |
} | |
else | |
{ | |
fprintf(fp, "%e \t",qx_[GID(i,j)]); | |
} | |
if(m1%10==0) | |
{ | |
fprintf(fp," \n"); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
m1=0; | |
for(i=1;i<(NumMeshx_-1);i++) | |
{ | |
for(j=1;j<(NumMeshy_-1);j++) | |
{ | |
m1++; | |
if(flag[GID(i,j)] ==0) | |
{ | |
} | |
else | |
{ | |
fprintf(fp, "%e \t",qy_[GID(i,j)]); | |
} | |
if(m1%10==0) | |
{ | |
fprintf(fp," \n"); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
for(i=1;i<(NumMeshx_-1);i++) | |
{ | |
for(j=1;j<(NumMeshy_-1);j++) | |
{ | |
if(i>aM && i<=cM && j>bN && j<=dN) | |
{ | |
} | |
else | |
{ | |
fprintf(fp, "%d %d %d %d \n ",index[i-1][j-1], index[i][j-1], index[i][j], index[i-1][j]); | |
} | |
} | |
} | |
fprintf(fp, " \n"); | |
fclose(fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment