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

Contents of /trunk-mpi-branch/finley/src/Mesh_write.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (12 years, 10 months ago) by gross
File MIME type: text/plain
File size: 4606 byte(s)
first attemt towards an improved MPI version.  

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26