/[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 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 9 months ago) by ksteube
File MIME type: text/plain
File size: 13847 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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_RefElement* ReferenceElement)
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->ReferenceElement=ReferenceElement;
32 out->volume=NULL;
33 out->DSDX=NULL;
34 return out;
35 }
36 }
37
38 /**************************************************************/
39
40 void Finley_ElementFile_Jacobeans_dealloc(Finley_ElementFile_Jacobeans* in)
41 {
42 if (in!=NULL) {
43 if (in->volume!=NULL) MEMFREE(in->volume);
44 if (in->DSDX!=NULL) MEMFREE(in->DSDX);
45 MEMFREE(in);
46 }
47 }
48
49 /**************************************************************/
50
51
52 /**************************************************************/
53
54 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
55 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
56 Finley_ElementFile_Jacobeans *out = NULL;
57 Finley_RefElement *shape=NULL;
58
59 if (reducedShapefunction) {
60 if (reducedIntegrationOrder) {
61 out=self->jacobeans_reducedS_reducedQ;
62 shape=self->ReferenceElement;
63 } else {
64 out=self->jacobeans_reducedS;
65 }
66 } else {
67 if (reducedIntegrationOrder) {
68 out=self->jacobeans_reducedQ;
69 } else {
70 out=self->jacobeans;
71 }
72 }
73 if (out->status < nodes->status) {
74 dim_t numNodes=self->ReferenceElement->Type->numNodes;
75 if (reducedIntegrationOrder) {
76 shape=self->ReferenceElementReducedOrder;
77 } else {
78 shape=self->ReferenceElement;
79 }
80 out->numDim=nodes->numDim;
81 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
82 if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
83 *(out->ReferenceElement->Type->numNodes)
84 *(out->numDim)
85 *(out->ReferenceElement->numQuadNodes),double);
86 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
87 /*========================== dim = 1 ============================================== */
88 if (out->numDim==1) {
89 if (out->ReferenceElement->Type->numLocalDim==0) {
90
91 } else if (out->ReferenceElement->Type->numLocalDim==1) {
92 if ((shape->Type->numShapes==numNodes) &&
93 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
94 Assemble_jacobeans_1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
95 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
96 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
97 out->DSDX,out->volume,self->Id);
98 } else {
99 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports numShape=NumNodes only.");
100 }
101 } else {
102 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
103 }
104 /*========================== dim = 2 ============================================== */
105 } else if (out->numDim==2) {
106 if (out->ReferenceElement->Type->numLocalDim==0) {
107
108 } else if (out->ReferenceElement->Type->numLocalDim==1) {
109 if (out->ReferenceElement->Type->numDim==2) {
110 if ((shape->Type->numShapes==numNodes) &&
111 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
112 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
113 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
114 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
115 out->DSDX,out->volume,self->Id);
116 } else if ((2*(shape->Type->numShapes)==numNodes) &&
117 (2*(out->ReferenceElement->Type->numShapes)==out->ReferenceElement->Type->numNodes)) {
118 Assemble_jacobeans_2D_M1D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
119 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
120 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
121 out->DSDX,out->volume,self->Id);
122 } else {
123 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
124 }
125 } else if (out->ReferenceElement->Type->numDim==1) {
126 if ((shape->Type->numShapes==numNodes) &&
127 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
128 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
129 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
130 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
131 out->DSDX,out->volume,self->Id);
132 } else if ((2*shape->Type->numShapes==numNodes) &&
133 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
134 Assemble_jacobeans_2D_M1D_E1D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
135 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
136 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
137 out->DSDX,out->volume,self->Id);
138 } else {
139 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
140 }
141 } else {
142 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
143 }
144 } else if (out->ReferenceElement->Type->numLocalDim==2) {
145 if ((shape->Type->numShapes==numNodes) &&
146 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
147 Assemble_jacobeans_2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
148 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
149 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
150 out->DSDX,out->volume,self->Id);
151 } else {
152 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
153 }
154
155 } else {
156 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
157 }
158 /*========================== dim = 3 ============================================== */
159 } else if (out->numDim==3) {
160 if (out->ReferenceElement->Type->numLocalDim==0) {
161
162 } else if (out->ReferenceElement->Type->numLocalDim==2) {
163 if (out->ReferenceElement->Type->numDim==3) {
164 if ((shape->Type->numShapes==numNodes) &&
165 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
166 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
167 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
168 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
169 out->DSDX,out->volume,self->Id);
170 } else if ((2*shape->Type->numShapes==numNodes) &&
171 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
172 Assemble_jacobeans_3D_M2D_E3D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
173 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
174 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
175 out->DSDX,out->volume,self->Id);
176 } else {
177 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
178 }
179 } else if (out->ReferenceElement->Type->numDim==2) {
180 if ((shape->Type->numShapes==numNodes) &&
181 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
182 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
183 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
184 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
185 out->DSDX,out->volume,self->Id);
186 } else if ((2*shape->Type->numShapes==numNodes) &&
187 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
188 Assemble_jacobeans_3D_M2D_E2D_C(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
189 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
190 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
191 out->DSDX,out->volume,self->Id);
192 } else {
193 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
194 }
195 } else {
196 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
197 }
198 } else if (out->ReferenceElement->Type->numLocalDim==3) {
199 if ((shape->Type->numShapes==numNodes) &&
200 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
201 Assemble_jacobeans_3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
202 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
203 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
204 out->DSDX,out->volume,self->Id);
205 } else {
206 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
207 }
208 } else {
209 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
210 }
211 } else {
212 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
213 }
214 }
215 if (Finley_noError()) {
216 out->status = nodes->status;
217 } else {
218 out=NULL;
219 }
220
221 }
222
223 return out;
224 }
225 /*
226 * $Log$
227 *
228 */

  ViewVC Help
Powered by ViewVC 1.1.26