/[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 781 - (show annotations)
Fri Jul 14 08:47:38 2006 UTC (13 years, 4 months ago) by gross
File MIME type: text/plain
File size: 14208 byte(s)
grad functions linked into the persistent jacobean scheme
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
66 if (reducedShapefunction) {
67 if (reducedIntegrationOrder) {
68 out=self->jacobeans_reducedS_reducedQ;
69 } else {
70 out=self->jacobeans_reducedS;
71 }
72 } else {
73 if (reducedIntegrationOrder) {
74 out=self->jacobeans_reducedQ;
75 } else {
76 out=self->jacobeans;
77 }
78 }
79 if (out->status < nodes->status) {
80 dim_t numNodes=self->ReferenceElement->Type->numNodes;
81 Finley_RefElement *shape;
82 if (reducedIntegrationOrder) {
83 shape=self->ReferenceElement;
84 } else {
85 shape=self->ReferenceElement;
86 }
87 out->numDim=nodes->numDim;
88 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
89 if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
90 *(out->ReferenceElement->Type->numNodes)
91 *(out->numDim)
92 *(out->ReferenceElement->numQuadNodes),double);
93 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
94 /*========================== dim = 1 ============================================== */
95 if (out->numDim==1) {
96 if (out->ReferenceElement->Type->numLocalDim==0) {
97
98 } else if (out->ReferenceElement->Type->numLocalDim==1) {
99 if ((shape->Type->numShapes==numNodes) &&
100 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
101 Assemble_jacobeans_1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
102 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
103 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
104 out->DSDX,out->volume,self->Id);
105 } else {
106 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports numShape=NumNodes only.");
107 }
108 } else {
109 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
110 }
111 /*========================== dim = 2 ============================================== */
112 } else if (out->numDim==2) {
113 if (out->ReferenceElement->Type->numLocalDim==0) {
114
115 } else if (out->ReferenceElement->Type->numLocalDim==1) {
116 if (out->ReferenceElement->Type->numDim==2) {
117 if ((shape->Type->numShapes==numNodes) &&
118 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
119 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
120 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
121 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
122 out->DSDX,out->volume,self->Id);
123 } else if ((2*(shape->Type->numShapes)==numNodes) &&
124 (2*(out->ReferenceElement->Type->numShapes)==out->ReferenceElement->Type->numNodes)) {
125 Assemble_jacobeans_2D_M1D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
126 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
127 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
128 out->DSDX,out->volume,self->Id);
129 } else {
130 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
131 }
132 } else if (out->ReferenceElement->Type->numDim==1) {
133 if ((shape->Type->numShapes==numNodes) &&
134 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
135 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
136 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
137 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
138 out->DSDX,out->volume,self->Id);
139 } else if ((2*shape->Type->numShapes==numNodes) &&
140 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
141 Assemble_jacobeans_2D_M1D_E1D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
142 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
143 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
144 out->DSDX,out->volume,self->Id);
145 } else {
146 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
147 }
148 } else {
149 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
150 }
151 } else if (out->ReferenceElement->Type->numLocalDim==2) {
152 if ((shape->Type->numShapes==numNodes) &&
153 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
154 Assemble_jacobeans_2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
155 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
156 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
157 out->DSDX,out->volume,self->Id);
158 } else {
159 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
160 }
161
162 } else {
163 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
164 }
165 /*========================== dim = 3 ============================================== */
166 } else if (out->numDim==3) {
167 if (out->ReferenceElement->Type->numLocalDim==0) {
168
169 } else if (out->ReferenceElement->Type->numLocalDim==2) {
170 if (out->ReferenceElement->Type->numDim==3) {
171 if ((shape->Type->numShapes==numNodes) &&
172 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
173 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
174 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
175 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
176 out->DSDX,out->volume,self->Id);
177 } else if ((2*shape->Type->numShapes==numNodes) &&
178 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
179 Assemble_jacobeans_3D_M2D_E3D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
180 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
181 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
182 out->DSDX,out->volume,self->Id);
183 } else {
184 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
185 }
186 } else if (out->ReferenceElement->Type->numDim==2) {
187 if ((shape->Type->numShapes==numNodes) &&
188 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
189 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
190 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
191 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
192 out->DSDX,out->volume,self->Id);
193 } else if ((2*shape->Type->numShapes==numNodes) &&
194 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
195 Assemble_jacobeans_3D_M2D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
196 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
197 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
198 out->DSDX,out->volume,self->Id);
199 } else {
200 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
201 }
202 } else {
203 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
204 }
205 } else if (out->ReferenceElement->Type->numLocalDim==3) {
206 if ((shape->Type->numShapes==numNodes) &&
207 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
208 Assemble_jacobeans_3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
209 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
210 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
211 out->DSDX,out->volume,self->Id);
212 } else {
213 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
214 }
215 } else {
216 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
217 }
218 } else {
219 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
220 }
221 }
222 if (Finley_noError()) {
223 out->status = nodes->status;
224 } else {
225 out=NULL;
226 }
227
228 }
229
230 return out;
231 }
232 /*
233 * $Log$
234 *
235 */

  ViewVC Help
Powered by ViewVC 1.1.26