/[escript]/branches/doubleplusgood/finley/src/Mesh.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/finley/src/Mesh.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26