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

Diff of /trunk/finley/src/Mesh_write.c

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

trunk/esys2/finley/src/finleyC/Mesh_write.c revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC trunk/finley/src/Mesh_write.c revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
 /**************************************************************/  
1    
2  /*   Finley: write Mesh */  /* $Id$ */
3    
4    /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   Copyrights by ACcESS Australia 2003 */  /*   Finley: write Mesh */
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
 #include "Common.h"  
 #include "Finley.h"  
22  #include "Mesh.h"  #include "Mesh.h"
23    
24  /**************************************************************/  /**************************************************************/
# Line 19  Line 26 
26  /*  writes the mesh to the external file fname unsing the Finley file format: */  /*  writes the mesh to the external file fname unsing the Finley file format: */
27    
28  void Finley_Mesh_write(Finley_Mesh *in,char* fname) {  void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
29      char error_msg[LenErrorMsg_MAX];
30    FILE *f;    FILE *f;
31    int NN,i,j,numDim;    int NN,i,j,numDim;
32      Finley_TagMap* tag_map=in->TagMap;
33    
34      if (in->MPIInfo->size >1 ) {
35        Finley_setError(IO_ERROR,"Mesh_write: only single processor runs are supported.");
36        return;
37    
38      }
39    /* open file */    /* open file */
40    f=fopen(fname,"w");    f=fopen(fname,"w");
41    if (f==NULL) {    if (f==NULL) {
42      Finley_ErrorCode=IO_ERROR;      sprintf(error_msg,"Mesh_write: Opening file %s for writing failed.",fname);
43      sprintf(Finley_ErrorMsg,"Opening file %s for writing failed.",fname);      Finley_setError(IO_ERROR,error_msg);
44      return;      return;
45    }    }
46    
# Line 40  void Finley_Mesh_write(Finley_Mesh *in,c Line 54  void Finley_Mesh_write(Finley_Mesh *in,c
54      numDim=Finley_Mesh_getDim(in);      numDim=Finley_Mesh_getDim(in);
55      fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);      fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
56      for (i=0;i<in->Nodes->numNodes;i++) {      for (i=0;i<in->Nodes->numNodes;i++) {
57        fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->degreeOfFreedom[i],in->Nodes->Tag[i]);        fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->globalDegreesOfFreedom[i],in->Nodes->Tag[i]);
58        for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);        for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
59        fprintf(f,"\n");        fprintf(f,"\n");
60      }      }
# Line 52  void Finley_Mesh_write(Finley_Mesh *in,c Line 66  void Finley_Mesh_write(Finley_Mesh *in,c
66    
67    if (in->Elements!=NULL) {    if (in->Elements!=NULL) {
68      fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);      fprintf(f, "%s %d\n",in->Elements->ReferenceElement->Type->Name,in->Elements->numElements);
69      NN=in->Elements->ReferenceElement->Type->numNodes;      NN=in->Elements->numNodes;
70      for (i=0;i<in->Elements->numElements;i++) {      for (i=0;i<in->Elements->numElements;i++) {
71        fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);        fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
72        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
# Line 65  void Finley_Mesh_write(Finley_Mesh *in,c Line 79  void Finley_Mesh_write(Finley_Mesh *in,c
79    /*  write face elements: */    /*  write face elements: */
80    if (in->FaceElements!=NULL) {    if (in->FaceElements!=NULL) {
81      fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);      fprintf(f, "%s %d\n", in->FaceElements->ReferenceElement->Type->Name,in->FaceElements->numElements);
82      NN=in->FaceElements->ReferenceElement->Type->numNodes;      NN=in->FaceElements->numNodes;
83      for (i=0;i<in->FaceElements->numElements;i++) {      for (i=0;i<in->FaceElements->numElements;i++) {
84        fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);        fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
85        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
# Line 78  void Finley_Mesh_write(Finley_Mesh *in,c Line 92  void Finley_Mesh_write(Finley_Mesh *in,c
92    /*  write Contact elements : */    /*  write Contact elements : */
93    if (in->ContactElements!=NULL) {    if (in->ContactElements!=NULL) {
94      fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);      fprintf(f, "%s %d\n",in->ContactElements->ReferenceElement->Type->Name,in->ContactElements->numElements);
95      NN=in->ContactElements->ReferenceElement->Type->numNodes;      NN=in->ContactElements->numNodes;
96      for (i=0;i<in->ContactElements->numElements;i++) {      for (i=0;i<in->ContactElements->numElements;i++) {
97        fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);        fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
98        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);        for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
# Line 97  void Finley_Mesh_write(Finley_Mesh *in,c Line 111  void Finley_Mesh_write(Finley_Mesh *in,c
111    } else {    } else {
112      fprintf(f,"Point1 0\n");      fprintf(f,"Point1 0\n");
113    }    }
114      
115      /*  write tags:*/
116      if (tag_map) {
117         fprintf(f,"Tags\n");
118         while (tag_map) {
119            fprintf(f,"%s %d\n",tag_map->name,tag_map->tag_key);
120            tag_map=tag_map->next;
121         }
122      }
123    fclose(f);    fclose(f);
124    #ifdef Finley_TRACE    #ifdef Finley_TRACE
125    printf("mesh %s has been written to file %s\n",in->Name,fname);    printf("mesh %s has been written to file %s\n",in->Name,fname);
# Line 106  void Finley_Mesh_write(Finley_Mesh *in,c Line 128  void Finley_Mesh_write(Finley_Mesh *in,c
128    
129  /*  /*
130  * $Log$  * $Log$
131  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.2  2005/09/15 03:44:23  jgs
132  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
133    *
134    * Revision 1.1.1.1.6.1  2005/09/07 06:26:20  gross
135    * the solver from finley are put into the standalone package paso now
136    *
137    * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
138    * initial import of project esys2
139  *  *
140  * Revision 1.1.1.1  2004/06/24 04:00:40  johng  * Revision 1.1.1.1  2004/06/24 04:00:40  johng
141  * Initial version of eys using boost-python.  * Initial version of eys using boost-python.

Legend:
Removed from v.82  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26