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

Annotation of /trunk-mpi-branch/finley/src/Mesh.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (hide annotations)
Fri Aug 3 02:40:39 2007 UTC (11 years, 9 months ago) by gross
File MIME type: text/plain
File size: 4432 byte(s)
first attemt towards an improved MPI version.  

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26