/[escript]/trunk/finley/src/ElementFile_jacobeans.c
ViewVC logotype

Contents of /trunk/finley/src/ElementFile_jacobeans.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1064 - (show annotations)
Tue Mar 27 06:21:02 2007 UTC (12 years, 2 months ago) by gross
File MIME type: text/plain
File size: 14263 byte(s)
test for reduced integration order for grad, interpolate and integrate added.
Bug shown by the tests have been fixed.


1 /*
2 ************************************************************
3 * Copyright 2006 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
16 /**************************************************************/
17
18 /* Author: gross@access.edu.au */
19 /* Version: $Id$ */
20
21 /**************************************************************/
22
23 #include "ElementFile.h"
24 #include "Assemble.h"
25 #ifdef _OPENMP
26 #include <omp.h>
27 #endif
28
29
30 /**************************************************************/
31
32 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_RefElement* ReferenceElement)
33 {
34 Finley_ElementFile_Jacobeans* out=MEMALLOC(1,Finley_ElementFile_Jacobeans);
35 if (Finley_checkPtr(out)) {
36 return NULL;
37 } else {
38 out->status=FINLEY_INITIAL_STATUS-1;
39 out->ReferenceElement=ReferenceElement;
40 out->volume=NULL;
41 out->DSDX=NULL;
42 return out;
43 }
44 }
45
46 /**************************************************************/
47
48 void Finley_ElementFile_Jacobeans_dealloc(Finley_ElementFile_Jacobeans* in)
49 {
50 if (in!=NULL) {
51 if (in->volume!=NULL) MEMFREE(in->volume);
52 if (in->DSDX!=NULL) MEMFREE(in->DSDX);
53 MEMFREE(in);
54 }
55 }
56
57 /**************************************************************/
58
59
60 /**************************************************************/
61
62 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
63 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
64 Finley_ElementFile_Jacobeans *out = NULL;
65 Finley_RefElement *shape=NULL;
66
67 if (reducedShapefunction) {
68 if (reducedIntegrationOrder) {
69 out=self->jacobeans_reducedS_reducedQ;
70 shape=self->ReferenceElement;
71 } else {
72 out=self->jacobeans_reducedS;
73 }
74 } else {
75 if (reducedIntegrationOrder) {
76 out=self->jacobeans_reducedQ;
77 } else {
78 out=self->jacobeans;
79 }
80 }
81 if (out->status < nodes->status) {
82 dim_t numNodes=self->ReferenceElement->Type->numNodes;
83 if (reducedIntegrationOrder) {
84 shape=self->ReferenceElementReducedOrder;
85 } else {
86 shape=self->ReferenceElement;
87 }
88 out->numDim=nodes->numDim;
89 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
90 if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
91 *(out->ReferenceElement->Type->numNodes)
92 *(out->numDim)
93 *(out->ReferenceElement->numQuadNodes),double);
94 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
95 /*========================== dim = 1 ============================================== */
96 if (out->numDim==1) {
97 if (out->ReferenceElement->Type->numLocalDim==0) {
98
99 } else if (out->ReferenceElement->Type->numLocalDim==1) {
100 if ((shape->Type->numShapes==numNodes) &&
101 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
102 Assemble_jacobeans_1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
103 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
104 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
105 out->DSDX,out->volume,self->Id);
106 } else {
107 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports numShape=NumNodes only.");
108 }
109 } else {
110 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
111 }
112 /*========================== dim = 2 ============================================== */
113 } else if (out->numDim==2) {
114 if (out->ReferenceElement->Type->numLocalDim==0) {
115
116 } else if (out->ReferenceElement->Type->numLocalDim==1) {
117 if (out->ReferenceElement->Type->numDim==2) {
118 if ((shape->Type->numShapes==numNodes) &&
119 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
120 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
121 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
122 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
123 out->DSDX,out->volume,self->Id);
124 } else if ((2*(shape->Type->numShapes)==numNodes) &&
125 (2*(out->ReferenceElement->Type->numShapes)==out->ReferenceElement->Type->numNodes)) {
126 Assemble_jacobeans_2D_M1D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
127 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
128 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
129 out->DSDX,out->volume,self->Id);
130 } else {
131 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
132 }
133 } else if (out->ReferenceElement->Type->numDim==1) {
134 if ((shape->Type->numShapes==numNodes) &&
135 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
136 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
137 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
138 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
139 out->DSDX,out->volume,self->Id);
140 } else if ((2*shape->Type->numShapes==numNodes) &&
141 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
142 Assemble_jacobeans_2D_M1D_E1D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
143 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
144 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
145 out->DSDX,out->volume,self->Id);
146 } else {
147 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
148 }
149 } else {
150 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
151 }
152 } else if (out->ReferenceElement->Type->numLocalDim==2) {
153 if ((shape->Type->numShapes==numNodes) &&
154 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
155 Assemble_jacobeans_2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
156 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
157 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
158 out->DSDX,out->volume,self->Id);
159 } else {
160 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
161 }
162
163 } else {
164 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
165 }
166 /*========================== dim = 3 ============================================== */
167 } else if (out->numDim==3) {
168 if (out->ReferenceElement->Type->numLocalDim==0) {
169
170 } else if (out->ReferenceElement->Type->numLocalDim==2) {
171 if (out->ReferenceElement->Type->numDim==3) {
172 if ((shape->Type->numShapes==numNodes) &&
173 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
174 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
175 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
176 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
177 out->DSDX,out->volume,self->Id);
178 } else if ((2*shape->Type->numShapes==numNodes) &&
179 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
180 Assemble_jacobeans_3D_M2D_E3D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
181 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
182 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
183 out->DSDX,out->volume,self->Id);
184 } else {
185 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
186 }
187 } else if (out->ReferenceElement->Type->numDim==2) {
188 if ((shape->Type->numShapes==numNodes) &&
189 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
190 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
191 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
192 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
193 out->DSDX,out->volume,self->Id);
194 } else if ((2*shape->Type->numShapes==numNodes) &&
195 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
196 Assemble_jacobeans_3D_M2D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
197 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
198 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
199 out->DSDX,out->volume,self->Id);
200 } else {
201 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
202 }
203 } else {
204 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
205 }
206 } else if (out->ReferenceElement->Type->numLocalDim==3) {
207 if ((shape->Type->numShapes==numNodes) &&
208 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
209 Assemble_jacobeans_3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
210 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
211 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
212 out->DSDX,out->volume,self->Id);
213 } else {
214 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
215 }
216 } else {
217 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
218 }
219 } else {
220 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
221 }
222 }
223 if (Finley_noError()) {
224 out->status = nodes->status;
225 } else {
226 out=NULL;
227 }
228
229 }
230
231 return out;
232 }
233 /*
234 * $Log$
235 *
236 */

  ViewVC Help
Powered by ViewVC 1.1.26