/[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 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 12870 byte(s)
Merging dudley and scons updates from branches

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 #include "ElementFile.h"
16 #include "Assemble.h"
17 #ifdef _OPENMP
18 #include <omp.h>
19 #endif
20
21
22 /**************************************************************/
23
24 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_ShapeFunction* BasisFunctions)
25 {
26 Finley_ElementFile_Jacobeans* out=MEMALLOC(1,Finley_ElementFile_Jacobeans);
27 if (Finley_checkPtr(out)) {
28 return NULL;
29 } else {
30 out->status=FINLEY_INITIAL_STATUS-1;
31 out->BasisFunctions=Finley_ShapeFunction_reference(BasisFunctions);
32 out->numDim=0;
33 out->numQuadTotal=0;
34 out->numElements=0;
35 out->volume=NULL;
36 out->DSDX=NULL;
37 return out;
38 }
39 }
40
41 /**************************************************************/
42
43 void Finley_ElementFile_Jacobeans_dealloc(Finley_ElementFile_Jacobeans* in)
44 {
45 if (in!=NULL) {
46 Finley_ShapeFunction_dealloc(in->BasisFunctions);
47 MEMFREE(in->volume);
48 MEMFREE(in->DSDX);
49 MEMFREE(in);
50 }
51 }
52
53 /**************************************************************/
54
55
56 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
57 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
58 Finley_ElementFile_Jacobeans *out = NULL;
59 Finley_ShapeFunction *shape=NULL, *basis;
60 Finley_ReferenceElement* refElement=NULL;
61 double *dBdv;
62
63 dim_t numNodes=self->numNodes;
64
65 if (reducedShapefunction) {
66 if (reducedIntegrationOrder) {
67 out=self->jacobeans_reducedS_reducedQ;
68 } else {
69 out=self->jacobeans_reducedS;
70 }
71 } else {
72 if (reducedIntegrationOrder) {
73 out=self->jacobeans_reducedQ;
74 } else {
75 out=self->jacobeans;
76 }
77 }
78 if (out->status < nodes->status) {
79
80 basis=out->BasisFunctions;
81 shape=Finley_ReferenceElementSet_borrowParametrization(self->referenceElementSet, reducedIntegrationOrder);
82 refElement= Finley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet, reducedIntegrationOrder);
83
84 out->numDim=nodes->numDim;
85 out->numQuadTotal=shape->numQuadNodes;
86 out->numSides=refElement->Type->numSides;
87 out->numShapesTotal=basis->Type->numShapes * out->numSides;
88 out->numElements=self->numElements;
89
90 if (reducedShapefunction) {
91 out->numSub=1;
92 out->node_selection=refElement->Type->linearNodes;
93 out->offsets=refElement->LinearType->offsets;
94 dBdv=basis->dSdv;
95 } else {
96 out->numSub=refElement->Type->numSubElements;
97 out->node_selection=refElement->Type->subElementNodes;
98 out->offsets=refElement->Type->offsets;
99 dBdv=refElement->DBasisFunctionDv;
100 }
101
102 if (out->numQuadTotal != out->numSub * basis->numQuadNodes) {
103 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: Incorrect total number of quadrature points.");
104 return NULL;
105 }
106 if (refElement->numNodes> numNodes) {
107 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: Too many nodes expected.");
108 return NULL;
109 }
110
111 if (out->volume==NULL) out->volume=MEMALLOC((out->numElements)*(out->numQuadTotal),double);
112 if (out->DSDX==NULL) out->DSDX=MEMALLOC((out->numElements)
113 *(out->numShapesTotal)
114 *(out->numDim)
115 *(out->numQuadTotal),double);
116 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
117 /*========================== dim = 1 ============================================== */
118 if (out->numDim==1) {
119 if (refElement->numLocalDim==0) {
120 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D does not support local dimension 0.");
121 } else if (refElement->numLocalDim==1) {
122 if (out->numSides==2) {
123 Finley_Assemble_jacobeans_1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
124 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
125 shape->dSdv,basis->Type->numShapes,dBdv, out->DSDX,out->volume,self->Id);
126
127 } else {
128 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports one sided elements only.");
129 }
130 } else {
131 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
132 }
133 /*========================== dim = 2 ============================================== */
134 } else if (out->numDim==2) {
135 if (refElement->numLocalDim==0) {
136 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
137 } else if (refElement->numLocalDim==1) {
138 if (out->BasisFunctions->Type->numDim==2) {
139 if (out->numSides==1) {
140 Finley_Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
141 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
142 shape->dSdv,basis->Type->numShapes,dBdv,
143 out->DSDX,out->volume,self->Id);
144 } else if (out->numSides==2) {
145 Finley_Assemble_jacobeans_2D_M1D_E2D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
146 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
147 shape->dSdv,basis->Type->numShapes,dBdv,
148 out->DSDX,out->volume,self->Id);
149 } else {
150 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports one or two sided elements only.");
151 }
152 } else if (out->BasisFunctions->Type->numDim==1) {
153 if (out->numSides==1) {
154 Finley_Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
155 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
156 shape->dSdv,basis->Type->numShapes,dBdv,
157 out->DSDX,out->volume,self->Id);
158 } else if (out->numSides==2) {
159 Finley_Assemble_jacobeans_2D_M1D_E1D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
160 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
161 shape->dSdv,basis->Type->numShapes,dBdv,
162 out->DSDX,out->volume,self->Id);
163 } else {
164 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports one or two sided elements only.");
165 }
166 } else {
167 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
168 }
169 } else if (refElement->numLocalDim==2) {
170 if (out->numSides==1) {
171 Finley_Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
172 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
173 shape->dSdv,basis->Type->numShapes,dBdv,
174 out->DSDX,out->volume,self->Id);
175 } else {
176 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D volume supports one sided elements only.");
177 }
178
179 } else {
180 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
181 }
182 /*========================== dim = 3 ============================================== */
183 } else if (out->numDim==3) {
184 if (refElement->numLocalDim==0) {
185 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
186 } else if (refElement->numLocalDim==2) {
187 if (out->BasisFunctions->Type->numDim==3) {
188 if (out->numSides==1) {
189 Finley_Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
190 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
191 shape->dSdv,basis->Type->numShapes,dBdv,
192 out->DSDX,out->volume,self->Id);
193 } else if (out->numSides==2) {
194 Finley_Assemble_jacobeans_3D_M2D_E3D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
195 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
196 shape->dSdv,basis->Type->numShapes,dBdv,
197 out->DSDX,out->volume,self->Id);
198 } else {
199 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports one or two sided elements only.");
200 }
201 } else if (out->BasisFunctions->Type->numDim==2) {
202 if (out->numSides==1) {
203 Finley_Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
204 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
205 shape->dSdv,basis->Type->numShapes,dBdv,
206 out->DSDX,out->volume,self->Id);
207 } else if (out->numSides==2) {
208 Finley_Assemble_jacobeans_3D_M2D_E2D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
209 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
210 shape->dSdv,basis->Type->numShapes,dBdv,
211 out->DSDX,out->volume,self->Id);
212 } else {
213 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports one or two sided elements only.");
214 }
215 } else {
216 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
217 }
218 } else if (refElement->numLocalDim==3) {
219 if (out->numSides==1) {
220 Finley_Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
221 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
222 shape->dSdv,basis->Type->numShapes,dBdv,
223 out->DSDX,out->volume,self->Id);
224 } else {
225 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume supports one sided elements only..");
226 }
227 } else {
228 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
229 }
230 } else {
231 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
232 }
233 }
234 if (Finley_noError()) {
235 out->status = nodes->status;
236 } else {
237 out=NULL;
238 }
239
240 }
241
242 return out;
243 }

  ViewVC Help
Powered by ViewVC 1.1.26