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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 /*
2 ************************************************************
3 * Copyright 2006, 2007 by ACcESS MNRF *
4 * *
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 */
12
13 /**************************************************************/
14
15 /* Finley: Mesh */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
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 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
34 {
35 Finley_Mesh *out;
36
37 /* allocate the return value */
38
39 out=MEMALLOC(1,Finley_Mesh);
40 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 out->TagMap=NULL;
48 out->reference_counter=0;
49
50 out->FullFullPattern=NULL;
51 out->FullReducedPattern=NULL;
52 out->ReducedFullPattern=NULL;
53 out->ReducedReducedPattern=NULL;
54 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
55 if (! Finley_noError()) {
56 Finley_Mesh_free(out);
57 return NULL;
58 }
59 /* copy name: */
60
61 out->Name=MEMALLOC(strlen(name)+1,char);
62 if (Finley_checkPtr(out->Name)) {
63 Finley_Mesh_free(out);
64 return NULL;
65 }
66 strcpy(out->Name,name);
67
68 /* allocate node table: */
69 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
70 if (! Finley_noError()) {
71 Finley_Mesh_free(out);
72 return NULL;
73 }
74 out->order=order;
75 out->reduced_order=reduced_order;
76 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 /* 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 /* freeates a mesh: */
92
93 void Finley_Mesh_free(Finley_Mesh* in) {
94 if (in!=NULL) {
95 in->reference_counter--;
96 if (in->reference_counter<1) {
97 #ifdef Finley_TRACE
98 if (in->Name!=NULL) {
99 printf("Finley_Mesh_free: mesh %s is freed.\n",in->Name);
100 } else {
101 printf("Finley_Mesh_free\n");
102 }
103 #endif
104 MEMFREE(in->Name);
105 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 Finley_TagMap_free(in->TagMap);
111 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 MEMFREE(in);
117 }
118 }
119 }
120
121 /**************************************************************/
122
123 /* returns the spatial dimension of the mesh: */
124
125 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
126 return in->Nodes->numDim;
127 }
128
129 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
130 Finley_ElementFile_free(self->Elements);
131 self->Elements=elements;
132 }
133 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
134 Finley_ElementFile_free(self->FaceElements);
135 self->FaceElements=elements;
136 }
137 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
138 Finley_ElementFile_free(self->ContactElements);
139 self->ContactElements=elements;
140 }
141 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
142 Finley_ElementFile_free(self->Points);
143 self->Points=elements;
144 }
145

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26