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

Annotation of /branches/domexper/dudley/src/ElementFile_jacobeans.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3080 - (hide annotations)
Tue Aug 3 04:28:03 2010 UTC (9 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 12793 byte(s)
inital rename
1 gross 552
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 gross 552
14 ksteube 1811
15 gross 777 #include "ElementFile.h"
16 gross 776 #include "Assemble.h"
17 gross 552 #ifdef _OPENMP
18     #include <omp.h>
19     #endif
20    
21    
22     /**************************************************************/
23    
24 gross 2748 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_ShapeFunction* BasisFunctions)
25 gross 776 {
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 gross 2748 out->BasisFunctions=Finley_ShapeFunction_reference(BasisFunctions);
32     out->numDim=0;
33     out->numQuadTotal=0;
34     out->numElements=0;
35 gross 776 out->volume=NULL;
36     out->DSDX=NULL;
37     return out;
38     }
39 gross 552 }
40    
41 gross 776 /**************************************************************/
42 gross 552
43 gross 776 void Finley_ElementFile_Jacobeans_dealloc(Finley_ElementFile_Jacobeans* in)
44     {
45     if (in!=NULL) {
46 gross 2748 Finley_ShapeFunction_dealloc(in->BasisFunctions);
47     MEMFREE(in->volume);
48     MEMFREE(in->DSDX);
49 gross 776 MEMFREE(in);
50     }
51 gross 552 }
52    
53 gross 776 /**************************************************************/
54 gross 552
55    
56 gross 776 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
57 gross 777 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
58 gross 776 Finley_ElementFile_Jacobeans *out = NULL;
59 gross 2748 Finley_ShapeFunction *shape=NULL, *basis;
60     Finley_ReferenceElement* refElement=NULL;
61     double *dBdv;
62 gross 552
63 gross 2748 dim_t numNodes=self->numNodes;
64    
65 gross 776 if (reducedShapefunction) {
66     if (reducedIntegrationOrder) {
67     out=self->jacobeans_reducedS_reducedQ;
68     } else {
69     out=self->jacobeans_reducedS;
70 gross 552 }
71 gross 776 } else {
72     if (reducedIntegrationOrder) {
73     out=self->jacobeans_reducedQ;
74     } else {
75     out=self->jacobeans;
76 gross 552 }
77 gross 776 }
78     if (out->status < nodes->status) {
79 gross 2748
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 gross 776 } else {
96 gross 2748 out->numSub=refElement->Type->numSubElements;
97     out->node_selection=refElement->Type->subElementNodes;
98     out->offsets=refElement->Type->offsets;
99     dBdv=refElement->DBasisFunctionDv;
100 gross 776 }
101 gross 2748
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 gross 781 *(out->numDim)
115 gross 2748 *(out->numQuadTotal),double);
116 gross 776 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
117 gross 781 /*========================== dim = 1 ============================================== */
118     if (out->numDim==1) {
119 gross 2748 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     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 gross 552
127 gross 781 } else {
128 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports one sided elements only.");
129 gross 781 }
130 gross 776 } else {
131 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
132 gross 776 }
133 gross 781 /*========================== dim = 2 ============================================== */
134     } else if (out->numDim==2) {
135 gross 2748 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     Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
141 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
142 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
143 gross 781 out->DSDX,out->volume,self->Id);
144 gross 2748 } else if (out->numSides==2) {
145     Assemble_jacobeans_2D_M1D_E2D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
146 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
147 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
148 gross 781 out->DSDX,out->volume,self->Id);
149     } else {
150 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports one or two sided elements only.");
151 gross 781 }
152 gross 2748 } else if (out->BasisFunctions->Type->numDim==1) {
153     if (out->numSides==1) {
154     Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
155 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
156 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
157 gross 781 out->DSDX,out->volume,self->Id);
158 gross 2748 } else if (out->numSides==2) {
159     Assemble_jacobeans_2D_M1D_E1D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
160 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
161 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
162 gross 781 out->DSDX,out->volume,self->Id);
163     } else {
164 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports one or two sided elements only.");
165 gross 781 }
166 gross 777 } 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 gross 2748 } else if (refElement->numLocalDim==2) {
170     if (out->numSides==1) {
171     Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
172 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
173 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
174 gross 781 out->DSDX,out->volume,self->Id);
175     } else {
176 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D volume supports one sided elements only.");
177 gross 781 }
178    
179 gross 776 } else {
180 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
181 gross 776 }
182 gross 781 /*========================== dim = 3 ============================================== */
183     } else if (out->numDim==3) {
184 gross 2748 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     Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
190 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
191 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
192 gross 781 out->DSDX,out->volume,self->Id);
193 gross 2748 } else if (out->numSides==2) {
194     Assemble_jacobeans_3D_M2D_E3D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
195 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
196 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
197 gross 781 out->DSDX,out->volume,self->Id);
198     } else {
199 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports one or two sided elements only.");
200 gross 781 }
201 gross 2748 } else if (out->BasisFunctions->Type->numDim==2) {
202     if (out->numSides==1) {
203     Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
204 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
205 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
206 gross 781 out->DSDX,out->volume,self->Id);
207 gross 2748 } else if (out->numSides==2) {
208     Assemble_jacobeans_3D_M2D_E2D_C(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
209 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
210 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
211 gross 781 out->DSDX,out->volume,self->Id);
212     } else {
213 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports one or two sided elements only.");
214 gross 781 }
215 gross 777 } 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 gross 2748 } else if (refElement->numLocalDim==3) {
219     if (out->numSides==1) {
220     Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
221 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
222 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
223 gross 781 out->DSDX,out->volume,self->Id);
224     } else {
225 gross 2748 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume supports one sided elements only..");
226 gross 781 }
227 gross 776 } else {
228 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
229 gross 776 }
230     } else {
231 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
232 gross 552 }
233 gross 776 }
234     if (Finley_noError()) {
235     out->status = nodes->status;
236     } else {
237     out=NULL;
238     }
239 gross 552
240 gross 776 }
241 gross 552
242 gross 776 return out;
243 gross 552 }

  ViewVC Help
Powered by ViewVC 1.1.26