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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (show annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 8 months ago) by elspeth
File MIME type: text/plain
File size: 4310 byte(s)
Copyright added to more source files.

1 /*
2 ************************************************************
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 */
12
13 /**************************************************************/
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 char error_msg[LenErrorMsg_MAX];
32 FILE *f;
33 int NN,i,j,numDim;
34
35 /* open file */
36 f=fopen(fname,"w");
37 if (f==NULL) {
38 sprintf(error_msg,"__FILE__: Opening file %s for writing failed.",fname);
39 Finley_setError(IO_ERROR,error_msg);
40 return;
41 }
42
43 /* write header */
44
45 fprintf(f,"%s\n",in->Name);
46
47 /* write nodes: */
48
49 if (in->Nodes!=NULL) {
50 numDim=Finley_Mesh_getDim(in);
51 fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
52 for (i=0;i<in->Nodes->numNodes;i++) {
53 fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->degreeOfFreedom[i],in->Nodes->Tag[i]);
54 for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
55 fprintf(f,"\n");
56 }
57 } else {
58 fprintf(f,"0D-Nodes 0\n");
59 }
60
61 /* write elements: */
62
63 if (in->Elements!=NULL) {
64 fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
65 NN=in->Elements->ReferenceElement->Type->numNodes;
66 for (i=0;i<in->Elements->numElements;i++) {
67 fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
68 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
69 fprintf(f,"\n");
70 }
71 } else {
72 fprintf(f,"Tet4 0\n");
73 }
74
75 /* write face elements: */
76 if (in->FaceElements!=NULL) {
77 fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
78 NN=in->FaceElements->ReferenceElement->Type->numNodes;
79 for (i=0;i<in->FaceElements->numElements;i++) {
80 fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
81 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
82 fprintf(f,"\n");
83 }
84 } else {
85 fprintf(f,"Tri3 0\n");
86 }
87
88 /* write Contact elements : */
89 if (in->ContactElements!=NULL) {
90 fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
91 NN=in->ContactElements->ReferenceElement->Type->numNodes;
92 for (i=0;i<in->ContactElements->numElements;i++) {
93 fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
94 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
95 fprintf(f,"\n");
96 }
97 } else {
98 fprintf(f,"Tri3_Contact 0\n");
99 }
100
101 /* write points: */
102 if (in->Points!=NULL) {
103 fprintf(f, "%s %d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements);
104 for (i=0;i<in->Points->numElements;i++) {
105 fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
106 }
107 } else {
108 fprintf(f,"Point1 0\n");
109 }
110
111 fclose(f);
112 #ifdef Finley_TRACE
113 printf("mesh %s has been written to file %s\n",in->Name,fname);
114 #endif
115 }
116
117 /*
118 * $Log$
119 * Revision 1.2 2005/09/15 03:44:23 jgs
120 * Merge of development branch dev-02 back to main trunk on 2005-09-15
121 *
122 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
123 * the solver from finley are put into the standalone package paso now
124 *
125 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
126 * initial import of project esys2
127 *
128 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
129 * Initial version of eys using boost-python.
130 *
131 *
132 */
133

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26