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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26