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

Annotation of /trunk/finley/src/Mesh.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (14 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh.c
File MIME type: text/plain
File size: 3324 byte(s)
Initial revision

1 jgs 82 /**************************************************************/
2    
3     /* Finley: Mesh */
4    
5     /**************************************************************/
6    
7     /* Copyrights by ACcESS Australia 2003,04 */
8     /* Author: gross@access.edu.au */
9     /* Version: $Id$ */
10    
11     /**************************************************************/
12    
13     #include "Finley.h"
14     #include "Mesh.h"
15    
16     /**************************************************************/
17    
18     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
19     /* the most appropriate order is selected indepently. */
20    
21     extern Finley_RefElementInfo Finley_RefElement_InfoList[];
22    
23     Finley_Mesh* Finley_Mesh_alloc(char* name,int numDim, int order) {
24     Finley_Mesh *out;
25    
26     /* allocate the return value */
27    
28     out=(Finley_Mesh*)MEMALLOC(sizeof(Finley_Mesh));
29     if (Finley_checkPtr(out)) return NULL;
30     out->Name=NULL;
31     out->Nodes=NULL;
32     out->Elements=NULL;
33     out->FaceElements=NULL;
34     out->Points=NULL;
35     out->ContactElements=NULL;
36     out->reference_counter=0;
37    
38     /* copy name: */
39    
40     out->Name=(char*)MEMALLOC((strlen(name)+1)*sizeof(char));
41     if (Finley_checkPtr(out->Name)) {
42     Finley_Mesh_dealloc(out);
43     return NULL;
44     }
45     strcpy(out->Name,name);
46    
47     /* allocate node table: */
48    
49     out->Nodes=Finley_NodeFile_alloc(numDim);
50     if (Finley_ErrorCode!=NO_ERROR) {
51     Finley_Mesh_dealloc(out);
52     return NULL;
53     }
54     out->order=order;
55     out->Elements=NULL;
56     out->FaceElements=NULL;
57     out->Points=NULL;
58     out->ContactElements=NULL;
59     out->reference_counter++;
60     return out;
61     }
62    
63     /* deallocates a mesh: */
64    
65     void Finley_Mesh_dealloc(Finley_Mesh* in) {
66     if (in!=NULL) {
67     in->reference_counter--;
68     if (in->reference_counter<1) {
69     #ifdef Finley_TRACE
70     if (in->Name!=NULL) {
71     printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);
72     } else {
73     printf("Finley_Mesh_dealloc\n");
74     }
75     #endif
76     MEMFREE(in->Name);
77     Finley_NodeFile_dealloc(in->Nodes);
78     Finley_ElementFile_dealloc(in->Elements);
79     Finley_ElementFile_dealloc(in->FaceElements);
80     Finley_ElementFile_dealloc(in->ContactElements);
81     Finley_ElementFile_dealloc(in->Points);
82     MEMFREE(in);
83     }
84     }
85     }
86    
87     /**************************************************************/
88    
89     /* returns the spatial dimension of the mesh: */
90    
91     int Finley_Mesh_getDim(Finley_Mesh *in) {
92     return in->Nodes->numDim;
93     }
94    
95     /**************************************************************/
96    
97     /* returns the number of nodes in the mesh: */
98    
99     int Finley_Mesh_getNumNodes(Finley_Mesh *in) {
100     return in->Nodes->numNodes;
101     }
102     /**************************************************************/
103    
104     /* returns the number of degrees of freedom in the mesh: */
105    
106     int Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {
107     return in->Nodes->numDegreesOfFreedom;
108     }
109     /**************************************************************/
110    
111     /* returns the number of degrees of freedom in the mesh: */
112    
113     int Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {
114     return in->Nodes->reducedNumDegreesOfFreedom;
115     }
116     /*
117     * $Log$
118     * Revision 1.1 2004/10/26 06:53:57 jgs
119     * Initial revision
120     *
121     * Revision 1.1.1.1 2004/06/24 04:00:40 johng
122     * Initial version of eys using boost-python.
123     *
124     *
125     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26