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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 781 - (hide 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 gross 552 /*
2 elspeth 616 ************************************************************
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 gross 552 */
12    
13    
14     /**************************************************************/
15    
16     /**************************************************************/
17    
18     /* Author: gross@access.edu.au */
19     /* Version: $Id$ */
20    
21     /**************************************************************/
22    
23 gross 777 #include "ElementFile.h"
24 gross 776 #include "Assemble.h"
25 gross 552 #ifdef _OPENMP
26     #include <omp.h>
27     #endif
28    
29    
30     /**************************************************************/
31    
32 gross 777 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_RefElement* ReferenceElement)
33 gross 776 {
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 gross 777 out->ReferenceElement=ReferenceElement;
40 gross 776 out->volume=NULL;
41     out->DSDX=NULL;
42     return out;
43     }
44 gross 552 }
45    
46 gross 776 /**************************************************************/
47 gross 552
48 gross 776 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 gross 552 }
56    
57 gross 776 /**************************************************************/
58 gross 552
59    
60 gross 776 /**************************************************************/
61 gross 552
62 gross 776 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
63 gross 777 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
64 gross 776 Finley_ElementFile_Jacobeans *out = NULL;
65 gross 552
66 gross 776 if (reducedShapefunction) {
67     if (reducedIntegrationOrder) {
68     out=self->jacobeans_reducedS_reducedQ;
69     } else {
70     out=self->jacobeans_reducedS;
71 gross 552 }
72 gross 776 } else {
73     if (reducedIntegrationOrder) {
74     out=self->jacobeans_reducedQ;
75     } else {
76     out=self->jacobeans;
77 gross 552 }
78 gross 776 }
79     if (out->status < nodes->status) {
80 gross 781 dim_t numNodes=self->ReferenceElement->Type->numNodes;
81 gross 777 Finley_RefElement *shape;
82     if (reducedIntegrationOrder) {
83     shape=self->ReferenceElement;
84 gross 776 } else {
85     shape=self->ReferenceElement;
86     }
87 gross 781 out->numDim=nodes->numDim;
88 gross 777 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
89     if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
90 gross 781 *(out->ReferenceElement->Type->numNodes)
91     *(out->numDim)
92 gross 777 *(out->ReferenceElement->numQuadNodes),double);
93 gross 776 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
94 gross 781 /*========================== dim = 1 ============================================== */
95     if (out->numDim==1) {
96 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
97 gross 552
98 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==1) {
99 gross 781 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 gross 776 } else {
109 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
110 gross 776 }
111 gross 781 /*========================== dim = 2 ============================================== */
112     } else if (out->numDim==2) {
113 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
114 gross 552
115 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==1) {
116     if (out->ReferenceElement->Type->numDim==2) {
117 gross 781 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 gross 777 } else if (out->ReferenceElement->Type->numDim==1) {
133 gross 781 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 gross 777 } 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 gross 781 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 gross 776 } else {
163 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
164 gross 776 }
165 gross 781 /*========================== dim = 3 ============================================== */
166     } else if (out->numDim==3) {
167 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
168 gross 552
169 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==2) {
170     if (out->ReferenceElement->Type->numDim==3) {
171 gross 781 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 gross 777 } else if (out->ReferenceElement->Type->numDim==2) {
187 gross 781 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 gross 777 } 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 gross 781 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 gross 776 } else {
216 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
217 gross 776 }
218     } else {
219 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
220 gross 552 }
221 gross 776 }
222     if (Finley_noError()) {
223     out->status = nodes->status;
224     } else {
225     out=NULL;
226     }
227 gross 552
228 gross 776 }
229 gross 552
230 gross 776 return out;
231 gross 552 }
232     /*
233     * $Log$
234     *
235     */

  ViewVC Help
Powered by ViewVC 1.1.26