/[escript]/branches/domexper/dudley/src/ReferenceElements.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/ReferenceElements.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3145 - (show annotations)
Fri Sep 3 01:25:52 2010 UTC (8 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 6874 byte(s)
Removed linearNodes and subElementNodes from ReferenceElementInfo
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Dudley: Reference elements */
18
19 /**************************************************************/
20
21 #include "ReferenceElements.h"
22
23 /**************************************************************
24
25 this list has been generated by generateReferenceElementList.py:.
26 */
27 Dudley_ReferenceElementInfo Dudley_ReferenceElement_InfoList[]={
28 { Point1, "Point1", 1, { 0, 1 }, Point1,
29 PointQuad, Point1Shape, Point1Shape,
30 1, { 0 },
31 1, { 0 },
32 { 0 },
33 { -1 } },
34 { Line2, "Line2", 2, { 0, 2 }, Line2,
35 LineQuad, Line2Shape, Line2Shape,
36 2, { 0, 1 },
37 2, { 0, 1 },
38 { 1, 0 },
39 { -1 } },
40 { Tri3, "Tri3", 3, { 0, 3 }, Tri3,
41 TriQuad, Tri3Shape, Tri3Shape,
42 3, { 0, 1, 2 },
43 3, { 0, 1, 2 },
44 { 1, 2, 0 },
45 { 0, 2, 1 } },
46 { Tet4, "Tet4", 4, { 0, 4 }, Tet4,
47 TetQuad, Tet4Shape, Tet4Shape,
48 4, { 0, 1, 2, 3 },
49 4, { 0, 1, 2, 3 },
50 { -1 },
51 { -1 } },
52 { Line2Face, "Line2Face", 2, { 0, 2 }, Line2Face,
53 PointQuad, Line2Shape, Line2Shape,
54 1, { 0 },
55 1, { 0 },
56 { 0, 1, 2 },
57 { -1 } },
58 { Tri3Face, "Tri3Face", 3, { 0, 3 }, Tri3Face,
59 LineQuad, Tri3Shape, Tri3Shape,
60 2, { 0, 1 },
61 2, { 0, 1 },
62 { 1, 0, 2 },
63 { -1 } },
64 { Tet4Face, "Tet4Face", 4, { 0, 4 }, Tet4Face,
65 TriQuad, Tet4Shape, Tet4Shape,
66 3, { 0, 1, 2 },
67 4, { 0, 1, 2, 3 },
68 { 1, 2, 0, 3 },
69 { 0, 2, 1, 3 } },
70 { NoRef, "noElement", 0, { 0 }, NoRef,
71 NoQuad, NoShape, NoShape,
72 -1, { 0 },
73 -1, { 0 },
74 { 0 },
75 { 0 } }
76
77 };
78
79 /**************************************************************
80
81 creates a ReferenceElement of type id and a given integration order
82
83 */
84
85
86 Dudley_ReferenceElement* Dudley_ReferenceElement_alloc(ElementTypeId id, int order)
87 {
88 dim_t numQuadNodes;
89 double *quadWeights=NULL, *quadNodes=NULL;
90 Dudley_ReferenceElement *out=NULL;
91 Dudley_QuadInfo* quadscheme;
92 Dudley_ShapeFunctionInfo* parametrization, *basisfunction, *linearbasisfunction;
93 Dudley_ReferenceElementInfo *type, *linear_type;
94
95 type=Dudley_ReferenceElement_getInfo(id);
96 if (type == NULL)
97 {
98 Dudley_setError(VALUE_ERROR,"Dudley_ReferenceElement_alloc: unable to identify element type.");
99 return NULL;
100 }
101 linear_type=Dudley_ReferenceElement_getInfo(type->LinearTypeId);
102 if (linear_type == NULL)
103 {
104 Dudley_setError(VALUE_ERROR,"Dudley_ReferenceElement_alloc: unable to identify linear element type.");
105 return NULL;
106 }
107 out=MEMALLOC(1,Dudley_ReferenceElement);
108 if (Dudley_checkPtr(out)) return NULL;
109 out->reference_counter=0;
110 out->Parametrization=NULL;
111 out->BasisFunctions=NULL;
112 out->LinearBasisFunctions=NULL;
113 out->Type=type;
114 out->numNodes=out->Type->numNodes;
115 out->LinearType=linear_type;
116 out->numLinearNodes=out->LinearType->numNodes;
117 out->integrationOrder=-1;
118 out->DBasisFunctionDv=NULL;
119 out->DBasisFunctionDvShared=TRUE;
120
121 quadscheme=Dudley_QuadInfo_getInfo(out->Type->Quadrature);
122 parametrization=Dudley_ShapeFunction_getInfo(out->Type->Parametrization);
123 basisfunction=Dudley_ShapeFunction_getInfo(out->Type->BasisFunctions);
124 linearbasisfunction=Dudley_ShapeFunction_getInfo(Dudley_ReferenceElement_InfoList[out->Type->LinearTypeId].BasisFunctions);
125 out->numLocalDim=quadscheme->numDim;
126
127 /* set up the basic integration scheme
128 note that quadscheme->numDim is not necessarily the diemnsion of the element
129 */
130
131 if (order<0) order=MAX(2*basisfunction->numOrder,0);
132 out->integrationOrder=order;
133 numQuadNodes=quadscheme->getNumQuadNodes(order);
134
135 quadNodes=MEMALLOC(numQuadNodes*quadscheme->numDim,double);
136 quadWeights=MEMALLOC(numQuadNodes,double);
137 if ( !( Dudley_checkPtr(quadNodes) || Dudley_checkPtr(quadWeights) ) )
138 {
139 quadscheme->getQuadNodes(numQuadNodes, quadNodes, quadWeights);
140
141 /* set the basis functions on the quadrature points:
142 * note: Dudley_ShapeFunction_alloc will introduce 0. if the dimensions of the quadrature scheme
143 * and the dimension of the element don;t match.
144 */
145 /*
146 * before we can set the shape function for the parametrization the quadrature scheme needs to be replicated :
147 */
148
149 out->Parametrization=Dudley_ShapeFunction_alloc(parametrization->TypeId, quadscheme->numDim, numQuadNodes, quadNodes, quadWeights);
150 out->BasisFunctions=Dudley_ShapeFunction_alloc(basisfunction->TypeId, quadscheme->numDim, numQuadNodes, quadNodes, quadWeights);
151 out->LinearBasisFunctions=Dudley_ShapeFunction_alloc(linearbasisfunction->TypeId, quadscheme->numDim, numQuadNodes, quadNodes, quadWeights);
152 out->DBasisFunctionDv=out->BasisFunctions->dSdv;
153 out->DBasisFunctionDvShared=TRUE;
154 }
155 MEMFREE(quadNodes);
156 MEMFREE(quadWeights);
157 if (Dudley_noError())
158 {
159 return Dudley_ReferenceElement_reference(out);
160 } else
161 {
162 Dudley_ReferenceElement_dealloc(out);
163 return NULL;
164 }
165 }
166
167 /**************************************************************/
168
169 void Dudley_ReferenceElement_dealloc(Dudley_ReferenceElement* in) {
170 if (in!=NULL) {
171 in->reference_counter--;
172 if (in->reference_counter<1) {
173 Dudley_ShapeFunction_dealloc(in->Parametrization);
174 Dudley_ShapeFunction_dealloc(in->BasisFunctions);
175 Dudley_ShapeFunction_dealloc(in->LinearBasisFunctions);
176 if (! in->DBasisFunctionDvShared) MEMFREE(in->DBasisFunctionDv);
177 MEMFREE(in);
178 }
179 }
180
181 }
182
183 /**************************************************************/
184
185 ElementTypeId Dudley_ReferenceElement_getTypeId(char* element_type) {
186 int ptr=0;
187 ElementTypeId out=NoRef;
188 while (Dudley_ReferenceElement_InfoList[ptr].TypeId!=NoRef && out==NoRef) {
189 if (strcmp(element_type,Dudley_ReferenceElement_InfoList[ptr].Name)==0) out=Dudley_ReferenceElement_InfoList[ptr].TypeId;
190 ptr++;
191 }
192 return out;
193 }
194
195 Dudley_ReferenceElement* Dudley_ReferenceElement_reference(Dudley_ReferenceElement* in) {
196 if (in!=NULL) ++(in->reference_counter);
197 return in;
198 }
199
200 Dudley_ReferenceElementInfo* Dudley_ReferenceElement_getInfo(ElementTypeId id)
201 {
202 int ptr=0;
203 Dudley_ReferenceElementInfo* out=NULL;
204 while (Dudley_ReferenceElement_InfoList[ptr].TypeId!=NoRef && out==NULL) {
205 if (Dudley_ReferenceElement_InfoList[ptr].TypeId==id) out=&(Dudley_ReferenceElement_InfoList[ptr]);
206 ptr++;
207 }
208 if (out==NULL) {
209 Dudley_setError(VALUE_ERROR,"Dudley_ReferenceElement_getInfo: cannot find requested reference element.");
210 }
211 return out;
212 }
213
214

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26