/[escript]/trunk/dudley/src/Mesh_saveDX.c
ViewVC logotype

Diff of /trunk/dudley/src/Mesh_saveDX.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/finley/src/finley/Mesh_saveDX.c revision 201 by jgs, Wed Nov 23 04:10:21 2005 UTC trunk/dudley/src/Mesh_saveDX.c revision 3259 by jfenwick, Mon Oct 11 01:48:14 2010 UTC
# Line 1  Line 1 
 /*  
  ******************************************************************************  
  *                                                                            *  
  *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *  
  *                                                                            *  
  * This software is the property of ACcESS. No part of this code              *  
  * may be copied in any form or by any means without the expressed written    *  
  * consent of ACcESS.  Copying, use or modification of this software          *  
  * by any unauthorised person is illegal unless that person has a software    *  
  * license agreement with ACcESS.                                             *  
  *                                                                            *  
  ******************************************************************************  
 */  
1    
2    /*******************************************************
3    *
4    * Copyright (c) 2003-2010 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  /*   writes data and mesh in an opendx file */  /*   writes data and mesh in an opendx file                      */
17    /*   the input data needs to be cell centered or on reducedNodes */
 /**************************************************************/  
   
 /*   Author: Lutz Gross, gross@access.edu.au */  
 /*   Version: $Id$ */  
