/[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 1044 - (hide annotations)
Mon Mar 19 07:29:31 2007 UTC (12 years, 7 months ago) by gross
File MIME type: text/plain
File size: 4534 byte(s)
clear name tagging is supported now.
1 jgs 150 /*
2 elspeth 616 ************************************************************
3     * Copyright 2006 by ACcESS MNRF *
4     * *
5     * http://www.access.edu.au *
6     * Primary Business: Queensland, Australia *
7     * Licensed under the Open Software License version 3.0 *
8     * http://www.opensource.org/licenses/osl-3.0.php *
9     * *
10     ************************************************************
11 jgs 150 */
12    
13 jgs 82 /**************************************************************/
14    
15     /* Finley: write Mesh */
16    
17     /**************************************************************/
18    
19     /* Author: gross@access.edu.au */
20     /* Version: $Id$ */
21    
22     /**************************************************************/
23    
24     #include "Mesh.h"
25    
26     /**************************************************************/
27    
28     /* writes the mesh to the external file fname unsing the Finley file format: */
29    
30     void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
31 jgs 150 char error_msg[LenErrorMsg_MAX];
32 jgs 82 FILE *f;
33     int NN,i,j,numDim;
34 gross 1044 Finley_TagMap* tag_map=in->TagMap;
35 jgs 82
36     /* open file */
37     f=fopen(fname,"w");
38     if (f==NULL) {
39 jgs 150 sprintf(error_msg,"__FILE__: Opening file %s for writing failed.",fname);
40     Finley_setError(IO_ERROR,error_msg);
41 jgs 82 return;
42     }
43    
44     /* write header */
45    
46     fprintf(f,"%s\n",in->Name);
47    
48     /* write nodes: */
49    
50     if (in->Nodes!=NULL) {
51     numDim=Finley_Mesh_getDim(in);
52     fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
53     for (i=0;i<in->Nodes->numNodes;i++) {
54     fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->degreeOfFreedom[i],in->Nodes->Tag[i]);
55     for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
56     fprintf(f,"\n");
57     }
58     } else {
59     fprintf(f,"0D-Nodes 0\n");
60     }
61    
62     /* write elements: */
63    
64     if (in->Elements!=NULL) {
65     fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
66     NN=in->Elements->ReferenceElement->Type->numNodes;
67     for (i=0;i<in->Elements->numElements;i++) {
68     fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
69     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
70     fprintf(f,"\n");
71     }
72     } else {
73     fprintf(f,"Tet4 0\n");
74     }
75    
76     /* write face elements: */
77     if (in->FaceElements!=NULL) {
78     fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
79     NN=in->FaceElements->ReferenceElement->Type->numNodes;
80     for (i=0;i<in->FaceElements->numElements;i++) {
81     fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
82     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
83     fprintf(f,"\n");
84     }
85     } else {
86     fprintf(f,"Tri3 0\n");
87     }
88    
89     /* write Contact elements : */
90     if (in->ContactElements!=NULL) {
91     fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
92     NN=in->ContactElements->ReferenceElement->Type->numNodes;
93     for (i=0;i<in->ContactElements->numElements;i++) {
94     fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
95     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
96     fprintf(f,"\n");
97     }
98     } else {
99     fprintf(f,"Tri3_Contact 0\n");
100     }
101    
102     /* write points: */
103     if (in->Points!=NULL) {
104     fprintf(f, "%s %d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements);
105     for (i=0;i<in->Points->numElements;i++) {
106     fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
107     }
108     } else {
109     fprintf(f,"Point1 0\n");
110     }
111 gross 1044
112     /* write tags:*/
113     if (tag_map) {
114     fprintf(f,"Tags\n");
115     while (tag_map) {
116     fprintf(f,"%s %d\n",tag_map->name,tag_map->tag_key);
117     tag_map=tag_map->next;
118     }
119     }
120 jgs 82 fclose(f);
121     #ifdef Finley_TRACE
122     printf("mesh %s has been written to file %s\n",in->Name,fname);
123     #endif
124     }
125    
126     /*
127     * $Log$
128 jgs 150 * Revision 1.2 2005/09/15 03:44:23 jgs
129     * Merge of development branch dev-02 back to main trunk on 2005-09-15
130 jgs 82 *
131 jgs 150 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
132     * the solver from finley are put into the standalone package paso now
133     *
134     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
135     * initial import of project esys2
136     *
137 jgs 82 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
138     * Initial version of eys using boost-python.
139     *
140     *
141     */
142    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26