/[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 3204 - (hide annotations)
Thu Sep 23 23:59:39 2010 UTC (9 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 6454 byte(s)
More params collapsed

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 jfenwick 3196 #include "ShapeTable.h"
22 gross 552
23     /**************************************************************/
24    
25 jfenwick 3086 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_Jacobeans_alloc(Dudley_ShapeFunction* BasisFunctions)
26 gross 776 {
27 jfenwick 3086 Dudley_ElementFile_Jacobeans* out=MEMALLOC(1,Dudley_ElementFile_Jacobeans);
28     if (Dudley_checkPtr(out)) {
29 gross 776 return NULL;
30     } else {
31 jfenwick 3086 out->status=DUDLEY_INITIAL_STATUS-1;
32     out->BasisFunctions=Dudley_ShapeFunction_reference(BasisFunctions);
33 gross 2748 out->numDim=0;
34     out->numQuadTotal=0;
35     out->numElements=0;
36 jfenwick 3184 out->absD=NULL;
37     out->quadweight=0;
38 gross 776 out->DSDX=NULL;
39     return out;
40     }
41 gross 552 }
42    
43 gross 776 /**************************************************************/
44 gross 552
45 jfenwick 3086 void Dudley_ElementFile_Jacobeans_dealloc(Dudley_ElementFile_Jacobeans* in)
46 gross 776 {
47     if (in!=NULL) {
48 jfenwick 3086 Dudley_ShapeFunction_dealloc(in->BasisFunctions);
49 gross 2748 MEMFREE(in->DSDX);
50 jfenwick 3184 MEMFREE(in->absD);
51 gross 776 MEMFREE(in);
52     }
53 gross 552 }
54    
55 gross 776 /**************************************************************/
56 gross 552
57    
58 jfenwick 3086 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_borrowJacobeans(Dudley_ElementFile* self, Dudley_NodeFile* nodes,
59 gross 777 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
60 jfenwick 3086 Dudley_ElementFile_Jacobeans *out = NULL;
61 jfenwick 3196 Dudley_ShapeFunction /* *shape=NULL, */ *basis;
62 jfenwick 3086 Dudley_ReferenceElement* refElement=NULL;
63 gross 2748 double *dBdv;
64 gross 552
65 gross 2748 dim_t numNodes=self->numNodes;
66    
67 jfenwick 3170 if (reducedIntegrationOrder)
68     {
69     out=self->jacobeans_reducedQ;
70 gross 776 }
71 jfenwick 3170 else
72     {
73     out=self->jacobeans;
74     }
75     if (out->status < nodes->status)
76     {
77 gross 2748 basis=out->BasisFunctions;
78 jfenwick 3196 // shape=Dudley_ReferenceElementSet_borrowParametrization(self->referenceElementSet, reducedIntegrationOrder);
79 jfenwick 3086 refElement= Dudley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet, reducedIntegrationOrder);
80 gross 2748
81     out->numDim=nodes->numDim;
82 jfenwick 3196 // out->numQuadTotal=shape->numQuadNodes;
83     out->numQuadTotal=QuadNums[self->numDim][!reducedIntegrationOrder];
84 jfenwick 3204 out->numShapes=basis->Type->numShapes;
85 gross 2748 out->numElements=self->numElements;
86    
87     if (reducedShapefunction) {
88     dBdv=basis->dSdv;
89 gross 776 } else {
90 gross 2748 dBdv=refElement->DBasisFunctionDv;
91 gross 776 }
92 gross 2748
93 jfenwick 3138 if (out->numQuadTotal != basis->numQuadNodes) {
94 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Incorrect total number of quadrature points.");
95 gross 2748 return NULL;
96     }
97     if (refElement->numNodes> numNodes) {
98 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Too many nodes expected.");
99 gross 2748 return NULL;
100     }
101    
102     if (out->DSDX==NULL) out->DSDX=MEMALLOC((out->numElements)
103 jfenwick 3204 *(out->numShapes)
104 gross 781 *(out->numDim)
105 gross 2748 *(out->numQuadTotal),double);
106 jfenwick 3184 if (out->absD==NULL) out->absD=MEMALLOC(out->numElements,double);
107     if (! (Dudley_checkPtr(out->DSDX) || Dudley_checkPtr(out->absD)) ) {
108 gross 781 /*========================== dim = 1 ============================================== */
109     if (out->numDim==1) {
110 jfenwick 3171 Dudley_setError(SYSTEM_ERROR, "Dudley does not support 1D domains.");
111 gross 781 /*========================== dim = 2 ============================================== */
112     } else if (out->numDim==2) {
113 gross 2748 if (refElement->numLocalDim==0) {
114 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
115 gross 2748 } else if (refElement->numLocalDim==1) {
116 jfenwick 3172 if (out->BasisFunctions->Type->numDim==1) {
117 jfenwick 3184 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates, out->numQuadTotal, self->numElements, numNodes,self->Nodes, out->DSDX,out->absD, &(out->quadweight), self->Id);
118 gross 777 } else {
119 jfenwick 3172 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1.");
120 gross 777 }
121 gross 2748 } else if (refElement->numLocalDim==2) {
122 jfenwick 3170 Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal, self->numElements,numNodes,self->Nodes,
123 jfenwick 3184 out->DSDX, out->absD, &(out->quadweight), self->Id);
124 gross 776 } else {
125 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
126 gross 776 }
127 gross 781 /*========================== dim = 3 ============================================== */
128     } else if (out->numDim==3) {
129 gross 2748 if (refElement->numLocalDim==0) {
130 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
131 gross 2748 } else if (refElement->numLocalDim==2) {
132 jfenwick 3173 if (out->BasisFunctions->Type->numDim==2) {
133     Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,self->numElements,numNodes,self->Nodes,
134 jfenwick 3184 out->DSDX,out->absD, &(out->quadweight), self->Id);
135 gross 777 } else {
136 jfenwick 3173 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 2.");
137 gross 777 }
138 gross 2748 } else if (refElement->numLocalDim==3) {
139 jfenwick 3172 Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,self->numElements,numNodes,self->Nodes,
140 jfenwick 3184 out->DSDX,out->absD, &(out->quadweight), self->Id);
141 gross 776 } else {
142 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
143 gross 776 }
144     } else {
145 jfenwick 3086 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
146 gross 552 }
147 gross 776 }
148 jfenwick 3086 if (Dudley_noError()) {
149 gross 776 out->status = nodes->status;
150     } else {
151     out=NULL;
152     }
153 gross 552
154 gross 776 }
155 gross 552
156 gross 776 return out;
157 gross 552 }

  ViewVC Help
Powered by ViewVC 1.1.26