/[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 3251 - (hide annotations)
Thu Oct 7 04:02:30 2010 UTC (8 years, 5 months ago) by jfenwick
Original Path: branches/domexper/dudley/src/Mesh.c
File MIME type: text/plain
File size: 4113 byte(s)
Merged sconcript changes - weipa doesn't build unit test binary
1 ksteube 1312 /*******************************************************
2 ksteube 1811 *
3 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
4 ksteube 1811 * 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 jgs 82 /**************************************************************/
14    
15 jfenwick 3086 /* Dudley: Mesh */
16 jgs 82
17     /**************************************************************/
18    
19     #include "Mesh.h"
20    
21     /**************************************************************/
22    
23     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
24     /* the most appropriate order is selected indepently. */
25    
26 jfenwick 3227 Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
27 bcumming 730 {
28 jfenwick 3224 Dudley_Mesh *out;
29 jgs 102
30 jfenwick 3224 /* allocate the return value */
31 gross 2856
32 jfenwick 3224 out = MEMALLOC(1, Dudley_Mesh);
33     if (Dudley_checkPtr(out))
34     return NULL;
35     out->Name = NULL;
36     out->Nodes = NULL;
37     out->Elements = NULL;
38     out->FaceElements = NULL;
39     out->Points = NULL;
40     out->TagMap = NULL;
41     out->reference_counter = 0;
42    
43     out->FullFullPattern = NULL;
44     out->FullReducedPattern = NULL;
45     out->ReducedFullPattern = NULL;
46     out->ReducedReducedPattern = NULL;
47 jfenwick 3227 out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
48 jfenwick 3224 if (!Dudley_noError())
49     {
50     Dudley_Mesh_free(out);
51     return NULL;
52     }
53     /* copy name: */
54    
55     out->Name = MEMALLOC(strlen(name) + 1, char);
56     if (Dudley_checkPtr(out->Name))
57     {
58     Dudley_Mesh_free(out);
59     return NULL;
60     }
61     strcpy(out->Name, name);
62    
63     /* allocate node table: */
64     out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
65     if (!Dudley_noError())
66     {
67     Dudley_Mesh_free(out);
68     return NULL;
69     }
70     out->approximationOrder = -1;
71     out->reducedApproximationOrder = -1;
72     out->integrationOrder = -1;
73     out->reducedIntegrationOrder = -1;
74    
75     out->Elements = NULL;
76     out->FaceElements = NULL;
77     out->Points = NULL;
78     out->reference_counter++;
79     return out;
80 jgs 82 }
81    
82 jfenwick 3086 /* returns a reference to Dudley_Mesh in */
83 jgs 102
84 jfenwick 3224 Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
85     {
86     if (in != NULL)
87     ++(in->reference_counter);
88     return in;
89 jgs 102 }
90    
91 jfenwick 3227 /* frees a mesh: */
92 jgs 82
93 jfenwick 3224 void Dudley_Mesh_free(Dudley_Mesh * in)
94     {
95     if (in != NULL)
96     {
97     in->reference_counter--;
98     if (in->reference_counter < 1)
99     {
100     MEMFREE(in->Name);
101     Dudley_NodeFile_free(in->Nodes);
102     Dudley_ElementFile_free(in->FaceElements);
103     Dudley_ElementFile_free(in->Elements);
104     Dudley_ElementFile_free(in->Points);
105     Dudley_TagMap_free(in->TagMap);
106     Paso_SystemMatrixPattern_free(in->FullFullPattern);
107     Paso_SystemMatrixPattern_free(in->FullReducedPattern);
108     Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
109     Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
110 jfenwick 3227 Esys_MPIInfo_free(in->MPIInfo);
111 jfenwick 3224 MEMFREE(in);
112     }
113     }
114 jgs 82 }
115    
116     /**************************************************************/
117    
118     /* returns the spatial dimension of the mesh: */
119    
120 jfenwick 3224 dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
121     {
122     return in->Nodes->numDim;
123 jgs 82 }
124    
125 jfenwick 3224 void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
126     {
127 jfenwick 3086 Dudley_ElementFile_free(self->Elements);
128 jfenwick 3224 self->Elements = elements;
129 jgs 82 }
130 jfenwick 3224
131     void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
132     {
133 jfenwick 3086 Dudley_ElementFile_free(self->FaceElements);
134 jfenwick 3224 self->FaceElements = elements;
135 jgs 82 }
136 jfenwick 3224
137     void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
138     {
139 jfenwick 3086 Dudley_ElementFile_free(self->Points);
140 jfenwick 3224 self->Points = elements;
141 ksteube 1312 }
142 jfenwick 3224
143     int Dudley_Mesh_getStatus(Dudley_Mesh * in)
144     {
145     if (in == NULL)
146     {
147     return -1;
148     }
149     else if (in->Nodes == NULL)
150     {
151     return -1;
152     }
153     else
154     {
155     return in->Nodes->status;
156     }
157 gross 2533 }
158 gross 2856
159 caltinay 3247 void Dudley_Mesh_setOrders(Dudley_Mesh * in)
160 gross 2856 {
161 jfenwick 3251 in->approximationOrder = 1; /* order of shapeFunctions is always 1 in Dudley */
162 jfenwick 3224 in->reducedApproximationOrder = 1;
163     in->integrationOrder = 2;
164     in->reducedIntegrationOrder = 0;
165 gross 2856
166     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26