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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26