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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (hide annotations)
Wed Dec 15 07:08:39 2004 UTC (15 years ago) by jgs
File MIME type: text/plain
File size: 3765 byte(s)
*** empty log message ***

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 jgs 102 out=MEMALLOC(1,Finley_Mesh);
29 jgs 82 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 jgs 102
38     out->FullFullPattern=NULL;
39     out->FullReducedPattern=NULL;
40     out->ReducedFullPattern=NULL;
41     out->ReducedReducedPattern=NULL;
42 jgs 82
43     /* copy name: */
44    
45 jgs 102 out->Name=MEMALLOC(strlen(name)+1,char);
46 jgs 82 if (Finley_checkPtr(out->Name)) {
47     Finley_Mesh_dealloc(out);
48     return NULL;
49     }
50     strcpy(out->Name,name);
51    
52     /* allocate node table: */
53    
54     out->Nodes=Finley_NodeFile_alloc(numDim);
55     if (Finley_ErrorCode!=NO_ERROR) {
56     Finley_Mesh_dealloc(out);
57     return NULL;
58     }
59     out->order=order;
60     out->Elements=NULL;
61     out->FaceElements=NULL;
62     out->Points=NULL;
63     out->ContactElements=NULL;
64     out->reference_counter++;
65     return out;
66     }
67    
68 jgs 102 /* returns a reference to Finley_Mesh in */
69    
70     Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
71     if (in!=NULL) ++(in->reference_counter);
72     return in;
73     }
74    
75 jgs 82 /* deallocates a mesh: */
76    
77     void Finley_Mesh_dealloc(Finley_Mesh* in) {
78     if (in!=NULL) {
79     in->reference_counter--;
80     if (in->reference_counter<1) {
81     #ifdef Finley_TRACE
82     if (in->Name!=NULL) {
83     printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);
84     } else {
85     printf("Finley_Mesh_dealloc\n");
86     }
87     #endif
88     MEMFREE(in->Name);
89     Finley_NodeFile_dealloc(in->Nodes);
90     Finley_ElementFile_dealloc(in->Elements);
91     Finley_ElementFile_dealloc(in->FaceElements);
92     Finley_ElementFile_dealloc(in->ContactElements);
93     Finley_ElementFile_dealloc(in->Points);
94 jgs 102 Finley_SystemMatrixPattern_dealloc(in->FullFullPattern);
95     Finley_SystemMatrixPattern_dealloc(in->FullReducedPattern);
96     Finley_SystemMatrixPattern_dealloc(in->ReducedFullPattern);
97     Finley_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);
98 jgs 82 MEMFREE(in);
99     }
100     }
101     }
102    
103     /**************************************************************/
104    
105     /* returns the spatial dimension of the mesh: */
106    
107     int Finley_Mesh_getDim(Finley_Mesh *in) {
108     return in->Nodes->numDim;
109     }
110    
111     /**************************************************************/
112    
113     /* returns the number of nodes in the mesh: */
114    
115     int Finley_Mesh_getNumNodes(Finley_Mesh *in) {
116     return in->Nodes->numNodes;
117     }
118     /**************************************************************/
119    
120     /* returns the number of degrees of freedom in the mesh: */
121    
122     int Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {
123     return in->Nodes->numDegreesOfFreedom;
124     }
125     /**************************************************************/
126    
127     /* returns the number of degrees of freedom in the mesh: */
128    
129     int Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {
130     return in->Nodes->reducedNumDegreesOfFreedom;
131     }
132     /*
133     * $Log$
134 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
135 jgs 97 * *** empty log message ***
136 jgs 82 *
137 jgs 97 *
138 jgs 82 *
139     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26