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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2748 - (hide annotations)
Tue Nov 17 07:32:59 2009 UTC (9 years, 7 months ago) by gross
File MIME type: text/plain
File size: 4070 byte(s)
Macro elements are implemented now. VTK writer for macro elements still needs testing.
1 ksteube 1312 /*******************************************************
2 ksteube 1811 *
3 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
4 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
5     * http://www.uq.edu.au/esscc
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     *******************************************************/
12 ksteube 1312
13 ksteube 1811
14 jgs 82 /**************************************************************/
15    
16     /* Finley: Mesh */
17    
18     /**************************************************************/
19    
20     #include "Mesh.h"
21    
22     /**************************************************************/
23    
24     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
25     /* the most appropriate order is selected indepently. */
26    
27 gross 1062 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
28 bcumming 730 {
29 jgs 82 Finley_Mesh *out;
30    
31     /* allocate the return value */
32    
33 jgs 102 out=MEMALLOC(1,Finley_Mesh);
34 jgs 82 if (Finley_checkPtr(out)) return NULL;
35     out->Name=NULL;
36     out->Nodes=NULL;
37     out->Elements=NULL;
38     out->FaceElements=NULL;
39     out->Points=NULL;
40     out->ContactElements=NULL;
41 gross 1044 out->TagMap=NULL;
42 jgs 82 out->reference_counter=0;
43 jgs 102
44     out->FullFullPattern=NULL;
45     out->FullReducedPattern=NULL;
46     out->ReducedFullPattern=NULL;
47     out->ReducedReducedPattern=NULL;
48 bcumming 730 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
49     if (! Finley_noError()) {
50 ksteube 1312 Finley_Mesh_free(out);
51 bcumming 730 return NULL;
52     }
53 jgs 82 /* copy name: */
54    
55 jgs 102 out->Name=MEMALLOC(strlen(name)+1,char);
56 jgs 82 if (Finley_checkPtr(out->Name)) {
57 ksteube 1312 Finley_Mesh_free(out);
58 jgs 82 return NULL;
59     }
60     strcpy(out->Name,name);
61    
62     /* allocate node table: */
63 bcumming 730 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
64 jgs 150 if (! Finley_noError()) {
65 ksteube 1312 Finley_Mesh_free(out);
66 jgs 82 return NULL;
67     }
68     out->order=order;
69 gross 1062 out->reduced_order=reduced_order;
70 jgs 82 out->Elements=NULL;
71     out->FaceElements=NULL;
72     out->Points=NULL;
73     out->ContactElements=NULL;
74     out->reference_counter++;
75     return out;
76     }
77    
78 jgs 102 /* returns a reference to Finley_Mesh in */
79    
80     Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
81     if (in!=NULL) ++(in->reference_counter);
82     return in;
83     }
84    
85 ksteube 1312 /* freeates a mesh: */
86 jgs 82
87 ksteube 1312 void Finley_Mesh_free(Finley_Mesh* in) {
88 jgs 82 if (in!=NULL) {
89     in->reference_counter--;
90     if (in->reference_counter<1) {
91     MEMFREE(in->Name);
92 ksteube 1312 Finley_NodeFile_free(in->Nodes);
93 gross 1804 Finley_ElementFile_free(in->FaceElements);
94 ksteube 1312 Finley_ElementFile_free(in->Elements);
95     Finley_ElementFile_free(in->ContactElements);
96     Finley_ElementFile_free(in->Points);
97 gross 1044 Finley_TagMap_free(in->TagMap);
98 ksteube 1312 Paso_SystemMatrixPattern_free(in->FullFullPattern);
99     Paso_SystemMatrixPattern_free(in->FullReducedPattern);
100     Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
101     Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
102     Paso_MPIInfo_free( in->MPIInfo );
103 jgs 82 MEMFREE(in);
104     }
105     }
106     }
107    
108     /**************************************************************/
109    
110     /* returns the spatial dimension of the mesh: */
111    
112 jgs 123 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
113 jgs 82 return in->Nodes->numDim;
114     }
115    
116 ksteube 1312 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
117     Finley_ElementFile_free(self->Elements);
118     self->Elements=elements;
119 jgs 82 }
120 ksteube 1312 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
121     Finley_ElementFile_free(self->FaceElements);
122     self->FaceElements=elements;
123 jgs 82 }
124 ksteube 1312 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
125     Finley_ElementFile_free(self->ContactElements);
126     self->ContactElements=elements;
127 jgs 82 }
128 ksteube 1312 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
129     Finley_ElementFile_free(self->Points);
130     self->Points=elements;
131     }
132 gross 2533 int Finley_Mesh_getStatus(Finley_Mesh* in) {
133     if (in == NULL) {
134     return -1;
135     } else if (in->Nodes == NULL) {
136     return -1;
137     } else {
138     return in->Nodes->status;
139     }
140     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26