18    
19  /**************************************************************/  /**************************************************************/
20    
21  #include "Mesh.h"  #include "Mesh.h"
22    #include "Assemble.h"
23    
24  /**************************************************************/  /**************************************************************/
25    
26  void Finley_Mesh_saveDX(const char * filename_p, Finley_Mesh *mesh_p, const dim_t num_data,char* *names_p,escriptDataC* *data_pp) {  void Dudley_Mesh_saveDX(const char *filename_p, Dudley_Mesh * mesh_p, const dim_t num_data, char **names_p,
27    char error_msg[LenErrorMsg_MAX];              escriptDataC * *data_pp)
28    /* if there is no mesh we just return */  {
29    if (mesh_p==NULL) return;      char error_msg[LenErrorMsg_MAX], elemTypeStr[32];
30        /* some tables needed for reordering */
31    /* some tables needed for reordering */      int resort[6][9] = {
32    int resort[6][9]={      {0, 1},         /* line */
33                      {0,1},   /* line */      {0, 1, 2},      /* triagle */
34                      {0,1,2},  /* triagle */      {0, 1, 2, 3},       /* tetrahedron */
35                      {0,1,2,3}, /* tetrahedron */      {0, 3, 1, 2},       /* quadrilateral */
36                      {0,3,1,2}, /* quadrilateral */      {3, 0, 7, 4, 2, 1, 6, 5},   /* hexahedron */
37                      {3,0,7,4,2,1,6,5}, /* hexahedron */      };
38                     };      FILE *fileHandle_p = NULL;
39    int i,j,k,i_data;      int i, j, k, i_data, elementtype, numPoints = 0, nDim, *resortIndex = NULL, p,
40    /* open the file  and check handel */      numDXNodesPerElement = 0, numCells, NN, object_count, rank, nComp, numPointsPerSample;
41        __const double *values;
42    FILE * fileHandle_p = fopen(filename_p, "w");      double rtmp;
43    if (fileHandle_p==NULL) {      bool_t *isCellCentered = NULL;
44      sprintf(error_msg,"File %s could not be opened for writing.",filename_p);      Dudley_ElementFile *elements = NULL;
45      Finley_setError(IO_ERROR,error_msg);      Dudley_ElementTypeId TypeId;
46      return;      /* open the file  and check handel */
47    }  
48    /* find the mesh type to be written */      /* if there is no mesh we just return */
49    int nodetype=FINLEY_DEGREES_OF_FREEDOM;      if (mesh_p == NULL)
50    int elementtype=FINLEY_UNKNOWN;      return;
51    bool_t isCellCentered[num_data];      isCellCentered = MEMALLOC(num_data, bool_t);
52    for (i_data=0;i_data<num_data;++i_data) {      if (Dudley_checkPtr(isCellCentered))
53       if (! isEmpty(data_pp[i_data])) {      return;
54          switch(getFunctionSpaceType(data_pp[i_data])) {  
55             case FINLEY_DEGREES_OF_FREEDOM:      fileHandle_p = fopen(filename_p, "w");
56               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;      if (fileHandle_p == NULL)
57               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS) {      {
58                   elementtype=FINLEY_ELEMENTS;      sprintf(error_msg, "File %s could not be opened for writing.", filename_p);
59               } else {      MEMFREE(isCellCentered);
60                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");      fclose(fileHandle_p);
61                   return;      Dudley_setError(IO_ERROR, error_msg);
62               }      return;
63               isCellCentered[i_data]=FALSE;      }
64               break;      /* find the mesh type to be written */
65             case FINLEY_REDUCED_DEGREES_OF_FREEDOM:      elementtype = DUDLEY_UNKNOWN;
66               nodetype = FINLEY_REDUCED_DEGREES_OF_FREEDOM;      for (i_data = 0; i_data < num_data; ++i_data)
67               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS) {      {
68                   elementtype=FINLEY_ELEMENTS;      if (!isEmpty(data_pp[i_data]))
69               } else {      {
70                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");          switch (getFunctionSpaceType(data_pp[i_data]))
71                   return;          {
72               }          case DUDLEY_REDUCED_NODES:
73               isCellCentered[i_data]=FALSE;          if (elementtype == DUDLEY_UNKNOWN || elementtype == DUDLEY_ELEMENTS)
74               break;          {
75             case FINLEY_NODES:              elementtype = DUDLEY_ELEMENTS;
76               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          }
77               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS) {          else
78                   elementtype=FINLEY_ELEMENTS;          {
79               } else {              Dudley_setError(TYPE_ERROR, "saveDX: cannot write given data into single file.");
80                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");              MEMFREE(isCellCentered);
81                   return;              fclose(fileHandle_p);
82               }              return;
83               isCellCentered[i_data]=FALSE;          }
84               break;          isCellCentered[i_data] = FALSE;
85             case FINLEY_ELEMENTS:          break;
86               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          case DUDLEY_ELEMENTS:
87               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS) {          case DUDLEY_REDUCED_ELEMENTS:
88                   elementtype=FINLEY_ELEMENTS;          if (elementtype == DUDLEY_UNKNOWN || elementtype == DUDLEY_ELEMENTS)
89               } else {          {
90                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");              elementtype = DUDLEY_ELEMENTS;
91                   return;          }
92               }          else
93               isCellCentered[i_data]=TRUE;          {
94               break;              Dudley_setError(TYPE_ERROR, "saveDX: cannot write given data into single file.");
95             case FINLEY_FACE_ELEMENTS:              MEMFREE(isCellCentered);
96               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;              fclose(fileHandle_p);
97               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_FACE_ELEMENTS) {              return;
98                   elementtype=FINLEY_FACE_ELEMENTS;          }
99               } else {          isCellCentered[i_data] = TRUE;
100                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");          break;
101                   return;          case DUDLEY_FACE_ELEMENTS:
102               }          case DUDLEY_REDUCED_FACE_ELEMENTS:
103               isCellCentered[i_data]=TRUE;          if (elementtype == DUDLEY_UNKNOWN || elementtype == DUDLEY_FACE_ELEMENTS)
104               break;          {
105             case FINLEY_POINTS:              elementtype = DUDLEY_FACE_ELEMENTS;
106               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          }
107               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_POINTS) {          else
108                   elementtype=FINLEY_POINTS;          {
109               } else {              Dudley_setError(TYPE_ERROR, "saveDX: cannot write given data into single file.");
110                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");              MEMFREE(isCellCentered);
111                   return;              fclose(fileHandle_p);
112               }              return;
113               isCellCentered[i_data]=TRUE;          }
114               break;          isCellCentered[i_data] = TRUE;
115             case FINLEY_CONTACT_ELEMENTS_1:          break;
116               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          case DUDLEY_POINTS:
117               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1) {          if (elementtype == DUDLEY_UNKNOWN || elementtype == DUDLEY_POINTS)
118                   elementtype=FINLEY_CONTACT_ELEMENTS_1;          {
119               } else {              elementtype = DUDLEY_POINTS;
120                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");          }
121                   return;          else
122               }          {
123               isCellCentered[i_data]=TRUE;              Dudley_setError(TYPE_ERROR, "saveDX: cannot write given data into single file.");
124               break;              MEMFREE(isCellCentered);
125             case FINLEY_CONTACT_ELEMENTS_2:              fclose(fileHandle_p);
126               nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;              return;
127               if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1) {          }
128                   elementtype=FINLEY_CONTACT_ELEMENTS_1;          isCellCentered[i_data] = TRUE;
129               } else {          break;
130                   Finley_setError(TYPE_ERROR,"saveDX: cannot write given data in single file.");          default:
131                   return;          sprintf(error_msg, "saveDX: I don't know how to handle function space type %d",
132               }              getFunctionSpaceType(data_pp[i_data]));
133               isCellCentered[i_data]=TRUE;          Dudley_setError(TYPE_ERROR, error_msg);
134               break;          MEMFREE(isCellCentered);
135             default:          fclose(fileHandle_p);
136               sprintf(error_msg,"saveDX: Finley does not know anything about function space type %d",getFunctionSpaceType(data_pp[i_data]));          return;
137               Finley_setError(TYPE_ERROR,error_msg);          }
138               return;      }
139          }      }
140       }      /* select number of points and the mesh component */
141    }      numPoints = mesh_p->Nodes->reducedNodesMapping->numTargets;
142    /* select number of points and the mesh component */      nDim = mesh_p->Nodes->numDim;
143    int numPoints = mesh_p->Nodes->numNodes;      if (elementtype == DUDLEY_UNKNOWN)
144    int nDim = mesh_p->Nodes->numDim;      elementtype = DUDLEY_ELEMENTS;
145    if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {      switch (elementtype)
146         numPoints = mesh_p->Nodes->reducedNumNodes;      {
147    } else {      case DUDLEY_ELEMENTS:
148         numPoints = mesh_p->Nodes->numNodes;      elements = mesh_p->Elements;
149    }      break;
150    if (elementtype==FINLEY_UNKNOWN) elementtype=FINLEY_ELEMENTS;      case DUDLEY_FACE_ELEMENTS:
151    Finley_ElementFile* elements=NULL;      elements = mesh_p->FaceElements;
152    switch(elementtype) {      break;
153      case FINLEY_ELEMENTS:      case DUDLEY_POINTS:
154        elements=mesh_p->Elements;      elements = mesh_p->Points;
155        break;      break;
156      case FINLEY_FACE_ELEMENTS:      }
157        elements=mesh_p->FaceElements;      if (elements == NULL)
158        break;      {
159      case FINLEY_POINTS:      Dudley_setError(SYSTEM_ERROR, "saveDX: undefined element file");
160        elements=mesh_p->Points;      MEMFREE(isCellCentered);
161        break;      fclose(fileHandle_p);
162      case FINLEY_CONTACT_ELEMENTS_1:      return;
163        elements=mesh_p->ContactElements;      }
164        break;  
165    }      /* map dudley element type to DX element type */
166    if (elements==NULL) {      TypeId = elements->etype;
167       Finley_setError(SYSTEM_ERROR,"saveDX: undefined element file");      numDXNodesPerElement = 0;
168       return;      numCells = elements->numElements;
169    }      if (TypeId == Dudley_Line2)
170        {
171    /* map finley element type to DX element type */      numDXNodesPerElement = 2;
172    ElementTypeId TypeId = elements->ReferenceElement->Type->TypeId;      resortIndex = resort[0];
173    int *resortIndex=NULL;      strcpy(elemTypeStr, "lines");
174    int numDXNodesPerElement=0;      }
175    int numCells = elements->numElements;      else if (TypeId == Dudley_Tri3)
176    char elemTypeStr[32];      {
177    if (TypeId==Line2 || TypeId==Line3 || TypeId==Line4 ) {      numDXNodesPerElement = 3;
178       numDXNodesPerElement=2;      resortIndex = resort[1];
179       resortIndex=resort[0];      strcpy(elemTypeStr, "triangles");
180       strcpy(elemTypeStr, "lines");  /*   } else if (TypeId==Rec4 || TypeId==Rec8 || TypeId==Rec9 || TypeId==Rec12 || TypeId==Rec16 || TypeId==Rec9Macro ) {
    } else if (TypeId==Tri3 || TypeId==Tri6 || TypeId==Tri9 || TypeId==Tri10 ) {  
      numDXNodesPerElement = 3;  
      resortIndex=resort[1];  
      strcpy(elemTypeStr, "triangles");  
    } else if (TypeId==Rec4 || TypeId==Rec8 || TypeId==Rec9 || TypeId==Rec12 || TypeId==Rec16 ) {  
181       numDXNodesPerElement = 4;       numDXNodesPerElement = 4;
182       resortIndex=resort[3];       resortIndex=resort[3];
183       strcpy(elemTypeStr, "quads");       strcpy(elemTypeStr, "quads");*/
184     } else if (TypeId==Tet4 || TypeId==Tet10 || TypeId==Tet16 ) {      }
185       numDXNodesPerElement = 4;      else if (TypeId == Dudley_Tet4)
186       resortIndex=resort[2];      {
187       strcpy(elemTypeStr, "tetrahedra");      numDXNodesPerElement = 4;
188     } else if (TypeId==Hex8 || TypeId==Hex20 || TypeId==Hex32 ) {      resortIndex = resort[2];
189        strcpy(elemTypeStr, "tetrahedra");
190    /*   } else if (TypeId==Hex8 || TypeId==Hex20 || TypeId==Hex32 ) {
191       numDXNodesPerElement = 8;       numDXNodesPerElement = 8;
192       resortIndex=resort[4];       resortIndex=resort[4];
193       strcpy(elemTypeStr, "cubes");       strcpy(elemTypeStr, "cubes");*/
194     } else {      }
195       sprintf(error_msg,"saveDX: Element type %s is not supported by DX",elements->ReferenceElement->Type->Name);      else
196       Finley_setError(VALUE_ERROR,error_msg);      {
197       return;      sprintf(error_msg, "saveDX: Element type %s is not supported by DX", elements->ename);
198     }      Dudley_setError(VALUE_ERROR, error_msg);
199        MEMFREE(isCellCentered);
200    /* positions */      fclose(fileHandle_p);
201    fprintf(fileHandle_p, "object 1 class array type float rank 1 shape %d items %d data follows\n",nDim, mesh_p->Nodes->reducedNumNodes);      return;
202    for (i = 0; i < mesh_p->Nodes->numNodes; i++) {      }
203      if (mesh_p->Nodes->toReduced[i]>=0) {  
204         for (j = 0; j < nDim; j++) fprintf(fileHandle_p, " %g",mesh_p->Nodes->Coordinates[INDEX2(j, i, nDim)]);      /* positions */
205         fprintf(fileHandle_p, "\n");      fprintf(fileHandle_p, "object 1 class array type float rank 1 shape %d items %d data follows\n", nDim, numPoints);
206      }      for (i = 0; i < numPoints; i++)
207    }      {
208    /* connection table */      p = mesh_p->Nodes->reducedNodesMapping->map[i];
209    int NN=elements->ReferenceElement->Type->numNodes;      for (j = 0; j < nDim; j++)
210    fprintf(fileHandle_p, "object 2 class array type int rank 1 shape %d items %d data follows\n",numDXNodesPerElement, numCells);          fprintf(fileHandle_p, " %g", mesh_p->Nodes->Coordinates[INDEX2(j, p, nDim)]);
211    for (i = 0; i < numCells; i++) {      fprintf(fileHandle_p, "\n");
212        for (j = 0; j < numDXNodesPerElement; j++) fprintf(fileHandle_p," %d",mesh_p->Nodes->toReduced[elements->Nodes[INDEX2(resortIndex[j], i, NN)]]);      }
213        fprintf(fileHandle_p, "\n");      /* connection table */
214    }      NN = elements->numNodes;
215    fprintf(fileHandle_p, "attribute \"element type\" string \"%s\"\n",elemTypeStr);      fprintf(fileHandle_p, "object 2 class array type int rank 1 shape %d items %d data follows\n", numDXNodesPerElement,
216    fprintf(fileHandle_p, "attribute \"ref\" string \"positions\"\n");          numCells);
217        for (i = 0; i < numCells; i++)
218    /* data */      {
219    int object_count=2;      for (j = 0; j < numDXNodesPerElement; j++)
220    for (i_data =0 ;i_data<num_data;++i_data) {          fprintf(fileHandle_p, " %d",
221        if (! isEmpty(data_pp[i_data])) {              mesh_p->Nodes->reducedNodesMapping->target[elements->Nodes[INDEX2(resortIndex[j], i, NN)]]);
222           object_count++;      fprintf(fileHandle_p, "\n");
223           int rank=getDataPointRank(data_pp[i_data]);      }
224           int nComp=getDataPointSize(data_pp[i_data]);      fprintf(fileHandle_p, "attribute \"element type\" string \"%s\"\n", elemTypeStr);
225           double* values,rtmp;      fprintf(fileHandle_p, "attribute \"ref\" string \"positions\"\n");
226           fprintf(fileHandle_p, "object %d class array type float rank %d ",object_count,rank);  
227           if (0 < rank) {      /* data */
228              fprintf(fileHandle_p, "shape ");      object_count = 2;
229              for (i = 0; i < rank; i++) fprintf(fileHandle_p, "%d ", getDataPointShape(data_pp[i_data],i));      for (i_data = 0; i_data < num_data; ++i_data)
230           }      {
231           if (isCellCentered[i_data]) {      if (!isEmpty(data_pp[i_data]))
232               int numPointsPerSample=elements->ReferenceElement->numQuadNodes;      {
233               if (numPointsPerSample>0) {          object_count++;
234                  fprintf(fileHandle_p, "items %d data follows\n", numCells);          rank = getDataPointRank(data_pp[i_data]);
235                  for (i=0;i<elements->numElements;i++) {          nComp = getDataPointSize(data_pp[i_data]);
236                      values=getSampleData(data_pp[i_data],i);          fprintf(fileHandle_p, "object %d class array type float rank %d ", object_count, rank);
237                      for (k=0;k<nComp;k++) {          if (0 < rank)
238                          rtmp=0.;          {
239                          for (j=0;j<numPointsPerSample;j++) rtmp+=values[INDEX2(k,j,nComp)];          fprintf(fileHandle_p, "shape ");
240                          fprintf(fileHandle_p, " %g", rtmp/numPointsPerSample);          for (i = 0; i < rank; i++)
241                      }              fprintf(fileHandle_p, "%d ", getDataPointShape(data_pp[i_data], i));
242                  fprintf(fileHandle_p, "\n");          }
243                  }          if (isCellCentered[i_data])
244                  fprintf(fileHandle_p, "attribute \"dep\" string \"connections\"\n");          {
245              }          if (Dudley_Assemble_reducedIntegrationOrder(data_pp[i_data]))
246           } else {          {
247               fprintf(fileHandle_p, "items %d data follows\n", mesh_p->Nodes->reducedNumNodes);              numPointsPerSample = (elements->numLocalDim == 0) ? 0 : 1;
248               for (i=0;i<mesh_p->Nodes->numNodes;i++) {          }
249                   if (mesh_p->Nodes->toReduced[i]>=0) {          else
250                      switch (getFunctionSpaceType(data_pp[i_data])) {          {
251                         case FINLEY_DEGREES_OF_FREEDOM:              numPointsPerSample = (elements->numLocalDim == 0) ? 0 : (elements->numLocalDim + 1);
252                            values=getSampleData(data_pp[i_data],mesh_p->Nodes->degreeOfFreedom[i]);          }
253                            break;          if (numPointsPerSample > 0)
254                         case FINLEY_REDUCED_DEGREES_OF_FREEDOM:          {
255                            values=getSampleData(data_pp[i_data],mesh_p->Nodes->reducedDegreeOfFreedom[i]);              fprintf(fileHandle_p, "items %d data follows\n", numCells);
256                            break;              for (i = 0; i < elements->numElements; i++)
257                         case FINLEY_NODES:              {
258                            values=getSampleData(data_pp[i_data],i);              values = getSampleDataRO(data_pp[i_data], i);
259                            break;              for (k = 0; k < nComp; k++)
260                      }              {
261                      for (k=0;k<nComp;k++) fprintf(fileHandle_p, " %g", values[k]);                  if (isExpanded(data_pp[i_data]))
262                  fprintf(fileHandle_p, "\n");                  {
263                   }                  rtmp = 0.;
264               }                  for (j = 0; j < numPointsPerSample; j++)
265               fprintf(fileHandle_p, "attribute \"dep\" string \"positions\"\n");                      rtmp += values[INDEX2(k, j, nComp)];
266           }                  fprintf(fileHandle_p, " %g", rtmp / numPointsPerSample);
267       }                  }
268    }                  else
269                    {
270    /* and finish it up */                  fprintf(fileHandle_p, " %g", values[k]);
271    if (num_data==0) {                  }
272       fprintf(fileHandle_p, "object %d class field\n",object_count+1);              }
273       fprintf(fileHandle_p, "component \"positions\" value 1\n");              fprintf(fileHandle_p, "\n");
274       fprintf(fileHandle_p, "component \"connections\" value 2\n");              }
275    } else {              fprintf(fileHandle_p, "attribute \"dep\" string \"connections\"\n");
276       object_count=2;          }
277       for (i_data=0; i_data<num_data;++i_data) {          }
278           if (! isEmpty(data_pp[i_data])) {          else
279              object_count++;          {
280              fprintf(fileHandle_p, "object \"%s\" class field\n",names_p[i_data]);          fprintf(fileHandle_p, "items %d data follows\n", numPoints);
281              fprintf(fileHandle_p, "component \"positions\" value 1\n");          for (i = 0; i < numPoints; i++)
282              fprintf(fileHandle_p, "component \"connections\" value 2\n");          {
283              fprintf(fileHandle_p, "component \"data\" value %d\n",object_count);              values = getSampleDataRO(data_pp[i_data], i);
284           }              for (k = 0; k < nComp; k++)
285       }              fprintf(fileHandle_p, " %g", values[k]);
286    }              fprintf(fileHandle_p, "\n");
287    fprintf(fileHandle_p, "end\n");          }
288    /* close the file */          fprintf(fileHandle_p, "attribute \"dep\" string \"positions\"\n");
289    fclose(fileHandle_p);          }
290    return;      }
291        }
292    
293        /* and finish it up */
294        if (num_data == 0)
295        {
296        fprintf(fileHandle_p, "object %d class field\n", object_count + 1);
297        fprintf(fileHandle_p, "component \"positions\" value 1\n");
298        fprintf(fileHandle_p, "component \"connections\" value 2\n");
299        }
300        else
301        {
302        object_count = 2;
303        for (i_data = 0; i_data < num_data; ++i_data)
304        {
305            if (!isEmpty(data_pp[i_data]))
306            {
307            object_count++;
308            fprintf(fileHandle_p, "object \"%s\" class field\n", names_p[i_data]);
309            fprintf(fileHandle_p, "component \"positions\" value 1\n");
310            fprintf(fileHandle_p, "component \"connections\" value 2\n");
311            fprintf(fileHandle_p, "component \"data\" value %d\n", object_count);
312            }
313        }
314        }
315        fprintf(fileHandle_p, "end\n");
316        /* close the file */
317        fclose(fileHandle_p);
318        MEMFREE(isCellCentered);
319        return;
320  }  }

Legend:
Removed from v.201  
changed lines
  Added in v.3259

  ViewVC Help
Powered by ViewVC 1.1.26