/[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 2548 - (hide annotations)
Mon Jul 20 06:20:06 2009 UTC (10 years, 4 months ago) by jfenwick
Original Path: trunk/finley/src/ElementFile_jacobeans.c
File MIME type: text/plain
File size: 13847 byte(s)
Updating copyright notices
1 gross 552
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 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 777 Finley_ElementFile_Jacobeans* Finley_ElementFile_Jacobeans_alloc(Finley_RefElement* ReferenceElement)
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 777 out->ReferenceElement=ReferenceElement;
32 gross 776 out->volume=NULL;
33     out->DSDX=NULL;
34     return out;
35     }
36 gross 552 }
37    
38 gross 776 /**************************************************************/
39 gross 552
40 gross 776 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 gross 552 }
48    
49 gross 776 /**************************************************************/
50 gross 552
51    
52 gross 776 /**************************************************************/
53 gross 552
54 gross 776 Finley_ElementFile_Jacobeans* Finley_ElementFile_borrowJacobeans(Finley_ElementFile* self, Finley_NodeFile* nodes,
55 gross 777 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
56 gross 776 Finley_ElementFile_Jacobeans *out = NULL;
57 gross 1064 Finley_RefElement *shape=NULL;
58 gross 552
59 gross 776 if (reducedShapefunction) {
60     if (reducedIntegrationOrder) {
61     out=self->jacobeans_reducedS_reducedQ;
62 gross 1064 shape=self->ReferenceElement;
63 gross 776 } else {
64     out=self->jacobeans_reducedS;
65 gross 552 }
66 gross 776 } else {
67     if (reducedIntegrationOrder) {
68     out=self->jacobeans_reducedQ;
69     } else {
70     out=self->jacobeans;
71 gross 552 }
72 gross 776 }
73     if (out->status < nodes->status) {
74 gross 781 dim_t numNodes=self->ReferenceElement->Type->numNodes;
75 gross 777 if (reducedIntegrationOrder) {
76 gross 1064 shape=self->ReferenceElementReducedOrder;
77 gross 776 } else {
78     shape=self->ReferenceElement;
79     }
80 gross 781 out->numDim=nodes->numDim;
81 gross 777 if (out->volume==NULL) out->volume=MEMALLOC((self->numElements)*(out->ReferenceElement->numQuadNodes),double);
82     if (out->DSDX==NULL) out->DSDX=MEMALLOC((self->numElements)
83 gross 781 *(out->ReferenceElement->Type->numNodes)
84     *(out->numDim)
85 gross 777 *(out->ReferenceElement->numQuadNodes),double);
86 gross 776 if (! (Finley_checkPtr(out->volume) || Finley_checkPtr(out->DSDX)) ) {
87 gross 781 /*========================== dim = 1 ============================================== */
88     if (out->numDim==1) {
89 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
90 gross 552
91 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==1) {
92 gross 781 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 gross 776 } else {
102 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
103 gross 776 }
104 gross 781 /*========================== dim = 2 ============================================== */
105     } else if (out->numDim==2) {
106 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
107 gross 552
108 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==1) {
109     if (out->ReferenceElement->Type->numDim==2) {
110 gross 781 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 gross 777 } else if (out->ReferenceElement->Type->numDim==1) {
126 gross 781 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 gross 777 } 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 gross 781 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 gross 776 } else {
156 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
157 gross 776 }
158 gross 781 /*========================== dim = 3 ============================================== */
159     } else if (out->numDim==3) {
160 gross 777 if (out->ReferenceElement->Type->numLocalDim==0) {
161 gross 552
162 gross 777 } else if (out->ReferenceElement->Type->numLocalDim==2) {
163     if (out->ReferenceElement->Type->numDim==3) {
164 gross 781 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 gross 777 } else if (out->ReferenceElement->Type->numDim==2) {
180 gross 781 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 gross 777 } 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 gross 781 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 gross 776 } else {
209 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
210 gross 776 }
211     } else {
212 gross 777 Finley_setError(SYSTEM_ERROR,"Finley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
213 gross 552 }
214 gross 776 }
215     if (Finley_noError()) {
216     out->status = nodes->status;
217     } else {
218     out=NULL;
219     }
220 gross 552
221 gross 776 }
222 gross 552
223 gross 776 return out;
224 gross 552 }
225     /*
226     * $Log$
227     *
228     */

  ViewVC Help
Powered by ViewVC 1.1.26