/[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 1912 - (show annotations)
Thu Oct 23 05:08:31 2008 UTC (10 years, 10 months ago) by ksteube
File MIME type: text/plain
File size: 9433 byte(s)
Finished wrapper script by setting PATH.

The wrapper script reproduces the environment of the person who built
the software + values specified in his hostname_options.py file.  A
user can run a python script without setting any environment variables
or loading any SGI modules.

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 fprintf(stdout, "\tNodes: %1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
141 if (full) {
142 fprintf(stdout, "\t Id Tag gDOF gNI grDfI grNI: Coordinates\n");
143 for (i=0;i<in->Nodes->numNodes;i++) {
144 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]);
145 for (j=0;j<numDim;j++) fprintf(stdout," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
146 fprintf(stdout,"\n");
147 }
148 }
149 } else {
150 fprintf(stdout, "\tNodes: 0D-Nodes 0\n");
151 }
152
153 /* write elements: */
154 if (in->Elements!=NULL) {
155 int mine=0, overlap=0;
156 for (i=0;i<in->Elements->numElements;i++) {
157 if (in->Elements->Owner[i] == in->MPIInfo->rank) mine++;
158 else overlap++;
159 }
160 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);
161 NN=in->Elements->numNodes;
162 if (full) {
163 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
164 for (i=0;i<in->Elements->numElements;i++) {
165 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->Elements->Id[i],in->Elements->Tag[i],in->Elements->Owner[i],in->Elements->Color[i]);
166 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
167 fprintf(stdout,"\n");
168 }
169 }
170 } else {
171 fprintf(stdout, "\tElements: Tet4 0\n");
172 }
173
174 /* write face elements: */
175 if (in->FaceElements!=NULL) {
176 int mine=0, overlap=0;
177 for (i=0;i<in->FaceElements->numElements;i++) {
178 if (in->FaceElements->Owner[i] == in->MPIInfo->rank) mine++;
179 else overlap++;
180 }
181 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);
182 NN=in->FaceElements->numNodes;
183 if (full) {
184 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
185 for (i=0;i<in->FaceElements->numElements;i++) {
186 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->FaceElements->Id[i],in->FaceElements->Tag[i],in->FaceElements->Owner[i],in->FaceElements->Color[i]);
187 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
188 fprintf(stdout,"\n");
189 }
190 }
191 } else {
192 fprintf(stdout, "\tFace elements: Tri3 0\n");
193 }
194
195 /* write Contact elements : */
196 if (in->ContactElements!=NULL) {
197 int mine=0, overlap=0;
198 for (i=0;i<in->ContactElements->numElements;i++) {
199 if (in->ContactElements->Owner[i] == in->MPIInfo->rank) mine++;
200 else overlap++;
201 }
202 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);
203 NN=in->ContactElements->numNodes;
204 if (full) {
205 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
206 for (i=0;i<in->ContactElements->numElements;i++) {
207 fprintf(stdout, "\t %5d %5d %5d %5d: ",in->ContactElements->Id[i],in->ContactElements->Tag[i],in->ContactElements->Owner[i],in->ContactElements->Color[i]);
208 for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
209 fprintf(stdout,"\n");
210 }
211 }
212 } else {
213 fprintf(stdout, "\tContact elements: Tri3_Contact 0\n");
214 }
215
216 /* write points: */
217 if (in->Points!=NULL) {
218 int mine=0, overlap=0;
219 for (i=0;i<in->Points->numElements;i++) {
220 if (in->Points->Owner[i] == in->MPIInfo->rank) mine++;
221 else overlap++;
222 }
223 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);
224 if (full) {
225 fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
226 for (i=0;i<in->Points->numElements;i++) {
227 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)]]);
228 }
229 }
230 } else {
231 fprintf(stdout, "\tPoints: Point1 0\n");
232 }
233
234 /* write tags:*/
235 if (tag_map) {
236 fprintf(stdout, "\tTags:\n");
237 while (tag_map) {
238 fprintf(stdout, "\t %5d %s\n", tag_map->tag_key, tag_map->name);
239 tag_map=tag_map->next;
240 }
241 }
242 }
243
244 /*
245 * $Log$
246 * Revision 1.2 2005/09/15 03:44:23 jgs
247 * Merge of development branch dev-02 back to main trunk on 2005-09-15
248 *
249 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
250 * the solver from finley are put into the standalone package paso now
251 *
252 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
253 * initial import of project esys2
254 *
255 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
256 * Initial version of eys using boost-python.
257 *
258 *
259 */
260

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26