/[escript]/trunk/finley/src/Mesh_write.c
ViewVC logotype

Annotation of /trunk/finley/src/Mesh_write.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (14 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_write.c
File MIME type: text/plain
File size: 3525 byte(s)
Initial revision

1 jgs 82 /**************************************************************/
2    
3     /* Finley: write Mesh */
4    
5     /**************************************************************/
6    
7     /* Copyrights by ACcESS Australia 2003 */
8     /* Author: gross@access.edu.au */
9     /* Version: $Id$ */
10    
11     /**************************************************************/
12    
13     #include "Common.h"
14     #include "Finley.h"
15     #include "Mesh.h"
16    
17     /**************************************************************/
18    
19     /* writes the mesh to the external file fname unsing the Finley file format: */
20    
21     void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
22     FILE *f;
23     int NN,i,j,numDim;
24    
25     /* open file */
26     f=fopen(fname,"w");
27     if (f==NULL) {
28     Finley_ErrorCode=IO_ERROR;
29     sprintf(Finley_ErrorMsg,"Opening file %s for writing failed.",fname);
30     return;
31     }
32    
33     /* write header */
34    
35     fprintf(f,"%s\n",in->Name);
36    
37     /* write nodes: */
38    
39     if (in->Nodes!=NULL) {
40     numDim=Finley_Mesh_getDim(in);
41     fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
42     for (i=0;i<in->Nodes->numNodes;i++) {
43     fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->degreeOfFreedom[i],in->Nodes->Tag[i]);
44     for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
45     fprintf(f,"\n");
46     }
47     } else {
48     fprintf(f,"0D-Nodes 0\n");
49     }
50    
51     /* write elements: */
52    
53     if (in->Elements!=NULL) {
54     fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
55     NN=in->Elements->ReferenceElement->Type->numNodes;
56     for (i=0;i<in->Elements->numElements;i++) {
57     fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
58     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
59     fprintf(f,"\n");
60     }
61     } else {
62     fprintf(f,"Tet4 0\n");
63     }
64    
65     /* write face elements: */
66     if (in->FaceElements!=NULL) {
67     fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
68     NN=in->FaceElements->ReferenceElement->Type->numNodes;
69     for (i=0;i<in->FaceElements->numElements;i++) {
70     fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
71     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
72     fprintf(f,"\n");
73     }
74     } else {
75     fprintf(f,"Tri3 0\n");
76     }
77    
78     /* write Contact elements : */
79     if (in->ContactElements!=NULL) {
80     fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
81     NN=in->ContactElements->ReferenceElement->Type->numNodes;
82     for (i=0;i<in->ContactElements->numElements;i++) {
83     fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
84     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
85     fprintf(f,"\n");
86     }
87     } else {
88     fprintf(f,"Tri3_Contact 0\n");
89     }
90    
91     /* write points: */
92     if (in->Points!=NULL) {
93     fprintf(f, "%s %d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements);
94     for (i=0;i<in->Points->numElements;i++) {
95     fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
96     }
97     } else {
98     fprintf(f,"Point1 0\n");
99     }
100    
101     fclose(f);
102     #ifdef Finley_TRACE
103     printf("mesh %s has been written to file %s\n",in->Name,fname);
104     #endif
105     }
106    
107     /*
108     * $Log$
109     * Revision 1.1 2004/10/26 06:53:57 jgs
110     * Initial revision
111     *
112     * Revision 1.1.1.1 2004/06/24 04:00:40 johng
113     * Initial version of eys using boost-python.
114     *
115     *
116     */
117    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26