/[escript]/branches/domexper/dudley/src/ElementFile_jacobeans.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/ElementFile_jacobeans.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3138 - (show annotations)
Thu Sep 2 05:18:42 2010 UTC (9 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 9140 byte(s)


1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_Jacobeans_alloc(Dudley_ShapeFunction* BasisFunctions)
25 {
26 Dudley_ElementFile_Jacobeans* out=MEMALLOC(1,Dudley_ElementFile_Jacobeans);
27 if (Dudley_checkPtr(out)) {
28 return NULL;
29 } else {
30 out->status=DUDLEY_INITIAL_STATUS-1;
31 out->BasisFunctions=Dudley_ShapeFunction_reference(BasisFunctions);
32 out->numDim=0;
33 out->numQuadTotal=0;
34 out->numElements=0;
35 out->volume=NULL;
36 out->DSDX=NULL;
37 return out;
38 }
39 }
40
41 /**************************************************************/
42
43 void Dudley_ElementFile_Jacobeans_dealloc(Dudley_ElementFile_Jacobeans* in)
44 {
45 if (in!=NULL) {
46 Dudley_ShapeFunction_dealloc(in->BasisFunctions);
47 MEMFREE(in->volume);
48 MEMFREE(in->DSDX);
49 MEMFREE(in);
50 }
51 }
52
53 /**************************************************************/
54
55
56 Dudley_ElementFile_Jacobeans* Dudley_ElementFile_borrowJacobeans(Dudley_ElementFile* self, Dudley_NodeFile* nodes,
57 bool_t reducedShapefunction, bool_t reducedIntegrationOrder) {
58 Dudley_ElementFile_Jacobeans *out = NULL;
59 Dudley_ShapeFunction *shape=NULL, *basis;
60 Dudley_ReferenceElement* refElement=NULL;
61 double *dBdv;
62
63 dim_t numNodes=self->numNodes;
64
65 if (reducedShapefunction) {
66 if (reducedIntegrationOrder) {
67 out=self->jacobeans_reducedS_reducedQ;
68 } else {
69 out=self->jacobeans_reducedS;
70 }
71 } else {
72 if (reducedIntegrationOrder) {
73 out=self->jacobeans_reducedQ;
74 } else {
75 out=self->jacobeans;
76 }
77 }
78 if (out->status < nodes->status) {
79
80 basis=out->BasisFunctions;
81 shape=Dudley_ReferenceElementSet_borrowParametrization(self->referenceElementSet, reducedIntegrationOrder);
82 refElement= Dudley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet, reducedIntegrationOrder);
83
84 out->numDim=nodes->numDim;
85 out->numQuadTotal=shape->numQuadNodes;
86 out->numShapesTotal=basis->Type->numShapes;
87 out->numElements=self->numElements;
88
89 if (reducedShapefunction) {
90 out->node_selection=refElement->Type->linearNodes;
91 out->offsets=refElement->LinearType->offsets;
92 dBdv=basis->dSdv;
93 } else {
94 out->node_selection=refElement->Type->subElementNodes;
95 out->offsets=refElement->Type->offsets;
96 dBdv=refElement->DBasisFunctionDv;
97 }
98
99 if (out->numQuadTotal != basis->numQuadNodes) {
100 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Incorrect total number of quadrature points.");
101 return NULL;
102 }
103 if (refElement->numNodes> numNodes) {
104 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Too many nodes expected.");
105 return NULL;
106 }
107
108 if (out->volume==NULL) out->volume=MEMALLOC((out->numElements)*(out->numQuadTotal),double);
109 if (out->DSDX==NULL) out->DSDX=MEMALLOC((out->numElements)
110 *(out->numShapesTotal)
111 *(out->numDim)
112 *(out->numQuadTotal),double);
113 if (! (Dudley_checkPtr(out->volume) || Dudley_checkPtr(out->DSDX)) ) {
114 /*========================== dim = 1 ============================================== */
115 if (out->numDim==1) {
116 if (refElement->numLocalDim==0) {
117 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 1D does not support local dimension 0.");
118 } else if (refElement->numLocalDim==1) {
119 Assemble_jacobeans_1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
120 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
121 shape->dSdv,basis->Type->numShapes,dBdv, out->DSDX,out->volume,self->Id);
122
123 } else {
124 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 1D domain has to be 0 or 1.");
125 }
126 /*========================== dim = 2 ============================================== */
127 } else if (out->numDim==2) {
128 if (refElement->numLocalDim==0) {
129 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
130 } else if (refElement->numLocalDim==1) {
131 if (out->BasisFunctions->Type->numDim==2) {
132 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
133 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
134 shape->dSdv,basis->Type->numShapes,dBdv,
135 out->DSDX,out->volume,self->Id);
136 } else if (out->BasisFunctions->Type->numDim==1) {
137 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
138 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
139 shape->dSdv,basis->Type->numShapes,dBdv,
140 out->DSDX,out->volume,self->Id);
141 } else {
142 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
143 }
144 } else if (refElement->numLocalDim==2) {
145 Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
146 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
147 shape->dSdv,basis->Type->numShapes,dBdv,
148 out->DSDX,out->volume,self->Id);
149 } else {
150 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
151 }
152 /*========================== dim = 3 ============================================== */
153 } else if (out->numDim==3) {
154 if (refElement->numLocalDim==0) {
155 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
156 } else if (refElement->numLocalDim==2) {
157 if (out->BasisFunctions->Type->numDim==3) {
158 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
159 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
160 shape->dSdv,basis->Type->numShapes,dBdv,
161 out->DSDX,out->volume,self->Id);
162 } else if (out->BasisFunctions->Type->numDim==2) {
163 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
164 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
165 shape->dSdv,basis->Type->numShapes,dBdv,
166 out->DSDX,out->volume,self->Id);
167 } else {
168 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
169 }
170 } else if (refElement->numLocalDim==3) {
171 Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
172 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
173 shape->dSdv,basis->Type->numShapes,dBdv,
174 out->DSDX,out->volume,self->Id);
175 } else {
176 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
177 }
178 } else {
179 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
180 }
181 }
182 if (Dudley_noError()) {
183 out->status = nodes->status;
184 } else {
185 out=NULL;
186 }
187
188 }
189
190 return out;
191 }

  ViewVC Help
Powered by ViewVC 1.1.26