/[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 3171 - (show annotations)
Fri Sep 10 00:31:11 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 7705 byte(s)
Remove some contact jacobean functions.
Assemble_jacobeans_2D_M1D_E2D finished first pass

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 (reducedIntegrationOrder)
66 {
67 out=self->jacobeans_reducedQ;
68 }
69 else
70 {
71 out=self->jacobeans;
72 }
73 if (out->status < nodes->status)
74 {
75 basis=out->BasisFunctions;
76 shape=Dudley_ReferenceElementSet_borrowParametrization(self->referenceElementSet, reducedIntegrationOrder);
77 refElement= Dudley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet, reducedIntegrationOrder);
78
79 out->numDim=nodes->numDim;
80 out->numQuadTotal=shape->numQuadNodes;
81 out->numShapesTotal=basis->Type->numShapes;
82 out->numElements=self->numElements;
83
84 if (reducedShapefunction) {
85 dBdv=basis->dSdv;
86 } else {
87 dBdv=refElement->DBasisFunctionDv;
88 }
89
90 if (out->numQuadTotal != basis->numQuadNodes) {
91 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Incorrect total number of quadrature points.");
92 return NULL;
93 }
94 if (refElement->numNodes> numNodes) {
95 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: Too many nodes expected.");
96 return NULL;
97 }
98
99 if (out->volume==NULL) out->volume=MEMALLOC((out->numElements)*(out->numQuadTotal),double);
100 if (out->DSDX==NULL) out->DSDX=MEMALLOC((out->numElements)
101 *(out->numShapesTotal)
102 *(out->numDim)
103 *(out->numQuadTotal),double);
104 if (! (Dudley_checkPtr(out->volume) || Dudley_checkPtr(out->DSDX)) ) {
105 /*========================== dim = 1 ============================================== */
106 if (out->numDim==1) {
107 Dudley_setError(SYSTEM_ERROR, "Dudley does not support 1D domains.");
108 /*========================== dim = 2 ============================================== */
109 } else if (out->numDim==2) {
110 if (refElement->numLocalDim==0) {
111 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
112 } else if (refElement->numLocalDim==1) {
113 if (out->BasisFunctions->Type->numDim==2) {
114
115 Assemble_jacobeans_2D_M1D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
116 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
117 shape->dSdv,basis->Type->numShapes,dBdv,
118 out->DSDX,out->volume,self->Id);
119 } else if (out->BasisFunctions->Type->numDim==1) {
120
121 Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates, out->numQuadTotal, self->numElements, numNodes,self->Nodes,
122 out->DSDX,out->volume,self->Id);
123 } else {
124 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 1 in a 2D domain has to be 1 or 2.");
125 }
126 } else if (refElement->numLocalDim==2) {
127 Assemble_jacobeans_2D(nodes->Coordinates,out->numQuadTotal, self->numElements,numNodes,self->Nodes,
128 out->DSDX, out->volume, self->Id);
129 } else {
130 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
131 }
132 /*========================== dim = 3 ============================================== */
133 } else if (out->numDim==3) {
134 if (refElement->numLocalDim==0) {
135 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
136 } else if (refElement->numLocalDim==2) {
137 if (out->BasisFunctions->Type->numDim==3) {
138 Assemble_jacobeans_3D_M2D_E3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
139 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
140 shape->dSdv,basis->Type->numShapes,dBdv,
141 out->DSDX,out->volume,self->Id);
142 } else if (out->BasisFunctions->Type->numDim==2) {
143 Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
144 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
145 shape->dSdv,basis->Type->numShapes,dBdv,
146 out->DSDX,out->volume,self->Id);
147 } else {
148 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: element dimension for local dimenion 2 in a 3D domain has to be 3 or 2.");
149 }
150 } else if (refElement->numLocalDim==3) {
151 Assemble_jacobeans_3D(nodes->Coordinates,out->numQuadTotal,shape->QuadWeights,
152 shape->Type->numShapes,self->numElements,numNodes,self->Nodes,
153 shape->dSdv,basis->Type->numShapes,dBdv,
154 out->DSDX,out->volume,self->Id);
155 } else {
156 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
157 }
158 } else {
159 Dudley_setError(SYSTEM_ERROR,"Dudley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
160 }
161 }
162 if (Dudley_noError()) {
163 out->status = nodes->status;
164 } else {
165 out=NULL;
166 }
167
168 }
169
170 return out;
171 }

  ViewVC Help
Powered by ViewVC 1.1.26