/[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 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 13882 byte(s)
And get the *(&(*&(* name right
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #include "ElementFile.h"
17 #include "Assemble.h"
18 #ifdef _OPENMP
19 #include <omp.h>
20 #endif
21
22
23 /**************************************************************/
24
25 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_RefElement* ReferenceElement)
26 {
27 Finley_ElementFile_Jacobeans* out=MEMALLOC(1,Finley_ElementFile_Jacobeans);
28 if (Finley_checkPtr(out)) {
29 return NULL;
30 } else {
31 out->status=FINLEY_INITIAL_STATUS-1;
32 out->ReferenceElement=ReferenceElement;
33 out->volume=NULL;
34 out->DSDX=NULL;
35 return out;
36 }
37 }
38
39 /**************************************************************/
40
41 void Finley_ElementFile_Jacobeans_dealloc(Finley_ElementFile_Jacobeans* in)
42 {
43 if (in!=NULL) {
44 if (in->volume!=NULL) MEMFREE(in->volume);
45 if (in->DSDX!=NULL) MEMFREE(in->DSDX);
46 MEMFREE(in);
47 }
48 }
49
50 /**************************************************************/
51
52
53 /**************************************************************/
54
55 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
56 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
57 Finley_ElementFile_Jacobeans *out = NULL;
58 Finley_RefElement *shape=NULL;
59
60 if (reducedShapefunction) {
61 if (reducedIntegrationOrder) {
62 out=self->jacobeans_reducedS_reducedQ;
63 shape=self->ReferenceElement;
64 } else {
65 out=self->jacobeans_reducedS;
66 }
67 } else {
68 if (reducedIntegrationOrder) {
69 out=self->jacobeans_reducedQ;
70 } else {
71 out=self->jacobeans;
72 }
73 }
74 if (out->status < nodes->status) {
75 dim_t numNodes=self->ReferenceElement->Type->numNodes;
76 if (reducedIntegrationOrder) {
77 shape=self->ReferenceElementReducedOrder;
78 } else {
79 shape=self->ReferenceElement;
80 }
81 out->numDim=nodes->numDim;
82 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
83 if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
84 *(out->ReferenceElement->Type->numNodes)
85 *(out->numDim)
86 *(out->ReferenceElement->numQuadNodes),double);
87 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
88 /*========================== dim = 1 ============================================== */
89 if (out->numDim==1) {
90 if (out->ReferenceElement->Type->numLocalDim==0) {
91
92 } else if (out->ReferenceElement->Type->numLocalDim==1) {
93 if ((shape->Type->numShapes==numNodes) &&
94 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
95 Assemble_jacobeans_1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
96 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
97 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
98 out->DSDX,out->volume,self->Id);
99 } else {
100 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 1D supports numShape=NumNodes only.");
101 }
102 } else {
103 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
104 }
105 /*========================== dim = 2 ============================================== */
106 } else if (out->numDim==2) {
107 if (out->ReferenceElement->Type->numLocalDim==0) {
108
109 } else if (out->ReferenceElement->Type->numLocalDim==1) {
110 if (out->ReferenceElement->Type->numDim==2) {
111 if ((shape->Type->numShapes==numNodes) &&
112 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
113 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
114 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
115 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
116 out->DSDX,out->volume,self->Id);
117 } else if ((2*(shape->Type->numShapes)==numNodes) &&
118 (2*(out->ReferenceElement->Type->numShapes)==out->ReferenceElement->Type->numNodes)) {
119 Assemble_jacobeans_2D_M1D_E2D_C(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 {
124 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
125 }
126 } else if (out->ReferenceElement->Type->numDim==1) {
127 if ((shape->Type->numShapes==numNodes) &&
128 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
129 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
130 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
131 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
132 out->DSDX,out->volume,self->Id);
133 } else if ((2*shape->Type->numShapes==numNodes) &&
134 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
135 Assemble_jacobeans_2D_M1D_E1D_C(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 {
140 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 2D supports numShape=NumNodes or 2*numShape=NumNodes only.");
141 }
142 } else {
143 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
144 }
145 } else if (out->ReferenceElement->Type->numLocalDim==2) {
146 if ((shape->Type->numShapes==numNodes) &&
147 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
148 Assemble_jacobeans_2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
149 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
150 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
151 out->DSDX,out->volume,self->Id);
152 } else {
153 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
154 }
155
156 } else {
157 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
158 }
159 /*========================== dim = 3 ============================================== */
160 } else if (out->numDim==3) {
161 if (out->ReferenceElement->Type->numLocalDim==0) {
162
163 } else if (out->ReferenceElement->Type->numLocalDim==2) {
164 if (out->ReferenceElement->Type->numDim==3) {
165 if ((shape->Type->numShapes==numNodes) &&
166 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
167 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
168 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
169 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
170 out->DSDX,out->volume,self->Id);
171 } else if ((2*shape->Type->numShapes==numNodes) &&
172 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
173 Assemble_jacobeans_3D_M2D_E3D_C(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 {
178 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
179 }
180 } else if (out->ReferenceElement->Type->numDim==2) {
181 if ((shape->Type->numShapes==numNodes) &&
182 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
183 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
184 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
185 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
186 out->DSDX,out->volume,self->Id);
187 } else if ((2*shape->Type->numShapes==numNodes) &&
188 (2*out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
189 Assemble_jacobeans_3D_M2D_E2D_C(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 {
194 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D supports numShape=NumNodes or 2*numShape=NumNodes only.");
195 }
196 } else {
197 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
198 }
199 } else if (out->ReferenceElement->Type->numLocalDim==3) {
200 if ((shape->Type->numShapes==numNodes) &&
201 (out->ReferenceElement->Type->numShapes==out->ReferenceElement->Type->numNodes)) {
202 Assemble_jacobeans_3D(nodes->Coordinates,out->ReferenceElement->numQuadNodes,out->ReferenceElement->QuadWeights,
203 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
204 shape->dSdv,out->ReferenceElement->Type->numShapes,out->ReferenceElement->dSdv,
205 out->DSDX,out->volume,self->Id);
206 } else {
207 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: 3D volume elements supports numShape=NumNodes only.");
208 }
209 } else {
210 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
211 }
212 } else {
213 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
214 }
215 }
216 if (Finley_noError()) {
217 out->status = nodes->status;
218 } else {
219 out=NULL;
220 }
221
222 }
223
224 return out;
225 }
226 /*
227 * $Log$
228 *
229 */

  ViewVC Help
Powered by ViewVC 1.1.26