/[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 3184 - (hide annotations)
Wed Sep 15 00:23:42 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 6356 byte(s)
Removed volume from ElementFile_Jacobeans

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

  ViewVC Help
Powered by ViewVC 1.1.26