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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 8 months ago) by ksteube
File MIME type: text/plain
File size: 4143 byte(s)
Copyright updated in all files

1 jgs 150
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 ksteube 1312
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17     /* Finley: Mesh */
18    
19     /**************************************************************/
20    
21     #include "Mesh.h"
22    
23     /**************************************************************/
24    
25     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
26     /* the most appropriate order is selected indepently. */
27    
28     extern Finley_RefElementInfo Finley_RefElement_InfoList[];
29    
30 gross 1062 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
31 bcumming 730 {
32 jgs 82 Finley_Mesh *out;
33    
34     /* allocate the return value */
35    
36 jgs 102 out=MEMALLOC(1,Finley_Mesh);
37 jgs 82 if (Finley_checkPtr(out)) return NULL;
38     out->Name=NULL;
39     out->Nodes=NULL;
40     out->Elements=NULL;
41     out->FaceElements=NULL;
42     out->Points=NULL;
43     out->ContactElements=NULL;
44 gross 1044 out->TagMap=NULL;
45 jgs 82 out->reference_counter=0;
46 jgs 102
47     out->FullFullPattern=NULL;
48     out->FullReducedPattern=NULL;
49     out->ReducedFullPattern=NULL;
50     out->ReducedReducedPattern=NULL;
51 bcumming 730 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
52     if (! Finley_noError()) {
53 ksteube 1312 Finley_Mesh_free(out);
54 bcumming 730 return NULL;
55     }
56 jgs 82 /* copy name: */
57    
58 jgs 102 out->Name=MEMALLOC(strlen(name)+1,char);
59 jgs 82 if (Finley_checkPtr(out->Name)) {
60 ksteube 1312 Finley_Mesh_free(out);
61 jgs 82 return NULL;
62     }
63     strcpy(out->Name,name);
64    
65     /* allocate node table: */
66 bcumming 730 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
67 jgs 150 if (! Finley_noError()) {
68 ksteube 1312 Finley_Mesh_free(out);
69 jgs 82 return NULL;
70     }
71     out->order=order;
72 gross 1062 out->reduced_order=reduced_order;
73 jgs 82 out->Elements=NULL;
74     out->FaceElements=NULL;
75     out->Points=NULL;
76     out->ContactElements=NULL;
77     out->reference_counter++;
78     return out;
79     }
80    
81 jgs 102 /* returns a reference to Finley_Mesh in */
82    
83     Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
84     if (in!=NULL) ++(in->reference_counter);
85     return in;
86     }
87    
88 ksteube 1312 /* freeates a mesh: */
89 jgs 82
90 ksteube 1312 void Finley_Mesh_free(Finley_Mesh* in) {
91 jgs 82 if (in!=NULL) {
92     in->reference_counter--;
93     if (in->reference_counter<1) {
94     #ifdef Finley_TRACE
95     if (in->Name!=NULL) {
96 ksteube 1312 printf("Finley_Mesh_free: mesh %s is freed.\n",in->Name);
97 jgs 82 } else {
98 ksteube 1312 printf("Finley_Mesh_free\n");
99 jgs 82 }
100     #endif
101     MEMFREE(in->Name);
102 ksteube 1312 Finley_NodeFile_free(in->Nodes);
103 gross 1804 Finley_ElementFile_free(in->FaceElements);
104 ksteube 1312 Finley_ElementFile_free(in->Elements);
105     Finley_ElementFile_free(in->ContactElements);
106     Finley_ElementFile_free(in->Points);
107 gross 1044 Finley_TagMap_free(in->TagMap);
108 ksteube 1312 Paso_SystemMatrixPattern_free(in->FullFullPattern);
109     Paso_SystemMatrixPattern_free(in->FullReducedPattern);
110     Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
111     Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
112     Paso_MPIInfo_free( in->MPIInfo );
113 jgs 82 MEMFREE(in);
114     }
115     }
116     }
117    
118     /**************************************************************/
119    
120     /* returns the spatial dimension of the mesh: */
121    
122 jgs 123 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
123 jgs 82 return in->Nodes->numDim;
124     }
125    
126 ksteube 1312 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
127     Finley_ElementFile_free(self->Elements);
128     self->Elements=elements;
129 jgs 82 }
130 ksteube 1312 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
131     Finley_ElementFile_free(self->FaceElements);
132     self->FaceElements=elements;
133 jgs 82 }
134 ksteube 1312 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
135     Finley_ElementFile_free(self->ContactElements);
136     self->ContactElements=elements;
137 jgs 82 }
138 ksteube 1312 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
139     Finley_ElementFile_free(self->Points);
140     self->Points=elements;
141     }
142 bcumming 782

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26