/[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 3134 - (hide annotations)
Thu Sep 2 03:01:29 2010 UTC (9 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 9231 byte(s)
Removed numSides
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 jfenwick 3086 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_Jacobeans_alloc(Dudley_ShapeFunction* BasisFunctions)
25 gross 776 {
26 jfenwick 3086 Dudley_ElementFile_Jacobeans* out=MEMALLOC(1,Dudley_ElementFile_Jacobeans);
27     if (Dudley_checkPtr(out)) {
28 gross 776 return NULL;
29     } else {
30 jfenwick 3086 out->status=DUDLEY_INITIAL_STATUS-1;
31     out->BasisFunctions=Dudley_ShapeFunction_reference(BasisFunctions);
32 gross 2748 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 jfenwick 3086 void Dudley_ElementFile_Jacobeans_dealloc(Dudley_ElementFile_Jacobeans* in)
44 gross 776 {
45     if (in!=NULL) {
46 jfenwick 3086 Dudley_ShapeFunction_dealloc(in->BasisFunctions);
47 gross 2748 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 jfenwick 3086 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_borrowJacobeans(Dudley_ElementFile* self, Dudley_NodeFile* nodes,
57 gross 777 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
58 jfenwick 3086 Dudley_ElementFile_Jacobeans *out = NULL;
59     Dudley_ShapeFunction *shape=NULL, *basis;
60     Dudley_ReferenceElement* refElement=NULL;
61 gross 2748 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 jfenwick 3086 shape=Dudley_ReferenceElementSet_borrowParametrization(self->referenceElementSet, reducedIntegrationOrder);
82     refElement= Dudley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet, reducedIntegrationOrder);
83 gross 2748
84     out->numDim=nodes->numDim;
85     out->numQuadTotal=shape->numQuadNodes;
86 jfenwick 3134 out->numShapesTotal=basis->Type->numShapes;
87 gross 2748 out->numElements=self->numElements;
88    
89     if (reducedShapefunction) {
90     out->numSub=1;
91     out->node_selection=refElement->Type->linearNodes;
92     out->offsets=refElement->LinearType->offsets;
93     dBdv=basis->dSdv;
94 gross 776 } else {
95 gross 2748 out->numSub=refElement->Type->numSubElements;
96     out->node_selection=refElement->Type->subElementNodes;
97     out->offsets=refElement->Type->offsets;
98     dBdv=refElement->DBasisFunctionDv;
99 gross 776 }
100 gross 2748
101     if (out->numQuadTotal != out->numSub * basis->numQuadNodes) {
102 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Incorrect total number of quadrature points.");
103 gross 2748 return NULL;
104     }
105     if (refElement->numNodes> numNodes) {
106 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Too many nodes expected.");
107 gross 2748 return NULL;
108     }
109    
110     if (out->volume==NULL) out->volume=MEMALLOC((out->numElements)*(out->numQuadTotal),double);
111     if (out->DSDX==NULL) out->DSDX=MEMALLOC((out->numElements)
112     *(out->numShapesTotal)
113 gross 781 *(out->numDim)
114 gross 2748 *(out->numQuadTotal),double);
115 jfenwick 3086 if (! (Dudley_checkPtr(out->volume) || Dudley_checkPtr(out->DSDX)) ) {
116 gross 781 /*========================== dim = 1 ============================================== */
117     if (out->numDim==1) {
118 gross 2748 if (refElement->numLocalDim==0) {
119 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 1D does not support local dimension 0.");
120 gross 2748 } else if (refElement->numLocalDim==1) {
121     Assemble_jacobeans_1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
122     shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
123     shape->dSdv,basis->Type->numShapes,dBdv, out->DSDX,out->volume,self->Id);
124 gross 552
125 gross 776 } else {
126 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
127 gross 776 }
128 gross 781 /*========================== dim = 2 ============================================== */
129     } else if (out->numDim==2) {
130 gross 2748 if (refElement->numLocalDim==0) {
131 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
132 gross 2748 } else if (refElement->numLocalDim==1) {
133     if (out->BasisFunctions->Type->numDim==2) {
134     Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
135 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
136 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
137 gross 781 out->DSDX,out->volume,self->Id);
138 gross 2748 } else if (out->BasisFunctions->Type->numDim==1) {
139     Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
140 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
141 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
142 gross 781 out->DSDX,out->volume,self->Id);
143 gross 777 } else {
144 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
145 gross 777 }
146 gross 2748 } else if (refElement->numLocalDim==2) {
147     Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
148 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
149 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
150 gross 781 out->DSDX,out->volume,self->Id);
151 gross 776 } else {
152 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
153 gross 776 }
154 gross 781 /*========================== dim = 3 ============================================== */
155     } else if (out->numDim==3) {
156 gross 2748 if (refElement->numLocalDim==0) {
157 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
158 gross 2748 } else if (refElement->numLocalDim==2) {
159     if (out->BasisFunctions->Type->numDim==3) {
160     Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
161 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
162 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
163 gross 781 out->DSDX,out->volume,self->Id);
164 gross 2748 } else if (out->BasisFunctions->Type->numDim==2) {
165     Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
166 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
167 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
168 gross 781 out->DSDX,out->volume,self->Id);
169 gross 777 } else {
170 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
171 gross 777 }
172 gross 2748 } else if (refElement->numLocalDim==3) {
173     Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
174 gross 781 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
175 gross 2748 shape->dSdv,basis->Type->numShapes,dBdv,
176 gross 781 out->DSDX,out->volume,self->Id);
177 gross 776 } else {
178 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
179 gross 776 }
180     } else {
181 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
182 gross 552 }
183 gross 776 }
184 jfenwick 3086 if (Dudley_noError()) {
185 gross 776 out->status = nodes->status;
186     } else {
187     out=NULL;
188     }
189 gross 552
190 gross 776 }
191 gross 552
192 gross 776 return out;
193 gross 552 }

  ViewVC Help
Powered by ViewVC 1.1.26