/[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 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years ago) by ksteube
File MIME type: text/plain
File size: 9717 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Finley: write Mesh */
18
19 /**************************************************************/
20
21 #include "Mesh.h"
22
23 /**************************************************************/
24
25 /* writes the mesh to the external file fname unsing the Finley file format: */
26
27 void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
28 char error_msg[LenErrorMsg_MAX];
29 FILE *f;
30 int NN,i,j,numDim;
31 Finley_TagMap* tag_map=in->TagMap;
32
33 if (in->MPIInfo->size >1 ) {
34 Finley_setError(IO_ERROR,"Mesh_write: only single processor runs are supported.");
35 return;
36
37 }
38 /* open file */
39 f=fopen(fname,"w");
40 if (f==NULL) {
41 sprintf(error_msg,"Mesh_write: Opening file %s for writing failed.",fname);
42 Finley_setError(IO_ERROR,error_msg);
43 return;
44 }
45
46 /* write header */
47
48 fprintf(f,"%s\n",in->Name);
49
50 /* write nodes: */
51
52 if (in->Nodes!=NULL) {
53 numDim=Finley_Mesh_getDim(in);
54 fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
55 for (i=0;i<in->Nodes->numNodes;i++) {
56 fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->globalDegreesOfFreedom[i],in->Nodes->Tag[i]);
57 for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
58 fprintf(f,"\n");
59 }
60 } else {
61 fprintf(f,"0D-Nodes 0\n");
62 }
63
64 /* write elements: */
65
66 if (in->Elements!=NULL) {
67 fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
68 NN=in->Elements->numNodes;
69 for (i=0;i<in->Elements->numElements;i++) {
70 fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
71 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
72 fprintf(f,"\n");
73 }
74 } else {
75 fprintf(f,"Tet4 0\n");
76 }
77
78 /* write face elements: */
79 if (in->FaceElements!=NULL) {
80 fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
81 NN=in->FaceElements->numNodes;
82 for (i=0;i<in->FaceElements->numElements;i++) {
83 fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
84 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
85 fprintf(f,"\n");
86 }
87 } else {
88 fprintf(f,"Tri3 0\n");
89 }
90
91 /* write Contact elements : */
92 if (in->ContactElements!=NULL) {
93 fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
94 NN=in->ContactElements->numNodes;
95 for (i=0;i<in->ContactElements->numElements;i++) {
96 fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
97 for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
98 fprintf(f,"\n");
99 }
100 } else {
101 fprintf(f,"Tri3_Contact 0\n");
102 }
103
104 /* write points: */
105 if (in->Points!=NULL) {
106 fprintf(f, "%s %d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements);
107 for (i=0;i<in->Points->numElements;i++) {
108 fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
109 }
110 } else {
111 fprintf(f,"Point1 0\n");
112 }
113
114 /* write tags:*/
115 if (tag_map) {
116 fprintf(f,"Tags\n");
117 while (tag_map) {
118 fprintf(f,"%s %d\n",tag_map->name,tag_map->tag_key);
119 tag_map=tag_map->next;
120 }
121 }
122 fclose(f);
123 #ifdef Finley_TRACE
124 printf("mesh %s has been written to file %s\n",in->Name,fname);
125 #endif
126 }
127
128 void Finley_PrintMesh_Info(Finley_Mesh *in, bool_t full) {
129 int NN,i,j,numDim;
130 Finley_TagMap* tag_map=in->TagMap;
131
132 fprintf(stdout, "Finley_PrintMesh_Info running on CPU %d of %d\n",in->MPIInfo->rank, in->MPIInfo->size);
133 fprintf(stdout, "\tMesh name '%s'\n",in->Name);
134 fprintf(stdout, "\tOrder %d\n",in->order);
135 fprintf(stdout, "\tReduced order %d\n",in->reduced_order);
136
137 /* write nodes: */
138 if (in->Nodes!=NULL) {
139 numDim=Finley_Mesh_getDim(in);
140 if (in->Nodes->degreesOfFreedomDistribution != NULL) {
141 fprintf(stdout, "\tNodes->degreesOfFreedomDistribution:");
142 for (j=0;j<in->MPIInfo->size+1;j++) fprintf(stdout," %d",in->Nodes->degreesOfFreedomDistribution->first_component[j]);
143 fprintf(stdout, "\n");
144 }
145 fprintf(stdout, "\tNodes: %1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
146 if (full) {
147 fprintf(stdout, "\t Id Tag gDOF gNI grDfI grNI: Coordinates\n");
148 for (i=0;i<in->Nodes->numNodes;i++) {
149 fprintf(stdout, "\t %5d %5d %5d %5d %5d %5d: ", in->Nodes->Id[i], in->Nodes->Tag[i], in->Nodes->globalDegreesOfFreedom[i], in->Nodes->globalNodesIndex[i], in->Nodes->globalReducedDOFIndex[i], in->Nodes->globalReducedNodesIndex[i]);
150 for (j=0;j<numDim;j++) fprintf(stdout," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
151 fprintf(stdout,"\n");
152 }
153 }
154 } else {
155 fprintf(stdout, "\tNodes: 0D-Nodes 0\n");
156 }
157
158 /* write elements: */
159 if (in->Elements!=NULL) {
160 int mine=0, overlap=0;
161 for (i=0;i<in->Elements->numElements;i++) {
162 if (in->Elements->Owner[i] == in->MPIInfo->rank) mine++;
163 else overlap++;
164 }
165 fprintf(stdout, "\tElements: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements,in->Elements->ReferenceElement->Type->TypeId, mine, overlap);
166 NN=in->Elements->numNodes;
167 if (full) {
168 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
169 for (i=0;i<in->Elements->numElements;i++) {
170 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->Elements->Id[i],in->Elements->Tag[i],in->Elements->Owner[i],in->Elements->Color[i]);
171 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
172 fprintf(stdout,"\n");
173 }
174 }
175 } else {
176 fprintf(stdout, "\tElements: Tet4 0\n");
177 }
178
179 /* write face elements: */
180 if (in->FaceElements!=NULL) {
181 int mine=0, overlap=0;
182 for (i=0;i<in->FaceElements->numElements;i++) {
183 if (in->FaceElements->Owner[i] == in->MPIInfo->rank) mine++;
184 else overlap++;
185 }
186 fprintf(stdout, "\tFace elements: %s %d (TypeId=%d) owner=%d overlap=%d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements,in->FaceElements->ReferenceElement->Type->TypeId, mine, overlap);
187 NN=in->FaceElements->numNodes;
188 if (full) {
189 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
190 for (i=0;i<in->FaceElements->numElements;i++) {
191 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->FaceElements->Id[i],in->FaceElements->Tag[i],in->FaceElements->Owner[i],in->FaceElements->Color[i]);
192 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
193 fprintf(stdout,"\n");
194 }
195 }
196 } else {
197 fprintf(stdout, "\tFace elements: Tri3 0\n");
198 }
199
200 /* write Contact elements : */
201 if (in->ContactElements!=NULL) {
202 int mine=0, overlap=0;
203 for (i=0;i<in->ContactElements->numElements;i++) {
204 if (in->ContactElements->Owner[i] == in->MPIInfo->rank) mine++;
205 else overlap++;
206 }
207 fprintf(stdout, "\tContact elements: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements,in->ContactElements->ReferenceElement->Type->TypeId, mine, overlap);
208 NN=in->ContactElements->numNodes;
209 if (full) {
210 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
211 for (i=0;i<in->ContactElements->numElements;i++) {
212 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->ContactElements->Id[i],in->ContactElements->Tag[i],in->ContactElements->Owner[i],in->ContactElements->Color[i]);
213 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
214 fprintf(stdout,"\n");
215 }
216 }
217 } else {
218 fprintf(stdout, "\tContact elements: Tri3_Contact 0\n");
219 }
220
221 /* write points: */
222 if (in->Points!=NULL) {
223 int mine=0, overlap=0;
224 for (i=0;i<in->Points->numElements;i++) {
225 if (in->Points->Owner[i] == in->MPIInfo->rank) mine++;
226 else overlap++;
227 }
228 fprintf(stdout, "\tPoints: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->Points->ReferenceElement->Type->Name,in->Points->numElements,in->Points->ReferenceElement->Type->TypeId, mine, overlap);
229 if (full) {
230 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
231 for (i=0;i<in->Points->numElements;i++) {
232 fprintf(stdout, "\t %5d %5d %5d %5d %5d\n",in->Points->Id[i],in->Points->Tag[i],in->Points->Owner[i],in->Points->Color[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
233 }
234 }
235 } else {
236 fprintf(stdout, "\tPoints: Point1 0\n");
237 }
238
239 /* write tags:*/
240 if (tag_map) {
241 fprintf(stdout, "\tTags:\n");
242 while (tag_map) {
243 fprintf(stdout, "\t %5d %s\n", tag_map->tag_key, tag_map->name);
244 tag_map=tag_map->next;
245 }
246 }
247 }
248
249 /*
250 * $Log$
251 * Revision 1.2 2005/09/15 03:44:23 jgs
252 * Merge of development branch dev-02 back to main trunk on 2005-09-15
253 *
254 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
255 * the solver from finley are put into the standalone package paso now
256 *
257 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
258 * initial import of project esys2
259 *
260 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
261 * Initial version of eys using boost-python.
262 *
263 *
264 */
265

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26