/[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 471 - (show annotations)
Fri Jan 27 01:33:02 2006 UTC (13 years, 5 months ago) by jgs
File MIME type: text/plain
File size: 4632 byte(s)
reorganise finley src tree to remove inc dir and src/finley directory

1 /*
2 ******************************************************************************
3 * *
4 * COPYRIGHT ACcESS 2003,2004,2005 - All Rights Reserved *
5 * *
6 * This software is the property of ACcESS. No part of this code *
7 * may be copied in any form or by any means without the expressed written *
8 * consent of ACcESS. Copying, use or modification of this software *
9 * by any unauthorised person is illegal unless that person has a software *
10 * license agreement with ACcESS. *
11 * *
12 ******************************************************************************
13 */
14
15 /**************************************************************/
16
17 /* Finley: write Mesh */
18
19 /**************************************************************/
20
21 /* Author: gross@access.edu.au */
22 /* Version: $Id$ */
23
24 /**************************************************************/
25
26 #include "Mesh.h"
27
28 /**************************************************************/
29
30 /* writes the mesh to the external file fname unsing the Finley file format: */
31
32 void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
33 char error_msg[LenErrorMsg_MAX];
34 FILE *f;
35 int NN,i,j,numDim;
36
37 /* open file */
38 f=fopen(fname,"w");
39 if (f==NULL) {
40 sprintf(error_msg,"__FILE__: Opening file %s for writing failed.",fname);
41 Finley_setError(IO_ERROR,error_msg);
42 return;
43 }
44
45 /* write header */
46
47 fprintf(f,"%s\n",in->Name);
48
49 /* write nodes: */
50
51 if (in->Nodes!=NULL) {
52 numDim=Finley_Mesh_getDim(in);
53 fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
54 for (i=0;i<in->Nodes->numNodes;i++) {
55 fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->degreeOfFreedom[i],in->Nodes->Tag[i]);
56 for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
57 fprintf(f,"\n");
58 }
59 } else {
60 fprintf(f,"0D-Nodes 0\n");
61 }
62
63 /* write elements: */
64
65 if (in->Elements!=NULL) {
66 fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
67 NN=in->Elements->ReferenceElement->Type->numNodes;
68 for (i=0;i<in->Elements->numElements;i++) {
69 fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
70 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
71 fprintf(f,"\n");
72 }
73 } else {
74 fprintf(f,"Tet4 0\n");
75 }
76
77 /* write face elements: */
78 if (in->FaceElements!=NULL) {
79 fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
80 NN=in->FaceElements->ReferenceElement->Type->numNodes;
81 for (i=0;i<in->FaceElements->numElements;i++) {
82 fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
83 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
84 fprintf(f,"\n");
85 }
86 } else {
87 fprintf(f,"Tri3 0\n");
88 }
89
90 /* write Contact elements : */
91 if (in->ContactElements!=NULL) {
92 fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
93 NN=in->ContactElements->ReferenceElement->Type->numNodes;
94 for (i=0;i<in->ContactElements->numElements;i++) {
95 fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
96 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
97 fprintf(f,"\n");
98 }
99 } else {
100 fprintf(f,"Tri3_Contact 0\n");
101 }
102
103 /* write points: */
104 if (in->Points!=NULL) {
105 fprintf(f, "%s %d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements);
106 for (i=0;i<in->Points->numElements;i++) {
107 fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
108 }
109 } else {
110 fprintf(f,"Point1 0\n");
111 }
112
113 fclose(f);
114 #ifdef Finley_TRACE
115 printf("mesh %s has been written to file %s\n",in->Name,fname);
116 #endif
117 }
118
119 /*
120 * $Log$
121 * Revision 1.2 2005/09/15 03:44:23 jgs
122 * Merge of development branch dev-02 back to main trunk on 2005-09-15
123 *
124 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
125 * the solver from finley are put into the standalone package paso now
126 *
127 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
128 * initial import of project esys2
129 *
130 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
131 * Initial version of eys using boost-python.
132 *
133 *
134 */
135

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26